implement
npx skills add https://github.com/darraghh1/my-claude-setup --skill implement
Agent 安装分布
Skill 文档
Implement Plan
Implement phases from: $ARGUMENTS/plan.md
Architecture
This skill is a thin dispatcher. It does NOT read references, extract patterns, or implement code. Builders handle implementation, validators handle review, and auditors handle cross-phase analysis.
| Role | Responsibility |
|---|---|
| Orchestrator (you) | Parse groups, gate checks, spawn/shutdown agents, route verdicts, triage auditor findings, track cross-group state |
| Builder | Phase implementation: read phase, find references, invoke skills, code, test, typecheck. Does NOT review its own code. |
| Validator | Independent review: runs /code-review (reference-grounded, with auto-fix), then typecheck + tests. Reports PASS/FAIL. |
| Auditor | Group-level audit: cross-phase regressions, deferred items, plan drift, system integrity. Read-only â reports findings with severity ratings. |
All agents are ephemeral. Each gets a fresh 200K context and is shut down after its cycle. This prevents context contamination, ensures skill instructions are never compacted, and eliminates bottlenecks.
Processing Model
for each group (sequential):
1. Gate check all phases in group
2. Build phases (parallel where deps allow)
3. Validate each phase (PASS/FAIL routing)
4. When all group phases PASS â spawn auditor
5. Orchestrator reads auditor report and triages:
- Clean/Low â log deviations, continue to next group
- Medium â auto-spawn builder + validator to fix
- High/Critical â checkpoint with user, then fix
6. Track deviation summary for next group's auditor
Step 1: Read and Review the Plan
- Read the plan file at
$ARGUMENTS/plan.md - Check if
$ARGUMENTS/reviews/planning/plan.mdexists - If no review exists, run
/review-plan $ARGUMENTSfirst - Read the review file at
$ARGUMENTS/reviews/planning/plan.md - Check the Verdict section:
- If
Yesâ proceed to Step 2 - If
Noâ STOP and report the Critical Issues to the user
- If
Step 2: Check Flow Audit
1. Count phases in the Phase Table.
2. Skip for small plans: If 1-2 phases, skip to Step 3.
3. Check if audit exists: Look for $ARGUMENTS/reviews/planning/flow-audit.md.
4. If missing: STOP and tell the user to run /audit-plan $ARGUMENTS first.
5. Gate logic:
| Overall Assessment | Behaviour |
|---|---|
| “Major Restructuring Needed” | HARD BLOCK: STOP. Report issues to user. |
| “Significant Issues” | SOFT BLOCK: WARN user. Ask whether to proceed or fix. |
| “Minor Issues” or “Coherent” | PROCEED. |
Step 3: Parse Groups and Build Execution Plan
3a: Check for existing tasks (compact recovery):
Run TaskList first. If tasks already exist from a previous session or context compact:
- Read existing tasks with
TaskGetfor each task ID - If any task is
in_progressâ resume from that point - Do NOT recreate the task list
3b: Parse the Phase Table and Group Summary:
Read plan.md’s Phase Table. For each phase, extract: number, title, group, focus, status, dependencies.
Read the Group Summary table to get group ordering and descriptions.
Build a group execution plan:
groups = [
{ name: "auth-system", phases: [P01, P02, P03], description: "..." },
{ name: "dashboard-ui", phases: [P04, P05, P06, P07], description: "..." },
...
]
Groups are processed sequentially in the order listed in the Group Summary. Phases within a group are processed in parallel where dependencies allow.
If all phases are done:
- Remove the plan’s sidecar:
rm -f ~/.cache/claude-statusline/plans/PLAN_NAME.json - Report completion to the user
- Skip to Step 10 (cleanup)
3c: Create orchestrator tasks (first run only):
If no tasks exist yet, create tasks with rich, self-contained descriptions:
TaskCreate({
subject: "Group: {group-name} â Phase {NN}: {title}",
description: `Phase file: $ARGUMENTS/phase-{NN}-{slug}.md
Group: {group-name} ({N} phases in group: P{NN}, P{MM}, ...)
Skill: {skill-from-frontmatter}
Dependencies: {list or "none"}
Key deliverables from acceptance criteria:
- {criterion 1}
- {criterion 2}
- {criterion 3}
Gate check â build â validate â mark done.
After all phases in group "{group-name}" complete, spawn auditor for group review.`,
activeForm: "Implementing Phase {NN} ({group-name})"
})
Then set up dependencies with TaskUpdate using addBlockedBy to mirror each phase’s dependencies frontmatter.
Also create one task per group for the audit step:
TaskCreate({
subject: "Audit group: {group-name}",
description: `Spawn auditor after all phases in group complete.
Group: {group-name}
Phases: P{NN}, P{MM}, ...
Plan folder: $ARGUMENTS
Auditor reviews: cross-phase regressions, deferred items, plan drift, acceptance criteria.
Triage: Clean/Low â continue. Medium â auto-fix. High/Critical â ask user.`,
activeForm: "Auditing group {group-name}"
})
Set audit tasks to be blocked by all phase tasks in their group.
3d: Determine current group and unblocked phases:
Find the first group with pending phases. Within that group, identify unblocked phases (all dependencies satisfied).
Update the statusline sidecar:
mkdir -p ~/.cache/claude-statusline/plans && echo '{"plan":"PLAN_NAME","phase":PHASE_NUM,"group":"GROUP_NAME","updated":'$(date +%s)'}' > ~/.cache/claude-statusline/plans/PLAN_NAME.json
Step 4: Gate Check Phases
Before spawning builders, gate-check each unblocked phase. Mark each phase task as in_progress:
TaskUpdate({ taskId: "{phase-task-id}", status: "in_progress" })
4a: Check for skeleton/placeholder content:
echo '{"cwd":"."}' | uv run $CLAUDE_PROJECT_DIR/.claude/hooks/validators/validate_no_placeholders.py \
--directory $ARGUMENTS --extension .md
If non-zero exit, the phase contains placeholder content. STOP â do not spawn a builder for a skeleton phase.
4b: Verify the phase review:
- Check if
$ARGUMENTS/reviews/planning/phase-{NN}.mdexists - If no review exists, run
/review-plan $ARGUMENTS phase {NN} - Read the review Verdict:
- Ready: Yes â proceed to Step 5
- Ready: No â FIX the phase first, re-run review, then proceed
Step 5: Create Team (First Run Only)
Create the team on the first run. Reuse it across all groups.
TeamCreate({
team_name: "{plan-name}-impl",
description: "Implementation team for {plan title}"
})
Concurrency Limits
Hard cap: 4 total active agents (builders + validators + auditor combined). The auditor runs alone â no builders or validators during audit.
| Constraint | Limit | Why |
|---|---|---|
| Builders per batch | Max 2 | Context pressure from parallel completions |
| Validators per batch | Max 2 (one per active builder) | Each builder gets one validator |
| Total active agents | Max 4 | Orchestrator context budget |
| Auditor | Runs alone | Needs undivided orchestrator attention for triage |
| Batch overlap | None | Wait for current batch to fully complete before next |
Step 6: Spawn Builders
Spawn a fresh builder for each unblocked phase that passed gate-checking. Max 2 builders per batch.
Before spawning, extract the skill: field from each phase’s YAML frontmatter.
Task({
description: "Implement phase {NN}",
subagent_type: "builder",
model: "opus",
team_name: "{plan-name}-impl",
name: "builder-1",
mode: "bypassPermissions",
prompt: `Implement the phase at: $ARGUMENTS/phase-{NN}-{slug}.md
Plan folder: $ARGUMENTS
Skill: {skill-from-frontmatter}
Follow your preloaded builder-workflow skill. It teaches you how to:
1. Read the phase and extract requirements
2. Invoke the Skill above (if not "none") and find reference files
3. Create internal tasks (TaskCreate) for each step â prefix with [Step]. This is REQUIRED for context compact recovery
4. Implement with TDD (Step 0 first), marking tasks in_progress/completed as you go
5. Run tests and typecheck
6. Report completion to team-lead (do NOT run /code-review â the validator handles that independently)
IMPORTANT: Before using the Write tool on any existing file, you MUST Read it first or the write will silently fail.`
})
Step 7: Wait and Route Builder/Validator Cycle
Wait for builder completion messages. When a builder reports done:
- Spawn a fresh validator for this phase:
Task({
description: "Validate phase {NN}",
subagent_type: "validator",
team_name: "{plan-name}-impl",
name: "validator-{N}",
mode: "bypassPermissions",
prompt: `Validate phase {NN} on the {plan-name}-impl team. Follow the workflow defined in your agent instructions.
Phase file: $ARGUMENTS/phase-{NN}-{slug}.md
Plan folder: $ARGUMENTS
Run /code-review against the phase file, then verify with typecheck + tests. Report PASS/FAIL to team-lead via SendMessage.`
})
- Wait for ALL validator verdicts in this batch before proceeding.
Handle Verdict
PASS:
- Update phase YAML frontmatter:
status: done - Update Phase Table in plan.md: status â “Done”
- Mark the phase task as completed
- Shutdown the builder and validator for this phase
- When the entire batch is complete, check: are ALL phases in the current group done?
- Yes â proceed to Step 8 (Group Audit)
- No â loop back to find next unblocked phases in this group, spawn next batch
FAIL:
- Shutdown current builder AND validator (both contexts may be stale)
- Spawn a fresh builder with the validator’s fix instructions
- Wait for fix builder â spawn fresh validator â re-validate â repeat until PASS
Step 8: Group Audit
When all phases in a group have passed validation, spawn an auditor for the group.
Mark the group audit task as in_progress:
TaskUpdate({ taskId: "{audit-task-id}", status: "in_progress" })
Shutdown all builders and validators from this group first â the auditor runs alone.
Spawn the auditor:
Task({
description: "Audit group {group-name}",
subagent_type: "auditor",
model: "opus",
team_name: "{plan-name}-impl",
name: "auditor-{group-name}",
mode: "bypassPermissions",
prompt: `Audit the "{group-name}" phase group.
Plan folder: $ARGUMENTS
Group: {group-name}
Phases in this group:
- Phase {NN}: {title} â $ARGUMENTS/phase-{NN}-{slug}.md
- Phase {MM}: {title} â $ARGUMENTS/phase-{MM}-{slug}.md
[...list all phases in group...]
Previous group deviations:
{deviation-summary-from-previous-groups OR "None â this is the first group."}
Follow your preloaded auditor-workflow skill. It teaches you how to:
1. Read all group phases and build inventory
2. Collect and review code reviews for group phases
3. Check deferred items against current code
4. Cross-phase impact analysis (shared files, imports, overwrites)
5. Run verification (tests + typecheck)
6. Plan vs implementation comparison (acceptance criteria, ADRs)
7. Consider previous groups' deviations
8. Write audit report to $ARGUMENTS/reviews/implementation/group-{group-name}-audit.md
9. Report findings to team-lead with severity ratings
IMPORTANT: You are READ-ONLY. Do not modify source code. Write only the audit report file.`
})
Step 9: Triage Auditor Findings
When the auditor reports back, read the full audit report at $ARGUMENTS/reviews/implementation/group-{group-name}-audit.md.
9a: Create tasks from findings FIRST (compact safety):
Before spawning any fix builders, create tasks for each finding that needs action. This ensures findings survive context compaction:
TaskCreate({
subject: "Fix: {finding summary} (group {group-name})",
description: `From auditor report: $ARGUMENTS/reviews/implementation/group-{group-name}-audit.md
Severity: {Critical/High/Medium/Low}
Phase: P{NN}
File: {file:line from auditor report}
Issue: {description from auditor report}
Suggested fix: {fix from auditor report}`,
activeForm: "Fixing {finding summary}"
})
9b: Triage by severity:
| Finding Severity | Action |
|---|---|
| No issues / Low only | Log deviation summary, mark audit task complete, continue to next group |
| Medium | Auto-spawn builder to fix + validator to verify. No user input needed. |
| High / Critical | Checkpoint with user. Present the findings and ask for direction before proceeding. |
9c: For Medium findings â auto-fix cycle:
- Spawn a builder with the specific fix instructions from the auditor report
- Wait for builder completion
- Spawn validator to verify the fix
- If PASS â mark fix task complete
- If FAIL â retry (max 3 attempts per finding, then escalate to user)
9d: For High/Critical findings â user checkpoint:
Present the auditor’s findings to the user:
## Group "{group-name}" Audit â Needs Your Input
**Assessment:** {from audit report}
### Critical/High Findings:
1. {finding 1 â severity, phase, file:line, issue}
2. {finding 2}
...
### Auditor's Recommendation:
{from audit report}
**Options:**
1. Fix all â I'll spawn builders for each finding
2. Fix specific items â tell me which ones
3. Skip and continue â accept the findings as-is
4. Stop implementation â address these manually
Use AskUserQuestion to get the user’s choice, then act accordingly.
9e: Track deviation summary:
After all findings are resolved (or accepted), build a deviation summary for the next group’s auditor:
deviation_summaries[group_name] = {
assessment: "{from audit report}",
key_deviations: ["{finding 1}", "{finding 2}"],
unresolved: ["{any findings user chose to skip}"]
}
Pass this to the next auditor in its spawn prompt (see Step 8, “Previous group deviations”).
9f: Mark audit task complete and continue:
TaskUpdate({ taskId: "{audit-task-id}", status: "completed" })
Shutdown the auditor:
SendMessage({ type: "shutdown_request", recipient: "auditor-{group-name}" })
Loop back to Step 3 to start the next group.
Step 10: Cleanup
When all groups are done OR an error breakout condition is met:
- Shutdown all active teammates:
// For each active agent:
SendMessage({ type: "shutdown_request", recipient: "{agent-name}" })
-
Delete team:
TeamDelete() -
Remove this plan’s statusline sidecar:
rm -f ~/.cache/claude-statusline/plans/PLAN_NAME.json
- Report final summary to user:
## Implementation Complete
**Plan:** $ARGUMENTS
**Groups:** {count} completed
**Phases:** {count} Done
### Group Audit Results:
| Group | Assessment | Critical | High | Medium | Low |
|-------|-----------|----------|------|--------|-----|
| {name} | {verdict} | {N} | {N} | {N} | {N} |
### Unresolved Items:
{any findings the user chose to skip}
### Verification:
- Tests: {pass/fail}
- Typecheck: {pass/fail}
Error breakout conditions â STOP and shut down if:
- Validator FAIL repeats 3+ times on the same phase
- Auditor finding fix fails 3+ times
- Phase has Critical blocking issues from plan review
- User requests cancellation
Resuming After Context Compact
If you notice context was compacted:
- Run
TaskListto see all tasks and their status - Find the
in_progresstask â that’s where you were - Run
TaskGet {id}on that task for full details - Read plan.md to get the Phase Table and Group Summary
- Check existing audit reports in
$ARGUMENTS/reviews/implementation/to rebuild deviation summaries - Check if team exists: read
~/.claude/teams/{plan-name}-impl/config.json- If team exists, teammates may still be active â coordinate via messages
- If no team, re-create it
- Continue from the in_progress task
Pattern for every work cycle:
TaskList â find in_progress or first pending â TaskGet â continue work â TaskUpdate (completed) â next task
Tasks are the orchestrator’s source of truth for progress â not memory, not plan.md alone.
Reference Material
For anti-pattern prevention, context compact recovery, and troubleshooting, see references/team-operations.md.