
implement-phase
by mhylle
Custom skills and agents for Claude Code - codebase research, context management, and implementation planning workflows
SKILL.md
name: implement-phase description: Execute a single phase from an implementation plan with all quality gates. This skill is the unit of work for implement-plan, handling implementation, verification, code review, ADR compliance, and plan synchronization for ONE phase. Triggers when implement-plan delegates a phase, or manually with "/implement-phase" and a phase reference.
Implement Phase
Execute a single phase from an implementation plan with comprehensive quality gates. This skill is designed to be called by implement-plan but can also be invoked directly.
CRITICAL: Orchestrator Pattern (MANDATORY)
THIS SESSION IS AN ORCHESTRATOR. YOU MUST NEVER IMPLEMENT CODE DIRECTLY.
What This Means
| DO (Orchestrator) | DO NOT (Direct Implementation) |
|---|---|
| Spawn subagents to write code | Write code yourself |
| Spawn subagents to create files | Use Write/Edit tools directly |
| Spawn subagents to run tests | Run tests yourself |
| Spawn subagents to fix issues | Fix code yourself |
| Read files to understand context | Read files to copy/paste code |
| Track progress with Task tools | Implement while tracking |
| Coordinate and delegate | Do the work yourself |
Enforcement
⛔ VIOLATION: Using Write/Edit/NotebookEdit tools directly
⛔ VIOLATION: Creating files without spawning a subagent
⛔ VIOLATION: Fixing code without spawning a subagent
⛔ VIOLATION: Running implementation commands directly
✅ CORRECT: Task(subagent): "Create the AuthService at src/auth/..."
✅ CORRECT: Task(subagent): "Fix the lint errors in src/auth/..."
✅ CORRECT: Task(subagent): "Run npm test and report results..."
Why Orchestration?
- Context preservation - Main session retains full plan context
- Parallelization - Independent tasks run concurrently
- Clean separation - Orchestration logic separate from implementation
- Better error handling - Failures don't pollute main context
Subagent Spawning Pattern
Task (run_in_background: true): "Create [file] implementing [feature].
Context: Phase [N] - [Name]
Requirements:
- [Requirement 1]
- [Requirement 2]
RESPONSE FORMAT: Be concise. Return only:
- STATUS: PASS/FAIL
- FILES: created/modified files
- ERRORS: any issues (omit if none)
Write verbose output to logs/[task].log"
Subagent Communication Protocol (CRITICAL)
Subagents MUST be concise. Context preservation is paramount.
Every subagent prompt MUST include the response format instruction. Verbose responses waste orchestrator context.
Required Response Format Block (include in EVERY subagent prompt):
RESPONSE FORMAT: Be concise. Return ONLY:
- STATUS: PASS/FAIL
- FILES: list of files created/modified
- ERRORS: brief error description (omit if none)
DO NOT include:
- Step-by-step explanations of what you did
- Code snippets (they're in the files)
- Suggestions for next steps
- Restating the original task
For large outputs, WRITE TO DISK:
- Test results → logs/test-[feature].log
- Build output → logs/build-[phase].log
- Error traces → logs/error-[task].log
Return only: "Full output: logs/[filename].log"
Good vs Bad Subagent Responses:
❌ BAD (wastes context):
"I have successfully created the SummaryAgentService. First, I analyzed
the requirements and determined that we need to implement three methods:
summarize(), retry(), and handleError(). I created the file at
src/agents/summary-agent/summary-agent.service.ts with the following
implementation: [300 lines of code]. The service uses dependency
injection to receive the OllamaService. I also updated the module file
to register the service. You should now be able to run the tests..."
✅ GOOD (preserves context):
"STATUS: PASS
FILES: src/agents/summary-agent/summary-agent.service.ts (created),
src/agents/summary-agent/summary-agent.module.ts (modified)
ERRORS: None"
Disk-Based Communication for Large Data:
| Data Type | Write To | Return |
|---|---|---|
| Test output (>20 lines) | logs/test-[name].log | "Tests: 47 passed. Full: logs/test-auth.log" |
| Build errors | logs/build-[phase].log | "Build FAIL. Details: logs/build-phase2.log" |
| Lint results | logs/lint-[phase].log | "Lint: 3 errors. See logs/lint-phase2.log" |
| Stack traces | logs/error-[task].log | "Error in X. Trace: logs/error-task.log" |
| Generated code review | logs/review-[phase].md | "Review complete. Report: logs/review-phase2.md" |
Architecture
implement-plan (orchestrates full plan)
│
└── implement-phase (this skill - one phase at a time)
│
├── 1. Implementation (subagents)
├── 2. Exit Condition Verification (build, lint, unit tests)
├── 3. Automated Integration Testing (Claude tests via API/Playwright)
├── 4. Code Review (code-review skill)
├── 5. ADR Compliance Check
├── 6. Plan Synchronization
├── 7. Prompt Archival (if prompt provided)
└── 8. Phase Completion Report
Design Principles
Single Responsibility
This skill does ONE thing: execute a single phase completely and correctly.
Extensibility
The phase execution pipeline is designed as a sequence of steps. New steps can be added without modifying the core logic. See Phase Steps.
Quality Gates
Each step is a gate. If any gate fails, the phase cannot complete.
Composability
This skill orchestrates other skills (code-review, adr) and can be extended to include more.
Input Context
When invoked, this skill expects:
Plan Path: [path to plan file]
Phase: [number or name]
Task ID: [task_id from implement-plan's TaskList]
Prompt Path: [optional - path to pre-generated prompt from prompt-generator]
Changed Files: [optional - auto-detected if not provided]
Skip Steps: [optional - list of steps to skip, e.g., for testing]
TDD Mode: [enabled/disabled - from plan metadata, CLI flag, or global settings]
Coverage Threshold: [percentage - default 80%, applies when TDD mode enabled]
Prompt Integration
If a Prompt Path is provided (from prompt-generator skill):
- Read the prompt file - Contains detailed orchestration instructions
- Use prompt as primary guidance - Follows established patterns and conventions
- Plan file as reference - For exit conditions and verification steps
- Archive on completion - Move prompt to
completed/subfolder
# Prompt provides:
- Detailed orchestration workflow
- Subagent delegation patterns
- Specific task breakdowns
- Error handling guidance
# Plan provides:
- Exit conditions (source of truth)
- Success criteria
- Dependencies
Phase Execution Pipeline
CRITICAL: Continuous Execution (MANDATORY)
The entire pipeline (Steps 1-8) MUST execute as one continuous flow.
After EACH step completes (including skill invocations), IMMEDIATELY proceed to the next step WITHOUT waiting for user input.
Pause Points (ONLY these):
| Scenario | Action |
|---|---|
| Step returns BLOCKED status | Stop and present blocker to user |
| Step 8 (Completion Report) done | Await user confirmation before next phase |
| Maximum retries exhausted | Present failure and options to user |
DO NOT PAUSE after:
- Integration tests pass → Continue to Step 4
- Code review returns PASS → Continue to Step 5
- ADR compliance returns PASS → Continue to Step 6
- Any successful step completion → Continue to next step
- Fix loop completes with PASS → Continue to next step
Fix Loops (internal, no user pause):
- Integration tests fail → Fix code, re-run tests, expect PASS
- Code review returns PASS_WITH_NOTES → Fix notes, re-run Step 4, expect PASS
- Code review returns NEEDS_CHANGES → Fix issues, re-run Step 4, expect PASS
- Any step has fixable issues → Spawn fix subagents, re-run step
Continuous Flow Example:
Step 1: Implementation → PASS
↓ (immediately)
Step 2: Exit Conditions → PASS
↓ (immediately)
Step 3: Automated Integration Testing → PASS
↓ (immediately)
Step 4: Code Review Skill → PASS_WITH_NOTES
↓ (fix loop - spawn subagents to fix notes)
→ Re-run Code Review → PASS
↓ (now continue)
Step 5: ADR Compliance → PASS
↓ (immediately)
Step 6: Plan Sync → PASS
↓ (immediately)
Step 7: Prompt Archival → PASS
↓ (immediately)
Step 8: Completion Report → Present to user
↓ (NOW wait for user confirmation)
Goal: Clean PASS on all steps. PASS_WITH_NOTES means there's work to do.
Blocking Elements (ONLY Valid Reasons to Stop)
A blocking element is something YOU cannot fix autonomously.
Do NOT stop for fixable issues. Only stop when you genuinely cannot proceed without user intervention.
Valid Blocking Elements:
| Blocker | Example | Action |
|---|---|---|
| Permission denied | Subagent cannot write to protected directory | Ask user to adjust permissions or run in correct mode |
| Infrastructure unavailable | Cannot reach required LLM inference server | Report the connectivity issue, ask user to verify infrastructure |
| Missing credentials | API key not configured, auth token expired | Ask user to provide/refresh credentials |
| External service down | Third-party API returning 503 | Report the outage, ask if user wants to wait or skip |
| Ambiguous requirements | Plan says "integrate with payment system" but doesn't specify which | Ask user to clarify before proceeding |
| Destructive operation | Phase requires dropping production database | Confirm with user before executing |
NOT Blocking (fix these yourself):
| Issue | Action |
|---|---|
| Test fails | Fix the code, re-run test |
| Lint errors | Fix the code, re-run lint |
| Build errors | Fix the code, re-build |
| Type errors | Fix the types, re-check |
| Code review feedback | Fix the issues, re-run review |
| API returns error | Debug and fix the implementation |
| UI element not found | Fix selector or implementation |
Blocker Protocol:
When you hit a genuine blocker:
⛔ BLOCKED: [Brief description]
Phase: [N] - [Name]
Step: [Current step]
Blocker Type: [Permission | Infrastructure | Credentials | External | Ambiguous | Destructive]
Details:
[Specific details about what failed and why]
What I Need:
[Specific action required from user]
Options:
A) [Resolve the blocker and continue]
B) [Skip this verification and proceed with risk]
C) [Abort phase]
Resume After Blocker:
Once the user resolves the blocker, resume from the blocked step (not from Step 1).
Step Completion Checklist (MANDATORY)
Before reporting phase complete, ALL steps must be executed.
Use this checklist internally. If any step is missing, execute it before completing:
PHASE COMPLETION VERIFICATION:
- [ ] Step 1: Implementation - Subagents spawned, work completed
- [ ] Step 2: Exit Conditions - Build, runtime, unit tests all verified
- [ ] Step 3: Integration Testing - YOU tested via API calls or Playwright
- [ ] Step 4: Code Review - Achieved PASS (not PASS_WITH_NOTES)
- [ ] Step 5: ADR Compliance - Checked against relevant ADRs
- [ ] Step 6: Plan Sync - Work items verified, phase status updated
- [ ] Step 7: Prompt Archival - Archived or explicitly skipped (no prompt)
- [ ] Step 8: Completion Report - Generated and presented
⛔ VIOLATION: Stopping before Step 8
⛔ VIOLATION: Waiting for user input between Steps 1-7
⛔ VIOLATION: Reporting "phase complete" with unchecked steps
⛔ VIOLATION: Proceeding with PASS_WITH_NOTES without fixing notes
⛔ VIOLATION: Asking user to "manually test" instead of testing yourself
Self-Check Protocol:
After invoking a skill (like code-review), ask yourself:
- Did the skill complete? → Check the result status
- Did it return PASS? → CONTINUE to next step immediately
- Did it return PASS_WITH_NOTES? → Spawn fix subagents, re-run step, expect PASS
- Did it return NEEDS_CHANGES? → Spawn fix subagents, re-run step, expect PASS
- Am I at Step 8? → If no, execute next step immediately
- Did I test the feature myself? → If no, go back to Step 3
The goal is always a clean PASS. PASS_WITH_NOTES is not "good enough" - fix the notes.
Progress Tracker (MANDATORY OUTPUT)
After EVERY step, you MUST output a Progress Tracker before doing ANYTHING else.
This is not optional. The Progress Tracker forces explicit acknowledgment of state and next action.
Format (output after each step completes):
┌─────────────────────────────────────────┐
│ PROGRESS: Step [N] → Step [N+1] │
├─────────────────────────────────────────┤
│ ✅ Step 1: Implementation [DONE/SKIP]│
│ ✅ Step 2: Exit Conditions [DONE/SKIP]│
│ ✅ Step 3: Integration Test [DONE/SKIP]│
│ ✅ Step 4: Code Review [DONE/SKIP]│
│ ⏳ Step 5: ADR Compliance [CURRENT] │
│ ⬚ Step 6: Plan Sync [PENDING] │
│ ⬚ Step 7: Prompt Archival [PENDING] │
│ ⬚ Step 8: Completion Report [PENDING] │
├─────────────────────────────────────────┤
│ NEXT ACTION: [Describe what you do next]│
└─────────────────────────────────────────┘
Rules:
- Output this tracker IMMEDIATELY after each step completes
- Mark the CURRENT step you are about to execute
- The NEXT ACTION must describe executing the next step (not waiting for user)
- If NEXT ACTION says anything other than executing a step, you are VIOLATING the protocol
Example - After Step 4 Code Review Returns PASS:
┌─────────────────────────────────────────┐
│ PROGRESS: Step 4 → Step 5 │
├─────────────────────────────────────────┤
│ ✅ Step 1: Implementation [DONE] │
│ ✅ Step 2: Exit Conditions [DONE] │
│ ✅ Step 3: Integration Test [DONE] │
│ ✅ Step 4: Code Review [DONE] │
│ ⏳ Step 5: ADR Compliance [CURRENT] │
│ ⬚ Step 6: Plan Sync [PENDING] │
│ ⬚ Step 7: Prompt Archival [PENDING] │
│ ⬚ Step 8: Completion Report [PENDING] │
├─────────────────────────────────────────┤
│ NEXT ACTION: Check ADR compliance now │
└─────────────────────────────────────────┘
⛔ VIOLATION Examples:
- Not outputting the Progress Tracker after a step
- NEXT ACTION: "Waiting for user confirmation" (before Step 8)
- NEXT ACTION: "Let me know if you want me to continue"
- NEXT ACTION: "Please manually verify the feature works"
- Skipping to Step 8 without completing Steps 5-7
Execution Contract (READ BEFORE STARTING)
Before executing ANY step, acknowledge this contract:
I WILL execute Steps 1-8 as ONE continuous operation.
I WILL output a Progress Tracker after EVERY step.
I WILL test the feature MYSELF in Step 3 (not ask the user).
I WILL NOT stop after Step 4 (code review) - there are 4 more steps.
I WILL NOT ask the user if they want me to continue.
I WILL NOT ask the user to manually verify anything.
I WILL only stop at Step 8 after presenting the Completion Report.
I WILL only stop early for genuine BLOCKING elements I cannot fix.
If you find yourself about to stop before Step 8, RE-READ this contract.
Step 1: Implementation
Responsibility: Execute all tasks in the phase using subagent delegation.
REMINDER: You are an orchestrator. Spawn subagents for ALL implementation work.
Process:
- Read phase requirements and tasks from plan (orchestrator reads)
- Identify independent tasks for parallelization
- SPAWN test subagents FIRST (verification-first)
- SPAWN implementation subagents
- Monitor subagent progress and handle blockers
- Collect results and changed files list from subagent responses
Subagent Spawning Examples:
# Writing tests (FIRST - verification-first pattern)
Task (run_in_background: true): "Write unit tests for SummaryAgentService.
Context: Phase 5b-ii - SummaryAgent Service
Location: agentic-core/src/agents/implementations/summary-agent/
Test scenarios:
- Successful summarization
- Retry with feedback
- Error handling
RESPONSE FORMAT: STATUS, FILES created, test count. Write output to logs/."
# Implementation (AFTER tests exist)
Task (run_in_background: true): "Implement SummaryAgentService.
Context: Phase 5b-ii - SummaryAgent Service
Requirements from plan: [list requirements]
Must pass the tests at: [test file path]
RESPONSE FORMAT: STATUS, FILES created/modified, ERRORS if any."
# Verification
Task (run_in_background: true): "Run build and test verification.
Commands: npm run build && npm run lint && npm test
Report: PASS/FAIL per command, error details if any.
Write full output to logs/verify-phase-5b-ii.log"
What You Do vs What Subagents Do:
| Orchestrator (You) | Subagents |
|---|---|
| Read plan/prompt | Write code |
| Identify tasks | Create files |
| Spawn subagents | Run tests |
| Track progress | Fix issues |
| Handle blockers | Build/lint |
| Collect results | Report back |
Output:
IMPLEMENTATION_STATUS: PASS | FAIL
FILES_CREATED: [list]
FILES_MODIFIED: [list]
TEST_RESULTS: [summary]
ERRORS: [if any]
SUBAGENTS_SPAWNED: [count]
Gate: Implementation must PASS to proceed.
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 2 (Exit Condition Verification). Do NOT wait for user input.
Step 2: Exit Condition Verification (verification-loop)
Responsibility: Verify all exit conditions using the comprehensive 6-phase verification-loop.
verification-loop is the DEFAULT exit condition verification. It provides comprehensive validation that goes beyond basic build/test checks.
Process:
- Read exit conditions from plan
- Invoke
verification-loopskill with phase context - verification-loop executes 6 phases:
- Phase 1: Build - Compilation, bundling, artifact generation
- Phase 2: Type - Type checking, interface compliance
- Phase 3: Lint - Code style, static analysis
- Phase 4: Test - Unit tests, integration tests, coverage
- Phase 5: Security - Dependency audit, secret scanning
- Phase 6: Diff - Review changes, detect unintended modifications
- Aggregate results and report
Invocation:
Skill(skill="verification-loop"): Verify Phase [N] implementation.
Context:
- Plan: [plan file path]
- Phase: [N] ([Phase Name])
- Changed Files: [list of files modified in this phase]
Execute all 6 verification phases and return structured result.
Output:
VERIFICATION_LOOP_STATUS: PASS | FAIL
PHASES_COMPLETED: 6/6
PHASE_RESULTS:
BUILD: PASS | FAIL
TYPE: PASS | FAIL
LINT: PASS | FAIL
TEST: PASS | FAIL
SECURITY: PASS | FAIL
DIFF: PASS | FAIL
FAILED_PHASES: [list if any]
EVIDENCE: logs/verification-loop-phase-N.log
Gate: ALL 6 verification phases must PASS to proceed.
On Failure: Spawn fix subagents for failed phases, re-run verification-loop, repeat until all pass or escalate.
Disabling verification-loop (not recommended):
# In plan metadata - only for special cases
phase_config:
verification_loop: false # Falls back to basic exit conditions
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 3 (Automated Integration Testing). Do NOT wait for user input.
Step 3: Automated Integration Testing
Responsibility: Verify the implementation works end-to-end through automated testing performed by YOU, not the user.
YOU are the tester. Do not ask the user to manually verify. Use tools to test the system yourself.
For UI Testing: Use the
browser-verification-agent- spawn ONE agent per test scenario for context preservation. The agent wraps Playwright MCP and returns structured evidence.
Process:
- Determine the testing approach based on implementation type:
- Backend/API: Use curl, httpie, or spawn subagent to make API calls
- Frontend/UI: Spawn
browser-verification-agentfor each test scenario - CLI tools: Execute commands and verify output
- Libraries: Write and run integration test scripts
- Spawn testing subagents for each verification scenario (ONE test per agent for UI)
- Capture results and any failures
- On failure: spawn fix subagents, re-test
Testing by Implementation Type:
| Type | Testing Method | Tools/Agents |
|---|---|---|
| REST API | Make HTTP requests, verify responses | curl, httpie, fetch |
| GraphQL | Execute queries/mutations | curl with GraphQL payload |
| Web UI | Navigate, interact, assert | browser-verification-agent |
| Database | Query and verify data | psql, mysql, prisma |
| Background jobs | Trigger and verify completion | API calls + polling |
| File processing | Provide input, check output | Bash, Read tool |
Subagent Examples:
# API Testing (general-purpose subagent)
Task: "Test the new /api/users endpoint.
Make these API calls and report results:
1. POST /api/users with valid payload - expect 201
2. POST /api/users with invalid email - expect 400
3. GET /api/users/:id - expect 200 with user data
4. GET /api/users/nonexistent - expect 404
RESPONSE FORMAT: STATUS, test results summary, ERRORS if any."
# UI Testing (browser-verification-agent) - ONE test per agent spawn
Task(subagent_type="browser-verification-agent"): "Verify login with valid credentials.
base_url: http://localhost:3000
test_description: Navigate to /login, enter 'test@example.com' in email field,
enter 'password123' in password field, click Login button
expected_outcome: URL changes to /dashboard, welcome message visible
session_context: fresh"
Task(subagent_type="browser-verification-agent"): "Verify login with invalid credentials.
base_url: http://localhost:3000
test_description: Navigate to /login, enter 'test@example.com' in email field,
enter 'wrongpassword' in password field, click Login button
expected_outcome: Error message 'Invalid credentials' is displayed, URL stays on /login
session_context: fresh"
UI Testing Response Format (from browser-verification-agent):
STATUS: PASS | FAIL | FLAKY | BLOCKED
SCREENSHOT: logs/screenshots/2026-01-23-143022-login-test.png
OBSERVED: [what actually happened]
EXPECTED: [echo of expected_outcome]
ERRORS: [if any]
Aggregated Output (for Step 3 completion):
INTEGRATION_TEST_STATUS: PASS | FAIL
TESTS_RUN: [count]
TESTS_PASSED: [count]
TESTS_FAILED: [count]
FAILURE_DETAILS: [if any]
EVIDENCE: [log files, screenshots]
Gate: Integration tests must PASS to proceed.
On Failure:
- Analyze failure root cause
- Spawn fix subagents
- Re-run failed tests
- Repeat until pass or hit blocking element
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 4 (Code Review). Do NOT wait for user input.
Step 4: Code Review
Responsibility: Validate implementation quality across all dimensions.
Process:
- Invoke
code-reviewskill with phase context - Provide: plan path, phase number, changed files
- Receive structured review result
Output:
CODE_REVIEW_STATUS: PASS | PASS_WITH_NOTES | NEEDS_CHANGES
BLOCKING_ISSUES: [count]
RECOMMENDATIONS: [list]
Gate: Code review must be PASS to proceed.
On PASS_WITH_NOTES or NEEDS_CHANGES:
- Spawn fix subagents to address all issues (blocking AND recommendations)
- Re-run code review
- Repeat until PASS (max 3 retries)
- Escalate to user only if max retries exhausted
Why fix notes too? Recommendations often indicate pattern violations, missing tests, or technical debt. Fixing them now prevents accumulation and maintains code quality standards.
⚠️ CRITICAL TRANSITION POINT - DO NOT STOP HERE ⚠️
After code-review skill returns, you MUST continue. This is the #1 failure point.
- Code review returned PASS? → Output Progress Tracker → Execute Step 5 NOW
- Code review returned PASS_WITH_NOTES? → Fix issues → Re-run → Get PASS → Execute Step 5
- DO NOT report to user and wait. DO NOT ask if they want to continue.
- The phase is NOT complete. You have 4 more steps to execute.
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 5 (ADR Compliance). Do NOT wait for user input. Do NOT report "code review complete" and stop.
Step 5: ADR Compliance Check
Responsibility: Ensure architectural decisions are followed and documented.
Process:
- Read
docs/decisions/INDEX.mdto identify relevant ADRs - Check implementation against applicable ADRs
- Identify any new architectural decisions made during implementation
- If new decisions found, invoke
adrskill to document them
Output:
ADR_COMPLIANCE_STATUS: PASS | NEEDS_DOCUMENTATION
APPLICABLE_ADRS: [list]
COMPLIANCE_RESULTS: [per-ADR status]
NEW_DECISIONS_DOCUMENTED: [list of new ADR numbers, if any]
Gate: ADR compliance must PASS to proceed.
On NEEDS_DOCUMENTATION: Invoke adr skill for each undocumented decision.
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 6 (Plan Synchronization). Do NOT wait for user input.
Step 6: Plan Synchronization
Responsibility: Verify work items completed and update plan status.
Process:
- Verify all work items for this phase were completed
- Add ADR references if new ADRs were created
- Note any deviations from original plan
- Mark phase status as complete (add ✅ to phase header)
Note: Per ADR-0001, plans are specification documents. Progress is tracked via Task tools, not by modifying checkboxes in the plan file.
Output:
PLAN_SYNC_STATUS: PASS | FAIL
WORK_ITEMS_VERIFIED: [count]
DEVIATIONS_NOTED: [count]
ADR_REFERENCES_ADDED: [count]
Gate: Plan sync must complete successfully.
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 7 (Prompt Archival). Do NOT wait for user input.
Step 7: Prompt Archival
Responsibility: Archive the phase prompt to the completed folder (if prompt was provided).
Process:
- Check if a prompt file was used for this phase
- If yes, move to
completed/subfolder:# Create completed folder if it doesn't exist mkdir -p docs/prompts/completed # Move the prompt file mv docs/prompts/phase-2-data-pipeline.md docs/prompts/completed/ - Log the archival
Output:
PROMPT_ARCHIVAL_STATUS: PASS | SKIPPED | FAIL
PROMPT_FILE: [original path]
ARCHIVED_TO: [new path in completed/]
Gate: Non-blocking (failure logged but doesn't stop completion).
Why Archive?
- Prevents re-using the same prompt accidentally
- Creates a record of completed work
- Keeps the prompts folder clean for pending work
- Allows review of what instructions were used
→ NEXT STEP: Output Progress Tracker, then IMMEDIATELY execute Step 8 (Completion Report). Do NOT wait for user input.
Step 8: Phase Completion Report
Responsibility: Generate summary for orchestrator and user.
Output Format:
═══════════════════════════════════════════════════════════════
● PHASE [N] COMPLETE: [Phase Name]
═══════════════════════════════════════════════════════════════
Implementation:
Files Created: [count] ([file list])
Files Modified: [count] ([file list])
Tests: [X passing, Y failing]
Exit Conditions:
Build: ✅ PASS
Runtime: ✅ PASS
Unit Tests: ✅ PASS
Integration Testing (performed by Claude):
API Tests: ✅ [X/Y passed] (or N/A)
UI Tests: ✅ [X/Y passed] (or N/A)
Evidence: logs/integration-test-phase-N.log
Code Review:
Status: ✅ PASS (or ⚠️ PASS_WITH_NOTES)
Recommendations: [count] (see details below)
ADR Compliance:
Status: ✅ PASS
Applicable ADRs: [list]
New ADRs Created: [list or "None"]
Plan Updated:
Work Items Verified: [count]
Phase Status: ✅ Complete
Task Status: completed (via TaskUpdate)
Prompt:
Status: ✅ Archived (or ⏭️ Skipped - no prompt provided)
Archived To: docs/prompts/completed/phase-2-data-pipeline.md
User Verification (only if truly not automatable):
[None - all verification automated]
OR
- [ ] [Physical hardware check]
- [ ] [Third-party dashboard verification]
═══════════════════════════════════════════════════════════════
PHASE STATUS: ✅ COMPLETE - Ready for next phase
═══════════════════════════════════════════════════════════════
Note on User Verification: This section should almost always be empty. Claude performs integration testing in Step 3. Only include items here that genuinely require human eyes (e.g., "verify email arrived in inbox", "check physical device display").
→ STOP POINT: This is the ONLY valid stopping point. After outputting the Completion Report:
- Output final Progress Tracker showing all steps ✅ DONE
- Present the report to the user
- NOW (and ONLY now) await user confirmation before proceeding to next phase
Progress Tracking
Progress is tracked via Task tools, not checkboxes. See ADR-0001.
- Task status is managed by implement-plan (in_progress when starting, completed when done)
- Plan files remain pure specification documents
- Step 6 verifies work items but does not modify plan checkboxes
Phase Steps (Extensible)
The execution pipeline is defined as an ordered list of steps. This design allows easy extension:
PHASE_STEPS = [
{ name: "implementation", required: true, skill: null },
{ name: "exit_conditions", required: true, skill: null },
{ name: "integration_testing", required: true, skill: null }, // Claude tests via API/Playwright
{ name: "code_review", required: true, skill: "code-review" },
{ name: "adr_compliance", required: true, skill: "adr" },
{ name: "plan_sync", required: true, skill: null },
{ name: "prompt_archival", required: false, skill: null },
{ name: "completion_report", required: true, skill: null },
]
Adding New Steps
To add a new step (e.g., security scan, performance check):
- Define the step with its gate criteria
- Add to the pipeline at appropriate position
- Implement the step logic or delegate to a skill
Example - Adding Security Scan:
{ name: "security_scan", required: false, skill: "security-scan" }
Conditional Steps
Steps can be conditional based on:
- Phase type (e.g., only run security scan on auth phases)
- Configuration flags
- Plan metadata
if (phase.metadata.security_sensitive) {
run_step("security_scan")
}
Optional Skill Steps
Optional steps can be added to the phase execution pipeline when needed. These steps are not run by default and must be explicitly enabled via plan metadata or configuration.
Optional Steps Overview
| Step | Skill | Purpose | Default |
|---|---|---|---|
| Security Review | security-review | Comprehensive OWASP security audit | Disabled |
Note:
verification-loopis NOT optional - it is the default exit condition verification in Step 2.
Key characteristics:
- Not included in standard pipeline execution
- Enabled via plan metadata
optional_stepsconfiguration - Can be enabled globally or per-phase
- Integrate at specific points in the pipeline
Security Review Step
Skill: security-review
Purpose: Comprehensive security audit for implementations that handle sensitive operations, user data, or security-critical code paths.
When to enable:
- Authentication and authorization code
- User input handling and validation
- API endpoints exposed to external clients
- Secrets management and credential handling
- Payment processing or financial transactions
- Personal data processing (PII, PHI)
- Cryptographic operations
How to enable:
# In plan metadata
phase_config:
optional_steps:
security_review: true
Integration point: After Step 4 (Code Review), before Step 5 (ADR Compliance)
Step 1: Implementation
Step 2: Exit Conditions
Step 3: Integration Testing
Step 4: Code Review
Step 4.5: Security Review ← INSERTED HERE
Step 5: ADR Compliance
Step 6: Plan Sync
Step 7: Prompt Archival
Step 8: Completion Report
Expected output format:
SECURITY_REVIEW_STATUS: PASS | FAIL | NEEDS_REMEDIATION
VULNERABILITIES_FOUND: [count]
SEVERITY_BREAKDOWN:
CRITICAL: [count]
HIGH: [count]
MEDIUM: [count]
LOW: [count]
ISSUES:
- [severity] [category]: [description]
RECOMMENDATIONS: [list]
COMPLIANCE_CHECKS: [list of standards checked, e.g., OWASP Top 10]
Gate behavior: Security review must PASS to proceed. NEEDS_REMEDIATION triggers fix subagents, then re-review.
Enabling Security Review
Security review can be enabled for phases that handle sensitive operations.
Example configuration:
# In plan metadata
phase_config:
optional_steps:
security_review: true
Execution order with security review enabled:
Step 1: Implementation
Step 2: Exit Conditions (verification-loop - always runs)
Step 3: Integration Testing
Step 4: Code Review
Step 4.5: Security Review (if enabled)
Step 5: ADR Compliance
Step 6: Plan Sync
Step 7: Prompt Archival
Step 8: Completion Report
Per-phase overrides:
# Enable globally but override for specific phases
phase_config:
optional_steps:
security_review: true
phases:
- name: "Database Schema"
# Inherits security_review: true from global config
- name: "Static Content"
optional_steps:
security_review: false # Override: skip for this phase
Invocation
From implement-plan (primary use)
Skill(skill="implement-phase"): Execute Phase 2 of the implementation plan.
Context:
- Plan: docs/plans/auth-implementation.md
- Phase: 2 (Authentication Service)
- Previous Phase Status: Complete
Execute all quality gates and return structured result.
Manual Invocation
/implement-phase docs/plans/my-plan.md phase:3
Or interactively:
/implement-phase
> Which plan? docs/plans/auth-implementation.md
> Which phase? 2
Return Value
When called by implement-plan, return structured result:
PHASE_RESULT:
phase_number: 2
phase_name: "Authentication Service"
task_id: [task_id from input context]
task_status: "completed"
status: COMPLETE | FAILED | BLOCKED
steps:
implementation: PASS
exit_conditions: PASS
integration_testing: PASS
code_review: PASS
adr_compliance: PASS
plan_sync: PASS
prompt_archival: PASS | SKIPPED
files_changed:
created: [list]
modified: [list]
integration_tests:
api_tests: { passed: X, failed: 0 }
ui_tests: { passed: Y, failed: 0 }
evidence: "logs/integration-test-phase-2.log"
new_adrs: [list or empty]
prompt:
used: true | false
original_path: "docs/prompts/phase-2-data-pipeline.md"
archived_to: "docs/prompts/completed/phase-2-data-pipeline.md"
recommendations: [list]
user_verification: # Should usually be empty
[]
# Only include items that truly cannot be automated, e.g.:
# - "Verify physical device display"
# - "Check email arrived in inbox"
ready_for_next: true | false
blocker: null | "description of blocker"
Error Handling
Step Failures
When a step fails:
- Log failure details with full context
- Attempt automatic fix if possible (spawn fix subagent)
- Re-run the step after fix
- Escalate to user if fix fails or requires decision
Maximum Retries
Each step has a retry limit (default: 3). After exhausting retries:
⛔ PHASE BLOCKED: [Step Name] failed after 3 attempts
Last Error: [error details]
Options:
A) Retry with different approach
B) Skip this step (if non-blocking)
C) Abort phase and return to plan
How should I proceed?
Blocker Protocol
When a blocker is encountered:
- STOP all pending work
- PRESERVE state for resume
- REPORT to orchestrator with full context
- AWAIT decision
Integration with Other Skills
code-review
Called in Step 3. Receives phase context, returns structured review.
adr
Called in Step 4 when:
- New architectural decisions need documentation
- Compliance check identifies undocumented decisions
Future Integrations
The extensible step design allows adding:
security-scan- Security vulnerability scanningperformance-check- Performance regression testingdocumentation-update- Auto-update relevant docschangelog-entry- Add to CHANGELOG.md
Configuration
Phase behavior can be configured via plan metadata or global settings:
# In plan file
phase_config:
strict_mode: true # Fail on any warning
skip_steps: [] # Steps to skip
additional_steps: [] # Extra steps to run
retry_limit: 3 # Max retries per step
tdd_mode: false # Enable TDD (Test-Driven Development) mode
coverage_threshold: 80 # Minimum code coverage percentage (TDD mode)
# Global settings (~/.claude/settings.json)
implement_phase:
default_retry_limit: 3
always_run_security: false
require_adr_for_decisions: true
default_tdd_mode: false
default_coverage_threshold: 80
TDD Mode (Optional)
TDD Mode Overview
TDD (Test-Driven Development) mode inverts the traditional implementation flow by requiring tests to be written before implementation code. This approach ensures:
- Higher test coverage: Tests are not an afterthought
- Better design: Writing tests first forces cleaner interfaces
- Confidence: Every line of production code exists to make a test pass
- Documentation: Tests serve as executable specifications
When to enable TDD mode:
- Building new features with well-defined requirements
- Implementing business logic with clear acceptance criteria
- Working on code that requires high reliability
- When the plan specifies TDD as a requirement
How it modifies the implementation flow: In normal mode, Step 1 spawns implementation subagents first, then test subagents. In TDD mode, this order is reversed, and an additional verification step ensures tests fail before implementation.
Enabling TDD Mode
Via plan metadata:
# In plan file metadata section
phase_config:
tdd_mode: true
coverage_threshold: 80 # Optional, defaults to 80%
Via command line flag:
/implement-phase docs/plans/my-plan.md phase:3 --tdd
Via global settings:
# ~/.claude/settings.json
implement_phase:
default_tdd_mode: true
default_coverage_threshold: 80
RED → GREEN → REFACTOR Cycle
TDD follows the classic three-phase cycle:
┌─────────────────────────────────────────────────────────────┐
│ TDD CYCLE │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌───────┐ ┌───────┐ ┌──────────┐ │
│ │ RED │ ──────► │ GREEN │ ──────► │ REFACTOR │ │
│ └───────┘ └───────┘ └──────────┘ │
│ │ │ │
│ └─────────────────────────────────────┘ │
│ (repeat) │
│ │
├─────────────────────────────────────────────────────────────┤
│ RED: Write a failing test that defines desired behavior│
│ GREEN: Write minimal code to make the test pass │
│ REFACTOR: Improve code quality while keeping tests green │
└─────────────────────────────────────────────────────────────┘
RED Phase:
- Write test(s) that describe the expected behavior
- Tests MUST fail initially (this proves they test something real)
- If tests pass immediately, either the test is wrong or the feature already exists
GREEN Phase:
- Write the minimum code necessary to make the test pass
- Do not add extra functionality "just in case"
- Ugly code is acceptable at this stage - it will be refactored
REFACTOR Phase:
- Improve code structure, naming, and design
- Remove duplication
- Tests must remain green throughout refactoring
- If tests fail, you've broken something - revert and try again
Step 1 Modifications for TDD
Normal Flow (TDD disabled):
Step 1: Implementation
├── 1a. Read phase requirements
├── 1b. Spawn IMPLEMENTATION subagents
├── 1c. Spawn TEST subagents
└── 1d. Verify tests pass
TDD Flow (TDD enabled):
Step 1: Implementation (TDD Mode)
├── 1a. Read phase requirements
├── 1b. Spawn TEST subagents FIRST (RED)
├── 1c. Verify tests FAIL (proves tests are valid)
├── 1d. Spawn IMPLEMENTATION subagents (GREEN)
├── 1e. Verify tests PASS
├── 1f. Spawn REFACTOR subagents (optional)
└── 1g. Verify tests still PASS
Subagent Spawning Order Changes:
| Step | Normal Mode | TDD Mode |
|---|---|---|
| First | Implementation code | Test code |
| Second | Test code | Verify tests fail (RED) |
| Third | Verify tests pass | Implementation code (GREEN) |
| Fourth | - | Verify tests pass |
| Fifth | - | Refactor (optional) |
TDD Subagent Examples:
# Step 1b: Write failing tests FIRST (RED)
Task (run_in_background: true): "Write unit tests for UserAuthService.
Context: Phase 3 - User Authentication (TDD Mode - RED phase)
Location: src/auth/user-auth.service.spec.ts
Test scenarios (from requirements):
- authenticateUser() returns token for valid credentials
- authenticateUser() throws UnauthorizedError for invalid password
- authenticateUser() throws NotFoundError for unknown user
- refreshToken() extends session for valid refresh token
IMPORTANT: Implementation does NOT exist yet. Tests MUST fail.
Write tests that will drive the implementation.
RESPONSE FORMAT: STATUS, FILES created, test count, ERRORS if any."
# Step 1c: Verify tests fail
Task: "Run tests and verify they FAIL.
Command: npm test -- --testPathPattern=user-auth.service.spec.ts
Expected: Tests should FAIL (RED phase of TDD)
If tests PASS, there is a problem - either tests are wrong or feature already exists.
RESPONSE FORMAT: STATUS (expect FAIL), test count, failure summary."
# Step 1d: Write minimal implementation (GREEN)
Task (run_in_background: true): "Implement UserAuthService to pass tests.
Context: Phase 3 - User Authentication (TDD Mode - GREEN phase)
Location: src/auth/user-auth.service.ts
Tests at: src/auth/user-auth.service.spec.ts
Write MINIMAL code to make all tests pass. Do not add extra functionality.
Follow the interface defined by the tests.
RESPONSE FORMAT: STATUS, FILES created/modified, ERRORS if any."
Coverage Verification
TDD mode enforces a minimum code coverage threshold (default: 80%).
How coverage is checked:
- After Step 1 completes, spawn a coverage verification subagent
- Run tests with coverage reporting enabled
- Parse coverage report and compare against threshold
- Fail the phase if coverage is below threshold
Coverage Subagent Example:
Task: "Verify code coverage meets TDD threshold.
Commands:
1. npm test -- --coverage --coverageReporters=text
2. Parse coverage percentage from output
Threshold: 80%
Scope: Files created/modified in this phase
RESPONSE FORMAT:
STATUS: PASS | FAIL
COVERAGE: [percentage]%
UNCOVERED_LINES: [count]
DETAILS: [brief summary or path to full report]"
Handling coverage failures:
- Identify uncovered lines/branches
- Spawn subagent to add missing tests
- Re-run coverage check
- Repeat until threshold met or max retries exhausted
COVERAGE_STATUS: FAIL
COVERAGE: 72%
THRESHOLD: 80%
UNCOVERED:
- src/auth/user-auth.service.ts: lines 45-52 (error handling)
- src/auth/user-auth.service.ts: lines 78-80 (edge case)
ACTION: Spawning subagent to add tests for uncovered code paths...
TDD Mode Checklist
Before marking Step 1 as complete in TDD mode, verify:
TDD VERIFICATION CHECKLIST:
- [ ] Tests written BEFORE implementation code
- [ ] Tests failed initially (RED phase verified)
- [ ] Minimal code written to pass tests (GREEN phase)
- [ ] Refactoring done with passing tests (REFACTOR phase)
- [ ] Coverage threshold met (default: 80%)
- [ ] No implementation code without corresponding tests
Step 1 Output (TDD Mode):
IMPLEMENTATION_STATUS: PASS
TDD_MODE: enabled
TDD_PHASES:
RED: VERIFIED (tests failed as expected)
GREEN: PASS (all tests now passing)
REFACTOR: PASS (tests still green)
COVERAGE: 85% (threshold: 80%)
FILES_CREATED: [list]
FILES_MODIFIED: [list]
TEST_RESULTS: 12 passing, 0 failing
ERRORS: None
Best Practices
For implement-plan Authors
- Provide complete phase context when calling
- Trust the structured return value
- Handle BLOCKED status appropriately
- Present manual verification steps to user
For Direct Users
- Ensure plan file is up-to-date before running
- Have ADR INDEX.md available
- Review manual verification steps carefully
- Check recommendations even on PASS_WITH_NOTES
For Step Developers
- Each step must have clear PASS/FAIL criteria
- Steps should be idempotent (safe to re-run)
- Provide detailed error messages
- Log sufficient context for debugging
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon