---
name: step-05-report
description: Generate final feature report
next_step: null
---

# Step 5: Generate Report

## YOUR TASK:

Generate a comprehensive feature report documenting what was accomplished.

---

## EXECUTION SEQUENCE:

### 1. Gather Statistics

**Collect data from prd.json and progress.txt:**

```javascript
const prd = readJSON('.ralph/prd.json');
const stats = {
  feature: prd.feature,
  started: prd.created,
  completed: new Date().toISOString(),
  iterations: prd.current_iteration,
  maxIterations: prd.max_iterations,
  tasksCompleted: prd.tasks.filter(t => t.passes).length,
  tasksTotal: prd.tasks.length,
  status: allComplete ? "COMPLETE" : "PARTIAL"
};
```

### 2. Collect File Changes

**Get files from git log:**

```bash
git log --name-status --pretty=format:"%H" HEAD~{iterations}..HEAD
```

**Categorize:**
- Files created (A)
- Files modified (M)
- Files deleted (D)

### 3. Collect MCP Usage

**From verbose logs (if available):**

```javascript
const mcpStats = {
  validate_conventions: X,
  check_migrations: Y,
  scaffold_extension: Z,
  context7_queries: W
};
```

### 4. Generate Report File

**Write to `.ralph/reports/{feature-slug}.md`:**

```markdown
# Feature Report: {feature}

## Summary
- **Started**: {started}
- **Completed**: {completed}
- **Duration**: {iterations} iterations
- **Status**: {status}

## Task Progress

| # | Task | Status |
|---|------|--------|
| 1 | {task_1_description} | ✅ |
| 2 | {task_2_description} | ✅ |
| 3 | {task_3_description} | ❌ (if incomplete) |

## MCP Usage Statistics

| Tool | Calls | Success | Failures |
|------|-------|---------|----------|
| validate_conventions | X | X | 0 |
| check_migrations | Y | Y | 0 |
| scaffold_extension | Z | Z | 0 |
| context7 query-docs | W | W | 0 |

## Files Created

```
{list of created files}
```

## Files Modified

```
{list of modified files}
```

## Git Commits

```
{commit_hash_1} feat(ralph): {message_1}
{commit_hash_2} feat(ralph): {message_2}
```

## Validations Performed

- [x] SmartStack conventions validated
- [x] EF Core migrations checked (if applicable)
- [x] No conflicts detected
- [x] Build passes
- [x] Tests pass (if applicable)

## Key Learnings

{Extracted from progress.txt - key insights from each iteration}

## Notes

{Any additional observations about the implementation}
```

### 5. Display Final Summary

```
╔══════════════════════════════════════════════════════════════════╗
║                    RALPH LOOP COMPLETE                            ║
╠══════════════════════════════════════════════════════════════════╣
║  Feature: {feature}                                               ║
║  Status:  {status}                                                ║
║  Iterations: {iterations}                                         ║
║  Tasks: {tasksCompleted} / {tasksTotal}                          ║
╠══════════════════════════════════════════════════════════════════╣
║  Files Created:  {created_count}                                  ║
║  Files Modified: {modified_count}                                 ║
║  Commits:        {commit_count}                                   ║
╠══════════════════════════════════════════════════════════════════╣
║  Report saved to:                                                 ║
║  .ralph/reports/{feature-slug}.md                                 ║
╚══════════════════════════════════════════════════════════════════╝
```

### 6. Output Completion (if applicable)

**If all tasks complete and not already output:**

```
<promise>{completion_promise}</promise>
```

---

## CLEANUP OPTIONS:

**Suggest to user:**

```
Next steps:
1. Review report: .ralph/reports/{feature-slug}.md
2. Run full test suite: dotnet test
3. Create PR: /gitflow:7-pull-request
4. Clean up Ralph files: rm -rf .ralph/
```

---

## SUCCESS CRITERIA:

- Report generated in `.ralph/reports/`
- All statistics accurate
- File lists complete
- Learnings documented
- Final summary displayed

## COMPLETION:

Ralph loop complete. No more steps.
