Agile Project Workflow
Workflow for Go projects using strict TDD, sprint-based agile, complexity-graded agents running as Claude Code teammates, scaffolding-first contracts, and spec isolation between paired teammates.
Go file editing — ABSOLUTE RULE
STRICTLY FORBIDDEN to use Edit, Write, Read, or any generic tool to read or modify a .go file.
For every .go file without exception:
- Reading →
go-surgeon symbol or go-surgeon overview
- Creation →
go-surgeon create
- Modification →
go-surgeon patch_function, patch_struct, patch_interface, update, insert_call, etc.
This rule applies even for a single-line change. No exceptions.
Parallelization — ABSOLUTE RULE
Use sub-agents (Agent tool) or agent teams (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS) for any task composed of independent parts (no file conflicts, no result dependencies).
- Launch parallel work in a single message (multiple simultaneous tool calls, or a team spawn).
- Never execute sequentially what can be parallelized.
- Examples: scaffolding multiple features in parallel, writing independent tests, creating files in different packages.
Parallelism granularity
Maximum theoretical fan-out (e.g., "23 independent red tasks") is rarely the right unit. Rate limits, token budgets, and the cost of recovering from concurrent crashes (see Agent crash recovery) make wide fan-outs fragile.
Default heuristic — feature as the unit of parallelism:
- One agent per feature, traversing all tasks of that feature (all reds first, then all greens, in dependency order).
- Features run in parallel with each other.
- Within a feature, tasks run sequentially under one agent — that agent keeps the feature context warm across tasks.
This caps live agents to roughly the number of features in scope (typically 2–4 per sprint). It trades some theoretical parallelism for crash containment: a rate-limit on one feature does not corrupt three others' in-flight state.
When to deviate (planner's call):
- A feature with one heavy
architectural task and several mechanical tasks: split the feature across two agents (one opus, one haiku) — the heavy task does not block the easy ones.
- A scaffold-only wave: scaffolders are short-lived and cheap; running them all in parallel is fine.
- An e2e wave at sprint end: e2e tests for different features touch different test files; one agent per e2e is fine.
What to avoid:
- Spawning N agents where N equals task count. Pattern observed in the wild: 23 reds spawned simultaneously, 3 crashed mid-run, batch-commit lost work across all 23.
- Mixing red and green of the same task on the same agent — spec isolation breaks.
- Two agents writing to the same package concurrently (file-level races on
go-surgeon edits).
The planner documents the chosen fan-out in SPRINT.md under ## Parallelization plan, with a one-sentence rationale.
Tests — ABSOLUTE RULE
Every feature must include:
- Unit tests: for any logic in
app/ and domain/ (table-driven, mocks via interfaces).
- Contract tests: for each repository adapter (via testcontainers).
- E2E / integration tests: at least one end-to-end scenario per feature.
Tests are produced after scaffolding and before implementation, following the strict red/green pattern. A feature without tests is not done.
Complexity classification — ABSOLUTE RULE
Every feature carries a ## Complexity field in its FEATURE.md, one of mechanical, standard, architectural.
- Missing complexity field fails DoR.
- The planner decides pipeline routing based on this field (see Pipeline routing by complexity below).
- A task can be upgraded in complexity during execution (via dispute type G), never downgraded while in flight. Over-classification is corrected in the retro for future calibration, not by demoting the running task.
Detailed classification heuristics, escalation signals, and retro calibration live in the task-complexity-routing skill. Load that skill only when classifying, routing, or reviewing classification accuracy — not for routine implementation work.
Scaffolding-first — ABSOLUTE RULE
Before red and green teammates start a feature, a scaffolder agent produces the testable contract — all exported types, interfaces, and function/method signatures with empty bodies that compile (panic("not implemented: ...") or zero-value returns).
- One
SCAFFOLD task per feature. Agent: scaffolder (haiku).
- Scaffolder couples with the
scaffor tool (https://github.com/JLugagne/scaffor) which generates mocks and test scaffolds from the interfaces scaffolded.
- All red tasks of the feature are
blocked by: SCAFFOLD.
- Red tests against scaffolded signatures. Green fills in the bodies.
- Red cannot modify scaffolded signatures. If a signature is untestable, red raises a dispute.
- Green cannot modify scaffolded signatures or add new exported symbols. Green may add private (unexported) helpers; these must be logged in the feature retro for retroactive test coverage via a sub-sprint.
Red/Green pattern — ABSOLUTE RULE
All production-code feature work at standard or architectural complexity follows strict TDD with paired teammates and spec isolation:
- Red phase: a
red-* teammate writes failing tests against the scaffolded contract. Cannot edit production code or scaffolded signatures.
- Green phase: a
green-* teammate implements scaffolded functions. Cannot edit test code, cannot modify scaffolded signatures, cannot add exported symbols.
- Spec isolation: red reads
TASK.md + TASK-red.md. Green reads TASK.md + TASK-green.md + red's test files. Neither reads the other's private spec.
- Dispute: if green disagrees with red, or either disagrees with the scaffold, they open
.disputes/SPRINT_00X/<TASK_ID>.md. The sprint-planner arbitrates based on public artifacts only.
All teammates (scaffolder, red, green, planner) stay alive simultaneously via Claude Code agent teams and communicate via teammate messaging and shared files.
Exception: scaffolder has its own standalone task (no pairing). E2E and review tasks are standalone (no red/green pairing).
In scope vs out of scope of red/green
The rule applies to production-code feature work. It does not apply to mechanical maintenance, where there is a unique correct answer and no design decision. The frontier is:
| In scope of red/green (rule applies) |
Out of scope (rule does not apply) |
standard features (use cases, adapters, middleware, validation) |
Rename a local symbol with no API change |
architectural features (new contracts, cross-cutting, invariants) |
gofmt, goimports, linter auto-fixes |
| Bug fixes that change observable behavior |
Dependency bump with no API impact |
| New exported APIs, signatures, types |
Comment / log message / error string fixes |
Behavior changes covered by acceptance criteria in FEATURE.md |
Regenerating mocks after an interface change already decided |
|
mechanical features (single-agent task; see Pipeline routing) |
The task-complexity-routing skill defines mechanical precisely as "transformation whose correct result is unique or quasi-unique" — that is exactly the zone where a red/green pair adds no signal (the test would only re-assert the input/output equality already enforced by the type system or the linter).
When in doubt, classify upward (standard over mechanical). Under-classification is corrected by an in-flight upgrade dispute (type G); over-classification only wastes one cheap pair.
Commit cadence — ABSOLUTE RULE
Each agent commits after every completed task, never in batches.
- One commit per
<TASK_ID> (one per T00X-red, one per T00X-green, one per SCAFFOLD, etc.).
- A teammate finishing two tasks in a row produces two commits, not one squashed commit.
- Do not defer commits to the end of a wave or the end of a sprint.
This bounds the blast radius of an agent crash, rate-limit interruption, or session loss to one task instead of a whole wave. The recovery procedure below depends on this.
Agent crash recovery — ABSOLUTE RULE
When one or more teammates crash mid-wave (rate limit, session disconnect, OOM), follow this procedure before re-spawning. Never delete dirty state blindly.
1. Inventory dirty state
Before any cleanup decision:
git status — list every modified or untracked file.
- For each dirty file, classify:
- complete — the task it belongs to is finished per its DoD; safe to commit.
- partial — task started, not finished; salvage decision needed.
- stale — leftover from a task that was already committed elsewhere; safe to revert.
- Map dirty files → expected task scope using
SPRINT.md and TASKS.md. Files outside any in-flight task scope are suspect — investigate before touching.
2. Salvage vs revert, per file
For each partial file:
- If the partial work is on a critical path of a downstream task → salvage: complete the minimum needed to satisfy the task DoD, then commit under the original
<TASK_ID>.
- If the partial work is non-load-bearing or duplicates work re-spawn will redo → revert that specific file (
git checkout -- <path>), not the whole tree.
For each stale file: revert.
For each complete file: commit under its <TASK_ID> immediately, before re-spawning anything.
3. Re-spawn with narrowed scope
When relaunching the crashed agents:
- Exclude every task already committed (check
git log --grep="Task:" for the sprint).
- Exclude every task whose files were just salvaged-and-committed in step 2.
- Pass the narrowed task list explicitly in the spawn prompt — do not let the agent infer scope from
TASKS.md alone (status fields may not yet reflect committed work).
4. Document the crash
Append a short entry to the sprint RETRO under ## Agent crashes (see retro template below): which agents, which wave, which tasks salvaged vs reverted, and any lost work. This feeds the parallelization heuristic at retro time.
Commits — ABSOLUTE RULE
Every commit message must reference feature and task:
<short description>
Feature: <feature-slug>
Task: <TASK_ID>
Feature: slug under .features/<slug>/.
Task: includes phase suffix: SCAFFOLD, T003-red, T003-green, E001, REVIEW, SPRINT_REVIEW, H001-red (sub-sprint helper task).
- Multiple tasks:
Task: T003-green, T004-green.
- Maintenance:
Feature: maintenance, Task: -.
Branches: <feature-slug>/<TASK_ID>-<short-description> (e.g., auth/T003-green-login-usecase, auth/SCAFFOLD).
Push timing — ABSOLUTE RULE
A red wave produces tests that fail by design. A pre-push hook running go test ./... will reject these commits, and bypassing it (--no-verify) defeats the gate for everyone.
The rule:
- Never push to
main (or any shared branch with a green-tests pre-push hook) in the middle of a red wave.
- A push to a shared branch is allowed only at the end of a complete green wave, when
go test ./... passes locally.
- Within a wave, commits stay local (or on a per-feature branch) until the matching green completes.
Allowed branching strategies, pick one per project:
- Trunk + delayed push (default for solo / small teams): commit red and green locally on
main, push only when the green wave finishes.
- Per-feature branch + sprint-end PR: each feature lives on
<feature-slug> branch; red and green commits push freely there (no green-tests gate on feature branches); sprint review opens a PR to main once all greens are complete.
What is not allowed:
git push --no-verify to bypass the green-tests hook during a red wave.
- A custom hook escape hatch keyed off the commit message (e.g., a
Task: T00X-red marker that disables the hook). This was considered and rejected: it makes the hook lie about what passed, and a forgotten marker leaks broken tests to main.
Document the chosen strategy in .architecture/CONVENTIONS.md under a ## Branching and push timing section.
Roles summary
| Role |
Owns |
Model |
| product-manager |
FEATURE.md (Context, Impact functional, Acceptance criteria, Out of scope), .features/INDEX.md |
sonnet |
| architect |
.architecture/, .features/<slug>/ARCHITECTURE.md, .adrs/ (strategic), FEATURE.md sections ## Technical impact and ## Relevant ADRs |
opus |
| sprint-planner |
.sprints/SPRINT_00X/SPRINT.md, .features/<slug>/TASKS.md, all per-task files (SCAFFOLD.md, TASK.md, TASK-red.md, TASK-green.md), dispute decisions, sub-sprint creation |
opus |
| scaffolder |
Exported types, interfaces, signatures (empty bodies) per ARCHITECTURE.md |
haiku |
| red-* |
*_test.go, testdata/, testutil/, mocks/ (along with scaffor) |
haiku / sonnet / opus |
| green-* |
Non-test .go files (function bodies in scaffolded stubs, private helpers), tactical ADRs |
haiku / sonnet / opus |
| e2e-tester |
End-to-end scenarios per feature |
sonnet default, opus if complex |
| reviewer |
REVIEW.md at feature and sprint level |
sonnet |
| bug-detective |
On-demand bug investigation. Produces .bugs/<bug-id>.md reports — does not fix. Routes via planner |
sonnet |
Project workflow
Principles
- Work happens in sprints. Maintenance (typos, dep updates, linting, small refactors) can happen outside sprints.
- Every non-trivial decision is documented in an ADR.
- Blockers and open questions always require human input — no auto-resolution. No sprint, feature, or task starts while a blocker or open question is pending.
- Red and green operate with spec isolation. Cross-reading private specs is forbidden.
- ADRs listed in
FEATURE.md propagate into SCAFFOLD.md and TASK.md by the planner. All agents read the ADRs relevant to their task.
Global architecture (.architecture/)
Owned by the architect. Typical contents:
OVERVIEW.md — high-level architecture.
CONVENTIONS.md — coding conventions, package layout, error handling, logging.
INTEGRATIONS.md — external services and contracts.
- Topic-specific files as needed (
AUTH.md, PERSISTENCE.md, OBSERVABILITY.md).
Every agent can read .architecture/. Only the architect writes.
Features (.features/)
INDEX.md: all features in priority order with status (todo / ready / in-progress / done / blocked) and complexity. Owned by the PM for priority and PM-side DoR transitions. Schema:
| Slug | Status | Complexity | Priority |
|---------------------|-------------|----------------|----------|
| user-login | ready | architectural | 1 |
| add-email-validation| ready | standard | 2 |
| rename-user-field | ready | mechanical | 3 |
<slug>/FEATURE.md: co-owned. PM owns Context/Impact functional/Acceptance criteria/Out of scope. Architect owns ## Technical impact, ## Complexity (with rationale), and ## Relevant ADRs.
<slug>/ARCHITECTURE.md: owned by the Architect. Describes the technical design for this feature: types, interfaces, package layout, dependencies, cross-cutting concerns. Primary input for the Scaffolder.
FEATURE.md template (co-authored)
# Context
[PM: why this feature exists, what problem it solves]
# Impact
[PM: functional impact — which user flows change, which personas]
## Technical impact
[Architect: services/apps/packages modified, infrastructure impact]
# Acceptance criteria
- [ ] [PM: detailed testable checklist]
# Out of scope
[PM: what is NOT included]
## Complexity
`<mechanical | standard | architectural>`
## Complexity rationale
[One to three sentences explaining why this level was chosen. Reference specific characteristics: new contract introduced, pattern already exists, invariants modified, etc. Set by the Architect during DoR enrichment, with PM input.]
## Relevant ADRs
- [Architect: list of ADRs that constrain this feature's implementation]
Definition of Ready (DoR)
A feature can only enter a sprint if all are true:
Features not satisfying DoR stay in todo. Only ready features enter a sprint.
Tasks (.features//TASKS.md + .features//tasks/)
Principle
Before a sprint starts, the sprint-planner agent (opus) breaks down all included features into tasks. Sprint cannot start until breakdown is complete.
Pipeline routing by complexity
The sprint-planner routes each feature according to its ## Complexity field (set at DoR by the Architect):
mechanical → single-agent task with a direct TASK.md. No SCAFFOLD, no red/green split, no separate reviewer pass. One agent (haiku or sonnet) executes end-to-end. This is the only allowed exception to the red/green absolute rule (see Red/Green pattern above for the exact carve-out).
standard → reduced pipeline: Planner → Scaffolder → Red/Green → Reviewer. Skip PM/Architect re-entry (their work is already captured in FEATURE.md and ADRs). Full triptyque TASK.md + TASK-red.md + TASK-green.md applies.
architectural → full pipeline: PM/Architect re-entry if needed → SCAFFOLD → Red/Green → E2E → Reviewer. Mandatory strategic ADR before SCAFFOLD starts.
SPRINT.md documents the per-feature routing in a ## Routing decisions section.
For classification heuristics, escalation rules, and retro calibration, the planner consults the task-complexity-routing skill at planning time (PM and Architect also load it, when proposing or amending complexity). Other agents (scaffolder, red, green, e2e, reviewer) inherit their assigned pipeline and do not classify.
Task types
- SCAFFOLD (one per feature, first): scaffolder produces contracts.
- Red/Green triple (one per unit of work): three files, two agents.
- E2E (at least one per feature): standalone, blocked by all greens.
- Feature REVIEW (one per feature): blocked by all red/green/e2e.
- Sprint REVIEW (one per sprint): blocked by all feature REVIEWs.
SCAFFOLD task — Definition of Done
A SCAFFOLD task is done only when every item below is verifiable. Red cannot start on a feature whose SCAFFOLD has any unchecked item. The scaffolder ticks each box in its SCAFFOLD.md with evidence (e.g., command output) attached.
If any item cannot be satisfied — e.g., ARCHITECTURE.md lists a type the scaffolder cannot construct without designing logic — the scaffolder opens a dispute against the architect (decision E in the dispute protocol), not a partial scaffold.
Three-file task structure (for red/green units)
Every red/green unit produces three files under .features/<slug>/tasks/:
<TASK_ID>.md — shared spec. Read by red, green, planner (for arbitration), reviewer.
<TASK_ID>-red.md — red's private spec. Read only by the red teammate.
<TASK_ID>-green.md — green's private spec. Read only by the green teammate.
Rules:
- Shared info goes in
TASK.md.
- Test design goes in
TASK-red.md only.
- Implementation design goes in
TASK-green.md only.
- ADRs are listed in
TASK.md ## Applicable ADRs, not duplicated in private specs.
- Red never reads
TASK-green.md. Green never reads TASK-red.md. The planner never reads either during arbitration.
TASKS.md (task index per feature)
| ID |
Title |
Phase |
Agent |
Status |
Deps |
Parallel |
| SCAFFOLD |
Scaffolding |
scaffold |
scaffolder |
todo |
— |
yes |
| T001 |
Login use case (shared) |
shared |
— |
— |
— |
— |
| T001-red |
Login use case — tests |
red |
red-sonnet |
todo |
SCAFFOLD |
yes |
| T001-green |
Login use case — impl |
green |
green-sonnet |
todo |
T001-red |
no |
| T002 |
User repo (shared) |
shared |
— |
— |
— |
— |
| T002-red |
User repo contract tests |
red |
red-haiku |
todo |
SCAFFOLD |
yes |
| T002-green |
User repo postgres adapter |
green |
green-sonnet |
todo |
T002-red |
no |
| E001 |
Login → JWT → refresh e2e |
e2e |
e2e-tester |
todo |
T001-green, T002-green |
no |
| REVIEW |
Feature review |
review |
reviewer |
todo |
T001-green, T002-green, E001 |
no |
Unplanned tasks use -unplanned suffix on the phase (e.g., T012-red-unplanned).
Sub-sprint helper tasks use H<NNN>-red (no green pair, see Sub-sprints).
Agent profiles
scaffolder: always haiku. One per feature.
red-haiku: mechanical tests (boilerplate, DTO validation, single file, <50 lines).
red-sonnet: standard tests (use case tests, contract tests, middleware tests).
red-opus: complex test design (concurrency, state machines, auth flows).
green-haiku: mechanical implementation (DTOs, simple adapters, wiring).
green-sonnet: standard implementation (use cases, adapters with transactions, middleware).
green-opus: complex implementation (architecture, cross-cutting, concurrency, ADR-level).
e2e-tester: end-to-end / integration scenarios.
reviewer: always sonnet — complexity encoded in the checklist.
Red and green in the same pair are assigned independently. Any combination across tiers is valid: e.g., red-opus paired with green-haiku, red-haiku paired with green-sonnet, red-sonnet paired with green-opus, etc. The planner judges test-design complexity and implementation complexity as two separate decisions — a task can have hard tests but a mechanical implementation, or a trivial assertion against a concurrency-heavy implementation. No teammate should assume its partner shares its model tier; the task files (TASKS.md and SPRINT.md) are the source of truth for which specific agent is paired on each task.
File edit permissions
Hard rule enforced by each agent's spec:
| Role |
Can edit |
Cannot edit |
| PM |
FEATURE.md (Context/Impact functional/AC/Out of scope), .features/INDEX.md |
.architecture/, .adrs/, ARCHITECTURE.md, any code, any other doc |
| architect |
.architecture/, .features/<slug>/ARCHITECTURE.md, .adrs/, FEATURE.md Technical impact and Relevant ADRs sections |
PM sections of FEATURE.md, INDEX.md, any code, tasks, sprints |
| planner |
SPRINT.md, TASKS.md, SCAFFOLD.md, TASK.md (shared), INDEX.mds, dispute decisions, .questions/, sub-sprints |
TASK-red.md, TASK-green.md, any .go file, any ADR |
| scaffolder |
Non-test .go (signatures, types, empty bodies only), own SCAFFOLD.md DoD checkboxes, dispute file sections |
*_test.go, test support dirs, any doc other than own spec |
| red |
*_test.go, testdata/, testutil/, mocks/, own TASK-red.md DoD checkboxes, dispute file sections |
Any non-test .go, scaffolded signatures, any doc other than own red spec |
| green |
Non-test .go files (fill scaffolded bodies, add private helpers), own TASK-green.md DoD checkboxes, dispute file sections, tactical ADRs |
Any *_test.go, scaffolded signatures, exported symbols, any doc other than own green spec |
ADR propagation
The architect lists relevant ADRs in FEATURE.md ## Relevant ADRs. The planner propagates these into:
SCAFFOLD.md ## Applicable ADRs — ADRs affecting types, interfaces, naming, package layout.
TASK.md ## Applicable ADRs — ADRs affecting the behavior of this specific task.
Red and green read ADRs via the shared TASK.md. Scaffolder reads via SCAFFOLD.md.
Dispute protocol
Location: .disputes/SPRINT_00X/<TASK_ID>.md (or SCAFFOLD-<slug>.md).
Hat-switching declaration (mono-assistant safeguard)
When a single assistant wears multiple roles in the same session (e.g., the same Claude instance acted as red earlier and is now arbitrating as sprint-planner), spec isolation is not enforced by the runtime — only by discipline. To make hat-switching auditable:
Before reading any artifact in a dispute, the assistant must append a hat-switch marker at the top of the dispute file:
## Planner hat activated: 2026-04-25 by <assistant-id>
Previous hats this session: red (T003-red), green (T005-green)
Confirms: will read only public artifacts (TASK.md, scaffolded code, test files, ADRs, ARCHITECTURE.md). Will NOT consult TASK-red.md or TASK-green.md.
The marker is a public artifact — it stays in the dispute file and is reviewed at retro.
Self-test before reading the other spec: "Am I currently red or green? If yes, I cannot read the other private spec — I must open a dispute first and let the planner hat (mine or another's) arbitrate."
A dispute file missing a hat-switch marker, written by an assistant who acted as red or green earlier in the session, is treated as invalid at retro and the decision must be re-litigated.
This applies to any mono-assistant role transition, not just planner: if you wrote tests as red-opus and are now asked to scaffold, declare the hat switch even though scaffolding has no isolation rule — the marker creates an audit trail.
Red → green on the same task (mono-assistant only)
The hat-switch marker covers the case where the assistant arbitrates another pair's dispute. The harder case is when the same assistant must be both red and green for the same task — typical when agent teams aren't enabled and you're working solo.
The rule for this case:
- The assistant completes the red phase end to end: writes the failing tests, runs them, confirms they fail for implementation reasons, and commits under
Task: <TASK_ID>-red.
- The assistant then starts a fresh session before reading
TASK-green.md. In Claude Code this means /clear or opening a new conversation. The session reset is what purges TASK-red.md from working context.
- The new session opens by reading only the green inputs:
TASK.md, TASK-green.md, the test files committed in step 1, and any source files referenced. It must not read TASK-red.md.
- The red commit is the only handoff. If green needs information that lived only in
TASK-red.md, that is a signal the shared TASK.md was incomplete or the test code was insufficient — open a dispute against the planner to amend TASK.md, do not bypass the reset to re-read the red spec.
Audit: at sprint review, for every task where red and green were the same assistant, check git log — there must be at least one commit between the red work and the green work (the Task: <TASK_ID>-red commit). A task whose red and green files appear in a single commit is treated as an isolation violation.
This rule does not prohibit a single assistant from doing red and green on the same task. It just makes the boundary explicit, observable, and machine-checkable.
Who can raise
- Scaffolder vs architect:
ARCHITECTURE.md ambiguous, contradictory, or incomplete.
- Red vs scaffolder: signature untestable.
- Red vs self-spec: shared spec ambiguous or contradictory.
- Green vs red: test unfulfilable, contradictory, over-specifying, missing-coverage, broken.
- Green vs scaffolder: scaffolded signature forces an untenable implementation.
- Any teammate vs planner: complexity-upgrade request (see Complexity escalation below).
Flow:
Disputing party creates/appends the dispute file with a structured section.
Disputing party messages affected teammates and the planner.
Work stops on the disputed portion.
Affected teammates may respond in their own sections — without reading the other's private spec.
The planner reads public artifacts only: shared specs, scaffolded code, test code, ADRs, ARCHITECTURE.md.
The planner writes ## Planner decision citing only public artifacts. Decision types: A (scaffolder revises), B (red revises), C (green proceeds under interpretation), D (both adjust), E (escalate to architect), F (escalate to human), G (complexity upgrade — see below).
Planner notifies every teammate listed under Action required: via teammate message, with a one-line summary of the decision and a pointer to the dispute file. The planner does not mark the dispute Status: resolved yet.
Each notified teammate acknowledges before resuming. Append a single line to the dispute file under a ## Acknowledgements section:
## Acknowledgements
- Acknowledged by red-sonnet on 2026-04-25 — will revise tests per decision B.
- Acknowledged by green-haiku on 2026-04-25 — will resume under interpretation C.
Acknowledgement implies the teammate has read the planner decision and accepts the action item. A teammate that disagrees does not ack — it raises a new dispute (rare, only when the decision contradicts a public artifact the planner missed).
Once every teammate listed under Action required: has acked, the planner marks the dispute Status: resolved (or awaiting-architect-input / awaiting-human-input for E/F). Without all acks, the status remains awaiting-ack.
Teammates resume per decision.
Disputes persist through sprint end and feed the retro. The sprint REVIEW.md checklist rejects any dispute marked resolved that lacks an ack from every teammate listed in Action required: — incomplete propagation is treated as an unresolved dispute.
Complexity escalation (dispute type G)
The skill states complexity can be upgraded but never downgraded. The mechanism:
When to raise. A teammate (most often green or red) discovers mid-task that the work classified as mechanical or standard actually requires architectural thinking — e.g., a state machine, a concurrency invariant, a cross-cutting concern not visible from the shared spec. Telltale signs: the implementation cannot be expressed without a new abstraction; tests cannot be written without inventing a model; an ADR feels necessary.
How to raise. Open the dispute as type G with a target:
## Dispute (type G — complexity upgrade)
Raised by: green-haiku on T007-green
Current classification: standard
Requested classification: architectural
Target retarget: green-haiku → green-opus
Evidence (public artifacts only):
- Scaffolded signature `CircuitBreaker.Trip()` requires a state machine with 4 states and 6 transitions; the shared TASK.md describes only "trip when threshold exceeded".
- Existing ADR-014 mentions backoff but not state ownership.
- Without a new ADR fixing state ownership, the implementation will encode an undocumented decision.
Planner response. The planner decides:
- G-finish-then-escalate (default): the current agent finishes the task with the simplest correct implementation, commits, and the planner schedules a follow-up refactor task at the higher tier in the next sprint (or as a sub-sprint if blocking other work). This is the default because mid-task agent handoff loses context and routinely produces worse code than letting the current agent finish.
- G-immediate-rerun: if the current agent declares it cannot finish at all (not "can finish but suboptimally"), the planner reverts the in-progress work, re-routes the task to the higher tier, and reassigns. The reverted commit, if any, is marked in the retro.
- G-architect-loop: if the upgrade reveals a missing ADR, escalate to the architect first (decision E), then re-classify once the ADR exists.
Hard rule. Never replace green-haiku with green-opus during a task. Either let the haiku agent finish (then schedule follow-up refactor) or revert and restart fresh. Mid-task handoff is forbidden.
Retro feedback. Every G dispute is logged in ## Complexity calibration of the RETRO. A pattern of upgrades from standard to architectural on similar tasks signals the planner is under-classifying — the calibration heuristics in task-complexity-routing should be tightened.
Breakdown rules
- Tasks must be atomic: completable in one session with a clear DoD.
- Tasks exceeding ~1 day: split further.
- Identify parallelizable tasks.
- Green is never parallel to its own red.
- Red is always blocked by SCAFFOLD.
- Scaffold tasks of different features can run in parallel.
Relation to other artifacts
- Blocker on a task →
.blockers/SPRINT_00X/ referencing <feature-slug>/<TASK_ID>.
- Question →
.questions/SPRINT_00X/ same reference.
- Non-trivial decision during green → tactical ADR under
.adrs/.
- Dispute →
.disputes/SPRINT_00X/<TASK_ID>.md.
- Private helper added by green → logged in feature RETRO, sub-sprint created by planner.
Unplanned tasks
A teammate may add an unplanned task during sprint execution without waiting for the planner, provided all of the following hold:
- The new task belongs to a feature already
in-progress in the current sprint scope. A new feature cannot be unplanned — it must wait for the next sprint, or be raised as a blocker if it cannot wait.
- The task is added to the feature's
TASKS.md with a phase suffix -unplanned (e.g., T012-red-unplanned, T012-green-unplanned).
- The task's
TASK.md includes a ## Why unplanned section with a one-paragraph justification: what made the work emerge mid-sprint, why it could not have been planned at sprint start, and which in-flight task it unblocks.
If writing the ## Why unplanned justification takes more than two minutes of thought, the work is probably not an unplanned task — it is a blocker. Open .blockers/SPRINT_00X/ instead and stop affected work.
The sprint-planner may, at any time during the sprint, defer an unplanned task: work stops on it and it moves to the next sprint's backlog. The planner cites the ## Why unplanned paragraph in its deferral note.
At sprint review:
- Each unplanned task has its own line in
metrics.unplanned_tasks count of the RETRO YAML.
- If
unplanned_tasks > 30 % of delivered_tasks, the sprint is flagged as under-planned in the prose ## Dispute analysis section, and the next sprint's planning gets an extra DoR review pass.
- Unplanned tasks that completed are folded into the regular sprint metrics (counted as delivered).
- Unplanned tasks that were deferred by the planner are listed under
## Notes the YAML can't capture with the deferral rationale.
A new feature cannot be unplanned. Mid-sprint pivots that introduce a new feature stop the sprint and require a planner-issued blocker, not an unplanned task.
Reviews (.features//REVIEW.md + .sprints/SPRINT_00X/REVIEW.md)
The reviewer agent (sonnet) produces exhaustive verification checklists. Two levels.
Feature-level review
Consolidates:
- Acceptance criteria from
FEATURE.md.
- DoD items from every task of the feature (scaffold, red, green, e2e).
- Non-functional requirements.
Every item must be explicitly checked, traceable to its source, and verified with evidence.
Feature marked done only when REVIEW.md is fully checked.
Sprint-level review
Aggregates feature REVIEWs plus cross-cutting:
Sprint marked done only when sprint REVIEW.md is fully checked.
Sprints (.sprints/)
INDEX.md: all sprints with start/end dates and status.
SPRINT_00X/SPRINT.md: focus, features, execution plan as todo list with agent names inline.
SPRINT_00X/REVIEW.md: sprint review checklist.
SPRINT_00X/RETRO.md: retrospective.
- Completion: all features done, all blockers/questions/disputes resolved, REVIEW.md fully checked, RETRO.md written, sub-sprint created if needed.
- Micro-work that can't wait:
SPRINT_00X-Y (also the
…(truncated)
1---2name: agile-project3description: Use this skill whenever you are working on a Go project following this agile workflow — features in .features/, sprints in .sprints/, ADRs in .adrs/, global architecture in .architecture/, per-feature ARCHITECTURE.md written by the Architect, tasks under .features/<slug>/tasks/ with scaffolding-first plus red/green triples (TASK.md shared + TASK-red.md + TASK-green.md), spec isolation between paired teammates, dispute arbitration by the sprint-planner, complexity-based agent assignment (scaffolder, red-opus/sonnet/haiku, green-opus/sonnet/haiku, e2e-tester, reviewer), PM and Architect roles for feature definition, and retro-driven sub-sprints for private-helper test coverage. Triggers: mention of sprint planning, feature breakdown, TASK.md / TASK-red.md / TASK-green.md / SCAFFOLD.md, SPRINT.md, REVIEW.md, RETRO.md, Definition of Ready, Definition of Done, blockers, questions, ADRs with revisit flag, dispute files in .disputes/, any of the sprint-planner/product-manager/architect/scaffolder/red-*/green-*/revie4---56# Agile Project Workflow78Workflow for Go projects using strict TDD, sprint-based agile, complexity-graded agents running as Claude Code teammates, scaffolding-first contracts, and spec isolation between paired teammates.910---1112# Go file editing — ABSOLUTE RULE1314**STRICTLY FORBIDDEN** to use `Edit`, `Write`, `Read`, or any generic tool to read or modify a `.go` file.1516For **every** `.go` file without exception:1718- Reading → `go-surgeon symbol` or `go-surgeon overview`19- Creation → `go-surgeon create`20- Modification → `go-surgeon patch_function`, `patch_struct`, `patch_interface`, `update`, `insert_call`, etc.2122This rule applies even for a single-line change. No exceptions.2324---2526# Parallelization — ABSOLUTE RULE2728Use **sub-agents** (`Agent` tool) or **agent teams** (`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`) for any task composed of independent parts (no file conflicts, no result dependencies).2930- Launch parallel work in a single message (multiple simultaneous tool calls, or a team spawn).31- Never execute sequentially what can be parallelized.32- Examples: scaffolding multiple features in parallel, writing independent tests, creating files in different packages.3334## Parallelism granularity3536Maximum theoretical fan-out (e.g., "23 independent red tasks") is rarely the right unit. Rate limits, token budgets, and the cost of recovering from concurrent crashes (see *Agent crash recovery*) make wide fan-outs fragile.3738**Default heuristic — feature as the unit of parallelism:**3940- One agent per feature, traversing all tasks of that feature (all reds first, then all greens, in dependency order).41- Features run in parallel with each other.42- Within a feature, tasks run sequentially under one agent — that agent keeps the feature context warm across tasks.4344This caps live agents to roughly the number of features in scope (typically 2–4 per sprint). It trades some theoretical parallelism for crash containment: a rate-limit on one feature does not corrupt three others' in-flight state.4546**When to deviate (planner's call):**4748- A feature with one heavy `architectural` task and several `mechanical` tasks: split the feature across two agents (one opus, one haiku) — the heavy task does not block the easy ones.49- A scaffold-only wave: scaffolders are short-lived and cheap; running them all in parallel is fine.50- An e2e wave at sprint end: e2e tests for different features touch different test files; one agent per e2e is fine.5152**What to avoid:**5354- Spawning N agents where N equals task count. Pattern observed in the wild: 23 reds spawned simultaneously, 3 crashed mid-run, batch-commit lost work across all 23.55- Mixing red and green of the same task on the same agent — spec isolation breaks.56- Two agents writing to the same package concurrently (file-level races on `go-surgeon` edits).5758The planner documents the chosen fan-out in `SPRINT.md` under `## Parallelization plan`, with a one-sentence rationale.5960---6162# Tests — ABSOLUTE RULE6364Every feature **must** include:6566- **Unit tests**: for any logic in `app/` and `domain/` (table-driven, mocks via interfaces).67- **Contract tests**: for each repository adapter (via testcontainers).68- **E2E / integration tests**: at least one end-to-end scenario per feature.6970Tests are produced **after scaffolding and before implementation**, following the strict red/green pattern. A feature without tests is not done.7172---7374# Complexity classification — ABSOLUTE RULE7576Every feature carries a `## Complexity` field in its `FEATURE.md`, one of `mechanical`, `standard`, `architectural`.7778- Missing complexity field fails DoR.79- The planner decides pipeline routing based on this field (see *Pipeline routing by complexity* below).80- A task can be **upgraded** in complexity during execution (via dispute type G), **never downgraded** while in flight. Over-classification is corrected in the retro for future calibration, not by demoting the running task.8182Detailed classification heuristics, escalation signals, and retro calibration live in the `task-complexity-routing` skill. Load that skill only when classifying, routing, or reviewing classification accuracy — not for routine implementation work.8384---8586# Scaffolding-first — ABSOLUTE RULE8788Before red and green teammates start a feature, a **scaffolder** agent produces the **testable contract** — all exported types, interfaces, and function/method signatures with empty bodies that compile (`panic("not implemented: ...")` or zero-value returns).8990- One `SCAFFOLD` task per feature. Agent: `scaffolder` (haiku).91- Scaffolder couples with the `scaffor` tool (https://github.com/JLugagne/scaffor) which generates mocks and test scaffolds from the interfaces scaffolded.92- All red tasks of the feature are `blocked by: SCAFFOLD`.93- Red tests against scaffolded signatures. Green fills in the bodies.94- **Red cannot modify scaffolded signatures.** If a signature is untestable, red raises a dispute.95- **Green cannot modify scaffolded signatures** or add new exported symbols. Green may add **private (unexported)** helpers; these must be logged in the feature retro for retroactive test coverage via a sub-sprint.9697---9899# Red/Green pattern — ABSOLUTE RULE100101All **production-code feature work** at `standard` or `architectural` complexity follows strict TDD with **paired teammates** and **spec isolation**:102103- **Red phase**: a `red-*` teammate writes failing tests against the scaffolded contract. Cannot edit production code or scaffolded signatures.104- **Green phase**: a `green-*` teammate implements scaffolded functions. Cannot edit test code, cannot modify scaffolded signatures, cannot add exported symbols.105- **Spec isolation**: red reads `TASK.md` + `TASK-red.md`. Green reads `TASK.md` + `TASK-green.md` + red's test files. Neither reads the other's private spec.106- **Dispute**: if green disagrees with red, or either disagrees with the scaffold, they open `.disputes/SPRINT_00X/<TASK_ID>.md`. The `sprint-planner` arbitrates based on public artifacts only.107108All teammates (scaffolder, red, green, planner) stay **alive simultaneously** via Claude Code agent teams and communicate via teammate messaging and shared files.109110Exception: scaffolder has its own standalone task (no pairing). E2E and review tasks are standalone (no red/green pairing).111112## In scope vs out of scope of red/green113114The rule applies to **production-code feature work**. It does **not** apply to mechanical maintenance, where there is a unique correct answer and no design decision. The frontier is:115116| In scope of red/green (rule applies) | Out of scope (rule does not apply) |117|-----------------------------------------------------------------------|-----------------------------------------------------------------|118| `standard` features (use cases, adapters, middleware, validation) | Rename a local symbol with no API change |119| `architectural` features (new contracts, cross-cutting, invariants) | `gofmt`, `goimports`, linter auto-fixes |120| Bug fixes that change observable behavior | Dependency bump with no API impact |121| New exported APIs, signatures, types | Comment / log message / error string fixes |122| Behavior changes covered by acceptance criteria in `FEATURE.md` | Regenerating mocks after an interface change already decided |123| | `mechanical` features (single-agent task; see *Pipeline routing*) |124125The `task-complexity-routing` skill defines `mechanical` precisely as "transformation whose correct result is unique or quasi-unique" — that is exactly the zone where a red/green pair adds no signal (the test would only re-assert the input/output equality already enforced by the type system or the linter).126127When in doubt, classify **upward** (`standard` over `mechanical`). Under-classification is corrected by an in-flight upgrade dispute (type G); over-classification only wastes one cheap pair.128129---130131# Commit cadence — ABSOLUTE RULE132133Each agent **commits after every completed task**, never in batches.134135- One commit per `<TASK_ID>` (one per `T00X-red`, one per `T00X-green`, one per `SCAFFOLD`, etc.).136- A teammate finishing two tasks in a row produces two commits, not one squashed commit.137- Do not defer commits to the end of a wave or the end of a sprint.138139This bounds the blast radius of an agent crash, rate-limit interruption, or session loss to **one task** instead of a whole wave. The recovery procedure below depends on this.140141---142143# Agent crash recovery — ABSOLUTE RULE144145When one or more teammates crash mid-wave (rate limit, session disconnect, OOM), follow this procedure before re-spawning. **Never** delete dirty state blindly.146147## 1. Inventory dirty state148149Before any cleanup decision:150151- `git status` — list every modified or untracked file.152- For each dirty file, classify:153 - **complete** — the task it belongs to is finished per its DoD; safe to commit.154 - **partial** — task started, not finished; salvage decision needed.155 - **stale** — leftover from a task that was already committed elsewhere; safe to revert.156- Map dirty files → expected task scope using `SPRINT.md` and `TASKS.md`. Files outside any in-flight task scope are suspect — investigate before touching.157158## 2. Salvage vs revert, per file159160For each **partial** file:161162- If the partial work is on a critical path of a downstream task → **salvage**: complete the minimum needed to satisfy the task DoD, then commit under the original `<TASK_ID>`.163- If the partial work is non-load-bearing or duplicates work re-spawn will redo → **revert** that specific file (`git checkout -- <path>`), not the whole tree.164165For each **stale** file: revert.166167For each **complete** file: commit under its `<TASK_ID>` immediately, before re-spawning anything.168169## 3. Re-spawn with narrowed scope170171When relaunching the crashed agents:172173- Exclude every task already committed (check `git log --grep="Task:"` for the sprint).174- Exclude every task whose files were just salvaged-and-committed in step 2.175- Pass the narrowed task list explicitly in the spawn prompt — do not let the agent infer scope from `TASKS.md` alone (status fields may not yet reflect committed work).176177## 4. Document the crash178179Append a short entry to the sprint RETRO under `## Agent crashes` (see retro template below): which agents, which wave, which tasks salvaged vs reverted, and any lost work. This feeds the parallelization heuristic at retro time.180181---182183# Commits — ABSOLUTE RULE184185Every commit message **must** reference feature and task:186187```188<short description>189190Feature: <feature-slug>191Task: <TASK_ID>192```193194- `Feature:` slug under `.features/<slug>/`.195- `Task:` includes phase suffix: `SCAFFOLD`, `T003-red`, `T003-green`, `E001`, `REVIEW`, `SPRINT_REVIEW`, `H001-red` (sub-sprint helper task).196- Multiple tasks: `Task: T003-green, T004-green`.197- Maintenance: `Feature: maintenance`, `Task: -`.198199Branches: `<feature-slug>/<TASK_ID>-<short-description>` (e.g., `auth/T003-green-login-usecase`, `auth/SCAFFOLD`).200201---202203# Push timing — ABSOLUTE RULE204205A red wave produces tests that fail by design. A pre-push hook running `go test ./...` will reject these commits, and bypassing it (`--no-verify`) defeats the gate for everyone.206207The rule:208209- **Never push to `main` (or any shared branch with a green-tests pre-push hook) in the middle of a red wave.**210- A push to a shared branch is allowed **only** at the end of a complete green wave, when `go test ./...` passes locally.211- Within a wave, commits stay local (or on a per-feature branch) until the matching green completes.212213Allowed branching strategies, pick one per project:2142151. **Trunk + delayed push** (default for solo / small teams): commit red and green locally on `main`, push only when the green wave finishes.2162. **Per-feature branch + sprint-end PR**: each feature lives on `<feature-slug>` branch; red and green commits push freely there (no green-tests gate on feature branches); sprint review opens a PR to `main` once all greens are complete.217218What is **not** allowed:219220- `git push --no-verify` to bypass the green-tests hook during a red wave.221- A custom hook escape hatch keyed off the commit message (e.g., a `Task: T00X-red` marker that disables the hook). This was considered and rejected: it makes the hook lie about what passed, and a forgotten marker leaks broken tests to main.222223Document the chosen strategy in `.architecture/CONVENTIONS.md` under a `## Branching and push timing` section.224225---226227# Roles summary228229| Role | Owns | Model |230|-------------------|---------------------------------------------------------------------|--------|231| product-manager | `FEATURE.md` (Context, Impact functional, Acceptance criteria, Out of scope), `.features/INDEX.md` | sonnet |232| architect | `.architecture/`, `.features/<slug>/ARCHITECTURE.md`, `.adrs/` (strategic), `FEATURE.md` sections `## Technical impact` and `## Relevant ADRs` | opus |233| sprint-planner | `.sprints/SPRINT_00X/SPRINT.md`, `.features/<slug>/TASKS.md`, all per-task files (`SCAFFOLD.md`, `TASK.md`, `TASK-red.md`, `TASK-green.md`), dispute decisions, sub-sprint creation | opus |234| scaffolder | Exported types, interfaces, signatures (empty bodies) per `ARCHITECTURE.md` | haiku |235| red-* | `*_test.go`, `testdata/`, `testutil/`, `mocks/` (along with `scaffor`) | haiku / sonnet / opus |236| green-* | Non-test `.go` files (function bodies in scaffolded stubs, private helpers), tactical ADRs | haiku / sonnet / opus |237| e2e-tester | End-to-end scenarios per feature | sonnet default, opus if complex |238| reviewer | `REVIEW.md` at feature and sprint level | sonnet |239| bug-detective | On-demand bug investigation. Produces `.bugs/<bug-id>.md` reports — does not fix. Routes via planner | sonnet |240241---242243# Project workflow244245## Principles246247- Work happens in sprints. Maintenance (typos, dep updates, linting, small refactors) can happen outside sprints.248- Every non-trivial decision is documented in an ADR.249- Blockers and open questions **always** require human input — no auto-resolution. No sprint, feature, or task starts while a blocker or open question is pending.250- Red and green operate with **spec isolation**. Cross-reading private specs is forbidden.251- ADRs listed in `FEATURE.md` propagate into `SCAFFOLD.md` and `TASK.md` by the planner. All agents read the ADRs relevant to their task.252253## Global architecture (.architecture/)254255Owned by the **architect**. Typical contents:256257- `OVERVIEW.md` — high-level architecture.258- `CONVENTIONS.md` — coding conventions, package layout, error handling, logging.259- `INTEGRATIONS.md` — external services and contracts.260- Topic-specific files as needed (`AUTH.md`, `PERSISTENCE.md`, `OBSERVABILITY.md`).261262Every agent can **read** `.architecture/`. Only the architect writes.263264## Features (.features/)265266- `INDEX.md`: all features in priority order with status (todo / ready / in-progress / done / blocked) and complexity. Owned by the PM for priority and PM-side DoR transitions. Schema:267268 ```markdown269 | Slug | Status | Complexity | Priority |270 |---------------------|-------------|----------------|----------|271 | user-login | ready | architectural | 1 |272 | add-email-validation| ready | standard | 2 |273 | rename-user-field | ready | mechanical | 3 |274 ```275276- `<slug>/FEATURE.md`: co-owned. PM owns Context/Impact functional/Acceptance criteria/Out of scope. Architect owns `## Technical impact`, `## Complexity` (with rationale), and `## Relevant ADRs`.277- `<slug>/ARCHITECTURE.md`: owned by the Architect. Describes the technical design for this feature: types, interfaces, package layout, dependencies, cross-cutting concerns. Primary input for the Scaffolder.278279### FEATURE.md template (co-authored)280281```282# Context283[PM: why this feature exists, what problem it solves]284285# Impact286[PM: functional impact — which user flows change, which personas]287288## Technical impact289[Architect: services/apps/packages modified, infrastructure impact]290291# Acceptance criteria292- [ ] [PM: detailed testable checklist]293294# Out of scope295[PM: what is NOT included]296297## Complexity298`<mechanical | standard | architectural>`299300## Complexity rationale301[One to three sentences explaining why this level was chosen. Reference specific characteristics: new contract introduced, pattern already exists, invariants modified, etc. Set by the Architect during DoR enrichment, with PM input.]302303## Relevant ADRs304- [Architect: list of ADRs that constrain this feature's implementation]305```306307### Definition of Ready (DoR)308309A feature can only enter a sprint if **all** are true:310311- [ ] **PM**: Context is clear and the problem is identified.312- [ ] **PM**: Acceptance criteria are testable.313- [ ] **PM**: Out of scope is explicit.314- [ ] **PM**: No open product-side question references this feature.315- [ ] **Architect**: `## Technical impact` is identified (services, packages, apps).316- [ ] **Architect**: External dependencies are listed in `ARCHITECTURE.md`.317- [ ] **Architect**: Technical risks are identified in `ARCHITECTURE.md`.318- [ ] **Architect**: No open technical question references this feature.319- [ ] **Architect**: `## Complexity` field is set to one of `mechanical`, `standard`, or `architectural` (with rationale).320- [ ] **Both**: No open blocker references this feature.321322Features not satisfying DoR stay in `todo`. Only `ready` features enter a sprint.323324## Tasks (.features/<slug>/TASKS.md + .features/<slug>/tasks/)325326### Principle327328Before a sprint starts, the `sprint-planner` agent (opus) breaks down all included features into tasks. Sprint cannot start until breakdown is complete.329330### Pipeline routing by complexity331332The sprint-planner routes each feature according to its `## Complexity` field (set at DoR by the Architect):333334- `mechanical` → **single-agent task** with a direct `TASK.md`. No SCAFFOLD, no red/green split, no separate reviewer pass. One agent (haiku or sonnet) executes end-to-end. This is the only allowed exception to the red/green absolute rule (see *Red/Green pattern* above for the exact carve-out).335- `standard` → **reduced pipeline**: Planner → Scaffolder → Red/Green → Reviewer. Skip PM/Architect re-entry (their work is already captured in `FEATURE.md` and ADRs). Full triptyque `TASK.md` + `TASK-red.md` + `TASK-green.md` applies.336- `architectural` → **full pipeline**: PM/Architect re-entry if needed → SCAFFOLD → Red/Green → E2E → Reviewer. Mandatory strategic ADR before SCAFFOLD starts.337338`SPRINT.md` documents the per-feature routing in a `## Routing decisions` section.339340For classification heuristics, escalation rules, and retro calibration, the planner consults the `task-complexity-routing` skill at planning time (PM and Architect also load it, when proposing or amending complexity). Other agents (scaffolder, red, green, e2e, reviewer) inherit their assigned pipeline and do not classify.341342### Task types343344- **SCAFFOLD** (one per feature, first): scaffolder produces contracts.345- **Red/Green triple** (one per unit of work): three files, two agents.346- **E2E** (at least one per feature): standalone, blocked by all greens.347- **Feature REVIEW** (one per feature): blocked by all red/green/e2e.348- **Sprint REVIEW** (one per sprint): blocked by all feature REVIEWs.349350### SCAFFOLD task — Definition of Done351352A SCAFFOLD task is **done** only when **every** item below is verifiable. Red cannot start on a feature whose SCAFFOLD has any unchecked item. The scaffolder ticks each box in its `SCAFFOLD.md` with evidence (e.g., command output) attached.353354- [ ] Every exported type listed in `ARCHITECTURE.md` exists in code.355- [ ] Every exported interface listed in `ARCHITECTURE.md` exists with all method signatures (no method bodies — interfaces only).356- [ ] Every exported constructor / factory / function listed in `ARCHITECTURE.md` exists with its signature.357- [ ] Every function body is exactly one of: `panic("not implemented: <fn>")` or a typed zero-value return. **No partial implementation.** No conditional logic, no helper calls, no early returns.358- [ ] `go build ./...` passes on the whole module (output pasted in `SCAFFOLD.md`).359- [ ] No test file is created or modified.360- [ ] Mocks are regenerated for every new interface — either by running the project's mock-generation tool, or by adding the interface to the generator's config so the next pass picks it up.361- [ ] No exported symbol exists in the diff that is not listed in `ARCHITECTURE.md` (no scope creep — new exported APIs require an architect ADR, not a scaffolder shortcut).362- [ ] `SCAFFOLD.md` checklist is fully ticked, with `go build` output and the list of new exported symbols pasted as evidence.363364If any item cannot be satisfied — e.g., `ARCHITECTURE.md` lists a type the scaffolder cannot construct without designing logic — the scaffolder opens a dispute against the architect (decision E in the dispute protocol), not a partial scaffold.365366### Three-file task structure (for red/green units)367368Every red/green unit produces **three files** under `.features/<slug>/tasks/`:3693701. **`<TASK_ID>.md`** — shared spec. Read by red, green, planner (for arbitration), reviewer.3712. **`<TASK_ID>-red.md`** — red's private spec. Read **only** by the red teammate.3723. **`<TASK_ID>-green.md`** — green's private spec. Read **only** by the green teammate.373374Rules:375376- Shared info goes in `TASK.md`.377- Test design goes in `TASK-red.md` only.378- Implementation design goes in `TASK-green.md` only.379- ADRs are listed in `TASK.md` `## Applicable ADRs`, not duplicated in private specs.380- Red never reads `TASK-green.md`. Green never reads `TASK-red.md`. The planner never reads either during arbitration.381382### TASKS.md (task index per feature)383384| ID | Title | Phase | Agent | Status | Deps | Parallel |385|------------|-------------------------------|----------|--------------|--------|------------------------------|----------|386| SCAFFOLD | Scaffolding | scaffold | scaffolder | todo | — | yes |387| T001 | Login use case (shared) | shared | — | — | — | — |388| T001-red | Login use case — tests | red | red-sonnet | todo | SCAFFOLD | yes |389| T001-green | Login use case — impl | green | green-sonnet | todo | T001-red | no |390| T002 | User repo (shared) | shared | — | — | — | — |391| T002-red | User repo contract tests | red | red-haiku | todo | SCAFFOLD | yes |392| T002-green | User repo postgres adapter | green | green-sonnet | todo | T002-red | no |393| E001 | Login → JWT → refresh e2e | e2e | e2e-tester | todo | T001-green, T002-green | no |394| REVIEW | Feature review | review | reviewer | todo | T001-green, T002-green, E001 | no |395396Unplanned tasks use `-unplanned` suffix on the phase (e.g., `T012-red-unplanned`).397398Sub-sprint helper tasks use `H<NNN>-red` (no green pair, see Sub-sprints).399400### Agent profiles401402- `scaffolder`: always haiku. One per feature.403- `red-haiku`: mechanical tests (boilerplate, DTO validation, single file, <50 lines).404- `red-sonnet`: standard tests (use case tests, contract tests, middleware tests).405- `red-opus`: complex test design (concurrency, state machines, auth flows).406- `green-haiku`: mechanical implementation (DTOs, simple adapters, wiring).407- `green-sonnet`: standard implementation (use cases, adapters with transactions, middleware).408- `green-opus`: complex implementation (architecture, cross-cutting, concurrency, ADR-level).409- `e2e-tester`: end-to-end / integration scenarios.410- `reviewer`: always sonnet — complexity encoded in the checklist.411412Red and green in the same pair are assigned **independently**. Any combination across tiers is valid: e.g., `red-opus` paired with `green-haiku`, `red-haiku` paired with `green-sonnet`, `red-sonnet` paired with `green-opus`, etc. The planner judges test-design complexity and implementation complexity as two separate decisions — a task can have hard tests but a mechanical implementation, or a trivial assertion against a concurrency-heavy implementation. No teammate should assume its partner shares its model tier; the task files (`TASKS.md` and `SPRINT.md`) are the source of truth for which specific agent is paired on each task.413414### File edit permissions415416Hard rule enforced by each agent's spec:417418| Role | Can edit | Cannot edit |419|------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------|420| PM | `FEATURE.md` (Context/Impact functional/AC/Out of scope), `.features/INDEX.md` | `.architecture/`, `.adrs/`, `ARCHITECTURE.md`, any code, any other doc |421| architect | `.architecture/`, `.features/<slug>/ARCHITECTURE.md`, `.adrs/`, `FEATURE.md` Technical impact and Relevant ADRs sections | PM sections of FEATURE.md, `INDEX.md`, any code, tasks, sprints |422| planner | `SPRINT.md`, `TASKS.md`, `SCAFFOLD.md`, `TASK.md` (shared), `INDEX.md`s, dispute decisions, `.questions/`, sub-sprints | `TASK-red.md`, `TASK-green.md`, any `.go` file, any ADR |423| scaffolder | Non-test `.go` (signatures, types, empty bodies only), own `SCAFFOLD.md` DoD checkboxes, dispute file sections | `*_test.go`, test support dirs, any doc other than own spec |424| red | `*_test.go`, `testdata/`, `testutil/`, `mocks/`, own `TASK-red.md` DoD checkboxes, dispute file sections | Any non-test `.go`, scaffolded signatures, any doc other than own red spec |425| green | Non-test `.go` files (fill scaffolded bodies, add private helpers), own `TASK-green.md` DoD checkboxes, dispute file sections, tactical ADRs | Any `*_test.go`, scaffolded signatures, exported symbols, any doc other than own green spec |426427### ADR propagation428429The architect lists relevant ADRs in `FEATURE.md` `## Relevant ADRs`. The planner propagates these into:430431- `SCAFFOLD.md` `## Applicable ADRs` — ADRs affecting types, interfaces, naming, package layout.432- `TASK.md` `## Applicable ADRs` — ADRs affecting the behavior of this specific task.433434Red and green read ADRs via the shared `TASK.md`. Scaffolder reads via `SCAFFOLD.md`.435436### Dispute protocol437438Location: `.disputes/SPRINT_00X/<TASK_ID>.md` (or `SCAFFOLD-<slug>.md`).439440#### Hat-switching declaration (mono-assistant safeguard)441442When a single assistant wears multiple roles in the same session (e.g., the same Claude instance acted as `red` earlier and is now arbitrating as `sprint-planner`), spec isolation is **not** enforced by the runtime — only by discipline. To make hat-switching auditable:443444- Before reading any artifact in a dispute, the assistant **must** append a hat-switch marker at the top of the dispute file:445446 ```markdown447 ## Planner hat activated: 2026-04-25 by <assistant-id>448 Previous hats this session: red (T003-red), green (T005-green)449 Confirms: will read only public artifacts (TASK.md, scaffolded code, test files, ADRs, ARCHITECTURE.md). Will NOT consult TASK-red.md or TASK-green.md.450 ```451452- The marker is a public artifact — it stays in the dispute file and is reviewed at retro.453- Self-test before reading the *other* spec: *"Am I currently red or green? If yes, I cannot read the other private spec — I must open a dispute first and let the planner hat (mine or another's) arbitrate."*454- A dispute file missing a hat-switch marker, written by an assistant who acted as red or green earlier in the session, is treated as **invalid** at retro and the decision must be re-litigated.455456This applies to **any** mono-assistant role transition, not just planner: if you wrote tests as `red-opus` and are now asked to scaffold, declare the hat switch even though scaffolding has no isolation rule — the marker creates an audit trail.457458#### Red → green on the same task (mono-assistant only)459460The hat-switch marker covers the case where the assistant arbitrates *another* pair's dispute. The harder case is when **the same assistant must be both red and green for the same task** — typical when agent teams aren't enabled and you're working solo.461462The rule for this case:4634641. The assistant **completes the red phase end to end**: writes the failing tests, runs them, confirms they fail for implementation reasons, and **commits** under `Task: <TASK_ID>-red`.4652. The assistant then **starts a fresh session** before reading `TASK-green.md`. In Claude Code this means `/clear` or opening a new conversation. The session reset is what purges `TASK-red.md` from working context.4663. The new session opens by reading **only** the green inputs: `TASK.md`, `TASK-green.md`, the test files committed in step 1, and any source files referenced. It must **not** read `TASK-red.md`.4674. The red commit is the only handoff. If green needs information that lived only in `TASK-red.md`, that is a signal the shared `TASK.md` was incomplete or the test code was insufficient — open a dispute against the planner to amend `TASK.md`, do not bypass the reset to re-read the red spec.468469Audit: at sprint review, for every task where red and green were the same assistant, check `git log` — there must be **at least one commit** between the red work and the green work (the `Task: <TASK_ID>-red` commit). A task whose red and green files appear in a single commit is treated as an isolation violation.470471This rule does **not** prohibit a single assistant from doing red and green on the same task. It just makes the boundary explicit, observable, and machine-checkable.472473#### Who can raise474475476477- **Scaffolder** vs architect: `ARCHITECTURE.md` ambiguous, contradictory, or incomplete.478- **Red** vs scaffolder: signature untestable.479- **Red** vs self-spec: shared spec ambiguous or contradictory.480- **Green** vs red: test unfulfilable, contradictory, over-specifying, missing-coverage, broken.481- **Green** vs scaffolder: scaffolded signature forces an untenable implementation.482- **Any teammate** vs planner: complexity-upgrade request (see *Complexity escalation* below).483484Flow:4854861. Disputing party creates/appends the dispute file with a structured section.4872. Disputing party messages affected teammates and the planner.4883. Work stops on the disputed portion.4894. Affected teammates may respond in their own sections — **without** reading the other's private spec.4905. The planner reads public artifacts only: shared specs, scaffolded code, test code, ADRs, `ARCHITECTURE.md`.4916. The planner writes `## Planner decision` citing only public artifacts. Decision types: A (scaffolder revises), B (red revises), C (green proceeds under interpretation), D (both adjust), E (escalate to architect), F (escalate to human), **G (complexity upgrade — see below)**.4927. **Planner notifies every teammate listed under `Action required:`** via teammate message, with a one-line summary of the decision and a pointer to the dispute file. The planner does **not** mark the dispute `Status: resolved` yet.4938. **Each notified teammate acknowledges before resuming.** Append a single line to the dispute file under a `## Acknowledgements` section:494495 ```markdown496 ## Acknowledgements497 - Acknowledged by red-sonnet on 2026-04-25 — will revise tests per decision B.498 - Acknowledged by green-haiku on 2026-04-25 — will resume under interpretation C.499 ```500501 Acknowledgement implies the teammate has read the planner decision and accepts the action item. A teammate that disagrees does **not** ack — it raises a new dispute (rare, only when the decision contradicts a public artifact the planner missed).5025039. Once **every** teammate listed under `Action required:` has acked, the planner marks the dispute `Status: resolved` (or `awaiting-architect-input` / `awaiting-human-input` for E/F). Without all acks, the status remains `awaiting-ack`.50450510. Teammates resume per decision.506507Disputes persist through sprint end and feed the retro. The sprint REVIEW.md checklist rejects any dispute marked `resolved` that lacks an ack from every teammate listed in `Action required:` — incomplete propagation is treated as an unresolved dispute.508509#### Complexity escalation (dispute type G)510511The skill states complexity can be upgraded but never downgraded. The mechanism:512513**When to raise.** A teammate (most often green or red) discovers mid-task that the work classified as `mechanical` or `standard` actually requires architectural thinking — e.g., a state machine, a concurrency invariant, a cross-cutting concern not visible from the shared spec. Telltale signs: the implementation cannot be expressed without a new abstraction; tests cannot be written without inventing a model; an ADR feels necessary.514515**How to raise.** Open the dispute as type G with a target:516517```markdown518## Dispute (type G — complexity upgrade)519Raised by: green-haiku on T007-green520Current classification: standard521Requested classification: architectural522Target retarget: green-haiku → green-opus523524Evidence (public artifacts only):525- Scaffolded signature `CircuitBreaker.Trip()` requires a state machine with 4 states and 6 transitions; the shared TASK.md describes only "trip when threshold exceeded".526- Existing ADR-014 mentions backoff but not state ownership.527- Without a new ADR fixing state ownership, the implementation will encode an undocumented decision.528```529530**Planner response.** The planner decides:531532- **G-finish-then-escalate (default)**: the current agent **finishes the task** with the simplest correct implementation, commits, and the planner schedules a follow-up refactor task at the higher tier in the next sprint (or as a sub-sprint if blocking other work). This is the default because mid-task agent handoff loses context and routinely produces worse code than letting the current agent finish.533- **G-immediate-rerun**: if the current agent declares it cannot finish at all (not "can finish but suboptimally"), the planner reverts the in-progress work, re-routes the task to the higher tier, and reassigns. The reverted commit, if any, is marked in the retro.534- **G-architect-loop**: if the upgrade reveals a missing ADR, escalate to the architect first (decision E), then re-classify once the ADR exists.535536**Hard rule.** Never replace `green-haiku` with `green-opus` *during* a task. Either let the haiku agent finish (then schedule follow-up refactor) or revert and restart fresh. Mid-task handoff is forbidden.537538**Retro feedback.** Every G dispute is logged in `## Complexity calibration` of the RETRO. A pattern of upgrades from `standard` to `architectural` on similar tasks signals the planner is under-classifying — the calibration heuristics in `task-complexity-routing` should be tightened.539540### Breakdown rules541542- Tasks must be **atomic**: completable in one session with a clear DoD.543- Tasks exceeding ~1 day: split further.544- Identify **parallelizable** tasks.545- Green is **never** parallel to its own red.546- Red is always blocked by SCAFFOLD.547- Scaffold tasks of different features can run in parallel.548549### Relation to other artifacts550551- Blocker on a task → `.blockers/SPRINT_00X/` referencing `<feature-slug>/<TASK_ID>`.552- Question → `.questions/SPRINT_00X/` same reference.553- Non-trivial decision during green → tactical ADR under `.adrs/`.554- Dispute → `.disputes/SPRINT_00X/<TASK_ID>.md`.555- Private helper added by green → logged in feature RETRO, sub-sprint created by planner.556557### Unplanned tasks558559A teammate may add an unplanned task during sprint execution **without waiting for the planner**, provided **all** of the following hold:5605611. The new task belongs to a feature already `in-progress` in the current sprint scope. **A new feature** cannot be unplanned — it must wait for the next sprint, or be raised as a blocker if it cannot wait.5622. The task is added to the feature's `TASKS.md` with a phase suffix `-unplanned` (e.g., `T012-red-unplanned`, `T012-green-unplanned`).5633. The task's `TASK.md` includes a `## Why unplanned` section with a one-paragraph justification: what made the work emerge mid-sprint, why it could not have been planned at sprint start, and which in-flight task it unblocks.564565If writing the `## Why unplanned` justification takes more than two minutes of thought, the work is probably **not** an unplanned task — it is a blocker. Open `.blockers/SPRINT_00X/` instead and stop affected work.566567The sprint-planner may, at any time during the sprint, **defer** an unplanned task: work stops on it and it moves to the next sprint's backlog. The planner cites the `## Why unplanned` paragraph in its deferral note.568569At sprint review:570571- Each unplanned task has its own line in `metrics.unplanned_tasks` count of the RETRO YAML.572- If `unplanned_tasks > 30 %` of `delivered_tasks`, the sprint is flagged as **under-planned** in the prose `## Dispute analysis` section, and the next sprint's planning gets an extra DoR review pass.573- Unplanned tasks that completed are folded into the regular sprint metrics (counted as delivered).574- Unplanned tasks that were deferred by the planner are listed under `## Notes the YAML can't capture` with the deferral rationale.575576A new feature cannot be unplanned. Mid-sprint pivots that introduce a new feature stop the sprint and require a planner-issued blocker, not an unplanned task.577578## Reviews (.features/<slug>/REVIEW.md + .sprints/SPRINT_00X/REVIEW.md)579580The `reviewer` agent (sonnet) produces exhaustive verification checklists. Two levels.581582### Feature-level review583584Consolidates:585586- Acceptance criteria from `FEATURE.md`.587- DoD items from every task of the feature (scaffold, red, green, e2e).588- Non-functional requirements.589590Every item must be explicitly checked, traceable to its source, and verified with evidence.591592Feature marked `done` only when REVIEW.md is fully checked.593594### Sprint-level review595596Aggregates feature REVIEWs plus cross-cutting:597598- [ ] All feature REVIEW.md fully checked.599- [ ] Integration between features works.600- [ ] ADRs consistent with each other.601- [ ] All blockers resolved.602- [ ] All open questions answered.603- [ ] All disputes resolved, **with an `## Acknowledgements` line per teammate listed in `Action required:`**.604- [ ] All unplanned tasks documented and closed.605- [ ] Private helpers logged for sub-sprint coverage (if any).606- [ ] Global test suite green.607- [ ] `RETRO.md` YAML frontmatter present and complete (`metrics`, `helpers_added`, `crashes`, `complexity_routing`, `template_extensions`, `adrs_to_revisit`).608- [ ] Push to `main` happened only after the final green wave (no in-flight red wave on main).609- [ ] `SPRINT.md` and per-feature `TASKS.md` agree on task scope (no scope drift).610- [ ] For every task where red and green were the same assistant, `git log` shows at least one commit between the red and green work (no single combined red+green commit).611612Sprint marked `done` only when sprint REVIEW.md is fully checked.613614## Sprints (.sprints/)615616- `INDEX.md`: all sprints with start/end dates and status.617- `SPRINT_00X/SPRINT.md`: focus, features, execution plan as todo list with agent names inline.618- `SPRINT_00X/REVIEW.md`: sprint review checklist.619- `SPRINT_00X/RETRO.md`: retrospective.620- Completion: all features done, all blockers/questions/disputes resolved, REVIEW.md fully checked, RETRO.md written, sub-sprint created if needed.621- Micro-work that can't wait: `SPRINT_00X-Y` (also the 622623…(truncated)