Skill Tracer
Skills › BMAD Method › bmad-build-auto › step-01-clarify-and-route.md

step-01-clarify-and-route.md

68 lines · skills/bmad-build-auto/step-01-clarify-and-route.md at bd70c64

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1---
2plan_file: '' # set at runtime once a route resolves it; some HALT branches exit before it is set
3ticket_args: '' # set at runtime to the arguments `tickets.py find` resolved the ticket with (its folder, when one was passed, then the ref); HALT passes them to `mark`
4followup_pass: '' # set at runtime when a `built` or `done` plan is re-dispatched for a follow-up review pass; empty on a first pass
5---
6
7# Step 1: Clarify and Route
8

Step 1: Clarify and Route

Raw lines 1 to 8
Starts an agent dispatched :4
9## RULES
11- Treat the invocation intent as workflow input, not as a substitute for step-02 investigation and plan generation.
12- **EARLY EXIT** means: stop this step immediately, then read and follow the target file. Return here only if a later step explicitly says to loop back.

RULES

  • Treat the invocation intent as workflow input, not as a substitute for step-02 investigation and plan generation.
  • EARLY EXIT means: stop this step immediately, then read and follow the target file. Return here only if a later step explicitly says to loop back.
Raw lines 9 to 13
14## Intent check (do this first)
16Use the invocation prompt as the intent.
18The invocation prompt names a ticket from the tree when it calls a reference a ticket (such as `ticket 1.2`, a ticket file's name, or a ticket's title), or points to a file whose frontmatter `type` is `story`, `spike`, or `bug`, whatever its `status`. A ref or title it does not present as a ticket is not one. Resolve a named ticket's plan, entry, and prerequisites with `uv run {project-root}/_bmad/method/scripts/tickets.py --project-root {project-root} find <ref>`; for a ticket file, pass its folder before its file name. Non-zero exit → HALT with status `blocked` and blocking condition `ticket not resolved`, with find's error. Otherwise follow **Ticket resolution** (below).
20If the invocation prompt explicitly points to an existing plan file with recognized `status` frontmatter, set `plan_file`, then **EARLY EXIT** to the appropriate step:
21- `draft` → `{{ rendered("step-02-plan.md") }}`
22- `ready-for-dev` or `in-progress` → `{{ rendered("step-03-implement.md") }}`
23- `in-review` → `{{ rendered("step-04-review.md") }}`
24- `blocked` → HALT with status `blocked` and blocking condition `blocked plan supplied`.
25- `dropped` → HALT with status `blocked` and blocking condition `dropped plan supplied`.
26- `built` or `done` → set `review_loop_iteration` to `0` in the frontmatter and set `followup_pass` to `true`, then **EARLY EXIT** to `{{ rendered("step-04-review.md") }}` for a fresh review pass.
28Otherwise, treat the invocation prompt as starting intent. This may be a story ID, ticket ID, a ticket file whose `type` is `initiative` or `epic` (read it in full), another file path, short description, or longer free-form intent. Do not infer workflow state from non-plan files.
29If the invocation prompt does not contain enough intent to identify what to implement, HALT with status `blocked` and blocking condition `unclear intent`.
31One ticket per invocation: never read another entry, and never advance to a different ticket regardless of outcome.

Intent check (do this first)

Use the invocation prompt as the intent.

The invocation prompt names a ticket from the tree when it calls a reference a ticket (such as ticket 1.2, a ticket file's name, or a ticket's title), or points to a file whose frontmatter type is story, spike, or bug, whatever its status. A ref or title it does not present as a ticket is not one. Resolve a named ticket's plan, entry, and prerequisites with uv run {project-root}/_bmad/method/scripts/tickets.py --project-root {project-root} find <ref>; for a ticket file, pass its folder before its file name. Non-zero exit → HALT with status blocked and blocking condition ticket not resolved, with find's error. Otherwise follow Ticket resolution (below).

If the invocation prompt explicitly points to an existing plan file with recognized status frontmatter, set plan_file, then EARLY EXIT to the appropriate step:

  • draft → {{ rendered("step-02-plan.md") }}
  • ready-for-dev or in-progress → {{ rendered("step-03-implement.md") }}
  • in-review → {{ rendered("step-04-review.md") }}
  • blocked → HALT with status blocked and blocking condition blocked plan supplied.
  • dropped → HALT with status blocked and blocking condition dropped plan supplied.
  • built or done → set review_loop_iteration to 0 in the frontmatter and set followup_pass to true, then EARLY EXIT to {{ rendered("step-04-review.md") }} for a fresh review pass.

Otherwise, treat the invocation prompt as starting intent. This may be a story ID, ticket ID, a ticket file whose type is initiative or epic (read it in full), another file path, short description, or longer free-form intent. Do not infer workflow state from non-plan files. If the invocation prompt does not contain enough intent to identify what to implement, HALT with status blocked and blocking condition unclear intent.

