From auto-bmad
Close an epic: trace, retrospective, resolve retro actions, and project context refresh
npx claudepluginhub bramvera/claude-code-plugins --plugin auto-bmad# Load Configuration
Read `_bmad/bmm/config.yaml` and `_bmad/tea/config.yaml` and set the following variables (resolve `{project-root}` to the actual project root path):
| Variable | Source | Example |
|----------|--------|---------|
| `{{output_folder}}` | bmm `output_folder` | `_bmad-output` |
| `{{planning_artifacts}}` | bmm `planning_artifacts` | `_bmad-output/planning-artifacts` |
| `{{implementation_artifacts}}` | bmm `implementation_artifacts` | `_bmad-output/implementation-artifacts` |
| `{{test_artifacts}}` | tea `test_artifacts` | `_bmad-output/test-artifacts` |
| `{{auto_bmad_a...Read _bmad/bmm/config.yaml and _bmad/tea/config.yaml and set the following variables (resolve {project-root} to the actual project root path):
| Variable | Source | Example |
|---|---|---|
{{output_folder}} | bmm output_folder | _bmad-output |
{{planning_artifacts}} | bmm planning_artifacts | _bmad-output/planning-artifacts |
{{implementation_artifacts}} | bmm implementation_artifacts | _bmad-output/implementation-artifacts |
{{test_artifacts}} | tea test_artifacts | _bmad-output/test-artifacts |
{{auto_bmad_artifacts}} | derived: {{output_folder}}/auto-bmad-artifacts | _bmad-output/auto-bmad-artifacts |
All paths in this command that reference BMAD output directories MUST use these variables — never hardcode _bmad-output paths.
Read {{output_folder}}/project-context.md if it exists. This gives you general context about the project — its purpose, stack, conventions, and current state. Use this context to make informed decisions throughout the pipeline.
An epic number is a single integer identifying the epic (e.g., 1, 2, 3).
IF user provides an epic number: THEN set {{EPIC_ID}} to the provided number. ELSE ask the user to provide the epic number to close and set {{EPIC_ID}} to the provided value.
Close epic {{EPIC_ID}} with BMAD slash commands only — traceability, retrospective, retro action resolution, and project context refresh. Lightweight orchestration with git safety, no reports beyond the pipeline report.
Each step MUST run in its own foreground Task tool call (subagent_type: "general-purpose") so that each agent gets a fresh context window.
CRITICAL — Tool usage rules:
Retry policy: If a step fails, run git reset --hard HEAD to discard its partial changes, then retry once. If the retry also fails, stop the pipeline and tell the user:
git reset --hard {{START_COMMIT_HASH}} to roll back the entire pipeline, or git reset --hard HEAD to retry the failed step.Before running any steps, record:
{{START_TIME}} — run date -u +"%Y-%m-%dT%H:%M:%S" via Bash and store the output{{START_COMMIT_HASH}} — run git rev-parse --short HEAD and store the resultAfter each successful step, the coordinator runs git add -A && git commit --no-verify -m "wip(epic-{{EPIC_ID}}-end): step N/5 <step-name> - done" and prints a 1-line progress update: Step N/5: <step-name> — <status>. The coordinator must also track a running list of (step_name, status, start_time, end_time) — note the wall-clock time before and after each Task call to use in the final report.
Epic {{EPIC_ID}} Trace
/bmad-testarch-trace yolo — run in epic-level mode for epic {{EPIC_ID}}Epic {{EPIC_ID}} NFR
/bmad-testarch-nfr yolo - run in epic-level mode for epic {{EPIC_ID}}Epic {{EPIC_ID}} Test Review
/bmad-testarch-test-review yolo — run in epic-level mode for epic {{EPIC_ID}}. Include test pyramid compliance in the review: flag any E2E tests that duplicate coverage from lower layers (unit/integration/API), flag excessive E2E test counts, and recommend pushing tests down the pyramid where possibleEpic {{EPIC_ID}} Retrospective
/bmad-retrospective epic {{EPIC_ID}} ultrathink yolo - and fix all implementable action items required before the next epic, mark them as done/resolved, and defer any non-implementable items with a clear explanationEpic {{EPIC_ID}} Project Context Refresh
/bmad-generate-project-context yolo{{END_TIME}} — run date -u +"%Y-%m-%dT%H:%M:%S" via Bash and store the output.{{output_folder}}/ recursively for files modified after {{START_TIME}} to build the artifact list.{{auto_bmad_artifacts}}/ directory if it doesn't exist.{{auto_bmad_artifacts}}/epic-{{EPIC_ID}}-end-YYYY-MM-DD-HHMMSS.md (using {{END_TIME}} for the timestamp).Run the token cost report: python3 "$(find ~/.claude/plugins/cache/bramvera-plugins/auto-bmad -name token-report.py | sort | tail -1)" . — saves accurate billing breakdown to {{auto_bmad_artifacts}}/. Use the Cost: $X.XX standard line for the Est. Cost row.
Use this template for the report:
# Pipeline Report: epic-end [Epic {{EPIC_ID}}]
| Field | Value |
|-------|-------|
| Pipeline | epic-end |
| Epic | {{EPIC_ID}} |
| Start | {{START_TIME}} |
| End | {{END_TIME}} |
| Duration | <minutes>m |
| Est. Cost | ~$X.XX (see token-report-*.md) |
| Initial Commit | {{START_COMMIT_HASH}} |
## Artifacts
- `<relative-path>` — new/updated
## Pipeline Outcome
| # | Step | Status | Duration | Summary |
|---|------|--------|----------|---------|
| 1 | Trace | done/failed | Xm | <traceability coverage for the epic> |
| 2 | NFR | done/failed | Xm | <NFR assessment result (pass/concerns)> |
| 3 | Test Review | done/failed | Xm | <test quality verdict, pyramid violations flagged> |
| 4 | Retrospective | done/failed | Xm | <top takeaway or improvement identified> |
| 5 | Project Context | done/failed | Xm | <refreshed with epic outcomes> |
## Key Decisions & Learnings
Summarize notable decisions, issues, and learnings from the pipeline run. Include only items worth remembering — skip routine outcomes. If nothing notable, write "None."
## Action Items
Report only items that genuinely require human action based on what happened during this pipeline run. If the pipeline completed cleanly with no concerns, write "None — pipeline completed without issues requiring human attention."
For each item, prefix with one of:
- **[Review]** — a retrospective finding or deferred item that needs human decision (e.g., backlog item to prioritize, process change to adopt)
- **[Verify]** — something the pipeline couldn't validate (e.g., project-context.md accuracy, commit diff correctness)
- **[Attention]** — a risk or concern surfaced during the retrospective (e.g., recurring issue pattern, technical debt accumulation, scope creep signal)
Do NOT include items the pipeline already handled successfully. Do NOT fabricate items to fill a quota.
**IMPORTANT: Use dash syntax (e.g. `/auto-bmad-story`) NOT colon syntax (e.g. `/auto-bmad:story`) when suggesting next commands to the user.**
### Next
- If more epics remain, start a new session with fresh context and run `/auto-bmad-epic-start <next-epic-number>` to prepare the next epic
- If all epics are done, the project is complete — consider a final end-to-end review
git reset --soft {{START_COMMIT_HASH}} — squash all checkpoint commits, keep changes staged.git add -A && git commit -m "chore(epic-{{EPIC_ID}}): epic end — retro done, actions resolved"From this point on, do NOT auto-commit. Only commit when the user explicitly asks you to.