Stories go wrong in the gaps: an edge case nobody decided, a screen rebuilt that already existed, a contract drifted from the spec, an agent swarm that read the same files five times. This skill runs inside worktree-flow (its worktree, commits, and PR/MR rules apply unchanged) and covers what happens between opening the branch and opening the PR/MR. In a repo opted in to feature-status, the worktree comes from its pick (section 1), and the status file is updated at the points marked "Status" below.
Pick the lane
Choose by what you can observe after reading the ticket, and say the lane in one line.
| Lane | Signals | Steps |
|---|---|---|
| S | No open gap, one obvious edit (a copy fix, a one-line tweak), no risk trigger: none of the flow-trace triggers in AGENTS.md, none of security-pass section 0 | 1 (the AC list and its Status line), 5, 6; in an opted-in repo set the feature in-progress with the edit, since pick leaves it picked; skip 2-4, and 1b unless the edit uses a framework API |
| M | The default: anything that is not S or L | 1 to 6 |
| L | Several modules, a schema or contract change, or too big for one PR/MR | 1 to 6, with design options in step 4, and the split proposal there when it is too big for one PR/MR |
- Move up a lane the moment a signal appears (the edit reveals a gap, a trigger, or a second module); never move down.
- Load other skills lazily, only the section named, only when its trigger occurs:
ask-or-decidesection 2 when deciding a gap, section 4 only when a question or scope call actually arises.- Tech files (step 1b) only for technologies the change touches.
fe-guardrailsonly when the change touches UI;logging-standardonly when it adds logging;environmentssection 8 only with a migration.feature-statussections 2 and 3 only in an opted-in repo.verify-loopalways, at step 6; it picks its own gate set from the diff (verify-loopsections 1-2), which is whene2e-verify,security-passandflow-traceload.
1. Read the story and its sources of truth
- Read the whole ticket per
bug-triagesection 1: description, every comment, every attachment. - Read the sources of truth in the priority order of the project-init block in
AGENTS.md(decision log, spec, design, API contract). No block: runproject-initfirst, or ask where the spec lives; do not guess. - Reconcile the story with the API contract: every field, status, and error it needs either exists there or is a contract change listed in step 2.
- Before planning new UI, search for existing screens, routes, and mock-data pages (
fe-guardrails"Before building a screen"). - Write the acceptance criteria as a numbered list; every later step refers to them by number.
- Status: record each AC with its tiers (
feature-statussection 2).
1b. Load the tech files for the stack you will touch
Training data lags the installed versions, so each technology the change touches gets its file from this skill's tech/ folder before step 3. Pick from the repo, not from memory, and only what the change touches (a supabase/ folder does not load tech/supabase.md for a copy-only UI change):
| Signal | Read |
|---|---|
next in package.json | tech/nextjs.md and tech/react.md |
react without next | tech/react.md |
vercel.json, vercel.ts, .vercel/, a Vercel environment in .agents/environments.json, or a README or CI step that deploys to Vercel | tech/vercel.md |
@supabase/* in package.json, or a supabase/ folder | tech/supabase.md |
@nestjs/core in package.json | tech/nestjs.md |
- Run each file's "Before writing code" steps now: check the installed versions and read the docs it points to; step 5 follows its traps, and step 6 adds its Verify section.
- A technology with no file: read the docs of its installed version (its
llms.txtor.mdpages when it has them) before using an API not yet seen in this codebase, and name it in the report as a candidate for a new file (tech/README.md).
2. List what is underspecified
Write one line per gap, going through:
- Edge cases: empty, zero, duplicate, very large, concurrent edits.
- Error handling: which failures the user sees and how (display rules:
fe-guardrails"Loading, empty, and error states" and "Form errors: exactly three groups"). - Integration points: other modules, webhooks, jobs, emails, third-party APIs.
- Tenant and role scope: which tenants and roles can see and do each action.
- Scope boundaries: what the story does not include.
- Design preferences: what the design source does not show (states, responsive, copy).
- Backward compatibility: existing data, running clients, API consumers, migrations.
- Performance: data volume per tenant and any list or query that grows with it.
Decide a gap yourself when ask-or-decide section 2 covers it, and record the decision with its reason; keep the rest for one batched question in step 4, never gap by gap.
3. Explore the code: read directly, or at most 3 explorers
- Small or known area (one module, files you can name): read it directly, no subagents.
- Unfamiliar or multi-module area: at most 3 read-only explorer subagents, each on a different aspect (a similar existing feature, the data and permission path, the UI and test patterns); never a second wave.
- Explorer prompt:
- The story in two sentences and the aspect this explorer owns.
- Read-only: no edits, installs, tests, or dev servers.
- Return at most 300 words: the 5-10 key files with
path:lineand why each matters; the pattern to copy; anything surprising (a guard, a half-built version, a TODO).
- Then read yourself the files you will edit or copy a pattern from, and trust the summaries for the rest; open another file only when the edit needs it.
- Close the step 2 gaps the code settles (existing validation, error shape, role check).
- Status: exploration done, set the feature
in-progress.
4. Choose the design, then ask once
- Obvious design (one existing pattern to copy, no new table, contract, or state): state it in one line and go to step 5.
- Otherwise draft 2-3 approaches yourself, without architect subagents: minimal change (smallest diff meeting every AC, reusing what exists), clean architecture (maintainable long term), and a pragmatic balance. For each: files and layers touched, schema and contract changes, risks, what it makes harder later; then your recommendation, weighted per
AGENTS.mdtoward quality over development cost. - Approaches that differ only in internals: pick one and record it for the PR/MR body.
- Approaches that differ in product behavior, the API contract, the schema, or scope: the user's call.
- Lane L, when the story is too big for one reviewable PR/MR: propose the split into PRs/MRs, each mergeable on its own.
- Ask per
ask-or-decidesection 4, with the open gaps and the design choice in one message; until it is answered, build only what no open question can change.
5. Implement in small committed steps
- Order: contract and schema, then server logic with its tests, then UI wiring, so each commit runs.
- Schema changes are migration files in the repo: a tenant column and an RLS policy on every new table, backward compatible with the running code (full checklist:
environmentssection 8). - UI follows
fe-guardrails, code follows the traps of its step 1b tech file, and code that logs followslogging-standard. - After each change, classify it against the spec for the report:
- Matches spec: continue.
- Design deviation the user asked for: note it with the user's words.
- Spec deviation nobody approved: stop that change and ask per
ask-or-decidesection 4; never ship it silently.
6. Verify
- Run
verify-loop(sections 1-2) on the final head; it owns the gates and the loop back after a red one, its requirements gate uses the step 1 AC list, and its toolchain gate adds each step 1b Verify section. Tests for each AC sit at their contract boundary and followroot-causesection 5. - Status: record each AC tier as it passes, then set
in-reviewwith a passingcheck(feature-statussection 3). - Open the PR/MR per
worktree-flowsection 4, with theverify-looptable in its body.
Token discipline
- At most 3 explorer subagents per story, plus the reviewers
fresh-reviewandsecurity-passspawn; no other subagents, and "the feature is big" is a reason to read the explorers' file lists carefully, not to spawn more. - No parallel architects or reviewers: one design pass by you, one review loop by
fresh-review. - Do not re-read a file an explorer summarized unless you will edit it or copy its pattern.
- Run the touched package's tests while building and the full checks once in step 6, not after every commit.
- Run
e2e-verifyonce per story; after a late fix, rerun only whatverify-loopsection 2 names.
Report
In this order, also used as the PR/MR body:
- The lane, the story, and its AC list, each AC with status: matches spec, design deviation (who asked), or open; in an opted-in repo, read the ACs and tier results from the status file instead of retyping them.
- Decisions from steps 2 and 4 with their reasons, and the tech files loaded with each framework's installed version.
- What changed, by layer (schema, contract, server, UI).
- Verification: the
verify-looptable, theflow-tracefile andsecurity-passresult if they ran, and the E2E evidence file and its commit. - What is deliberately left out, open questions, and the PR/MR URL.