Implement Task with Verification
Your job is to implement solution in best quality using task specification and sub-agents. You MUST NOT stop until it is critically necessary or you are done! Avoid asking questions until it is critically necessary! Dispatch one implementation agent per step, then — when every step of an implementation phase is done — launch ONE sdd:code-reviewer for that phase, iterate till issues are fixed, then move to the next phase!
Execute task implementation steps with automated quality verification using a single sdd:code-reviewer agent per implementation phase.
User Input
$ARGUMENTS
Vocabulary (read this first — two different things are called "phase")
| Term |
Meaning |
| Workflow Phase 0-5 |
The stages of THIS skill (select task, load, execute, DoD, move, report). |
Implementation phase / Phase N |
A milestone in the TASK file's ### Phase Overview. It groups steps, names a Reviewer model, and lists the acceptance criteria due at that milestone. This is the unit of code review. |
| Step |
One sub-task file at .specs/sub-tasks/<task-name>/<NN>-<step-slug>.md. This is the unit of implementation dispatch. The step name is that file's basename without .md. |
Command Arguments
Parse the following arguments from $ARGUMENTS:
Argument Definitions
| Argument |
Format |
Default |
Description |
task-file |
Path or filename |
Auto-detect |
Task file name or path (e.g., add-validation.feature.md) |
--continue |
--continue |
None |
Continue implementation from the last completed step: resolves the implementation phase in progress, completes its outstanding steps, then reviews that phase — see Context Resolution for --continue. |
--refine |
--refine |
false |
Incremental refinement mode - detect changes against git, map them to steps, and re-verify from the implementation phase that owns the earliest affected step. |
--human-in-the-loop |
--human-in-the-loop [Phase 1,Phase 3,...] |
None |
Implementation phases after whose review to pause for human verification. If no phases specified, pauses after every implementation phase. |
--target-quality |
--target-quality X.X |
4.0 |
Single target threshold value (out of 5.0) applied to every implementation phase review. |
--max-iterations |
--max-iterations N |
3 |
Maximum fix→re-review cycles per implementation phase. Default is 3 iterations. Set to unlimited for no limit. |
--skip-reviews |
--skip-reviews |
false |
Skip all phase reviews - steps proceed without quality gates. |
--model |
opus|sonnet|haiku |
Unset |
Model for all sub-agents (implementation agents AND sdd:code-reviewer) that overrides every model in the task file; when omitted, step models come from the Parallelization Overview and reviewer models from the Phase Overview. |
--strict |
--strict |
false |
Disable the Iteration Discretion Rule - a phase is marked PASS ONLY when combined_score >= THRESHOLD, otherwise iterate until MAX_ITERATIONS is reached. |
Configuration Resolution
Parse $ARGUMENTS and resolve configuration as follows:
# Extract task file (first positional argument, optional - auto-detect if not provided)
TASK_FILE = first argument that is a file path or filename
# Single quality threshold — there is exactly one, and it is NEVER read from the task file
THRESHOLD = --target-quality value || 4.0
# Initialize other defaults
MODEL_OVERRIDE = --model value (opus|sonnet|haiku) || none # none = no override; models come from the task file
MAX_ITERATIONS = --max-iterations || 3 # default is 3 iterations
HUMAN_IN_THE_LOOP_PHASES = --human-in-the-loop || [] (empty = none, "*" = all implementation phases)
SKIP_REVIEWS = --skip-reviews || false
REFINE_MODE = --refine || false
CONTINUE_MODE = --continue || false
STRICT_MODE = --strict || false
# Special handling for --human-in-the-loop without a phase list
if --human-in-the-loop present without phase identifiers:
HUMAN_IN_THE_LOOP_PHASES = "*" (all implementation phases)
THRESHOLD is the ONLY quality threshold in this workflow. There is no separate standard/critical/lenient value, no comma-separated form, and no threshold anywhere in the task file — the planning agents are forbidden from writing one.
Context Resolution for --continue
When --continue is used, state is resolved by implementation phase, then step:
- Phase and Step Resolution:
- Read the task file's
### Parallelization Overview step table and ### Phase Overview.
- A step is complete when its row in the step table is marked
[DONE].
- An implementation phase is complete when its
#### Phase N heading carries either marker: [REVIEWED] (its review ran and passed) or [REVIEWED-SKIPPED] (its steps finished and its review was deliberately suppressed by an earlier --skip-reviews run).
RESUME_PHASE = the first implementation phase marked neither [REVIEWED] nor [REVIEWED-SKIPPED]. Treating [REVIEWED-SKIPPED] as unfinished would re-run exactly the review the user suppressed.
RESUME_STEPS = the steps of RESUME_PHASE that are not [DONE], in dependency order.
- Verify the resumed phase's existing work:
- If
RESUME_PHASE already has some [DONE] steps but neither marker, and RESUME_STEPS is empty (all steps done, review never ran):
- If
SKIP_REVIEWS is true: launch nothing. Mark the phase [REVIEWED-SKIPPED] and resume at the next implementation phase.
- Otherwise: launch the
sdd:code-reviewer for RESUME_PHASE (passing the 4 inputs documented in Workflow Phase 2) — Model: MODEL_OVERRIDE if set — otherwise that phase's Reviewer model.
- If
RESUME_STEPS is non-empty: dispatch those steps first, then review the phase as normal — and SKIP_REVIEWS still suppresses that review, marking the phase [REVIEWED-SKIPPED] instead.
- State Recovery:
- Check task file location (
in-progress/, todo/, done/)
- If in
todo/, move to in-progress/ before continuing
- Pre-populate captured values from existing artifacts
Refine Mode Behavior (--refine)
When --refine is used, it detects changes to project files (not the task file) and maps them to steps, then re-verifies from the implementation phase that owns the earliest affected step.
Detect Changed Project Files:
First, determine what to compare against based on git state:
# Check for staged changes
STAGED=$(git diff --cached --name-only)
# Check for unstaged changes
UNSTAGED=$(git diff --name-only)
Comparison logic:
| Staged |
Unstaged |
Compare Against |
Command |
| Yes |
Yes |
Staged (unstaged only) |
git diff --name-only |
| Yes |
No |
Last commit |
git diff HEAD --name-only |
| No |
Yes |
Last commit |
git diff HEAD --name-only |
| No |
No |
No changes |
Exit with message |
- If both staged AND unstaged: Compare working directory vs staging area (unstaged changes only)
- If only staged OR only unstaged: Compare against last commit
- This ensures refine operates on the most recent work in progress
Map Changes to Steps:
- Read the task file's
### Parallelization Overview to get every step name, its implementation phase, and its Sub-Task File path.
- Refine mode is the ONE case where you may read sub-task files: they are specification artifacts (like the task file), not implementation outputs, and their
#### Expected Output sections are the only place file paths per step are recorded. Read ONLY the #### Expected Output and #### Subtasks sections you need.
- Build a mapping:
{changed_file → step name → implementation phase}
Determine Affected Scope:
- Find all steps that have associated changed files
REFINE_FROM_PHASE = the earliest implementation phase containing an affected step
- All implementation phases from that point onwards need re-verification
- Earlier phases (unaffected) are preserved as-is
Refine Execution:
- For each affected implementation phase (in order):
- Launch ONE
sdd:code-reviewer agent to verify the phase (including the user's changes), passing the 4 standard inputs — Model: MODEL_OVERRIDE if set — otherwise that phase's Reviewer model
- If the phase PASSES per the Iteration Discretion Rule: mark it
[REVIEWED], proceed to the next phase
- Otherwise: enter the Failure Handling flow, then re-review
- User's manual fixes are preserved - implementation agents should build upon them, not overwrite
Example:
# User manually fixed src/validation/validation.service.ts
# (This file is the Expected Output of step `02-validation-service`, in Phase 1)
/implement my-task.feature.md --refine
# Detects: src/validation/validation.service.ts modified
# Maps to: step `02-validation-service` → Phase 1
# Action: Launch ONE sdd:code-reviewer for Phase 1
# - If PASS: User's fix is good, proceed to Phase 2
# - If FAIL: reason about blast radius, dispatch fixes for the affected
# steps only, without overwriting the user's changes, then re-review
# Continues: Phase 2, Phase 3... (re-verify all subsequent phases)
Multiple Files Changed:
# User edited an output of a Phase 1 step AND an output of a Phase 3 step
/implement my-task.feature.md --refine
# Earliest affected phase: Phase 1
# Re-verifies: Phase 1, Phase 2, Phase 3...
# (Phase 2 re-verified even though no direct changes, because it builds on Phase 1)
Staged vs Unstaged Changes:
# Scenario: User staged some changes, then made more edits
# Staged: src/validation/validation.service.ts (git add done)
# Unstaged: src/validation/validators/email.validator.ts (still editing)
/implement my-task.feature.md --refine
# Detects: Both staged AND unstaged changes exist
# Mode: Compares unstaged only (working dir vs staging)
# Only email.validator.ts is considered for refine
# --
# Scenario: User only has staged changes (ready to commit)
# Staged: src/validation/validation.service.ts
# Unstaged: none
/implement my-task.feature.md --refine
# Detects: Only staged changes
# Mode: Compares against last commit
Human-in-the-Loop Behavior
Human verification checkpoints are keyed on implementation phases, never on individual steps.
Trigger Conditions:
- After an orchestrator-level PASS on the review of an implementation phase in
HUMAN_IN_THE_LOOP_PHASES
- After a fix iteration completes for such a phase (before the next re-review)
- If
HUMAN_IN_THE_LOOP_PHASES is "*", triggers after every implementation phase
At Checkpoint:
- Display the phase's step results summary
- Display generated artifacts with paths
- Display the reviewer's
combined_score and consolidated issues
- Ask user: "Review phase output. Continue? [Y/n/feedback]"
- If user provides feedback, incorporate into the next iteration or phase
- If user says "n", pause workflow
Checkpoint Message Format:
---
## 🔍 Human Review Checkpoint - Phase N
**Phase:** {phase heading}
**Steps:** {step names}
**Reviewer model:** {model used}
**Combined Score:** {combined_score}/5.0 (threshold: {THRESHOLD})
**Status:** ✅ PASS / ☑️ ACCEPTED / 🔄 ITERATING (attempt {n})
**Artifacts Created/Modified:**
- {artifact_path_1}
- {artifact_path_2}
**Reviewer Feedback (top issues):**
{feedback summary — High/Medium issues from reviewer.issues, with the step each belongs to}
**Action Required:** Review the above artifacts and provide feedback or continue.
> Continue? [Y/n/feedback]:
---
Task Selection and Status Management
Task Status Folders
Task status is managed by folder location:
.specs/tasks/todo/ - Tasks waiting to be implemented
.specs/tasks/in-progress/ - Tasks currently being worked on
.specs/tasks/done/ - Completed tasks
The task's sub-task folder .specs/sub-tasks/<task-name>/ never moves while the task file travels between these folders, so the Sub-Task File paths recorded in the task file stay valid.
Status Transitions
| When |
Action |
| Start implementation |
Move task from todo/ to in-progress/ |
| Final verification PASS |
Move task from in-progress/ to done/ |
| Implementation failure (user aborts) |
Keep in in-progress/ |
CRITICAL: You Are an ORCHESTRATOR ONLY
Your role is DISPATCH and AGGREGATE. You do NOT do the work.
Properly build context of sub agents!
CRITICAL: For each sub-agent you dispatch, you MUST provide:
For an implementation agent (one per step):
- Task file path
- That step's sub-task file path — exactly one, taken from the
Sub-Task File column of the Parallelization Overview
- Value of
${CLAUDE_PLUGIN_ROOT} so agents can resolve paths like @${CLAUDE_PLUGIN_ROOT}/scripts/create-scratchpad.sh
For the sdd:code-reviewer (one per implementation phase):
- Task file path
- Phase identifier
- Artifact path(s) reported by that phase's implementation agents
CLAUDE_PLUGIN_ROOT
What You DO
- Read the task file ONCE (Workflow Phase 1 only)
- Launch sub-agents via Task tool
- Receive reports from sub-agents
- Mark steps and implementation phases complete after the orchestrator-level PASS rule on reviewer output as [DONE]
- Reason about blast radius when a phase review fails, and choose fix / re-review models accordingly
- Aggregate results and report to user
What You NEVER Do
| Prohibited Action |
Why |
What To Do Instead |
| Read implementation outputs |
Context bloat → command loss |
Sub-agent reports what it created |
Read sub-task files (except --refine mapping) |
The implementation agent reads its own sub-task file |
Pass the path from the Parallelization Overview |
| Read reference files |
Sub-agent's job to understand patterns |
Include path in sub-agent prompt |
| Read artifacts to "check" them |
Context bloat → forget verifications |
Launch sdd:code-reviewer agent |
| Evaluate code quality yourself |
Not your job, causes forgetting |
Launch sdd:code-reviewer agent |
| Review a step individually |
Review is a PHASE-level gate |
Review once, at the end of the phase |
| Skip a phase review "because simple" |
Every phase review is mandatory unless --skip-reviews |
Launch sdd:code-reviewer anyway |
| Never add comments/marks/notes about results of review, scratchpads, iterations, etc. to the task file. |
The task file is a specification artifact, not a log. If task not done, it should be visible from code only! |
You can write only [DONE] mark ever, or nothing at all! |
Anti-Rationalization Rules
If you think: "I should read this file to understand what was created"
→ STOP. The sub-agent's report tells you what was created. Use that information.
If you think: "I'll quickly verify this looks correct"
→ STOP. Launch a sdd:code-reviewer agent. That's not your job.
If you think: "This phase is too simple to need verification"
→ STOP. Unless SKIP_REVIEWS is true, every implementation phase gets exactly one review. No exceptions.
If you think: "This step looks risky, I'll review it before the phase ends"
→ STOP. Reviewing per step is exactly what this workflow removed. Wait for the phase to complete.
If you think: "I need to read the sub-task file to write a good prompt"
→ STOP. Put the sub-task file PATH in the sub-agent prompt. The sub-agent reads it.
Why This Matters
Orchestrators who read files themselves = context overflow = command loss = forgotten steps. Every time.
Orchestrators who "quickly verify" = skip sdd:code-reviewer agents = quality collapse = failed artifacts.
Your context window is precious. Protect it. Delegate everything.
CRITICAL
Configuration Rules
- Model precedence (
MODEL_OVERRIDE): if --model was given, that model WINS over the task file and over every default in this skill — dispatch EVERY sub-agent with it (implementation agents of any type AND sdd:code-reviewer), ignoring the Parallelization Overview's Model column and the Phase Overview's Reviewer model. It is an override, NOT a fallback. If --model was NOT given (MODEL_OVERRIDE = none), model selection is unchanged: each step uses the Model its Parallelization Overview row names, and each phase review uses that phase's Reviewer model, falling back to the default named in each dispatch block.
- Use the single
THRESHOLD (default 4.0) for every implementation phase review. There is no per-component, per-criticality or lenient variant.
- Never read a threshold from the task file. The planning agents write none; if one somehow appears, ignore it.
- The threshold is applied at THIS orchestrator layer against
combined_score returned by code-reviewer. NEVER pass any threshold to the code-reviewer agent — or he will try to reach target score and as result become subjective.
- A phase PASSES if
combined_score >= THRESHOLD. If 3.0 <= combined_score < THRESHOLD, the phase passes ONLY when the Iteration Discretion Rule says so — never below the fixed floor of 3.0. If combined_score < 3.0, the phase FAILS unconditionally.
- Default is 3 iterations - stop after 3 fix→re-review cycles for an implementation phase and proceed to the next phase (with warning)!
- If
MAX_ITERATIONS is set to unlimited: Iterate until the quality threshold is met (no limit)
- Trigger human-in-the-loop checkpoints ONLY after implementation phases in
HUMAN_IN_THE_LOOP_PHASES (or all phases if "*")!
- If
SKIP_REVIEWS is true: Skip ALL code-reviewer dispatches - proceed directly to the next implementation phase after its steps complete!
- If
CONTINUE_MODE is true: Skip to RESUME_PHASE / RESUME_STEPS - do not re-implement already completed steps!
- If
REFINE_MODE is true: Detect changed project files, map to steps, re-verify from REFINE_FROM_PHASE - preserve user's fixes!
- If
STRICT_MODE is true: The Iteration Discretion Rule is DISABLED - a phase passes ONLY on combined_score >= THRESHOLD, otherwise iterate until MAX_ITERATIONS!
Execution & Evaluation Rules
- Use foreground agents only: Do not use background agents. Launch parallel agents when possible. Background agents constantly run in permissions issues and other errors.
- Parallelism comes from the task file: steps whose
Parallel with: column names each other MUST be dispatched simultaneously in one message. Never serialize what the plan says is parallel.
- Never cross a phase boundary in parallel: a step of
Phase N+1 may only start after Phase N has been reviewed and marked [REVIEWED] (or marked [REVIEWED-SKIPPED] when SKIP_REVIEWS is true).
Relaunch the code-reviewer till you get valid results, if following happens:
- Reject Long Reports: If the code-reviewer returns a very long report instead of using the scratchpad as requested, reject the result. This indicates the agent failed to follow the "use scratchpad" instruction.
- Combined Score 5.0 is a Hallucination: If the code-reviewer returns a
combined_score of exactly 5.0/5.0, treat it as a hallucination or lazy evaluation. Reject it and re-run the agent. This applies to the weighted aggregate only — an individual criterion may legitimately score 5 and no score is rationed, but every criterion across spec compliance, code quality and Muda waste analysis landing strictly past its score_4 anchor at once is not a plausible review outcome. Never use it as a reason to question a single high criterion score.
- Reject Missing Scores: If the code-reviewer's report is missing the
combined_score (or any sub-score: spec_compliance_score, builtin_score), reject it. This indicates the agent failed to follow the rubric instructions.
- Reject PASS/FAIL Verdicts in Report: If the code-reviewer's output contains a PASS/FAIL verdict or references a threshold, reject it. The orchestrator owns that decision; the agent must remain threshold-blind.
- Reject Out-of-Scope Findings: If the reviewer penalizes acceptance criteria that the phase's
#### Phase N block does NOT list — reporting work a LATER phase delivers as "missing" or "incomplete" — reject the report and re-run the agent, restating that a phase is a checkpoint, not the finish line.
Iteration Discretion Rule
Your main task is to COMPLETE the task within target quality. Two failure modes are equally real:
- Burning iterations and context on nitpicks so the overall task never completes → the task is failed.
- Accepting a result whose quality is genuinely too poor to be considered complete → an even worse failure.
Apply to every implementation phase's combined_score:
combined_score < 3.0 → FAIL, unconditionally. No discretion. Iterate with reviewer feedback until the phase passes or MAX_ITERATIONS is reached.
3.0 <= combined_score < THRESHOLD → discretion band. ONLY inside this band MAY you decide that a phase below the target is acceptable. The fixed floor is 3.0 and the band ceiling is THRESHOLD. If --target-quality set THRESHOLD <= 3.0 the band is empty: every score is either an unconditional FAIL (< 3.0) or a PASS, and there is no discretion to exercise.
- Inside the band, when the outstanding issues are ONLY
Low/Medium priority (any High or Critical finding removes discretion entirely) AND none of them breaks an acceptance criterion the phase is responsible for or causes a meaningful defect (i.e. they are nitpicks), you MUST reason FIRST — before dispatching another iteration — about whether iterating (or marking the phase failed) is worth the time and context cost.
- At most ONE nitpick-driven iteration, and it counts against
MAX_ITERATIONS. If it again surfaces only nitpicks, you MUST mark the phase PASS (☑️ ACCEPTED in the summary table), report the outstanding issues in the final report, and continue with the next phase. If it returns a combined_score below 3.0, the FAIL path applies instead.
- A phase that does not build, lint or test green is NEVER inside the discretion band, whatever the score says. Each phase must leave a working, committable, CI-green state.
- You MUST be critical, NOT lenient. Stopping short of target MUST be an intentional decision grounded in the absence of real, requirement-breaking issues. A genuine blocking issue that prevents completing the phase within
MAX_ITERATIONS MUST be reported as a failure, never papered over.
- If
STRICT_MODE is true, this whole rule is DISABLED: stop only when combined_score >= THRESHOLD or MAX_ITERATIONS is reached. --strict changes nothing else — THRESHOLD, MAX_ITERATIONS, the < 3.0 unconditional FAIL, human-in-the-loop checkpoints, code-reviewer dispatch and --skip-reviews are unaffected. With --skip-reviews no combined_score is produced at all, so both this rule and --strict are inert.
Overview
This command orchestrates multi-step task implementation with:
- Sequential execution respecting step dependencies
- Parallel execution where the plan's
Parallel with: column allows
- One implementation agent per step, dispatched with the task file path AND its sub-task file path
- One automated verification per implementation phase, at that phase's
Reviewer model
- Blast-radius reasoning to pick the fix and re-review models when a phase review fails
- Progress tracking with confirmation after each orchestrator-level PASS
Complete Workflow Overview
Workflow Phase 0: Select Task & Move to In-Progress
│
├─── Use provided task file name or auto-select from todo/ (if only 1 task)
├─── Move task: todo/ → in-progress/
│
▼
Workflow Phase 1: Load Task
│ Parse ### Parallelization Overview (steps, models, agents, sub-task paths)
│ Parse ### Phase Overview (phases, steps, reviewer models, criteria due)
│
▼
Workflow Phase 2: Execute Implementation Phases
│
├─── For each implementation phase, in order:
│ │
│ ▼
│ ┌─────────────────────────────────────────────────┐
│ │ For each step of the phase, in dependency order │
│ │ (parallel steps dispatched simultaneously): │
│ │ Launch its agent at its Model with │
│ │ task file path + sub-task file path │
│ └─────────────────┬───────────────────────────────┘
│ │ all steps of the phase reported complete
│ ▼
│ ┌─────────────────────────────────────────────────┐
│ │ Launch ONE sdd:code-reviewer for the PHASE │
│ │ at the phase's Reviewer model │
│ └─────────────────┬───────────────────────────────┘
│ │
│ ▼
│ ┌─────────────────────────────────────────────────┐
│ │ Orchestrator reads combined_score and applies │
│ │ THRESHOLD: │
│ │ PASS → Mark phase [REVIEWED], next phase │
│ │ FAIL → Reason about BLAST RADIUS, choose fix │
│ │ model + scope + re-review model, │
│ │ re-review (max MAX_ITERATIONS) │
│ └─────────────────────────────────────────────────┘
│
▼
Workflow Phase 3: Definition of Done Verification
│
├─── Verify all Definition of Done items
│ │
│ ▼
│ ┌─────────────────────────────────────────────────┐
│ │ Launch sdd:developer agent │
│ │ (verify all DoD items) │
│ └─────────────────┬───────────────────────────────┘
│ │
│ ▼
│ ┌─────────────────────────────────────────────────┐
│ │ All DoD PASS? → Proceed to Workflow Phase 4 │
│ │ Any FAIL? → Fix and re-verify (iterate) │
│ └─────────────────────────────────────────────────┘
│
▼
Workflow Phase 4: Move Task to Done
│
├─── Move task: in-progress/ → done/
│
▼
Workflow Phase 5: Final Report
Workflow Phase 0: Parse User Input and Select Task
Parse user input to get the task file path and arguments.
Step 0.1: Resolve Task File
If $ARGUMENTS is empty or only contains flags:
Check in-progress folder first:
ls .specs/tasks/in-progress/*.md 2>/dev/null
- If exactly 1 file → Set
$TASK_FILE to that file, $TASK_FOLDER to in-progress
- If multiple files → List them and ask user: "Multiple tasks in progress. Which one to continue?"
- If no files → Continue to step 2
Check todo folder:
ls .specs/tasks/todo/*.md 2>/dev/null
- If exactly 1 file → Set
$TASK_FILE to that file, $TASK_FOLDER to todo
- If multiple files → List them and ask user: "Multiple tasks in todo. Which one to implement?"
- If no files → Report "No tasks available. Create one with /add-task first." and STOP
If $ARGUMENTS contains a task file name:
- Search for the file in order:
in-progress/ → todo/ → done/
- Set
$TASK_FILE and $TASK_FOLDER accordingly
- If not found, report error and STOP
Step 0.2: Move to In-Progress (if needed)
If task is in todo/ folder:
git mv .specs/tasks/todo/$TASK_FILE .specs/tasks/in-progress/
# Fallback if git not available: mv .specs/tasks/todo/$TASK_FILE .specs/tasks/in-progress/
Update $TASK_PATH to .specs/tasks/in-progress/$TASK_FILE
If task is already in in-progress/:
Set $TASK_PATH to .specs/tasks/in-progress/$TASK_FILE
Do NOT move the sub-task folder. .specs/sub-tasks/<task-name>/ stays where planning created it; the Sub-Task File paths in the task file already point there.
Step 0.3: Parse Flags and Initialize Configuration
Parse all flags from $ARGUMENTS and initialize configuration.
Display resolved configuration:
### Configuration
| Setting | Value |
|---------|-------|
| **Task File** | {TASK_PATH} |
| **Model Override** | {MODEL_OVERRIDE or "None (models from task file)"} |
| **Threshold** | {THRESHOLD}/5.0 |
| **Max Iterations** | {MAX_ITERATIONS or "3"} |
| **Human Checkpoints** | {HUMAN_IN_THE_LOOP_PHASES as comma-separated or "All phases" or "None"} |
| **Skip Reviews** | {SKIP_REVIEWS} |
| **Continue Mode** | {CONTINUE_MODE} |
| **Refine Mode** | {REFINE_MODE} |
| **Strict Mode** | {STRICT_MODE} |
Step 0.4: Handle Continue Mode
If CONTINUE_MODE is true: resolve RESUME_PHASE and RESUME_STEPS per Context Resolution for --continue, then in Workflow Phase 2 skip every implementation phase before RESUME_PHASE and every [DONE] step inside it.
Step 0.5: Handle Refine Mode
If REFINE_MODE is true:
Detect Changed Project Files:
# Check for staged and unstaged changes
STAGED=$(git diff --cached --name-only)
UNSTAGED=$(git diff --name-only)
Determine comparison mode:
if STAGED is not empty AND UNSTAGED is not empty:
# Both staged and unstaged - use unstaged only
CHANGED_FILES = git diff --name-only # working dir vs staging
COMPARISON_MODE = "unstaged_only"
elif STAGED is not empty OR UNSTAGED is not empty:
# Only one type - compare against last commit
CHANGED_FILES = git diff HEAD --name-only
COMPARISON_MODE = "vs_last_commit"
else:
# No changes
Report: "No project changes detected. Make edits first, then run --refine."
Exit
Build the Step→File Mapping:
- Read the task file's
### Parallelization Overview for step names, phases and Sub-Task File paths
- Read those sub-task files'
#### Expected Output and #### Subtasks sections for file paths (the one permitted exception to context protection — see Refine Mode Behavior)
- Build mapping:
STEP_FILE_MAP = {step name → [file paths]} and STEP_PHASE_MAP = {step name → implementation phase}
Map Changed Files to Steps:
AFFECTED_STEPS = []
for each changed_file:
for step_name, file_list in STEP_FILE_MAP:
if changed_file matches any path in file_list:
AFFECTED_STEPS.append(step_name)
- If no steps matched: "Changed files don't map to any step's Expected Output. Verify manually."
Determine Refine Scope:
REFINE_FROM_PHASE = the earliest implementation phase among STEP_PHASE_MAP[AFFECTED_STEPS]
- All implementation phases from
REFINE_FROM_PHASE onwards need re-verification
- Phases before
REFINE_FROM_PHASE are preserved as-is
Store Changed Files Context:
CHANGED_FILES = list of changed file paths
USER_CHANGES_CONTEXT = git diff output for affected files
- Pass this context to the implementation agents you dispatch for fixes
- Agents should build upon user's fixes, not overwrite them
Workflow Phase 1: Load and Analyze Task
This is the ONLY phase where you read a file (plus the sub-task #### Expected Output sections in --refine mode).
Step 1.1: Load Task Details
Read the task file ONCE:
Read $TASK_PATH
After this read, you MUST NOT read any other files for the rest of execution.
Step 1.2: Parse the Implementation Process
Parse the ## Implementation Process section into two working structures.
From ### Parallelization Overview — the step table has columns | Step | Phase | Model | Agent | Depends on | Parallel with | Sub-Task File |. Build, per step name:
| Field |
Source |
Used for |
| Step name |
Step column (backtick-quoted sub-task basename) |
Identity in all other lists |
| Implementation phase |
Phase column |
Which review gate it belongs to |
| Model |
Model column |
The model of its dispatch (unless MODEL_OVERRIDE) |
| Agent |
Agent column |
The sdd: agent type to dispatch |
| Depends on |
Depends on column |
Ordering |
| Parallel with |
Parallel with column |
Which steps to dispatch in ONE message |
| Sub-Task File |
Sub-Task File column |
The path you pass to the agent |
From ### Phase Overview — for each #### Phase N block, record Steps:, Reviewer model:, the Checklist items: list and the Rubrics: list. You use Reviewer model: to dispatch the review; the criteria lists are the reviewer's business, not yours — do NOT paste them into any prompt.
There is no threshold, no verification level and no judge count in the task file. Do not look for them.
Step 1.3: Create Todo List
Create TodoWrite with one entry per step plus one entry per implementation phase review:
{
"todos": [
{"content": "Phase 1 / Step 01-foundation [haiku]", "status": "pending", "activeForm": "Implementing 01-foundation"},
{"content": "Phase 1 / Step 02a-service [sonnet]", "status": "pending", "activeForm": "Implementing 02a-service"},
{"content": "Phase 1 review [reviewer: sonnet]", "status": "pending", "activeForm": "Reviewing Phase 1"},
{"content": "Phase 2 / Step 03-integration [sonnet]", "status": "pending", "activeForm": "Implementing 03-integration"},
{"content": "Phase 2 review [reviewer: opus]", "status": "pending", "activeForm": "Reviewing Phase 2"}
]
}
Workflow Phase 2: Execute Implementation Phases
Process implementation phases in order. Within a phase, process steps in dependency order, dispatching Parallel with: groups simultaneously. When every step of the phase has reported completion, run the phase review — once.
There is exactly ONE dispatch pattern, and it applies to every implementation phase without exception.
The Phase Review Pattern
for each implementation phase P, in order:
for each dependency-ordered group G of steps in P:
dispatch every step of G in ONE message (parallel), each with:
agent type = its Agent column
model = MODEL_OVERRIDE if set, else its Model column
prompt = task file path + its sub-task file path
collect each agent's reported artifact paths
if SKIP_REVIEWS:
mark P [REVIEWED-SKIPPED]; continue to the next phase
dispatch ONE sdd:code-reviewer for P with the 4 inputs
model = MODEL_OVERRIDE if set, else P's `Reviewer model`
apply THRESHOLD to combined_score
PASS → mark P [REVIEWED]; human checkpoint if due; next phase
FAIL → Failure Handling (blast radius) → re-review; up to MAX_ITERATIONS
Step Dispatch (one implementation agent per step)
Use Task tool, one call per step (all steps of a Parallel with: group in a single message):
- Agent Type: the step's
Agent column, prefixed sdd: (e.g. sdd:developer, sdd:tech-writer)
- Model:
MODEL_OVERRIDE if set — otherwise the step's Model column — otherwise sonnet
- Description: "Implement step [step-name]"
- Prompt:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
Implement step `[step-name]`.
Task File: $TASK_PATH
Sub-Task File: [the Sub-Task File path from the Parallelization Overview]
Your task:
- Read the sub-task file first — it IS your step
- Read the task file for Description, Acceptance Criteria (including the Test Strategy) and Architecture Overview
- Execute ONLY this step. Do NOT execute any other step, even one you can see in the Parallelization Overview
- Follow the sub-task file's Expected Output, Success Criteria and Subtasks exactly
- Your phase is a checkpoint, not the finish line: implement what this step delivers, and do not pull later phases' work forward
- Leave the tree building, linting and testing green
When complete, report:
1. What files were created/modified (paths)
2. Confirmation that the sub-task's success criteria are met
3. Self-critique summary
4. Any issues encountered
Do NOT paste the step's goal, expected output, success criteria or subtasks into the prompt. The agent reads its sub-task file. Passing the path is the contract; pasting the content is context bloat and drift.
Collect the artifact paths from each report. Do NOT read the artifacts.
Code-Reviewer Input Contract (NON-NEGOTIABLE)
Every sdd:code-reviewer dispatch MUST include exactly these 4 inputs and NOTHING else that resembles a threshold or pass/fail expectation (the Task tool's model parameter is a dispatch setting, not a prompt input — see MODEL_OVERRIDE):
- Task file path:
$TASK_PATH
- Phase identifier: the phase being reviewed, exactly as written in
### Phase Overview (e.g. Phase 2)
- Artifact path(s): every file path the phase's implementation agents reported as created or modified
- CLAUDE_PLUGIN_ROOT: The plugin root path
Dispatch prompt:
CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
Apply your full evaluation process (Stages 0-12) and return a single combined report.
Inputs:
1. Task file path:
$TASK_PATH
2. Phase identifier:
[e.g. Phase 2]
3. Artifact path(s):
[every file path reported by this phase's implementation agents]
4. CLAUDE_PLUGIN_ROOT: ${CLAUDE_PLUGIN_ROOT}
You MUST NOT pass to the code-reviewer:
- Any score threshold, target quality, or passing-line value
- Any PASS/FAIL expectation
- Any rubric or checklist you wrote yourself (only the task file's
## Acceptance Criteria, narrowed by the Phase Overview, is authoritative)
- The sub-task file paths — the reviewer resolves them itself from the Phase Overview's
Steps: line and the Parallelization Overview's Sub-Task File column
- The task description or acceptance criteria text — the agent reads the task file itself
Threshold Application (Orchestrator-Level Only)
After receiving the code-reviewer's report, the orchestrator (this skill) applies the threshold:
combined_score = reviewer.combined_score
all_issues = reviewer.issues # each carries the step it belongs to
blast_radius = reviewer.blast_radius
# PASS rule (orchestrator decides):
if combined_score >= THRESHOLD:
PASS
elif 3.0 <= combined_score < THRESHOLD and not STRICT_MODE:
apply the Iteration Discretion Rule → accepted: PASS | declined: FAIL → fix
else:
FAIL → fix
The combined_score already incorporates spec_compliance + code_quality + Muda waste analysis (the reviewer aggregates them internally per its STAGE 9). The orchestrator does NOT need to re-aggregate sub-scores; only combined_score, issues and blast_radius matter for the gate decision.
Failure Handling: Reason About Blast Radius (YOUR MOST CRITICAL JUDGEMENT)
This is the single most important judgement you make in this workflow. Think thoroughly before you dispatch anything.
There is no rule table here, and you must not build yourself one. There is a principle:
**Match the capability of the agent that fixes the ph
…(truncated)
1---
2name: implement-task
3description: Implement a task step by step with automated LLM-as-Judge verification at the end of each phase
4---
5
6# Implement Task with Verification
7
8Your job is to implement solution in best quality using task specification and sub-agents. You MUST NOT stop until it is critically necessary or you are done! Avoid asking questions until it is critically necessary! Dispatch one implementation agent per step, then — when every step of an implementation phase is done — launch ONE `sdd:code-reviewer` for that phase, iterate till issues are fixed, then move to the next phase!
9
10Execute task implementation steps with automated quality verification using a single `sdd:code-reviewer` agent per implementation phase.
11
12## User Input
13
14```text
15$ARGUMENTS
16```
17
18---
19
20## Vocabulary (read this first — two different things are called "phase")
21
22| Term | Meaning |
23|------|---------|
24| **Workflow Phase 0-5** | The stages of THIS skill (select task, load, execute, DoD, move, report). |
25| **Implementation phase** / `Phase N` | A milestone in the TASK file's `### Phase Overview`. It groups steps, names a `Reviewer model`, and lists the acceptance criteria due at that milestone. This is the unit of code review. |
26| **Step** | One sub-task file at `.specs/sub-tasks/<task-name>/<NN>-<step-slug>.md`. This is the unit of implementation dispatch. The **step name** is that file's basename without `.md`. |
27
28---
29
30## Command Arguments
31
32Parse the following arguments from `$ARGUMENTS`:
33
34### Argument Definitions
35
36| Argument | Format | Default | Description |
37|----------|--------|---------|-------------|
38| `task-file` | Path or filename | Auto-detect | Task file name or path (e.g., `add-validation.feature.md`) |
39| `--continue` | `--continue` | None | Continue implementation from the last completed step: resolves the implementation phase in progress, completes its outstanding steps, then reviews that phase — see [Context Resolution for `--continue`](#context-resolution-for---continue). |
40| `--refine` | `--refine` | `false` | Incremental refinement mode - detect changes against git, map them to steps, and re-verify from the implementation phase that owns the earliest affected step. |
41| `--human-in-the-loop` | `--human-in-the-loop [Phase 1,Phase 3,...]` | None | Implementation phases after whose review to pause for human verification. If no phases specified, pauses after every implementation phase. |
42| `--target-quality` | `--target-quality X.X` | `4.0` | Single target threshold value (out of 5.0) applied to every implementation phase review. |
43| `--max-iterations` | `--max-iterations N` | `3` | Maximum fix→re-review cycles per implementation phase. Default is 3 iterations. Set to `unlimited` for no limit. |
44| `--skip-reviews` | `--skip-reviews` | `false` | Skip all phase reviews - steps proceed without quality gates. |
45| `--model` | `opus\|sonnet\|haiku` | Unset | Model for **all** sub-agents (implementation agents AND `sdd:code-reviewer`) that **overrides** every model in the task file; when omitted, step models come from the Parallelization Overview and reviewer models from the Phase Overview. |
46| `--strict` | `--strict` | `false` | Disable the [Iteration Discretion Rule](#iteration-discretion-rule) - a phase is marked PASS ONLY when `combined_score >= THRESHOLD`, otherwise iterate until `MAX_ITERATIONS` is reached. |
47
48### Configuration Resolution
49
50Parse `$ARGUMENTS` and resolve configuration as follows:
51
52```
53# Extract task file (first positional argument, optional - auto-detect if not provided)
54TASK_FILE = first argument that is a file path or filename
55
56# Single quality threshold — there is exactly one, and it is NEVER read from the task file
57THRESHOLD = --target-quality value || 4.0
58
59# Initialize other defaults
60MODEL_OVERRIDE = --model value (opus|sonnet|haiku) || none # none = no override; models come from the task file
61MAX_ITERATIONS = --max-iterations || 3 # default is 3 iterations
62HUMAN_IN_THE_LOOP_PHASES = --human-in-the-loop || [] (empty = none, "*" = all implementation phases)
63SKIP_REVIEWS = --skip-reviews || false
64REFINE_MODE = --refine || false
65CONTINUE_MODE = --continue || false
66STRICT_MODE = --strict || false
67
68# Special handling for --human-in-the-loop without a phase list
69if --human-in-the-loop present without phase identifiers:
70 HUMAN_IN_THE_LOOP_PHASES = "*" (all implementation phases)
71```
72
73**`THRESHOLD` is the ONLY quality threshold in this workflow.** There is no separate standard/critical/lenient value, no comma-separated form, and no threshold anywhere in the task file — the planning agents are forbidden from writing one.
74
75### Context Resolution for `--continue`
76
77When `--continue` is used, state is resolved by **implementation phase, then step**:
78
791. **Phase and Step Resolution:**
80 - Read the task file's `### Parallelization Overview` step table and `### Phase Overview`.
81 - A step is complete when its row in the step table is marked `[DONE]`.
82 - An implementation phase is complete when its `#### Phase N` heading carries **either** marker: `[REVIEWED]` (its review ran and passed) or `[REVIEWED-SKIPPED]` (its steps finished and its review was deliberately suppressed by an earlier `--skip-reviews` run).
83 - `RESUME_PHASE` = the first implementation phase marked **neither** `[REVIEWED]` **nor** `[REVIEWED-SKIPPED]`. Treating `[REVIEWED-SKIPPED]` as unfinished would re-run exactly the review the user suppressed.
84 - `RESUME_STEPS` = the steps of `RESUME_PHASE` that are not `[DONE]`, in dependency order.
852. **Verify the resumed phase's existing work:**
86 - If `RESUME_PHASE` already has some `[DONE]` steps but neither marker, and `RESUME_STEPS` is empty (all steps done, review never ran):
87 - **If `SKIP_REVIEWS` is true: launch nothing.** Mark the phase `[REVIEWED-SKIPPED]` and resume at the next implementation phase.
88 - Otherwise: launch the `sdd:code-reviewer` for `RESUME_PHASE` (passing the 4 inputs documented in Workflow Phase 2) — **Model**: `MODEL_OVERRIDE` if set — otherwise that phase's `Reviewer model`.
89 - If the phase PASSES per the [Iteration Discretion Rule](#iteration-discretion-rule): mark it `[REVIEWED]` and resume at the next implementation phase.
90 - Otherwise: enter the [Failure Handling](#failure-handling-reason-about-blast-radius-your-most-critical-judgement) flow for that phase.
91 - If `RESUME_STEPS` is non-empty: dispatch those steps first, then review the phase as normal — and `SKIP_REVIEWS` still suppresses that review, marking the phase `[REVIEWED-SKIPPED]` instead.
923. **State Recovery:**
93 - Check task file location (`in-progress/`, `todo/`, `done/`)
94 - If in `todo/`, move to `in-progress/` before continuing
95 - Pre-populate captured values from existing artifacts
96
97### Refine Mode Behavior (`--refine`)
98
99When `--refine` is used, it detects changes to **project files** (not the task file) and maps them to steps, then re-verifies from the implementation phase that owns the earliest affected step.
100
1011. **Detect Changed Project Files:**
102
103 First, determine what to compare against based on git state:
104
105 ```bash
106 # Check for staged changes
107 STAGED=$(git diff --cached --name-only)
108
109 # Check for unstaged changes
110 UNSTAGED=$(git diff --name-only)
111 ```
112
113 **Comparison logic:**
114
115 | Staged | Unstaged | Compare Against | Command |
116 |--------|----------|-----------------|---------|
117 | Yes | Yes | Staged (unstaged only) | `git diff --name-only` |
118 | Yes | No | Last commit | `git diff HEAD --name-only` |
119 | No | Yes | Last commit | `git diff HEAD --name-only` |
120 | No | No | No changes | Exit with message |
121
122 - If **both staged AND unstaged**: Compare working directory vs staging area (unstaged changes only)
123 - If **only staged OR only unstaged**: Compare against last commit
124 - This ensures refine operates on the most recent work in progress
125
1262. **Map Changes to Steps:**
127 - Read the task file's `### Parallelization Overview` to get every step name, its implementation phase, and its `Sub-Task File` path.
128 - **Refine mode is the ONE case where you may read sub-task files**: they are specification artifacts (like the task file), not implementation outputs, and their `#### Expected Output` sections are the only place file paths per step are recorded. Read ONLY the `#### Expected Output` and `#### Subtasks` sections you need.
129 - Build a mapping: `{changed_file → step name → implementation phase}`
130
1313. **Determine Affected Scope:**
132 - Find all steps that have associated changed files
133 - `REFINE_FROM_PHASE` = the earliest implementation phase containing an affected step
134 - All implementation phases from that point onwards need re-verification
135 - Earlier phases (unaffected) are preserved as-is
136
1374. **Refine Execution:**
138 - For each affected implementation phase (in order):
139 - Launch ONE **`sdd:code-reviewer` agent** to verify the phase (including the user's changes), passing the 4 standard inputs — **Model**: `MODEL_OVERRIDE` if set — otherwise that phase's `Reviewer model`
140 - If the phase PASSES per the [Iteration Discretion Rule](#iteration-discretion-rule): mark it `[REVIEWED]`, proceed to the next phase
141 - Otherwise: enter the [Failure Handling](#failure-handling-reason-about-blast-radius-your-most-critical-judgement) flow, then re-review
142 - User's manual fixes are preserved - implementation agents should build upon them, not overwrite
143
1445. **Example:**
145
146 ```bash
147 # User manually fixed src/validation/validation.service.ts
148 # (This file is the Expected Output of step `02-validation-service`, in Phase 1)
149
150 /implement my-task.feature.md --refine
151
152 # Detects: src/validation/validation.service.ts modified
153 # Maps to: step `02-validation-service` → Phase 1
154 # Action: Launch ONE sdd:code-reviewer for Phase 1
155 # - If PASS: User's fix is good, proceed to Phase 2
156 # - If FAIL: reason about blast radius, dispatch fixes for the affected
157 # steps only, without overwriting the user's changes, then re-review
158 # Continues: Phase 2, Phase 3... (re-verify all subsequent phases)
159 ```
160
1616. **Multiple Files Changed:**
162
163 ```bash
164 # User edited an output of a Phase 1 step AND an output of a Phase 3 step
165
166 /implement my-task.feature.md --refine
167
168 # Earliest affected phase: Phase 1
169 # Re-verifies: Phase 1, Phase 2, Phase 3...
170 # (Phase 2 re-verified even though no direct changes, because it builds on Phase 1)
171 ```
172
1737. **Staged vs Unstaged Changes:**
174
175 ```bash
176 # Scenario: User staged some changes, then made more edits
177 # Staged: src/validation/validation.service.ts (git add done)
178 # Unstaged: src/validation/validators/email.validator.ts (still editing)
179
180 /implement my-task.feature.md --refine
181
182 # Detects: Both staged AND unstaged changes exist
183 # Mode: Compares unstaged only (working dir vs staging)
184 # Only email.validator.ts is considered for refine
185
186 # --
187
188 # Scenario: User only has staged changes (ready to commit)
189 # Staged: src/validation/validation.service.ts
190 # Unstaged: none
191
192 /implement my-task.feature.md --refine
193
194 # Detects: Only staged changes
195 # Mode: Compares against last commit
196 ```
197
198### Human-in-the-Loop Behavior
199
200Human verification checkpoints are keyed on **implementation phases**, never on individual steps.
201
2021. **Trigger Conditions:**
203 - After an orchestrator-level **PASS** on the review of an implementation phase in `HUMAN_IN_THE_LOOP_PHASES`
204 - After a fix iteration completes for such a phase (before the next re-review)
205 - If `HUMAN_IN_THE_LOOP_PHASES` is `"*"`, triggers after every implementation phase
206
2072. **At Checkpoint:**
208 - Display the phase's step results summary
209 - Display generated artifacts with paths
210 - Display the reviewer's `combined_score` and consolidated issues
211 - Ask user: "Review phase output. Continue? [Y/n/feedback]"
212 - If user provides feedback, incorporate into the next iteration or phase
213 - If user says "n", pause workflow
214
2153. **Checkpoint Message Format:**
216
217 ```markdown
218 ---
219 ## 🔍 Human Review Checkpoint - Phase N
220
221 **Phase:** {phase heading}
222 **Steps:** {step names}
223 **Reviewer model:** {model used}
224 **Combined Score:** {combined_score}/5.0 (threshold: {THRESHOLD})
225 **Status:** ✅ PASS / ☑️ ACCEPTED / 🔄 ITERATING (attempt {n})
226
227 **Artifacts Created/Modified:**
228 - {artifact_path_1}
229 - {artifact_path_2}
230
231 **Reviewer Feedback (top issues):**
232 {feedback summary — High/Medium issues from reviewer.issues, with the step each belongs to}
233
234 **Action Required:** Review the above artifacts and provide feedback or continue.
235
236 > Continue? [Y/n/feedback]:
237 ---
238 ```
239
240---
241
242## Task Selection and Status Management
243
244### Task Status Folders
245
246Task status is managed by folder location:
247
248- `.specs/tasks/todo/` - Tasks waiting to be implemented
249- `.specs/tasks/in-progress/` - Tasks currently being worked on
250- `.specs/tasks/done/` - Completed tasks
251
252The task's sub-task folder `.specs/sub-tasks/<task-name>/` **never moves** while the task file travels between these folders, so the `Sub-Task File` paths recorded in the task file stay valid.
253
254### Status Transitions
255
256| When | Action |
257|------|--------|
258| Start implementation | Move task from `todo/` to `in-progress/` |
259| Final verification PASS | Move task from `in-progress/` to `done/` |
260| Implementation failure (user aborts) | Keep in `in-progress/` |
261
262---
263
264## CRITICAL: You Are an ORCHESTRATOR ONLY
265
266**Your role is DISPATCH and AGGREGATE. You do NOT do the work.**
267
268Properly build context of sub agents!
269
270CRITICAL: For each sub-agent you dispatch, you MUST provide:
271
272**For an implementation agent (one per step):**
273
274- Task file path
275- **That step's sub-task file path** — exactly one, taken from the `Sub-Task File` column of the Parallelization Overview
276- **Value of `${CLAUDE_PLUGIN_ROOT}` so agents can resolve paths like `@${CLAUDE_PLUGIN_ROOT}/scripts/create-scratchpad.sh`**
277
278**For the `sdd:code-reviewer` (one per implementation phase):**
279
280- Task file path
281- Phase identifier
282- Artifact path(s) reported by that phase's implementation agents
283- `CLAUDE_PLUGIN_ROOT`
284
285### What You DO
286
287- Read the task file ONCE (Workflow Phase 1 only)
288- Launch sub-agents via Task tool
289- Receive reports from sub-agents
290- Mark steps and implementation phases complete after the orchestrator-level PASS rule on reviewer output as [DONE]
291- Reason about blast radius when a phase review fails, and choose fix / re-review models accordingly
292- Aggregate results and report to user
293
294### What You NEVER Do
295
296| Prohibited Action | Why | What To Do Instead |
297|-------------------|-----|-------------------|
298| Read implementation outputs | Context bloat → command loss | Sub-agent reports what it created |
299| Read sub-task files (except `--refine` mapping) | The implementation agent reads its own sub-task file | Pass the path from the Parallelization Overview |
300| Read reference files | Sub-agent's job to understand patterns | Include path in sub-agent prompt |
301| Read artifacts to "check" them | Context bloat → forget verifications | Launch `sdd:code-reviewer` agent |
302| Evaluate code quality yourself | Not your job, causes forgetting | Launch `sdd:code-reviewer` agent |
303| Review a step individually | Review is a PHASE-level gate | Review once, at the end of the phase |
304| Skip a phase review "because simple" | Every phase review is mandatory unless `--skip-reviews` | Launch `sdd:code-reviewer` anyway |
305| Never add comments/marks/notes about results of review, scratchpads, iterations, etc. to the task file. | The task file is a specification artifact, not a log. If task not done, it should be visible from code only! | You can write only [DONE] mark ever, or nothing at all! |
306
307### Anti-Rationalization Rules
308
309**If you think:** "I should read this file to understand what was created"
310**→ STOP.** The sub-agent's report tells you what was created. Use that information.
311
312**If you think:** "I'll quickly verify this looks correct"
313**→ STOP.** Launch a `sdd:code-reviewer` agent. That's not your job.
314
315**If you think:** "This phase is too simple to need verification"
316**→ STOP.** Unless `SKIP_REVIEWS` is true, every implementation phase gets exactly one review. No exceptions.
317
318**If you think:** "This step looks risky, I'll review it before the phase ends"
319**→ STOP.** Reviewing per step is exactly what this workflow removed. Wait for the phase to complete.
320
321**If you think:** "I need to read the sub-task file to write a good prompt"
322**→ STOP.** Put the sub-task file PATH in the sub-agent prompt. The sub-agent reads it.
323
324### Why This Matters
325
326Orchestrators who read files themselves = context overflow = command loss = forgotten steps. Every time.
327
328Orchestrators who "quickly verify" = skip `sdd:code-reviewer` agents = quality collapse = failed artifacts.
329
330**Your context window is precious. Protect it. Delegate everything.**
331
332---
333
334## CRITICAL
335
336### Configuration Rules
337
338- **Model precedence (`MODEL_OVERRIDE`): if `--model` was given, that model WINS over the task file and over every default in this skill — dispatch EVERY sub-agent with it (implementation agents of any type AND `sdd:code-reviewer`), ignoring the Parallelization Overview's `Model` column and the Phase Overview's `Reviewer model`. It is an override, NOT a fallback. If `--model` was NOT given (`MODEL_OVERRIDE = none`), model selection is unchanged: each step uses the `Model` its Parallelization Overview row names, and each phase review uses that phase's `Reviewer model`, falling back to the default named in each dispatch block.**
339- Use the single `THRESHOLD` (default 4.0) for every implementation phase review. There is no per-component, per-criticality or lenient variant.
340- **Never read a threshold from the task file.** The planning agents write none; if one somehow appears, ignore it.
341- The threshold is applied at THIS orchestrator layer against `combined_score` returned by code-reviewer. **NEVER pass any threshold to the code-reviewer agent — or he will try to reach target score and as result become subjective.**
342- A phase PASSES if `combined_score >= THRESHOLD`. If `3.0 <= combined_score < THRESHOLD`, the phase passes ONLY when the [Iteration Discretion Rule](#iteration-discretion-rule) says so — never below the fixed floor of `3.0`. If `combined_score < 3.0`, the phase FAILS unconditionally.
343- **Default is 3 iterations** - stop after 3 fix→re-review cycles for an implementation phase and proceed to the next phase (with warning)!
344- If `MAX_ITERATIONS` is set to `unlimited`: Iterate until the quality threshold is met (no limit)
345- Trigger human-in-the-loop checkpoints ONLY after implementation phases in `HUMAN_IN_THE_LOOP_PHASES` (or all phases if `"*"`)!
346- **If `SKIP_REVIEWS` is true: Skip ALL code-reviewer dispatches - proceed directly to the next implementation phase after its steps complete!**
347- **If `CONTINUE_MODE` is true: Skip to `RESUME_PHASE` / `RESUME_STEPS` - do not re-implement already completed steps!**
348- **If `REFINE_MODE` is true: Detect changed project files, map to steps, re-verify from `REFINE_FROM_PHASE` - preserve user's fixes!**
349- **If `STRICT_MODE` is true: The [Iteration Discretion Rule](#iteration-discretion-rule) is DISABLED - a phase passes ONLY on `combined_score >= THRESHOLD`, otherwise iterate until `MAX_ITERATIONS`!**
350
351### Execution & Evaluation Rules
352
353- **Use foreground agents only**: Do not use background agents. Launch parallel agents when possible. Background agents constantly run in permissions issues and other errors.
354- **Parallelism comes from the task file**: steps whose `Parallel with:` column names each other MUST be dispatched simultaneously in one message. Never serialize what the plan says is parallel.
355- **Never cross a phase boundary in parallel**: a step of `Phase N+1` may only start after `Phase N` has been reviewed and marked `[REVIEWED]` (or marked `[REVIEWED-SKIPPED]` when `SKIP_REVIEWS` is true).
356
357Relaunch the code-reviewer till you get valid results, if following happens:
358
359- Reject Long Reports: If the code-reviewer returns a very long report instead of using the scratchpad as requested, reject the result. This indicates the agent failed to follow the "use scratchpad" instruction.
360- Combined Score 5.0 is a Hallucination: If the code-reviewer returns a `combined_score` of exactly 5.0/5.0, treat it as a hallucination or lazy evaluation. Reject it and re-run the agent. This applies to the **weighted aggregate only** — an individual criterion may legitimately score 5 and no score is rationed, but every criterion across spec compliance, code quality and Muda waste analysis landing strictly past its `score_4` anchor at once is not a plausible review outcome. Never use it as a reason to question a single high criterion score.
361- Reject Missing Scores: If the code-reviewer's report is missing the `combined_score` (or any sub-score: `spec_compliance_score`, `builtin_score`), reject it. This indicates the agent failed to follow the rubric instructions.
362- Reject PASS/FAIL Verdicts in Report: If the code-reviewer's output contains a PASS/FAIL verdict or references a threshold, reject it. The orchestrator owns that decision; the agent must remain threshold-blind.
363- Reject Out-of-Scope Findings: If the reviewer penalizes acceptance criteria that the phase's `#### Phase N` block does NOT list — reporting work a LATER phase delivers as "missing" or "incomplete" — reject the report and re-run the agent, restating that a phase is a checkpoint, not the finish line.
364
365#### Iteration Discretion Rule
366
367Your main task is to COMPLETE the task within target quality. Two failure modes are equally real:
368
369- Burning iterations and context on nitpicks so the overall task never completes → **the task is failed**.
370- Accepting a result whose quality is genuinely too poor to be considered complete → **an even worse failure**.
371
372Apply to every implementation phase's `combined_score`:
373
374- **`combined_score < 3.0` → FAIL, unconditionally. No discretion.** Iterate with reviewer feedback until the phase passes or `MAX_ITERATIONS` is reached.
375- **`3.0 <= combined_score < THRESHOLD` → discretion band.** ONLY inside this band MAY you decide that a phase below the target is acceptable. The fixed floor is `3.0` and the band ceiling is `THRESHOLD`. If `--target-quality` set `THRESHOLD <= 3.0` the band is empty: every score is either an unconditional FAIL (`< 3.0`) or a PASS, and there is no discretion to exercise.
376- Inside the band, when the outstanding issues are ONLY `Low`/`Medium` priority (any `High` or `Critical` finding removes discretion entirely) AND none of them breaks an acceptance criterion the phase is responsible for or causes a meaningful defect (i.e. they are nitpicks), you MUST reason FIRST — before dispatching another iteration — about whether iterating (or marking the phase failed) is worth the time and context cost.
377- **At most ONE nitpick-driven iteration**, and it counts against `MAX_ITERATIONS`. If it again surfaces only nitpicks, you MUST mark the phase PASS (☑️ ACCEPTED in the summary table), report the outstanding issues in the final report, and continue with the next phase. If it returns a `combined_score` below `3.0`, the FAIL path applies instead.
378- **A phase that does not build, lint or test green is NEVER inside the discretion band**, whatever the score says. Each phase must leave a working, committable, CI-green state.
379- You MUST be critical, NOT lenient. Stopping short of target MUST be an intentional decision grounded in the absence of real, requirement-breaking issues. A genuine blocking issue that prevents completing the phase within `MAX_ITERATIONS` MUST be reported as a failure, never papered over.
380- **If `STRICT_MODE` is true, this whole rule is DISABLED**: stop only when `combined_score >= THRESHOLD` or `MAX_ITERATIONS` is reached. `--strict` changes nothing else — `THRESHOLD`, `MAX_ITERATIONS`, the `< 3.0` unconditional FAIL, human-in-the-loop checkpoints, code-reviewer dispatch and `--skip-reviews` are unaffected. With `--skip-reviews` no `combined_score` is produced at all, so both this rule and `--strict` are inert.
381
382---
383
384## Overview
385
386This command orchestrates multi-step task implementation with:
387
3881. **Sequential execution** respecting step dependencies
3892. **Parallel execution** where the plan's `Parallel with:` column allows
3903. **One implementation agent per step**, dispatched with the task file path AND its sub-task file path
3914. **One automated verification per implementation phase**, at that phase's `Reviewer model`
3925. **Blast-radius reasoning** to pick the fix and re-review models when a phase review fails
3936. **Progress tracking** with confirmation after each orchestrator-level PASS
394
395---
396
397## Complete Workflow Overview
398
399```
400Workflow Phase 0: Select Task & Move to In-Progress
401 │
402 ├─── Use provided task file name or auto-select from todo/ (if only 1 task)
403 ├─── Move task: todo/ → in-progress/
404 │
405 ▼
406Workflow Phase 1: Load Task
407 │ Parse ### Parallelization Overview (steps, models, agents, sub-task paths)
408 │ Parse ### Phase Overview (phases, steps, reviewer models, criteria due)
409 │
410 ▼
411Workflow Phase 2: Execute Implementation Phases
412 │
413 ├─── For each implementation phase, in order:
414 │ │
415 │ ▼
416 │ ┌─────────────────────────────────────────────────┐
417 │ │ For each step of the phase, in dependency order │
418 │ │ (parallel steps dispatched simultaneously): │
419 │ │ Launch its agent at its Model with │
420 │ │ task file path + sub-task file path │
421 │ └─────────────────┬───────────────────────────────┘
422 │ │ all steps of the phase reported complete
423 │ ▼
424 │ ┌─────────────────────────────────────────────────┐
425 │ │ Launch ONE sdd:code-reviewer for the PHASE │
426 │ │ at the phase's Reviewer model │
427 │ └─────────────────┬───────────────────────────────┘
428 │ │
429 │ ▼
430 │ ┌─────────────────────────────────────────────────┐
431 │ │ Orchestrator reads combined_score and applies │
432 │ │ THRESHOLD: │
433 │ │ PASS → Mark phase [REVIEWED], next phase │
434 │ │ FAIL → Reason about BLAST RADIUS, choose fix │
435 │ │ model + scope + re-review model, │
436 │ │ re-review (max MAX_ITERATIONS) │
437 │ └─────────────────────────────────────────────────┘
438 │
439 ▼
440Workflow Phase 3: Definition of Done Verification
441 │
442 ├─── Verify all Definition of Done items
443 │ │
444 │ ▼
445 │ ┌─────────────────────────────────────────────────┐
446 │ │ Launch sdd:developer agent │
447 │ │ (verify all DoD items) │
448 │ └─────────────────┬───────────────────────────────┘
449 │ │
450 │ ▼
451 │ ┌─────────────────────────────────────────────────┐
452 │ │ All DoD PASS? → Proceed to Workflow Phase 4 │
453 │ │ Any FAIL? → Fix and re-verify (iterate) │
454 │ └─────────────────────────────────────────────────┘
455 │
456 ▼
457Workflow Phase 4: Move Task to Done
458 │
459 ├─── Move task: in-progress/ → done/
460 │
461 ▼
462Workflow Phase 5: Final Report
463```
464
465---
466
467## Workflow Phase 0: Parse User Input and Select Task
468
469Parse user input to get the task file path and arguments.
470
471### Step 0.1: Resolve Task File
472
473**If `$ARGUMENTS` is empty or only contains flags:**
474
4751. **Check in-progress folder first:**
476
477 ```bash
478 ls .specs/tasks/in-progress/*.md 2>/dev/null
479 ```
480
481 - If exactly 1 file → Set `$TASK_FILE` to that file, `$TASK_FOLDER` to `in-progress`
482 - If multiple files → List them and ask user: "Multiple tasks in progress. Which one to continue?"
483 - If no files → Continue to step 2
484
4852. **Check todo folder:**
486
487 ```bash
488 ls .specs/tasks/todo/*.md 2>/dev/null
489 ```
490
491 - If exactly 1 file → Set `$TASK_FILE` to that file, `$TASK_FOLDER` to `todo`
492 - If multiple files → List them and ask user: "Multiple tasks in todo. Which one to implement?"
493 - If no files → Report "No tasks available. Create one with /add-task first." and STOP
494
495**If `$ARGUMENTS` contains a task file name:**
496
4971. Search for the file in order: `in-progress/` → `todo/` → `done/`
4982. Set `$TASK_FILE` and `$TASK_FOLDER` accordingly
4993. If not found, report error and STOP
500
501### Step 0.2: Move to In-Progress (if needed)
502
503**If task is in `todo/` folder:**
504
505```bash
506git mv .specs/tasks/todo/$TASK_FILE .specs/tasks/in-progress/
507# Fallback if git not available: mv .specs/tasks/todo/$TASK_FILE .specs/tasks/in-progress/
508```
509
510Update `$TASK_PATH` to `.specs/tasks/in-progress/$TASK_FILE`
511
512**If task is already in `in-progress/`:**
513Set `$TASK_PATH` to `.specs/tasks/in-progress/$TASK_FILE`
514
515**Do NOT move the sub-task folder.** `.specs/sub-tasks/<task-name>/` stays where planning created it; the `Sub-Task File` paths in the task file already point there.
516
517### Step 0.3: Parse Flags and Initialize Configuration
518
519Parse all flags from `$ARGUMENTS` and initialize configuration.
520**Display resolved configuration:**
521
522```markdown
523### Configuration
524
525| Setting | Value |
526|---------|-------|
527| **Task File** | {TASK_PATH} |
528| **Model Override** | {MODEL_OVERRIDE or "None (models from task file)"} |
529| **Threshold** | {THRESHOLD}/5.0 |
530| **Max Iterations** | {MAX_ITERATIONS or "3"} |
531| **Human Checkpoints** | {HUMAN_IN_THE_LOOP_PHASES as comma-separated or "All phases" or "None"} |
532| **Skip Reviews** | {SKIP_REVIEWS} |
533| **Continue Mode** | {CONTINUE_MODE} |
534| **Refine Mode** | {REFINE_MODE} |
535| **Strict Mode** | {STRICT_MODE} |
536```
537
538### Step 0.4: Handle Continue Mode
539
540**If `CONTINUE_MODE` is true:** resolve `RESUME_PHASE` and `RESUME_STEPS` per [Context Resolution for `--continue`](#context-resolution-for---continue), then in Workflow Phase 2 skip every implementation phase before `RESUME_PHASE` and every `[DONE]` step inside it.
541
542### Step 0.5: Handle Refine Mode
543
544**If `REFINE_MODE` is true:**
545
5461. **Detect Changed Project Files:**
547
548 ```bash
549 # Check for staged and unstaged changes
550 STAGED=$(git diff --cached --name-only)
551 UNSTAGED=$(git diff --name-only)
552 ```
553
554 **Determine comparison mode:**
555
556 ```
557 if STAGED is not empty AND UNSTAGED is not empty:
558 # Both staged and unstaged - use unstaged only
559 CHANGED_FILES = git diff --name-only # working dir vs staging
560 COMPARISON_MODE = "unstaged_only"
561 elif STAGED is not empty OR UNSTAGED is not empty:
562 # Only one type - compare against last commit
563 CHANGED_FILES = git diff HEAD --name-only
564 COMPARISON_MODE = "vs_last_commit"
565 else:
566 # No changes
567 Report: "No project changes detected. Make edits first, then run --refine."
568 Exit
569 ```
570
5712. **Build the Step→File Mapping:**
572 - Read the task file's `### Parallelization Overview` for step names, phases and `Sub-Task File` paths
573 - Read those sub-task files' `#### Expected Output` and `#### Subtasks` sections for file paths (the one permitted exception to context protection — see [Refine Mode Behavior](#refine-mode-behavior---refine))
574 - Build mapping: `STEP_FILE_MAP = {step name → [file paths]}` and `STEP_PHASE_MAP = {step name → implementation phase}`
575
5763. **Map Changed Files to Steps:**
577
578 ```
579 AFFECTED_STEPS = []
580 for each changed_file:
581 for step_name, file_list in STEP_FILE_MAP:
582 if changed_file matches any path in file_list:
583 AFFECTED_STEPS.append(step_name)
584 ```
585
586 - If no steps matched: "Changed files don't map to any step's Expected Output. Verify manually."
587
5884. **Determine Refine Scope:**
589 - `REFINE_FROM_PHASE` = the earliest implementation phase among `STEP_PHASE_MAP[AFFECTED_STEPS]`
590 - All implementation phases from `REFINE_FROM_PHASE` onwards need re-verification
591 - Phases before `REFINE_FROM_PHASE` are preserved as-is
592
5935. **Store Changed Files Context:**
594 - `CHANGED_FILES` = list of changed file paths
595 - `USER_CHANGES_CONTEXT` = git diff output for affected files
596 - Pass this context to the implementation agents you dispatch for fixes
597 - Agents should build upon user's fixes, not overwrite them
598
599## Workflow Phase 1: Load and Analyze Task
600
601**This is the ONLY phase where you read a file** (plus the sub-task `#### Expected Output` sections in `--refine` mode).
602
603### Step 1.1: Load Task Details
604
605Read the task file ONCE:
606
607```bash
608Read $TASK_PATH
609```
610
611**After this read, you MUST NOT read any other files for the rest of execution.**
612
613### Step 1.2: Parse the Implementation Process
614
615Parse the `## Implementation Process` section into two working structures.
616
617**From `### Parallelization Overview`** — the step table has columns `| Step | Phase | Model | Agent | Depends on | Parallel with | Sub-Task File |`. Build, per step name:
618
619| Field | Source | Used for |
620|-------|--------|----------|
621| Step name | `Step` column (backtick-quoted sub-task basename) | Identity in all other lists |
622| Implementation phase | `Phase` column | Which review gate it belongs to |
623| Model | `Model` column | The `model` of its dispatch (unless `MODEL_OVERRIDE`) |
624| Agent | `Agent` column | The `sdd:` agent type to dispatch |
625| Depends on | `Depends on` column | Ordering |
626| Parallel with | `Parallel with` column | Which steps to dispatch in ONE message |
627| Sub-Task File | `Sub-Task File` column | The path you pass to the agent |
628
629**From `### Phase Overview`** — for each `#### Phase N` block, record `Steps:`, `Reviewer model:`, the `Checklist items:` list and the `Rubrics:` list. You use `Reviewer model:` to dispatch the review; the criteria lists are the reviewer's business, not yours — do NOT paste them into any prompt.
630
631There is **no threshold, no verification level and no judge count** in the task file. Do not look for them.
632
633### Step 1.3: Create Todo List
634
635Create TodoWrite with one entry per step plus one entry per implementation phase review:
636
637```json
638{
639 "todos": [
640 {"content": "Phase 1 / Step 01-foundation [haiku]", "status": "pending", "activeForm": "Implementing 01-foundation"},
641 {"content": "Phase 1 / Step 02a-service [sonnet]", "status": "pending", "activeForm": "Implementing 02a-service"},
642 {"content": "Phase 1 review [reviewer: sonnet]", "status": "pending", "activeForm": "Reviewing Phase 1"},
643 {"content": "Phase 2 / Step 03-integration [sonnet]", "status": "pending", "activeForm": "Implementing 03-integration"},
644 {"content": "Phase 2 review [reviewer: opus]", "status": "pending", "activeForm": "Reviewing Phase 2"}
645 ]
646}
647```
648
649---
650
651## Workflow Phase 2: Execute Implementation Phases
652
653Process implementation phases **in order**. Within a phase, process steps in dependency order, dispatching `Parallel with:` groups simultaneously. When every step of the phase has reported completion, run the phase review — once.
654
655There is exactly ONE dispatch pattern, and it applies to every implementation phase without exception.
656
657### The Phase Review Pattern
658
659```
660for each implementation phase P, in order:
661 for each dependency-ordered group G of steps in P:
662 dispatch every step of G in ONE message (parallel), each with:
663 agent type = its Agent column
664 model = MODEL_OVERRIDE if set, else its Model column
665 prompt = task file path + its sub-task file path
666 collect each agent's reported artifact paths
667
668 if SKIP_REVIEWS:
669 mark P [REVIEWED-SKIPPED]; continue to the next phase
670
671 dispatch ONE sdd:code-reviewer for P with the 4 inputs
672 model = MODEL_OVERRIDE if set, else P's `Reviewer model`
673
674 apply THRESHOLD to combined_score
675 PASS → mark P [REVIEWED]; human checkpoint if due; next phase
676 FAIL → Failure Handling (blast radius) → re-review; up to MAX_ITERATIONS
677```
678
679### Step Dispatch (one implementation agent per step)
680
681Use Task tool, one call per step (all steps of a `Parallel with:` group in a single message):
682
683- **Agent Type**: the step's `Agent` column, prefixed `sdd:` (e.g. `sdd:developer`, `sdd:tech-writer`)
684- **Model**: `MODEL_OVERRIDE` if set — otherwise the step's `Model` column — otherwise `sonnet`
685- **Description**: "Implement step [step-name]"
686- **Prompt**:
687
688```
689CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
690
691Implement step `[step-name]`.
692
693Task File: $TASK_PATH
694Sub-Task File: [the Sub-Task File path from the Parallelization Overview]
695
696Your task:
697- Read the sub-task file first — it IS your step
698- Read the task file for Description, Acceptance Criteria (including the Test Strategy) and Architecture Overview
699- Execute ONLY this step. Do NOT execute any other step, even one you can see in the Parallelization Overview
700- Follow the sub-task file's Expected Output, Success Criteria and Subtasks exactly
701- Your phase is a checkpoint, not the finish line: implement what this step delivers, and do not pull later phases' work forward
702- Leave the tree building, linting and testing green
703
704When complete, report:
7051. What files were created/modified (paths)
7062. Confirmation that the sub-task's success criteria are met
7073. Self-critique summary
7084. Any issues encountered
709```
710
711**Do NOT** paste the step's goal, expected output, success criteria or subtasks into the prompt. The agent reads its sub-task file. Passing the path is the contract; pasting the content is context bloat and drift.
712
713Collect the artifact paths from each report. **Do NOT read the artifacts.**
714
715### Code-Reviewer Input Contract (NON-NEGOTIABLE)
716
717Every `sdd:code-reviewer` dispatch MUST include exactly these 4 inputs and NOTHING else that resembles a threshold or pass/fail expectation (the Task tool's `model` parameter is a dispatch setting, not a prompt input — see `MODEL_OVERRIDE`):
718
7191. **Task file path**: `$TASK_PATH`
7202. **Phase identifier**: the phase being reviewed, exactly as written in `### Phase Overview` (e.g. `Phase 2`)
7213. **Artifact path(s)**: every file path the phase's implementation agents reported as created or modified
7224. **CLAUDE_PLUGIN_ROOT**: The plugin root path
723
724**Dispatch prompt:**
725
726```
727CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
728
729Apply your full evaluation process (Stages 0-12) and return a single combined report.
730
731Inputs:
732
7331. Task file path:
734 $TASK_PATH
735
7362. Phase identifier:
737 [e.g. Phase 2]
738
7393. Artifact path(s):
740 [every file path reported by this phase's implementation agents]
741
7424. CLAUDE_PLUGIN_ROOT: ${CLAUDE_PLUGIN_ROOT}
743```
744
745**You MUST NOT pass to the code-reviewer:**
746
747- Any score threshold, target quality, or passing-line value
748- Any PASS/FAIL expectation
749- Any rubric or checklist you wrote yourself (only the task file's `## Acceptance Criteria`, narrowed by the Phase Overview, is authoritative)
750- The sub-task file paths — **the reviewer resolves them itself** from the Phase Overview's `Steps:` line and the Parallelization Overview's `Sub-Task File` column
751- The task description or acceptance criteria text — the agent reads the task file itself
752
753### Threshold Application (Orchestrator-Level Only)
754
755After receiving the code-reviewer's report, the orchestrator (this skill) applies the threshold:
756
757```
758combined_score = reviewer.combined_score
759all_issues = reviewer.issues # each carries the step it belongs to
760blast_radius = reviewer.blast_radius
761
762# PASS rule (orchestrator decides):
763if combined_score >= THRESHOLD:
764 PASS
765elif 3.0 <= combined_score < THRESHOLD and not STRICT_MODE:
766 apply the Iteration Discretion Rule → accepted: PASS | declined: FAIL → fix
767else:
768 FAIL → fix
769```
770
771The `combined_score` already incorporates spec_compliance + code_quality + Muda waste analysis (the reviewer aggregates them internally per its STAGE 9). The orchestrator does NOT need to re-aggregate sub-scores; only `combined_score`, `issues` and `blast_radius` matter for the gate decision.
772
773### Failure Handling: Reason About Blast Radius (YOUR MOST CRITICAL JUDGEMENT)
774
775**This is the single most important judgement you make in this workflow. Think thoroughly before you dispatch anything.**
776
777There is no rule table here, and you must not build yourself one. There is a principle:
778
779> **Match the capability of the agent that fixes the phase — and of the agent that re-reviews the fix — to the BLAST RADIUS of the reviewer's findings, not to the models that originally built the phase.**
780
781Before dispatching a single fix, reason **explicitly and in writing** through:
782
7831. **Scope** — which steps do the findings touch? Use `issues[].step` and `blast_radius.affected_steps`. Which steps are demonstrably sound?
7842. **Depth** — is this a local defect inside a step, or did the phase come out structurally wrong (`blast_radius.requires_phase_rework`)?
7853. **Coupling** — does fixing the affected steps force rewriting the unaffected ones? If yes, the unit of repair is the phase, not the step.
7864. **Severity** — High/Critical findings that break an acceptance criterion the phase owns, or Low/Medium nitpicks?
7875. **Ceiling** — does the failure look like the implementing model ran out of capability? If a model already failed once on the same finding, dispatching it again at the same tier will fail again. Escalate.
788
789Then decide three things:
790
791- **The fix model** — it may be higher OR lower than the model that originally built the step, and it may differ per step.
792- **The fix scope** — which sub-task files to re-dispatch. Never re-dispatch a step whose work is sound; that is how good work gets destroyed.
793- **The re-review model** — at least the phase's `Reviewer model`. When you escalate the fix because the phase came out structurally wrong, escalate the re-review too: a review at the tier that let the defect through is not a check.
794
795**Worked example (the anchor case).** A phase of three steps, all built by `haiku`, reviewer `sonnet`, fails its review. The same failure verdict points at two very different repairs depending only on blast radius:
796
797- *Case A — the whole phase failed.* The reviewer reports High findings in all three steps, `requires_phase_rework: true`, and the design of the phase's shared abstraction is wrong. Blast radius = the whole phase; depth = structural; coupling = total; ceiling = `haiku` clearly could not carry this design. **Decision:** re-dispatch the whole phase's steps to `sonnet` (or `opus` if the abstraction is genuinely hard), and re-review at `opus` rather than the phase's `sonnet` — the `sonnet` review is what passed the broken shape to you.
798- *Case B — one step failed.* The reviewer reports a single High finding, `affected_steps: [02b-token-service]`, `requires_phase_rework: false`, and the other two steps are clean. Blast radius = one step; depth = local; coupling = none; ceiling = not reached, the defect is a missed edge case rather than a design failure. **Decision:** re-dispatch ONLY `02b-token-service`, still at `haiku`, with the reviewer's issues for that step; leave the other two steps untouched; re-review at the phase's `sonnet`.
799
800**Everything else is DERIVED from that principle, not enumerated.** A mixed-model phase, a phase that fails only on tests, a phase that fails a second time, a phase where two of five steps are coupled — none of these has a pre-written answer. Walk scope → depth → coupling → severity → ceiling, write down your reasoning, and choose. Do NOT reach for a decision matrix; the situations are too varied for one, and a matrix would make you stop thinking exactly where thinking matters most.
801
802Record the reasoning and the choice in the final report so the user can see why each fix model was picked.
803
804### Retry Feedback Construction
805
806For each step you decided to re-dispatch, build this prompt (one per step, parallel where the steps are independent):
807
808```
809CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
810
811Fix step `[step-name]` — Phase [N] review iteration [K] of [MAX_ITERATIONS]
812
813Task File: $TASK_PATH
814Sub-Task File: [that step's Sub-Task File path]
815
816The phase this step belongs to failed its quality review. Reviewer combined_score: [X.XX] / threshold [THRESHOLD]
817
818Issues attributed to THIS step:
819[paste the reviewer.issues entries whose `step` is this step (plus any `phase-wide` entries), verbatim: source, priority, description, evidence (file:line), impact, suggestion]
820
821Full reviewer report (for additional context, do NOT skim — use the issues list as your primary work list):
822[path to reviewer's scratchpad report file under .specs/scratchpad/<hex>.md]
823
824Your task:
825- Address every High priority issue attributed to this step
826- Address every Medium priority issue attributed to this step
827- Do NOT introduce functionality beyond your sub-task file's Expected Output
828- Do NOT modify files owned by steps that were NOT re-dispatched
829- Re-run tests/lint/build to ensure no regressions
830
831When complete, report:
8321. Files changed (paths)
8332. Per-issue resolution status (Fixed / Partially Fixed / Skipped with justification)
8343. Any new concerns introduced by the fix
835```
836
837After every re-dispatched step reports completion, dispatch the code-reviewer again for the SAME phase with the SAME 4 inputs (the artifact list may have grown — pass the union). Iterate until PASS or `MAX_ITERATIONS` is reached.
838
839If `MAX_ITERATIONS` is reached:
840
841- Log warning: "Phase [N] did not pass after {MAX_ITERATIONS} iterations (final combined_score: X.XX, threshold: {THRESHOLD})"
842- Proceed to the next implementation phase (do not block indefinitely)
843
844### On PASS: Mark the Phase Complete
845
846- Update the task file:
847 - Mark each completed step in the `### Parallelization Overview` table with `[DONE]` next to its step name
848 - Mark the phase heading `[REVIEWED]` (e.g. `#### Phase 1: Foundation [REVIEWED]`), or `[REVIEWED-SKIPPED]` when `SKIP_REVIEWS` is true
849- Update the todos to `completed`
850- Record `combined_score` in tracking
851
852The steps' own `#### Subtasks` and `#### Success Criteria` checkboxes are marked by the implementation agents inside their sub-task files — not by you.
853
854### Human-in-the-Loop Checkpoint (if applicable)
855
856**Only after the implementation phase PASSES**, if the phase identifier is in `HUMAN_IN_THE_LOOP_PHASES` (or `HUMAN_IN_THE_LOOP_PHASES == "*"`), display the checkpoint from [Human-in-the-Loop Behavior](#human-in-the-loop-behavior).
857
858- If user provides feedback: store for the next phase or re-dispatch the affected steps with the feedback
859- If user says "n": pause workflow, report current progress
860- If user says "Y" or continues: proceed to the next implementation phase
861
862---
863
864## ⚠️ CHECKPOINT: Before Proceeding to Definition-of-Done Verification
865
866Before moving to DoD verification, verify you followed the rules:
867
868- [ ] Did you dispatch ONE implementation agent per step, with the task file path AND its sub-task file path?
869- [ ] Did you dispatch every step at the model its Parallelization Overview row names (unless `MODEL_OVERRIDE`)?
870- [ ] Did you launch exactly ONE `sdd:code-reviewer` at the END of every implementation phase (unless `SKIP_REVIEWS`), at that phase's `Reviewer model`?
871- [ ] Did you avoid reviewing any individual step?
872- [ ] Did you apply `THRESHOLD` yourself against `combined_score`, and pass no threshold to the reviewer?
873- [ ] Did you reason about blast radius in writing before choosing every fix and re-review model?
874- [ ] Did you mark phases `[REVIEWED]` ONLY after the orchestrator-level PASS rule was satisfied?
875- [ ] Did you avoid reading ANY artifact files yourself?
876
877**If you read files other than the task file (and sub-task Expected Outputs in `--refine`), you are doing it wrong. STOP and restart.**
878
879---
880
881## Workflow Phase 3: Definition of Done Verification
882
883After all implementation phases are complete, verify the task meets all Definition of Done criteria.
884
885### Step 3.1: Launch Definition of Done Verification
886
887**Use Task tool with:**
888
889- **Agent Type**: `sdd:developer`
890- **Model**: `MODEL_OVERRIDE` if set — otherwise `opus`
891- **Description**: "Verify Definition of Done"
892- **Prompt**:
893
894```
895CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}
896
897Verify all Definition of Done items in the task file.
898
899Task File: $TASK_PATH
900
901Your task:
9021. Read the task file and locate the `## Acceptance Criteria` section, then its `**Definition of Done:**` sub-block
9032. Go through each checkbox item one by one
9043. For each item, verify if it passes by:
905 - Running appropriate tests (unit tests, E2E tests)
906 - Checking build/compilation status
907 - Verifying file existence and correctness
908 - Checking code patterns and linting
9094. You MUST mark each item in the task file that passed verification with `[X]`
9105. Return a structured report:
911- List ALL Definition of Done items
912- Status for each:
913 - ✅ PASS - if the item is complete and verified
914 - ❌ FAIL - if the item fails verification, with specific reason why
915 - ⚠️ BLOCKED - if the item cannot be verified due to a blocker
916- Evidence for each status
917- Specific issues for any failures
918- Overall pass rate
919
920This is the TASK-LEVEL check, run once, after every implementation phase is done. Unlike a phase review, nothing here is "not yet due" — every Definition of Done item must hold now.
921
922Be thorough - check everything the task requires.
923```
924
925### Step 3.2: Review Verification Results
926
927- Receive the Definition of Done verification report
928- Note which DoD items PASS and which FAIL
929- If the verification agent reports that all DoD items PASS, you MUST confirm at the end of the task file that all DoD items are marked with `[X]`
930
931### Step 3.3: Fix Failing DoD Items (If Any)
932
933If any Definition of Done items FAIL:
934
935**1. Launch an implementation agent for each failing item** — **Model**: `MODEL_OVERRIDE` if set — otherwise `opus`:
936
937```
938Fix Definition of Done item: [Item Description]
939
940Task File: $TASK_PATH
941
942Current Status:
943[paste failure details from verification report]
944
945Your task:
9461. Fix the specific issue identified
9472. Verify the fix resolves the problem
9483. Ensure no regressions (all tests still pass)
949
950Return:
951- What was fixed
952- Confirmation the item now passes
953- Any related changes made
954```
955
956**2. Re-verify After Fixes:**
957
958Launch the verification agent again (Step 3.1) to confirm all items now PASS.
959
960**3. Iterate if Needed:**
961
962Repeat fix → verify cycle until all Definition of Done items PASS.
963
964---
965
966## Workflow Phase 4: Move Task to Done
967
968Once ALL Definition of Done items PASS, move the task to the done folder.
969
970### Step 4.1: Verify Completion
971
972Confirm all Definition of Done items are marked complete in the task file.
973
974### Step 4.2: Move Task
975
976```bash
977# Extract just the filename from $TASK_PATH
978TASK_FILENAME=$(basename $TASK_PATH)
979
980# Move from in-progress to done
981git mv .specs/tasks/in-progress/$TASK_FILENAME .specs/tasks/done/
982# Fallback if git not available: mv .specs/tasks/in-progress/$TASK_FILENAME .specs/tasks/done/
983```
984
985**Do NOT move `.specs/sub-tasks/<task-name>/`.** It stays where it is; the task file's recorded paths must keep resolving.
986
987---
988
989## Workflow Phase 5: Aggregation and Reporting
990
991### Final Report
992
993After all implementation phases complete and DoD verification passes:
994
995```markdown
996## Implementation Summary
997
998### Task Status
999- Task Status: `done` ✅
1000- All Definition of Done items: X/X PASS (100%)
1001
1002### Configuration Used
1003
1004| Setting | Value |
1005|---------|-------|
1006| **Model Override** | {MODEL_OVERRIDE or "None (models from task file)"} |
1007| **Threshold** | {THRESHOLD}/5.0 |
1008| **Max Iterations** | {MAX_ITERATIONS or "3"} |
1009| **Human Checkpoints** | {HUMAN_IN_THE_LOOP_PHASES or "None"} |
1010| **Skip Reviews** | {SKIP_REVIEWS} |
1011| **Continue Mode** | {CONTINUE_MODE} |
1012| **Refine Mode** | {REFINE_MODE} |
1013| **Strict Mode** | {STRICT_MODE} |
1014
1015### Steps Completed
1016
1017| Step | Phase | Model Used | Status |
1018|------|-------|------------|--------|
1019| `01-foundation` | Phase 1 | haiku | ✅ |
1020| `02a-service` | Phase 1 | sonnet | ✅ |
1021| `03-integration` | Phase 2 | sonnet | ✅ (re-dispatched at opus in iteration 1) |
1022
1023### Phase Reviews
1024
1025| Phase | Steps | Reviewer Model | Combined Score | Iterations | Status |
1026|-------|-------|----------------|----------------|------------|--------|
1027| Phase 1 | 2 | sonnet | 4.3/5 | 1 | ✅ |
1028| Phase 2 | 1 | opus | 3.6/5 | 2 | ☑️ |
1029
1030**Legend:**
1031- ✅ PASS - `combined_score >= THRESHOLD`
1032- ☑️ ACCEPTED - Score in discretion band `3.0 <= combined_score < THRESHOLD` accepted per the [Iteration Discretion Rule](#iteration-discretion-rule) (outstanding nitpicks listed under Recommendations)
1033- ⚠️ MAX_ITER - Did not pass but MAX_ITERATIONS reached, proceeded anyway
1034- ⏭️ SKIPPED - Review skipped (`--skip-reviews`, continue or refine mode); the phase heading carries `[REVIEWED-SKIPPED]`, not `[REVIEWED]`
1035
1036### Fix Decisions (blast-radius reasoning)
1037
1038| Phase | Iteration | Findings scope | Fix model chosen | Re-review model | Reasoning |
1039|-------|-----------|----------------|------------------|-----------------|-----------|
1040| Phase 2 | 1 | 1 of 1 step, structural | opus (was sonnet) | opus (was opus) | Shared abstraction wrong; sonnet had already failed on it |
1041
1042### Review Summary
1043
1044- Total implementation phases: X
1045- Phases reviewed: Y
1046- Passed on first review: Z
1047- Accepted below target per Iteration Discretion Rule: U (outstanding nitpicks listed under Recommendations)
1048- Required fix iterations: W
1049- Total iterations across all phases: V
1050- Final pass rate: 100%
1051
1052### Definition of Done Verification
1053
1054| Item | Status | Evidence |
1055|------|--------|----------|
1056| [DoD Item 1] | ✅ PASS | [Brief evidence] |
1057| [DoD Item 2] | ✅ PASS | [Brief evidence] |
1058| ... | ... | ... |
1059
1060**Issues Fixed During Verification:**
10611. [Issue]: [How it was fixed]
10622. [Issue]: [How it was fixed]
1063
1064### Human Review Summary (if --human-in-the-loop used)
1065
1066| Phase | Checkpoint | User Action | Feedback Incorporated |
1067|-------|------------|-------------|----------------------|
1068| Phase 1 | After PASS | Continued | - |
1069| Phase 2 | After iteration 1 | Feedback | "Improve error messages" |
1070
1071### Task File Updated
1072
1073- Task moved from `in-progress/` to `done/` folder
1074- All step rows marked `[DONE]` in the Parallelization Overview
1075- All phase headings marked `[REVIEWED]` in the Phase Overview — or `[REVIEWED-SKIPPED]` for phases whose review `--skip-reviews` suppressed
1076- All Definition of Done items marked `[X]`
1077- Sub-task files' subtasks marked `[X]` by their implementation agents
1078
1079### Recommendations
1080
10811. [Any follow-up actions]
10822. [Suggested improvements]
1083```
1084
1085---
1086
1087## Execution Flow Diagram
1088
1089```
1090┌──────────────────────────────────────────────────────────────┐
1091│ IMPLEMENT TASK WITH VERIFICATION │
1092├──────────────────────────────────────────────────────────────┤
1093│ │
1094│ Workflow Phase 0: Select Task │
1095│ ┌─────────────────────────────────────────────────────────┐ │
1096│ │ Use provided name or auto-select from todo/ (if 1 task) │ │
1097│ │ → Move task from todo/ to in-progress/ │ │
1098│ └─────────────────────────────────────────────────────────┘ │
1099│ │ │
1100│ ▼ │
1101│ Workflow Phase 1: Load Task │
1102│ ┌─────────────────────────────────────────────────────────┐ │
1103│ │ Read $TASK_PATH → Parse Parallelization Overview │ │
1104│ │ (steps, models, agents, sub-task paths) + Phase │ │
1105│ │ Overview (phases, reviewer models) → TodoWrite │ │
1106│ └─────────────────────────────────────────────────────────┘ │
1107│ │ │
1108│ ▼ │
1109│ Workflow Phase 2: Execute Implementation Phases │
1110│ ┌─────────────────────────────────────────────────────────┐ │
1111│ │ │ │
1112│ │ For each implementation phase: │ │
1113│ │ │ │
1114│ │ ┌──────────────┐ │ │
1115│ │ │ step agent │─┐ │ │
1116│ │ ├──────────────┤ │ (parallel where the plan says so) │ │
1117│ │ │ step agent │─┤ │ │
1118│ │ ├──────────────┤ │ │ │
1119│ │ │ step agent │─┘ │ │
1120│ │ └──────────────┘ │ │ │
1121│ │ ▼ │ │
1122│ │ ┌─────────────────────┐ ┌───────────┐ │ │
1123│ │ │ ONE code-reviewer │───▶│ PASS? │ │ │
1124│ │ │ for the whole phase │ │ │ │ │
1125│ │ └─────────────────────┘ └───────────┘ │ │
1126│ │ │ │ │ │
1127│ │ PASS FAIL │ │
1128│ │ │ │ │ │
1129│ │ ▼ ▼ │ │
1130│ │ ┌──────────┐ Blast-radius │ │
1131│ │ │ Mark │ reasoning → │ │
1132│ │ │[REVIEWED]│ fix model + │ │
1133│ │ └──────────┘ scope + re- │ │
1134│ │ review model ↺ │ │
1135│ └─────────────────────────────────────────────────────────┘ │
1136│ │ │
1137│ ▼ │
1138│ Workflow Phase 3: Definition of Done Verification │
1139│ ┌─────────────────────────────────────────────────────────┐ │
1140│ │ │ │
1141│ │ ┌──────────────┐ ┌───────────────┐ ┌───────────┐ │ │
1142│ │ │ DoD Verifier │───▶│ All DoD │───▶│ All PASS? │ │ │
1143│ │ │ Agent │ │ items checked │ │ │ │ │
1144│ │ └──────────────┘ └───────────────┘ └───────────┘ │ │
1145│ │ │ │ │ │
1146│ │ Yes No │ │
1147│ │ │ │ │ │
1148│ │ ▼ ▼ │ │
1149│ │ Fix & │ │
1150│ │ Retry │ │
1151│ │ ↺ │ │
1152│ │ │ │
1153│ └─────────────────────────────────────────────────────────┘ │
1154│ │ │
1155│ ▼ │
1156│ Workflow Phase 4: Move Task to Done │
1157│ ┌─────────────────────────────────────────────────────────┐ │
1158│ │ mv in-progress/$TASK → done/$TASK │ │
1159│ └─────────────────────────────────────────────────────────┘ │
1160│ │ │
1161│ ▼ │
1162│ Workflow Phase 5: Aggregate & Report │
1163│ ┌─────────────────────────────────────────────────────────┐ │
1164│ │ Collect all phase review results │ │
1165│ │ → Calculate aggregate metrics │ │
1166│ │ → Generate final report │ │
1167│ │ → Present to user │ │
1168│ └─────────────────────────────────────────────────────────┘ │
1169│ │
1170└──────────────────────────────────────────────────────────────┘
1171```
1172
1173---
1174
1175## Usage Examples
1176
1177### Basic Usage
1178
1179```bash
1180# Implement a specific task
1181/implement add-validation.feature.md
1182
1183# Auto-select task from todo/ or in-progress/ (if only 1 task)
1184/implement
1185
1186# Continue from the last completed step
1187/implement add-validation.feature.md --continue
1188
1189# Refine after user fixes project files (detects changes, re-verifies affected phases)
1190/implement add-validation.feature.md --refine
1191
1192# Human review after every implementation phase
1193/implement add-validation.feature.md --human-in-the-loop
1194
1195# Human review after specific phases only
1196/implement add-validation.feature.md --human-in-the-loop "Phase 1,Phase 3"
1197
1198# Higher quality threshold (stricter)
1199/implement add-validation.feature.md --target-quality 4.5
1200
1201# Lower quality threshold (faster convergence)
1202/implement add-validation.feature.md --target-quality 3.5
1203
1204# Unlimited iterations (default is 3)
1205/implement add-validation.feature.md --max-iterations unlimited
1206
1207# Skip all phase reviews (fast but no quality gates)
1208/implement add-validation.feature.md --skip-reviews
1209
1210# Strict mode: never accept a phase below target - iterate until threshold or MAX_ITERATIONS
1211/implement add-validation.feature.md --strict
1212
1213# Force ALL sub-agents (implementers + code-reviewer) onto one model, overriding the task file
1214/implement add-validation.feature.md --model sonnet
1215
1216# Combined: continue with human review
1217/implement add-validation.feature.md --continue --human-in-the-loop
1218```
1219
1220### Example 1: Implementing a Feature
1221
1222```
1223User: /implement add-validation.feature.md
1224
1225Workflow Phase 0: Task Selection...
1226Found task in: .specs/tasks/todo/add-validation.feature.md
1227Moving to in-progress: .specs/tasks/in-progress/add-validation.feature.md
1228
1229Workflow Phase 1: Loading task...
1230Task: "Add form validation service"
1231Parallelization Overview: 4 steps
1232Phase Overview: 2 implementation phases
1233- Phase 1: 01-validation-types, 02-validation-service — reviewer sonnet
1234- Phase 2: 03a-email-validator, 03b-phone-validator — reviewer opus
1235Threshold: 4.0/5.0
1236
1237Workflow Phase 2: Executing...
1238
1239Phase 1 / step 01-validation-types [haiku]
1240 Prompt: task file + .specs/sub-tasks/add-validation/01-validation-types.md
1241 Result: ✅ src/validation/types.ts
1242
1243Phase 1 / step 02-validation-service [sonnet]
1244 Prompt: task file + .specs/sub-tasks/add-validation/02-validation-service.md
1245 Result: ✅ src/validation/validation.service.ts + spec
1246
1247 Launching 1 sdd:code-reviewer for Phase 1 (model: sonnet)...
1248 Inputs: task file path, "Phase 1", 3 artifact paths, CLAUDE_PLUGIN_ROOT
1249 combined_score 4.3/5.0 ≥ threshold 4.0 → PASS ✅
1250 Marking Phase 1 [REVIEWED]
1251
1252Phase 2 / steps 03a-email-validator, 03b-phone-validator [haiku, haiku] — dispatched in parallel
1253 Result: ✅ 2 validators + specs
1254
1255 Launching 1 sdd:code-reviewer for Phase 2 (model: opus)...
1256 combined_score 4.5/5.0 ≥ threshold 4.0 → PASS ✅
1257
1258Workflow Phase 3: Definition of Done Verification...
1259 Result: 4/4 items PASS ✅
1260
1261Workflow Phase 4: Moving task to done...
1262
1263Workflow Phase 5: Final Report
1264Implementation complete.
1265- 4/4 steps completed, 2/2 phases reviewed
1266- All passed first review
1267- Definition of Done: 4/4 PASS
1268- Task location: .specs/tasks/done/add-validation.feature.md ✅
1269```
1270
1271### Example 2: Handling DoD Item Failure
1272
1273```
1274[All implementation phases complete and reviewed...]
1275
1276Workflow Phase 3: Definition of Done Verification...
1277Launching DoD verification agent...
1278 Result: 3/4 items PASS, 1 FAIL ❌
1279
1280Failing item:
1281- "Code follows ESLint rules": 356 errors found
1282
1283Should I attempt to fix this issue? [Y/n]
1284
1285User: Y
1286
1287Launching sdd:developer agent...
1288 Result: Fixed 356 errors, 0 warnings ✅
1289
1290Re-launching DoD verification agent...
1291 Result: 4/4 items PASS ✅
1292
1293Workflow Phase 4: Moving task to done...
1294All DoD checkboxes marked complete ✅
1295```
1296
1297Examples 3 and 4 below are the two halves of the SAME anchor case from [Failure Handling](#failure-handling-reason-about-blast-radius-your-most-critical-judgement), shown end-to-end as session logs. They are NOT a catalogue of situations — every other failure is reasoned out from the principle, never looked up.
1298
1299### Example 3: Phase Review Failure — Case A of the anchor example, as a session log
1300
1301```
1302Phase 2 complete: steps 03a, 03b, 03c — all built by haiku.
1303Launching 1 sdd:code-reviewer for Phase 2 (model: sonnet)...
1304
1305combined_score 2.1/5.0 — below threshold 4.0 and below the 3.0 floor → FAIL (no discretion)
1306
1307Reviewer blast_radius:
1308 affected_steps: [03a-parser, 03b-evaluator, 03c-formatter]
1309 unaffected_steps: []
1310 requires_phase_rework: true
1311
1312Blast-radius reasoning:
1313- Scope: all 3 steps carry High findings
1314- Depth: structural — the shared Rule interface the three steps agreed on is wrong
1315- Coupling: total — fixing one forces rewriting the other two
1316- Severity: 4 High findings, 2 of them break CK-3 and CK-4, which Phase 2 owns
1317- Ceiling: haiku produced three mutually inconsistent takes on the same interface
1318→ Fix model: sonnet for all three steps (was haiku)
1319→ Fix scope: whole phase
1320→ Re-review model: opus (was sonnet) — the sonnet review is what let this shape through
1321
1322Iteration 1/3: re-dispatching 03a, 03b, 03c at sonnet with their per-step issues...
1323Re-launching sdd:code-reviewer for Phase 2 at opus...
1324combined_score 4.4/5.0 ≥ threshold 4.0 → PASS ✅
1325Marking Phase 2 [REVIEWED]
1326```
1327
1328### Example 4: Phase Review Failure — Case B of the anchor example, as a session log
1329
1330```
1331Phase 1 complete: steps 01a, 01b, 01c — all built by haiku.
1332Launching 1 sdd:code-reviewer for Phase 1 (model: sonnet)...
1333
1334combined_score 3.4/5.0 — below threshold 4.0, inside discretion band → but a High finding removes discretion → FAIL
1335
1336Reviewer blast_radius:
1337 affected_steps: [01b-token-service]
1338 unaffected_steps: [01a-user-model, 01c-config]
1339 requires_phase_rework: false
1340
1341Blast-radius reasoning:
1342- Scope: 1 of 3 steps
1343- Depth: local — a missed expiry edge case, not a design failure
1344- Coupling: none — 01a and 01c do not touch the token path
1345- Severity: 1 High, breaks CK-2 which Phase 1 owns
1346- Ceiling: not reached — the step's design is right, one branch is missing
1347→ Fix model: haiku (unchanged)
1348→ Fix scope: 01b-token-service ONLY — 01a and 01c are not re-dispatched
1349→ Re-review model: sonnet (the phase's Reviewer model, unchanged)
1350
1351Iteration 1/3: re-dispatching 01b-token-service at haiku...
1352Re-launching sdd:code-reviewer for Phase 1 at sonnet...
1353combined_score 4.2/5.0 ≥ threshold 4.0 → PASS ✅
1354```
1355
1356### Example 5: Continue from Interruption
1357
1358```
1359User: /implement add-validation.feature.md --continue
1360
1361Workflow Phase 0: Parsing flags...
1362Configuration:
1363- Continue Mode: true
1364- Threshold: 4.0/5.0 (default)
1365
1366Scanning task file...
1367Parallelization Overview: 01-... [DONE], 02-... [DONE], 03-..., 04-...
1368Phase Overview: Phase 1 [REVIEWED], Phase 2 (not reviewed)
1369RESUME_PHASE = Phase 2
1370RESUME_STEPS = 03-..., 04-...
1371
1372Resuming: dispatching 03-... and 04-... (parallel per the plan)...
1373[both complete]
1374
1375Launching 1 sdd:code-reviewer for Phase 2 (model: opus)...
1376combined_score 4.3/5.0 ≥ threshold 4.0 → PASS ✅
1377```
1378
1379### Example 6: Refine After User Fixes
1380
1381```
1382# User manually fixed src/validation/validation.service.ts
1383# (Expected Output of step 02-validation-service, in Phase 1)
1384
1385User: /implement add-validation.feature.md --refine
1386
1387Workflow Phase 0: Parsing flags...
1388Configuration:
1389- Refine Mode: true
1390
1391Detecting changed project files...
1392- src/validation/validation.service.ts (modified)
1393
1394Mapping files to steps (reading sub-task Expected Output sections)...
1395- src/validation/validation.service.ts → 02-validation-service → Phase 1
1396
1397Earliest affected phase: Phase 1
1398Preserving: nothing earlier
1399Re-verifying from: Phase 1 onwards
1400
1401Launching 1 sdd:code-reviewer for Phase 1...
1402combined_score 4.3/5.0 ≥ threshold 4.0 → PASS ✅
1403
1404Launching 1 sdd:code-reviewer for Phase 2...
1405combined_score 2.8/5.0 — High finding "typescript error in src/validation/index.ts" → FAIL
1406Blast radius: 1 step (04-barrel-exports), local, no coupling, ceiling not reached
1407→ re-dispatch 04-barrel-exports at its original model with the user's diff as context
1408
1409Re-launching sdd:code-reviewer for Phase 2...
1410combined_score 4.5/5.0 → PASS ✅
1411
1412All phases verified with user's changes incorporated ✅
1413```
1414
1415### Example 7: Human-in-the-Loop Review
1416
1417```
1418User: /implement add-validation.feature.md --human-in-the-loop
1419
1420Configuration:
1421- Human Checkpoints: All phases
1422
1423Phase 1 / steps 01-..., 02-... dispatched...
1424Result: ✅ complete
1425
1426Launching 1 sdd:code-reviewer for Phase 1 (model: sonnet)...
1427combined_score 4.4/5.0 ≥ threshold 4.0 → PASS ✅
1428
1429---
1430## 🔍 Human Review Checkpoint - Phase 1
1431
1432**Phase:** Phase 1: Validation Core
1433**Steps:** `01-validation-types`, `02-validation-service`
1434**Reviewer model:** sonnet
1435**Combined Score:** 4.4/5.0 (threshold: 4.0)
1436**Status:** ✅ PASS
1437
1438**Artifacts Created/Modified:**
1439- src/validation/types.ts
1440- src/validation/validation.service.ts
1441- src/validation/tests/validation.service.spec.ts
1442
1443**Reviewer Feedback (top issues):**
1444- [Low] `02-validation-service` — Error messages could be more descriptive
1445
1446**Action Required:** Review the above artifacts and provide feedback or continue.
1447
1448> Continue? [Y/n/feedback]: The error messages could be more descriptive
1449---
1450
1451Incorporating feedback: re-dispatching 02-validation-service with the feedback...
1452[iteration continues]
1453```
1454
1455### Example 8: Strict Quality Threshold
1456
1457```
1458User: /implement add-validation.feature.md --strict
1459
1460Configuration:
1461- Strict Mode: true (Iteration Discretion Rule DISABLED)
1462- Threshold: 4.0/5.0 (default)
1463- Max Iterations: 3 (default)
1464
1465Phase 1 / steps 01-..., 02-... dispatched...
1466
1467Launching 1 sdd:code-reviewer for Phase 1 (model: sonnet)...
1468combined_score 3.6/5.0 — outstanding issues are 2 Low nitpicks only
1469Without --strict this would sit in the discretion band (3.0 <= 3.6 < 4.0) and be ☑️ ACCEPTED.
1470--strict disables that discretion → FAIL, iterate.
1471
1472Blast radius: 1 step (02-validation-service), local → re-dispatch it with the reviewer feedback
1473Re-launching sdd:code-reviewer for Phase 1 (iteration 2)...
1474combined_score 4.2/5.0 ≥ threshold 4.0 → PASS ✅
1475Marking Phase 1 [REVIEWED]
1476```
1477
1478---
1479
1480## Error Handling
1481
1482### Implementation Failure
1483
1484If an implementation agent reports failure:
1485
14861. Present the failure details to user
14872. Ask clarification questions that could help resolve
14883. Re-dispatch the agent for that step with the clarifications
14894. A step failure delays the phase's review; it never skips it. Once every step of the phase reports completion, the phase review runs exactly as normal (unless `SKIP_REVIEWS`).
1490
1491### Reviewer Returns an Invalid Report
1492
1493If the `sdd:code-reviewer` returns a report that trips any rule in [Execution & Evaluation Rules](#execution--evaluation-rules) — a 5.0 `combined_score`, a missing `combined_score`, a PASS/FAIL verdict, or findings against acceptance criteria the phase does not own — reject it and re-run the agent with the same 4 inputs. Never repair its report yourself.
1494
1495### Refine Mode: No Changes Detected
1496
1497If `--refine` mode finds no git changes in the project:
1498
14991. Report: "No project file changes detected since last commit."
15002. Suggest: "Make edits to project files first, then run --refine again."
15013. Alternatively: "Run without --refine to re-implement all steps."
1502
1503### Refine Mode: Changes Don't Map to Steps
1504
1505If `--refine` mode finds changed files but none map to a step's Expected Output:
1506
15071. Report: "Changed files don't match any step's Expected Output."
15082. List the changed files detected
15093. Suggest: "Verify manually or run without --refine to re-verify all phases."
1510
1511### Missing Sub-Task File
1512
1513If the `Sub-Task File` path in the Parallelization Overview does not exist:
1514
15151. Try `.specs/sub-tasks/<task-file-basename-without-extension>/<step-name>.md` — the folder never moves, so a stale path is usually recoverable
15162. If still missing, report it to the user and STOP. Do NOT invent the step's content, and do NOT dispatch the agent with only the task file.
1517
1518---
1519
1520## Checklist
1521
1522Before completing implementation:
1523
1524### Configuration Handling
1525
1526- [ ] Parsed all flags from `$ARGUMENTS` correctly
1527- [ ] Applied the `MODEL_OVERRIDE` precedence rule for `--model` (see [Configuration Rules](#configuration-rules))
1528- [ ] Used the single `THRESHOLD` (default 4.0) for every implementation phase review
1529- [ ] Read NO threshold from the task file
1530- [ ] Iterated until the orchestrator-level PASS rule was satisfied (or `MAX_ITERATIONS` reached, default 3)
1531- [ ] Applied the [Iteration Discretion Rule](#iteration-discretion-rule) only inside the discretion band `3.0 <= combined_score < THRESHOLD`, never accepted below `3.0`, treated `< 3.0` as unconditional FAIL, and spent at most ONE nitpick-driven iteration
1532- [ ] Passed NO threshold, floor or band value to the code-reviewer — the agent stayed threshold-blind
1533- [ ] If `STRICT_MODE` is true: Ignored the Iteration Discretion Rule and iterated until `THRESHOLD` or `MAX_ITERATIONS`
1534- [ ] Triggered human-in-the-loop checkpoints ONLY for implementation phases in `HUMAN_IN_THE_LOOP_PHASES`
1535- [ ] If `SKIP_REVIEWS` is true: Skipped ALL code-reviewer dispatches
1536- [ ] If `CONTINUE_MODE` is true: Resolved `RESUME_PHASE` + `RESUME_STEPS` and resumed correctly
1537- [ ] If `REFINE_MODE` is true: Detected changed project files, mapped to steps, re-verified from the earliest affected implementation phase
1538
1539### Context Protection (CRITICAL)
1540
1541- [ ] Read ONLY the task file (`$TASK_PATH` in `.specs/tasks/in-progress/`) — plus sub-task `#### Expected Output` sections in `--refine` mode, and nothing else
1542- [ ] Did NOT read implementation outputs, reference files, or artifacts
1543- [ ] Used sub-agent reports for status - did NOT read files to "check"
1544
1545### Delegation
1546
1547- [ ] EVERY step implemented by its own sub-agent via Task tool, with the task file path AND its sub-task file path
1548- [ ] Every step dispatched at the model and agent type its Parallelization Overview row names (unless `MODEL_OVERRIDE`)
1549- [ ] EXACTLY ONE `sdd:code-reviewer` dispatched per implementation phase, at that phase's `Reviewer model` (unless `SKIP_REVIEWS`)
1550- [ ] Did NOT review any individual step
1551- [ ] Did NOT perform any verification yourself
1552
1553### Progress Tracking
1554
1555- [ ] Each step row marked `[DONE]` in the Parallelization Overview after its agent reported completion
1556- [ ] Each phase heading marked `[REVIEWED]` ONLY after the orchestrator-level PASS (or `[REVIEWED-SKIPPED]` if `SKIP_REVIEWS`)
1557- [ ] Todo list updated after each step and each phase review
1558
1559### Execution Quality
1560
1561- [ ] All steps executed in dependency order
1562- [ ] `Parallel with:` groups launched simultaneously in one message (not sequentially)
1563- [ ] No step of a later phase started before the previous phase was reviewed
1564- [ ] Blast-radius reasoning written out BEFORE choosing each fix model, fix scope and re-review model
1565- [ ] Only affected steps re-dispatched — sound steps left untouched
1566- [ ] Failed reviews iterated using the reviewer's `issues` (attributed per step) as feedback until orchestrator-level PASS
1567- [ ] Final report generated with phase review results and fix decisions
1568
1569### Human-in-the-Loop (if enabled)
1570
1571- [ ] Displayed a checkpoint after each implementation phase in `HUMAN_IN_THE_LOOP_PHASES`
1572- [ ] Incorporated user feedback into subsequent iterations/phases
1573- [ ] Paused workflow when user requested
1574
1575### Final Verification and Completion
1576
1577- [ ] Definition of Done verification agent launched, reading `## Acceptance Criteria` → `**Definition of Done:**`
1578- [ ] All DoD items verified (PASS/FAIL/BLOCKED status)
1579- [ ] Failing DoD items fixed via implementation agents
1580- [ ] Re-verification performed after fixes
1581- [ ] Task moved from `in-progress/` to `done/` folder (sub-task folder left in place)
1582- [ ] All DoD checkboxes marked `[X]` in task file
1583- [ ] Final verification report presented to user
1584
1585---
1586
1587## Appendix A: What the Task File and Sub-Task Files Provide
1588
1589This appendix documents the artifacts this skill consumes. It is a reading guide, not an instruction to read more files than Workflow Phase 1 allows.
1590
1591### Task File Structure
1592
1593A planned task file contains exactly these sections:
1594
1595| Section | Written by | What this skill uses it for |
1596|---------|-----------|------------------------------|
1597| `# Description` | `sdd:business-analyst` | Nothing directly — the sub-agents read it |
1598| `## Acceptance Criteria` | `sdd:business-analyst` | Only its `**Definition of Done:**` sub-block, in Workflow Phase 3 |
1599| `## Architecture Overview` | `sdd:software-architect` | Nothing directly — the sub-agents read it |
1600| `## Implementation Process` | `sdd:tech-lead` | Everything: dispatch, models, phases, review gates |
1601
1602`## Acceptance Criteria` has exactly six sub-blocks, in order: `**Checklist:**`, `**Regular Checks:**`, `**Rubric:**`, `**Rubric Score Definitions:**`, `**Test Strategy:**`, `**Definition of Done:**`. The first five are the **reviewer's** input, narrowed per phase — you never parse or forward them.
1603
1604**A task file carries no scoring configuration at all** — no threshold, no judge count, no per-step review metadata. Scoring is orchestrator config only. If a task file contains any section not listed in the table above, it is a stale artifact from an older plan; ignore it and note it in the final report.
1605
1606### `## Implementation Process`
1607
1608```markdown
1609## Implementation Process
1610
1611[sub-agent execution directive: launch one agent per step; verify at PHASE level]
1612
1613### Parallelization Overview
1614
1615[ASCII dependency diagram]
1616
1617| Step | Phase | Model | Agent | Depends on | Parallel with | Sub-Task File |
1618|------|-------|-------|-------|------------|---------------|---------------|
1619| `01-foundation` | Phase 1 | haiku | developer | None | None | `.specs/sub-tasks/<task-name>/01-foundation.md` |
1620| `02a-service` | Phase 1 | sonnet | developer | `01-foundation` | `02b-docs` | `.specs/sub-tasks/<task-name>/02a-service.md` |
1621
1622### Phase Overview
1623
1624#### Phase 1
1625
1626Steps: `01-foundation`, `02a-service`
1627Reviewer model: `sonnet`
1628Acceptance Criteria that should be fulfiled:
1629Checklist items:
1630- `CK-1` — ...
1631- `CK-2` — ...
1632
1633Rubrics:
1634- `Contract Correctness`
1635```
1636
1637- The **phase identifier** is `Phase N` (a title may follow: `#### Phase 1: Foundation`). This exact identifier is what you pass to the reviewer.
1638- `Reviewer model:` is one of `haiku`, `sonnet`, `opus`. It is the model of that phase's single review dispatch.
1639- The `Checklist items:` and `Rubrics:` lists scope the reviewer's scoring. **They are the reviewer's input, not yours** — it reads them from the task file itself. Never paste them into a prompt.
1640
1641### Sub-Task Files
1642
1643One per step, at `.specs/sub-tasks/<task-name>/<NN>-<step-slug>.md`, where `<task-name>` is the task filename without its extension. The folder never moves.
1644
1645```markdown
1646# Step NN: [Title]
1647
1648**Task File:** `.specs/tasks/todo/<task-name>.md`
1649**Phase:** Phase N
1650**Model:** haiku | sonnet | opus
1651**Agent:** [agent type]
1652**Depends on:** [step names or None]
1653**Parallel with:** [step names or None]
1654**Note:** [or None]
1655
1656**Goal:** ...
1657
1658[step description]
1659
1660#### Expected Output
1661#### Success Criteria
1662#### Subtasks
1663#### Blockers & Risks
1664```
1665
1666The **step name** is the file's basename without `.md`. It is the identity used in `Steps:`, `Depends on:`, `Parallel with:` and in the reviewer's per-issue attribution.
1667
1668### Scoring Scale
1669
1670The `sdd:code-reviewer` scores every criterion on a 1-5 integer scale defined by its own `## Scoring Scale` section. That section is the sole definition and is **deliberately not reproduced here** — the reviewer owns scoring; you do not score anything, you only compare `combined_score` against `THRESHOLD`. Never restate the scale, or your own version of it, in any prompt or report.
1671
1672**The one consequence for you:** when applying the [Iteration Discretion Rule](#iteration-discretion-rule), read a score as a placement, never as an intuitive "out of 5" feel or a word like *adequate* or *excellent*.
1673
1674### Using These Artifacts During Execution
1675
1676**During Workflow Phase 2:**
1677
16781. Dispatch each step's agent with the task file path AND its sub-task file path, at its `Model`
16792. Wait for every step of the implementation phase to report completion
16803. Launch ONE `sdd:code-reviewer` at that phase's `Reviewer model` — **Model**: `MODEL_OVERRIDE` if set — otherwise the phase's `Reviewer model` — otherwise `opus`
16814. Pass exactly the 4 inputs (task file path, phase identifier, artifact paths, `CLAUDE_PLUGIN_ROOT`) — **NEVER a threshold, NEVER the sub-task paths**
16825. Receive the reviewer's combined report
16836. Apply `THRESHOLD` against `combined_score` at this layer
16847. If FAIL, reason about blast radius, dispatch fixes for the affected steps only, and re-review the phase