One ticket per invocation: never read another entry, and never advance to a different ticket regardless of outcome.

Raw lines 14 to 32
Runs code scripts/tickets.py :18
33### Ticket resolution
35This runs on the output of `tickets.py find` for one ticket. Set `ticket_args` to the arguments find resolved it with. Read `story_file` in full when it is not null, else take find's `description`, `verify`, `covers`, `references`, `notes`, and `unknown`; then read `epic_file` in full when it is not null. That is the intent. The ticket distills its `sources:`, so never re-read them; open a file its References or `companions:` name only for a need the ticket points at. Never write to a ticket file, and never run `pull`; only HALT runs `mark`.
37- When the file at find's `plan` exists on disk, treat it as a plan file the invocation prompt pointed to and route it by its `status` (above).
38- Otherwise set `plan_file` to find's `plan`; the plan's frontmatter carries `ticket` set to find's `id`, or to the stem of find's `story_file` when `id` is null, never its `ref`. Continue to INSTRUCTIONS, skipping item 5.

Ticket resolution

This runs on the output of tickets.py find for one ticket. Set ticket_args to the arguments find resolved it with. Read story_file in full when it is not null, else take find's description, verify, covers, references, notes, and unknown; then read epic_file in full when it is not null. That is the intent. The ticket distills its sources:, so never re-read them; open a file its References or companions: name only for a need the ticket points at. Never write to a ticket file, and never run pull; only HALT runs mark.

  • When the file at find's plan exists on disk, treat it as a plan file the invocation prompt pointed to and route it by its status (above).
  • Otherwise set plan_file to find's plan; the plan's frontmatter carries ticket set to find's id, or to the stem of find's story_file when id is null, never its ref. Continue to INSTRUCTIONS, skipping item 5.
Raw lines 33 to 39
40## INSTRUCTIONS
421. Load context.
43 - **A ticket from the tree** — when **Ticket resolution** set `plan_file`: the story file (or the entry) and the epic file, read in full under **Ticket resolution**, are already the intent. Then list the `<type>-*/` run folders in `{{ initiative_folder }}/` and in the ticket's epic folder, and load the main document of each whose `ticket` names this ticket and whose `container`, a path from `{project-root}`, has find's `folder` as its last folder name, since a run on an entry with no ticket file leaves no References line to follow. A document without `container` (a `research-*` run) loads only when it is `type: codebase` and its `ticket` names this ticket. When a loaded document lists test files, the plan includes the work that turns them green and a command in `## Verification` that runs each listed test; run those commands before you finish, and a failure blocks completion. For continuity, read the plans beside `plan_file` whose `ticket` is one of find's `after` ids that is a plain number (an entry of the same epic; a ref such as `1.5` is another epic's). Carry forward each one's **Code Map**, **Design Notes**, **Implementation Notes**, **Plan Change Log**, and **Tasks & Acceptance**, where present, as continuity context for step-02.
44 - **Anything else:**
45 {% if initiative_folder == config.output_folder %}
46 - List `{{ config.output_folder }}/`.
47 {% else %}
48 - List `{{ initiative_folder }}/`, then `{{ config.output_folder }}/`.
49 {% endif %}
50 - If the invocation prompt points to an unformatted plan or intent file, ingest that file. Do not scan for unrelated intent files.
51 - Planning documents sit in folders by type, main file named after the folder. Typical ones:
52 - **Ticket file** (`initiative-*/initiative-*.md`, and `tickets/epic-*/epic-*.md` under it) — the spec at its altitude; the documents below are its `sources:`, distilled into it, or its `companions:`
53 - **PRD** (`prd-*/prd-*.md`) — product requirements and success criteria
54 - **Architecture** (`architecture-*/architecture-*.md`) — technical design decisions and constraints
55 - **UX/Design** (`ux-*/`, with `DESIGN.md` and `EXPERIENCE.md`) — user experience and interaction design
56 - **Product Brief** (`brief-*/brief-*.md`) — project vision and scope
57 - **Research** (`research-*/research-*.md`) — cited evidence; a `type: codebase` one says how the code works and how it got that way, as of the commit in its frontmatter
58 - When the listing holds a ticket file for this work, read it first and in full and do not re-read its `sources:`; open a file its References or `companions:` name only for a need the ticket points at. With no ticket, load the planning documents that fit the intent.
592. Resolve intent from the invocation prompt and loaded artifacts. Do not fantasize or leave open questions. If the intent cannot be resolved, HALT with status `blocked` and the unresolved questions as blocking condition.
603. Version control sanity check. If version control is unavailable, skip this check. Otherwise require a clean working tree, a branch that fits the intent, and writable repository metadata. For Git, run `git add --refresh -- .`, then confirm the tree is still clean; on failure or change, HALT with status `blocked` and blocking condition `version-control metadata not writable`. For a ticket from the tree, judge the branch against the epic, not the story. HALT on a dirty tree or obvious branch mismatch.
614. Multi-goal warning. If the intent appears to contain multiple independently shippable goals, carry `multiple-goals` forward so step-02 can add it to `{plan_file}` frontmatter `warnings`. Do not split or block.
625. Set the plan file.
64 Derive a valid kebab-case slug from the clarified intent. If the intent references a tracking identifier (story number, issue number, ticket ID), lead the slug with it (e.g. `3-2-digest-delivery`, `gh-47-fix-auth`). If `{{ initiative_folder }}/plan-{slug}.md` already exists: if its status is `draft`, treat it as the same work and resume it (set `plan_file` to that path, **EARLY EXIT** → `{{ rendered("step-02-plan.md") }}`); otherwise append `-2`, `-3`, etc. Set `plan_file` = `{{ initiative_folder }}/plan-{slug}.md`.

