step-01-clarify-and-route.md
68 lines · skills/bmad-build-auto/step-01-clarify-and-route.md at bd70c64
Most marks come from matching words in the file, so treat them as pointers.
Step 1: Clarify and Route
Raw lines 1 to 8RULES
- 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.
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-devorin-progress→{{ rendered("step-03-implement.md") }}in-review→{{ rendered("step-04-review.md") }}blocked→ HALT with statusblockedand blocking conditionblocked plan supplied.dropped→ HALT with statusblockedand blocking conditiondropped plan supplied.builtordone→ setreview_loop_iterationto0in the frontmatter and setfollowup_passtotrue, 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 32Ticket 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
planexists on disk, treat it as a plan file the invocation prompt pointed to and route it by itsstatus(above). - Otherwise set
plan_fileto find'splan; the plan's frontmatter carriesticketset to find'sid, or to the stem of find'sstory_filewhenidis null, never itsref. Continue to INSTRUCTIONS, skipping item 5.
INSTRUCTIONS
- Load context.
- 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 whoseticketnames this ticket and whosecontainer, a path from{project-root}, has find'sfolderas its last folder name, since a run on an entry with no ticket file leaves no References line to follow. A document withoutcontainer(aresearch-*run) loads only when it istype: codebaseand itsticketnames this ticket. When a loaded document lists test files, the plan includes the work that turns them green and a command in## Verificationthat runs each listed test; run those commands before you finish, and a failure blocks completion. For continuity, read the plans besideplan_filewhoseticketis one of find'safterids that is a plain number (an entry of the same epic; a ref such as1.5is 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. - Anything else: {% if initiative_folder == config.output_folder %}
- List
{{ config.output_folder }}/. {% else %} - List
{{ initiative_folder }}/, then{{ config.output_folder }}/. {% endif %} - If the invocation prompt points to an unformatted plan or intent file, ingest that file. Do not scan for unrelated intent files.
- Planning documents sit in folders by type, main file named after the folder. Typical ones:
- Ticket file (
initiative-*/initiative-*.md, andtickets/epic-*/epic-*.mdunder it) — the spec at its altitude; the documents below are itssources:, distilled into it, or itscompanions: - PRD (
prd-*/prd-*.md) — product requirements and success criteria - Architecture (
architecture-*/architecture-*.md) — technical design decisions and constraints - UX/Design (
ux-*/, withDESIGN.mdandEXPERIENCE.md) — user experience and interaction design - Product Brief (
brief-*/brief-*.md) — project vision and scope - Research (
research-*/research-*.md) — cited evidence; atype: codebaseone says how the code works and how it got that way, as of the commit in its frontmatter - 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 orcompanions:name only for a need the ticket points at. With no ticket, load the planning documents that fit the intent. - 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
blockedand the unresolved questions as blocking condition. - 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 statusblockedand blocking conditionversion-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. - Multi-goal warning. If the intent appears to contain multiple independently shippable goals, carry
multiple-goalsforward so step-02 can add it to{plan_file}frontmatterwarnings. Do not split or block. - 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.