Implementation Stage Skill
Implement an approved plan using a TDD loop with TaskManagement-based progress tracking. Reads Implementation Steps and TDD Test Plan from the plan file. Dispatches the implementer agent step-by-step, runs mapped tests after each step.
Fully autonomous — does NOT use AskUserQuestion. Only true blockers (missing credentials, external dependency down) stop execution.
Step 1: Validate Inputs
Read the plan file and verify required sections exist:
## Requirementswith acceptance criteria## TDD Test Planwith test IDs## Implementation Stepswith step details## Plan Review Recordwith"status": "approved"in its fenced JSON block## Risk Registrywith all risks acknowledged
If plan review is not approved, tell the user to run /dev-buddy-review --plan first.
If any risk is unacknowledged, tell the user to acknowledge risks first.
Code review repair mode: If ## Code Review Record exists with "status": "needs_changes" in its fenced JSON block, this is a repair invocation:
- Read the
must_fixfindings from the code review record's fenced JSON - For each finding, identify which implementation step is affected (via
contract_referencefield referencing AC or step) - Reset affected steps' status from
[x] doneback to[ ] not startedin the plan file - Inject the findings into the implementer prompt for affected steps as:
ISSUES FROM PRIOR REVIEW: - {finding.description} (file: {finding.file}:{finding.line}, fix: {finding.suggestion}) - Re-run the TDD loop only for reset steps (skip steps still marked
[x] done)
Step 2: Load Config
bun -e "
import { loadDevBuddyConfig, getProviderType } from '${CLAUDE_PLUGIN_ROOT}/scripts/pipeline-config.ts';
const config = loadDevBuddyConfig();
const stage = config.stages['implementation'];
const executors = stage.executors.map(exec => ({
...exec,
providerType: getProviderType(exec.preset)
}));
console.log(JSON.stringify({ executors, max_tdd_iterations: config.max_tdd_iterations }));
"
Step 3: Extract Steps and Tests from Plan File
Read the plan file and extract:
- All implementation steps (titles, AC mappings, test IDs, files, descriptions, rollbacks)
- All tests from TDD Test Plan (IDs, commands, AC mappings)
- Total step count
Parse the step status checkboxes:
[ ] not started— pending[x] done— completed (skip)[!] blocked— blocked (skip)
This enables resume after context compaction.
Step 4: Create Progress Tasks (TaskManagement)
Create one task per implementation step using TaskCreate.
For each step N (that is not already completed):
T{N} = TaskCreate(
subject='Step {N}: {title}',
description='AC: {ac_ids} | Tests: {test_ids}
Files: {files}
What to do: {description}
Rollback: {rollback}',
activeForm='Implementing step {N}...'
)
If step has dependencies from the plan (e.g., "Dependencies: Step 1, Step 3"):
TaskUpdate(T{N}, addBlockedBy: [T{dep1}, T{dep2}])
Else if N > 1 (fallback — linear chain):
TaskUpdate(T{N}, addBlockedBy: [T{N-1}])
This creates a visible task list with dependency chaining.
Step 5: TDD Execution Loop
For each step in order (skip completed/blocked):
5a. Claim the step
TaskUpdate(step_task_id, status: 'in_progress')
5b. Run mapped tests FIRST (establish failing baseline)
For each test ID mapped to this step (from TDD Test Plan):
- Run the test command via Bash
- Record the baseline result (expected to fail — this IS TDD)
5c. Dispatch implementer
Construct the implementation prompt for this specific step:
SINGLE_STEP_MODE: step {N}
STRICT PLAN ADHERENCE: Follow the plan EXACTLY. No deviations.
STEP DETAILS (from plan file):
Title: {title}
AC: {ac_ids}
Tests: {test_ids}
Files to modify: {files_to_modify}
Files to create: {files_to_create}
Existing code to reuse: {existing_code_to_reuse}
What to do: {description}
Rollback: {rollback}
TDD CYCLE:
1. The mapped tests have been run — they should be failing (red)
2. Implement EXACTLY what the step says — no more, no less
3. Run the mapped tests again — they must pass (green)
4. Write your output
Write output to {TMPDIR}/.vcp/oneshot/impl-{RAND}-step{N}.json
Resolve system prompt and dispatch (same stage/role composition as other skills).
Route by provider type:
- subscription:
Task(subagent_type: "general-purpose", model, prompt) - api:
Bash(run_in_background: true)→bun "${CLAUDE_PLUGIN_ROOT}/scripts/one-shot-runner.ts" --type api --output-id impl-{RAND}-step{N} --preset "{PRESET}" --model "{MODEL}" --cwd "${CLAUDE_PROJECT_DIR}" --task-stdin
5d. Collect result and run tests
For API/CLI executors: The output file is wrapped in an envelope {"event":"complete","provider":"...","model":"...","result":"..."}. Parse the result field to get the actual implementer output. For subscription executors, the result is returned directly from the Task tool.
Read the implementer's output. Then run ALL mapped tests for this step:
- Run each test command from the TDD Test Plan where
test_idsincludes tests mapped to this step - Check pass/fail
5e. Handle test results
If all tests pass:
TaskUpdate(step_task_id, status: 'completed')- Update plan file: change step status from
[ ] not startedto[x] donevia Edit tool - Continue to next step
If any test fails:
- Increment TDD iteration counter for this step
- If iterations < max_tdd_iterations:
- Re-dispatch implementer with failure output appended:
ISSUES FROM PRIOR ATTEMPT: Test {test_id} failed: {test output} Fix the issue and ensure the test passes. - Return to 5d
- Re-dispatch implementer with failure output appended:
- If iterations >= max_tdd_iterations:
TaskUpdate(step_task_id, status: 'blocked')- Update plan file: change step status to
[!] blocked — test {test_id} fails after {N} retries - Do NOT ask the user — continue to next step
Step 6: Full Test Suite
After all steps are completed or blocked:
- Run ALL test commands from the TDD Test Plan (full suite)
- Record results
Step 7: Update Plan File
Update the plan file with implementation results:
- Update
**Status:**tocode-review - Verify all step statuses are updated (
[x] doneor[!] blocked)
Step 8: Cleanup and Report
- Remove temp files:
rm -f "{TMPDIR}/.vcp/oneshot/impl-{RAND}-"* - Present to user:
- Steps completed: {count}/{total}
- Steps blocked: {count} (if any, with reasons)
- Test results: {passed}/{total}
- If any steps blocked: report which ones and why
- Suggest next step:
/dev-buddy-review --code
Resume After Context Compaction
If the conversation context is compacted mid-implementation:
- Read the plan file — step statuses show what's done vs pending
TaskList()— shows task statuses with dependency chain- Find the first non-completed step
- Continue from that step (skip completed ones)
The combination of plan file checkboxes + TaskManagement ensures no work is lost.
Error Handling
| Scenario | Action |
|---|---|
| Plan not approved | Tell user to run /dev-buddy-review --plan first |
| Risks unacknowledged | Tell user to acknowledge risks first |
| All implementer dispatches fail | Report error to user |
| Test fails after max retries | Mark step blocked, continue to next |
| Missing credentials (true blocker) | Set status partial, report to user |
| No implementation executors configured | Report error, suggest /dev-buddy-config |
Anti-Patterns
- Do NOT ask the user anything — you are fully autonomous
- Do NOT skip TaskCreate/TaskUpdate — progress must be tracked
- Do NOT deviate from the plan — follow it exactly
- Do NOT implement from memory — read step details from plan file
- Do NOT skip tests — TDD is mandatory
- Do NOT stop after some steps — implement ALL steps (mark blocked ones and continue)