INSTRUCTIONS

  1. Load context.
  2. A ticket from the tree — when Ticket resolution set plan_file: the story file (or the entry) and the epic file, read in full under Ticket resolution, are already the intent. Then list the <type>-*/ run folders in {{ initiative_folder }}/ and in the ticket's epic folder, and load the main document of each whose ticket names this ticket and whose container, a path from {project-root}, has find's folder as its last folder name, since a run on an entry with no ticket file leaves no References line to follow. A document without container (a research-* run) loads only when it is type: codebase and its ticket names this ticket. When a loaded document lists test files, the plan includes the work that turns them green and a command in ## Verification that runs each listed test; run those commands before you finish, and a failure blocks completion. For continuity, read the plans beside plan_file whose ticket is one of find's after ids that is a plain number (an entry of the same epic; a ref such as 1.5 is another epic's). Carry forward each one's Code Map, Design Notes, Implementation Notes, Plan Change Log, and Tasks & Acceptance, where present, as continuity context for step-02.
  3. Anything else: {% if initiative_folder == config.output_folder %}
  4. List {{ config.output_folder }}/. {% else %}
  5. List {{ initiative_folder }}/, then {{ config.output_folder }}/. {% endif %}
  6. If the invocation prompt points to an unformatted plan or intent file, ingest that file. Do not scan for unrelated intent files.
  7. Planning documents sit in folders by type, main file named after the folder. Typical ones:
  8. Ticket file (initiative-*/initiative-*.md, and tickets/epic-*/epic-*.md under it) — the spec at its altitude; the documents below are its sources:, distilled into it, or its companions:
  9. PRD (prd-*/prd-*.md) — product requirements and success criteria
  10. Architecture (architecture-*/architecture-*.md) — technical design decisions and constraints
  11. UX/Design (ux-*/, with DESIGN.md and EXPERIENCE.md) — user experience and interaction design
  12. Product Brief (brief-*/brief-*.md) — project vision and scope
  13. Research (research-*/research-*.md) — cited evidence; a type: codebase one says how the code works and how it got that way, as of the commit in its frontmatter
  14. When the listing holds a ticket file for this work, read it first and in full and do not re-read its sources:; open a file its References or companions: name only for a need the ticket points at. With no ticket, load the planning documents that fit the intent.
  15. Resolve intent from the invocation prompt and loaded artifacts. Do not fantasize or leave open questions. If the intent cannot be resolved, HALT with status blocked and the unresolved questions as blocking condition.
  16. Version control sanity check. If version control is unavailable, skip this check. Otherwise require a clean working tree, a branch that fits the intent, and writable repository metadata. For Git, run git add --refresh -- ., then confirm the tree is still clean; on failure or change, HALT with status blocked and blocking condition version-control metadata not writable. For a ticket from the tree, judge the branch against the epic, not the story. HALT on a dirty tree or obvious branch mismatch.
  17. Multi-goal warning. If the intent appears to contain multiple independently shippable goals, carry multiple-goals forward so step-02 can add it to {plan_file} frontmatter warnings. Do not split or block.
  18. Set the plan file.

Derive a valid kebab-case slug from the clarified intent. If the intent references a tracking identifier (story number, issue number, ticket ID), lead the slug with it (e.g. 3-2-digest-delivery, gh-47-fix-auth). If {{ initiative_folder }}/plan-{slug}.md already exists: if its status is draft, treat it as the same work and resume it (set plan_file to that path, EARLY EXIT → {{ rendered("step-02-plan.md") }}); otherwise append -2, -3, etc. Set plan_file = {{ initiative_folder }}/plan-{slug}.md.

Raw lines 40 to 65
66## NEXT
68Read fully and follow `{{ rendered("step-02-plan.md") }}`

NEXT

Read fully and follow {{ rendered("step-02-plan.md") }}

Raw lines 66 to 68