[SPEC] Continue workflow from previous session. IMMEDIATELY use the Skill tool: Skill(skill="spec", args="--continue docs/plans/2026-02-14-github-migration.md") Do NOT do anything else first.
User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
For new features, major changes, and complex work. Creates a spec, gets your approval, implements with TDD, and verifies completion - all in one continuous flow.
This command is a dispatcher that determines which phase to run and invokes it via Skill().
⛔ MANDATORY: /spec = Workflow. No Exceptions.
When /spec is invoked, you MUST follow the spec workflow exactly. The user's phrasing after /spec is the TASK DESCRIPTION — it is NOT an instruction to change the workflow.
/spec brainstorm a caching layer → task_description = "brainstorm a caching layer" → invoke Skill('spec-plan') with that description
/spec let's discuss auth options → task_description = "let's discuss auth options" → invoke Skill('spec-plan') with that description
/spec explore and plan a new feature → task_description = "explore and plan a new feature" → invoke Skill('spec-plan') with that description
Words like "brainstorm", "discuss", "explore", "think about" are part of the task description, NOT instructions to skip the workflow. The spec-plan phase handles all exploration, discussion, and brainstorming within its structured flow.
NEVER interpret /spec arguments as a reason to have a freeform conversation instead of invoking the phase skill.
/spec <task-description> # Start new workflow from task
/spec <path/to/plan.md> # Continue existing plan
/spec --continue <path/to/plan.md> # Resume after session clear
Parse the arguments: --continue docs/plans/2026-02-14-github-migration.md
Determine Current State
code
IF arguments start with "--continue":
plan_path = extract path after "--continue"
1. Read ~/.pilot/sessions/$PILOT_SESSION_ID/continuation.md if it exists
2. Delete the continuation file after reading
3. Read plan file, check Status AND Approved fields
→ Dispatch to appropriate phase based on status
ELIF arguments end with ".md" AND file exists:
plan_path = arguments
→ Read plan file, check Status AND Approved fields
→ Dispatch to appropriate phase based on status
ELSE:
task_description = arguments # ALWAYS treated as task description, regardless of phrasing
→ Ask worktree question FIRST (see Section 0.1.1 below)
→ Invoke planning phase with worktree choice: Skill(skill='spec-plan', args='<task_description> --worktree=yes|no')
# NEVER have a freeform conversation instead. ALWAYS invoke the Skill.
0.1.1 Worktree Question (New Plans Only)
Before invoking spec-plan for a NEW plan, ask the user about worktree isolation:
code
AskUserQuestion:
question: "Use git worktree isolation for this spec?"
header: "Worktree"
options:
- "Yes" - Isolate work on a dedicated branch; safe to experiment, easy to discard or squash merge
- "No" - Work directly on the current branch without worktree isolation
Append the choice to the spec-plan args:Skill(skill='spec-plan', args='<task_description> --worktree=yes') or --worktree=no.
This question is ONLY asked for new plans. When continuing an existing plan (--continue or .md path), the Worktree: field is already set in the plan header.
After reading the plan file, register the plan association (non-blocking):
This tells Console which session is working on which plan. Failure is silently ignored.
0.2 Status-Based Dispatch
Read the plan file and dispatch based on Status and Approved fields:
Status
Approved
Action
PENDING
No
Skill(skill='spec-plan', args='<plan-path>')
PENDING
Yes
Skill(skill='spec-implement', args='<plan-path>') (worktree if Worktree: Yes in plan)
COMPLETE
*
Skill(skill='spec-verify', args='<plan-path>')
VERIFIED
*
Report completion, workflow done
⛔ Phase Transition Context Guard applies before every dispatch (see Section 0.3).
Invoke the appropriate Skill immediately. Do not duplicate phase logic here.
Report Completion (VERIFIED)
If the plan status is already VERIFIED:
code
✅ Workflow complete! Plan status: VERIFIED
The plan at <plan-path> has been fully implemented and verified.
Is there anything else you'd like me to help with?
0.3 Phase Transition Context Guard
⛔ MANDATORY: Before EVERY Skill() call that transitions to another phase, check context:
bash
~/.pilot/bin/pilot check-context --json
Percentage
Action
< 80%
Proceed with phase transition
>= 80%
Do NOT invoke the next phase. Hand off instead.
Each phase (plan, implement, verify) needs significant context to complete. Starting a new phase above 80% risks overshooting to 100% — the worst-case scenario where all work is lost.
When >= 80%: Write continuation file, trigger send-clear. The next session dispatches to the correct phase automatically based on plan status.
This applies to ALL transitions: plan→implement, implement→verify, verify→implement (feedback loop), and dispatcher→any phase.
0.4 Context Management (90% Handoff)
After each major operation, check context:
bash
~/.pilot/bin/pilot check-context --json
Between iterations:
If context >= 90%: hand off cleanly (don't rush!)
If context 80-89%: continue but wrap up current task with quality
If context < 80%: continue the loop freely
If response shows "status": "CLEAR_NEEDED" (context >= 90%):
⚠️ CRITICAL: Execute ALL steps below in a SINGLE turn. DO NOT stop or wait for user response between steps.
Write to ~/.pilot/sessions/$PILOT_SESSION_ID/continuation.md:
markdown
# Session Continuation (/spec)
**Plan:** <plan-path>
**Phase:** [planning|implementation|verification]
**Current Task:** Task N - [description]
**Completed This Session:**
- [x] [What was finished]
**Next Steps:**
1. [What to do immediately when resuming]
**Context:**
- [Key decisions or blockers]
Step 2: Trigger session clear
bash
~/.pilot/bin/pilot send-clear <plan-path>
Pilot will restart with /spec --continue <plan-path>
Error Handling
No Active Session: If send-clear fails, tell user: "Context at X%. Please run /clear manually, then /spec --continue <plan-path>"
Plan File Not Found: Tell user: "Plan file not found: " and ask if they want to create a new plan.
0.5 Rules Summary (Quick Reference)
#
Rule
1
NO sub-agents except verification - Phases 1 and 2 use direct tools only. Verification steps (Step 1.7, Step 3.0/3.5) launch paired review agents via the Task tool (subagent_type="pilot:*"). Task tool is the ONLY allowed mechanism for sub-agents.
2
NEVER SKIP verification - Plan verification (Step 1.7) and Code verification (Step 3.5) are mandatory. No exceptions.
3
ONLY stopping point is plan approval - Everything else is automatic. Never ask "Should I fix these?"
4
Batch questions together - Don't interrupt user flow
5
Run explorations sequentially - One at a time, never in parallel
6
NEVER write code during planning - Separate phases
7
NEVER assume - verify by reading files
8
Re-read plan after user edits - Before asking for approval again
9
TDD is MANDATORY - No production code without failing test first
10
Update plan checkboxes after EACH task - Not at the end
11
Quality over speed - Never rush due to context pressure. But at 90%+ context, handoff overrides everything - do NOT start new fix cycles
12
Plan file is source of truth - Survives session clears
13
Phase Transition Context Guard - Check context before EVERY phase transition. If >= 80%, hand off instead of starting next phase (Section 0.3)
Context at 37% — proceeding with implementation phase. Deleting continuation file and dispatching.
User
0.5 Rules Summary (Quick Reference)
#
Rule
1
NO sub-agents except verification - Phases 1 and 2 use direct tools only. Verification steps (Step 1.7, Step 3.0/3.5) launch paired review agents via the Task tool (subagent_type="pilot:*"). Task tool is the ONLY allowed mechanism for sub-agents.
2
NEVER SKIP verification - Plan verification (Step 1.7) and Code verification (Step 3.5) are mandatory. No exceptions.
3
ONLY stopping point is plan approval - Everything else is automatic. Never ask "Should I fix these?"
4
Batch questions together - Don't interrupt user flow
5
Run explorations sequentially - One at a time, never in parallel
6
NEVER write code during planning - Separate phases
7
NEVER assume - verify by reading files
8
Re-read plan after user edits - Before asking for approval again
9
TDD is MANDATORY - No production code without failing test first
10
Update plan checkboxes after EACH task - Not at the end
11
Quality over speed - Never rush due to context pressure. But at 90%+ context, handoff overrides everything - do NOT start new fix cycles
12
Plan file is source of truth - Survives session clears
13
Phase Transition Context Guard - Check context before EVERY phase transition. If >= 80%, hand off instead of starting next phase (Section 0.3)
Write to ~/.pilot/sessions/$PILOT_SESSION_ID/continuation.md:
markdown
# Session Continuation (/spec)
**Plan:** <plan-path>
**Phase:** [planning|implementation|verification]
**Current Task:** Task N - [description]
**Completed This Session:**
- [x] [What was finished]
**Next Steps:**
1. [What to do immediately when resuming]
**Context:**
- [Key decisions or blockers]
Step 2: Trigger session clear
bash
~/.pilot/bin/pilot send-clear <plan-path>
Pilot will restart with /spec --continue <plan-path>
Error Handling
No Active Session: If send-clear fails, tell user: "Context at X%. Please run /clear manually, then /spec --continue <plan-path>"
Plan File Not Found: Tell user: "Plan file not found: " and ask if they want to create a new plan.
User
0.3 Phase Transition Context Guard
⛔ MANDATORY: Before EVERY Skill() call that transitions to another phase, check context:
bash
~/.pilot/bin/pilot check-context --json
Percentage
Action
< 80%
Proceed with phase transition
>= 80%
Do NOT invoke the next phase. Hand off instead.
Each phase (plan, implement, verify) needs significant context to complete. Starting a new phase above 80% risks overshooting to 100% — the worst-case scenario where all work is lost.
When >= 80%: Write continuation file, trigger send-clear. The next session dispatches to the correct phase automatically based on plan status.
This applies to ALL transitions: plan→implement, implement→verify, verify→implement (feedback loop), and dispatcher→any phase.
User
0.1 Parse Arguments
code
/spec <task-description> # Start new workflow from task
/spec <path/to/plan.md> # Continue existing plan
/spec --continue <path/to/plan.md> # Resume after session clear
Parse the arguments: --continue docs/plans/2026-02-14-github-migration.md
Determine Current State
code
IF arguments start with "--continue":
plan_path = extract path after "--continue"
1. Read ~/.pilot/sessions/$PILOT_SESSION_ID/continuation.md if it exists
2. Delete the continuation file after reading
3. Read plan file, check Status AND Approved fields
→ Dispatch to appropriate phase based on status
ELIF arguments end with ".md" AND file exists:
plan_path = arguments
→ Read plan file, check Status AND Approved fields
→ Dispatch to appropriate phase based on status
ELSE:
task_description = arguments # ALWAYS treated as task description, regardless of phrasing
→ Ask worktree question FIRST (see Section 0.1.1 below)
→ Invoke planning phase with worktree choice: Skill(skill='spec-plan', args='<task_description> --worktree=yes|no')
# NEVER have a freeform conversation instead. ALWAYS invoke the Skill.
0.1.1 Worktree Question (New Plans Only)
Before invoking spec-plan for a NEW plan, ask the user about worktree isolation:
code
AskUserQuestion:
question: "Use git worktree isolation for this spec?"
header: "Worktree"
options:
- "Yes" - Isolate work on a dedicated branch; safe to experiment, easy to discard or squash merge
- "No" - Work directly on the current branch without worktree isolation
Phase 2 of the /spec workflow. Reads the approved plan and implements each task using TDD (Red → Green → Refactor).
Input: Path to an approved plan file (Approved: Yes)
Output: All plan tasks completed, status set to COMPLETE
Next phase: On completion → Skill(skill='spec-verify', args='<plan-path>')
⛔ KEY CONSTRAINTS (Rules Summary)
#
Rule
1
NO sub-agents - Use direct tools only. All tasks are implemented sequentially in the main context.
2
TDD is MANDATORY - No production code without failing test first
3
Update plan checkboxes AND task status after EACH task - Not at the end
4
NEVER SKIP TASKS - Every task MUST be fully implemented
5
Quality over speed - Never rush due to context pressure
6
Plan file is source of truth - Survives session clears
7
NEVER assume - verify by reading files
8
Task management is MANDATORY - Use TaskCreate/TaskUpdate for progress tracking
Quality Over Speed - CRITICAL
NEVER rush or compromise quality due to context pressure.
Context warnings are informational, not emergencies
Work spans sessions seamlessly via plan file and continuation mechanisms
Finish the CURRENT task with full quality, then hand off cleanly
Do NOT skip tests, compress code, or cut corners to "beat" context limits
Quality is the #1 metric - a well-done task split across sessions beats rushed work
Feedback Loop Awareness
This phase may be called multiple times in a feedback loop:
Continuing from previous session. Reading plan and setting up for implementation.
Assistant· claude-sonnet-4-5-20250929
Worktree creation requires a clean working tree. You have uncommitted changes including modified files (rules, configs, cache data) and deleted files (old hooks, GitLab CI files, session docs).
Assistant· claude-sonnet-4-5-20250929
Worktree created successfully. Now entering the isolated worktree to begin implementation.
Assistant· claude-sonnet-4-5-20250929
Now setting up task tracking for the 7 implementation tasks.
Assistant· claude-sonnet-4-5-20250929
Tasks set up with dependencies. Starting Task 1: Install gh CLI and back up divergent commits.
Assistant· claude-sonnet-4-5-20250929
gh CLI is installed but not authenticated. For Task 2, we'll need gh to change the GitHub default branch via the API. Let me check what operations I can complete without gh auth first.
Assistant· claude-sonnet-4-5-20250929
Task 1 mostly complete. gh CLI is installed and working, SSH auth is verified, and the backup branch is created and verified. However, gh authentication is needed for Task 2's API operations.
Assistant· claude-sonnet-4-5-20250929
Please run this command in a terminal to authenticate gh:
bash
~/.local/bin/gh auth login
Follow the prompts to authenticate using your GitHub account (recommend using SSH for git operations since SSH is already configured). Once authentication is complete, let me know and I'll verify and continue with the implementation.
User
Context Management (90% Handoff)
After each major operation, check context:
bash
~/.pilot/bin/pilot check-context --json
Between iterations:
If context >= 90%: hand off cleanly (don't rush!)
If context 80-89%: continue but wrap up current task with quality
If context < 80%: continue the loop freely
If response shows "status": "CLEAR_NEEDED" (context >= 90%):
⚠️ CRITICAL: Execute ALL steps below in a SINGLE turn. DO NOT stop or wait for user response between steps.
IMMEDIATELY edit the plan file to change [ ] to [x] for that task
Update the Progress Tracking counts (Completed/Remaining)
DO NOT proceed to next task until the checkbox is updated
This is NON-NEGOTIABLE.
Example - After completing Task 5:
code
Edit the plan file:
- [ ] Task 5: Implement X → - [x] Task 5: Implement X
Update counts:
**Completed:** 4 | **Remaining:** 8 → **Completed:** 5 | **Remaining:** 7
User
Step 2.3: TDD Loop
TDD is MANDATORY. No production code without a failing test first.
Requires TDD
Skip TDD
New functions/methods
Documentation changes
API endpoints
Config file updates
Business logic
IaC code (CDK, Terraform, Pulumi)
Bug fixes
Formatting/style changes
For EVERY task, follow this exact sequence:
READ PLAN'S IMPLEMENTATION STEPS - List all files to create/modify/delete
Perform Call Chain Analysis:
Trace Upwards (Callers): Identify what calls the code you're modifying
Trace Downwards (Callees): Identify what the modified code calls
Side Effects: Check for database, cache, external system impacts
Mark task as in_progress - TaskUpdate(taskId="<id>", status="in_progress")
Execute TDD Flow (RED → GREEN → REFACTOR):
Write failing test first, verify it fails
Implement minimal code to pass
Refactor if needed (keep tests green)
Verify tests pass - Run the project's test runner (e.g., uv run pytest -q, bun test, npm test)
Run actual program - Use the plan's Runtime Environment section to start the service/program. Show real output with sample data.
Check diagnostics - Must be zero errors
Validate Definition of Done - Check all criteria from plan
Per-task commit (worktree mode only) - If Worktree: Yes in the plan, commit task changes immediately:
bash
git add <task-specific-files> # Stage only files related to this task
git commit -m "{type}(spec): {task-name}"
Use feat(spec): for new features, fix(spec): for bug fixes, test(spec): for test-only tasks, refactor(spec): for refactoring. Skip this step when Worktree: No (normal git rules apply).
Mark task as completed - TaskUpdate(taskId="<id>", status="completed")
UPDATE PLAN FILE IMMEDIATELY (see Step 2.4)
Check context usage - Run ~/.pilot/bin/pilot check-context --json
⚠️ NEVER SKIP TASKS:
EVERY task MUST be fully implemented
NO exceptions for "MVP scope" or complexity
If blocked: STOP and report specific blockers
NEVER mark complete without doing the work
User
Step 2.2: Set Up Task List (MANDATORY)
After reading the plan, set up task tracking using the Task management tools.
This makes implementation progress visible in the terminal (Ctrl+T), enables dependency tracking, and persists across session handoffs via CLAUDE_CODE_TASK_LIST_ID.
Process:
Check for existing tasks first: Run TaskList to see if a previous session already created tasks
Branch based on result:
If TaskList returns tasks (continuation session):
Tasks already exist from a prior session - do NOT recreate them
Review existing task statuses to understand where the previous session left off
Cross-reference with plan checkboxes ([x] = done, [ ] = remaining)
If a task is in_progress but the session that started it is gone, it was interrupted - keep it in_progress and resume it
Proceed to Step 2.3 starting with the first uncompleted task
If TaskList is empty (fresh start):
Create one task per uncompleted plan task ([ ] items):
code
TaskCreate(
subject="Task N: <title from plan>",
description="<objective + implementation steps from plan>",
activeForm="Implementing <short description>"
)
Set up dependencies if tasks have ordering requirements:
User sees real-time progress in their terminal via status spinners
Dependencies prevent skipping ahead when tasks have ordering requirements
Tasks persist across session handoffs (stored in ~/.claude/tasks/)
Continuation sessions pick up exactly where the previous session left off
User
Step 2.1b: Create or Resume Worktree (Conditional)
Check the plan's Worktree: header field to determine isolation mode.
Read the Worktree: header from the plan file:
Parse Worktree: Yes or Worktree: No from the plan content (regex: /^Worktree:\s*(\w+)/m)
If the field is missing, default to Yes (backward compatibility with older plans)
If Worktree: No: Skip the rest of Step 2.1b entirely. Implementation happens directly on the current branch. Proceed to Step 2.2.
If Worktree: Yes (or missing/default): All implementation happens in an isolated git worktree. This keeps the main branch clean until verification passes and the user approves sync.
Extract plan slug from the plan file path:
docs/plans/2026-02-09-add-auth.md → plan_slug = add-auth (strip date prefix and .md)
Check for existing worktree (continuation session or verify→implement feedback loop):
Append the choice to the spec-plan args:Skill(skill='spec-plan', args='<task_description> --worktree=yes') or --worktree=no.
This question is ONLY asked for new plans. When continuing an existing plan (--continue or .md path), the Worktree: field is already set in the plan header.
After reading the plan file, register the plan association (non-blocking):
This tells Console which session is working on which plan. Failure is silently ignored.
0.2 Status-Based Dispatch
Read the plan file and dispatch based on Status and Approved fields:
Status
Approved
Action
PENDING
No
Skill(skill='spec-plan', args='<plan-path>')
PENDING
Yes
Skill(skill='spec-implement', args='<plan-path>') (worktree if Worktree: Yes in plan)
COMPLETE
*
Skill(skill='spec-verify', args='<plan-path>')
VERIFIED
*
Report completion, workflow done
⛔ Phase Transition Context Guard applies before every dispatch (see Section 0.3).
Invoke the appropriate Skill immediately. Do not duplicate phase logic here.
Report Completion (VERIFIED)
If the plan status is already VERIFIED:
code
✅ Workflow complete! Plan status: VERIFIED
The plan at <plan-path> has been fully implemented and verified.
Is there anything else you'd like me to help with?
Read the plan - verification will have added fix tasks (marked with [MISSING] or similar)
Check the Iterations field in the plan header
Report iteration start: "🔄 Starting Iteration N implementation..."
Focus on uncompleted tasks [ ] - these are the fixes needed
Complete all fix tasks, then set status to COMPLETE as normal
Step 2.1: Read Plan & Gather Context
Before ANY implementation, you MUST:
Read the COMPLETE plan - Understanding overall architecture and design
Verify comprehension - Summarize what you learned to demonstrate understanding
Identify dependencies - List files, functions, classes that need modification
Check current state:
Git status: git status --short and git diff --name-only
Plan progress: Check for [x] completed tasks
🔧 Tools for Implementation
Tool
When to Use
Example
Context7
Library API lookup
resolve-library-id(query="how to use fixtures", libraryName="pytest") then query-docs(libraryId, query)
Step 2.1b: Create or Resume Worktree (Conditional)
Check the plan's Worktree: header field to determine isolation mode.
Read the Worktree: header from the plan file:
Parse Worktree: Yes or Worktree: No from the plan content (regex: /^Worktree:\s*(\w+)/m)
If the field is missing, default to Yes (backward compatibility with older plans)
If Worktree: No: Skip the rest of Step 2.1b entirely. Implementation happens directly on the current branch. Proceed to Step 2.2.
If Worktree: Yes (or missing/default): All implementation happens in an isolated git worktree. This keeps the main branch clean until verification passes and the user approves sync.
Extract plan slug from the plan file path:
docs/plans/2026-02-09-add-auth.md → plan_slug = add-auth (strip date prefix and .md)
Check for existing worktree (continuation session or verify→implement feedback loop):
Then cd to the path from the JSON output for all subsequent commands.
If creation fails due to dirty working tree (JSON contains "error": "dirty"):
The worktree cannot be created with uncommitted changes. Show the user the changed files from the error detail, then ask:
code
AskUserQuestion:
question: "Worktree creation requires a clean working tree. How should we handle your uncommitted changes?"
header: "Dirty tree"
options:
- "Commit changes" (Recommended) — Commit current changes before creating the worktree
- "Stash changes" — Stash changes (restore later with `git stash pop`)
- "Skip worktree" — Work directly on the current branch instead (no isolation)
If "Commit changes": Run git add for the changed files, commit with an appropriate message, then retry pilot worktree create.
If "Stash changes": Run git stash push -m "auto-stash before spec worktree", then retry pilot worktree create.
If "Skip worktree": Continue without worktree isolation — implementation happens on the current branch. Log a note to the user.
Do NOT proceed with worktree creation until the working tree is clean or the user chooses to skip.
If creation fails due to old git version (error contains "git >= 2.15 required"): Log a warning and continue without worktree isolation. Implementation will happen directly on the current branch. This is a graceful fallback for systems with older git versions.
Verify worktree is active: Run git branch --show-current in the worktree to confirm you're on the spec/<plan_slug> branch.
⚠️ All subsequent implementation steps happen inside the worktree directory (when worktree is active). The plan file exists at the same relative path in the worktree (e.g., docs/plans/...). Commits within the worktree are expected and allowed.
Step 2.2: Set Up Task List (MANDATORY)
After reading the plan, set up task tracking using the Task management tools.
This makes implementation progress visible in the terminal (Ctrl+T), enables dependency tracking, and persists across session handoffs via CLAUDE_CODE_TASK_LIST_ID.
Process:
Check for existing tasks first: Run TaskList to see if a previous session already created tasks
Branch based on result:
If TaskList returns tasks (continuation session):
Tasks already exist from a prior session - do NOT recreate them
Review existing task statuses to understand where the previous session left off
Cross-reference with plan checkboxes ([x] = done, [ ] = remaining)
If a task is in_progress but the session that started it is gone, it was interrupted - keep it in_progress and resume it
Proceed to Step 2.3 starting with the first uncompleted task
If TaskList is empty (fresh start):
Create one task per uncompleted plan task ([ ] items):
code
TaskCreate(
subject="Task N: <title from plan>",
description="<objective + implementation steps from plan>",
activeForm="Implementing <short description>"
)
Set up dependencies if tasks have ordering requirements:
User sees real-time progress in their terminal via status spinners
Dependencies prevent skipping ahead when tasks have ordering requirements
Tasks persist across session handoffs (stored in ~/.claude/tasks/)
Continuation sessions pick up exactly where the previous session left off
Step 2.3: TDD Loop
TDD is MANDATORY. No production code without a failing test first.
Requires TDD
Skip TDD
New functions/methods
Documentation changes
API endpoints
Config file updates
Business logic
IaC code (CDK, Terraform, Pulumi)
Bug fixes
Formatting/style changes
For EVERY task, follow this exact sequence:
READ PLAN'S IMPLEMENTATION STEPS - List all files to create/modify/delete
Perform Call Chain Analysis:
Trace Upwards (Callers): Identify what calls the code you're modifying
Trace Downwards (Callees): Identify what the modified code calls
Side Effects: Check for database, cache, external system impacts
Mark task as in_progress - TaskUpdate(taskId="<id>", status="in_progress")
Execute TDD Flow (RED → GREEN → REFACTOR):
Write failing test first, verify it fails
Implement minimal code to pass
Refactor if needed (keep tests green)
Verify tests pass - Run the project's test runner (e.g., uv run pytest -q, bun test, npm test)
Run actual program - Use the plan's Runtime Environment section to start the service/program. Show real output with sample data.
Check diagnostics - Must be zero errors
Validate Definition of Done - Check all criteria from plan
Per-task commit (worktree mode only) - If Worktree: Yes in the plan, commit task changes immediately:
bash
git add <task-specific-files> # Stage only files related to this task
git commit -m "{type}(spec): {task-name}"
Use feat(spec): for new features, fix(spec): for bug fixes, test(spec): for test-only tasks, refactor(spec): for refactoring. Skip this step when Worktree: No (normal git rules apply).
Mark task as completed - TaskUpdate(taskId="<id>", status="completed")
UPDATE PLAN FILE IMMEDIATELY (see Step 2.4)
Check context usage - Run ~/.pilot/bin/pilot check-context --json
⚠️ NEVER SKIP TASKS:
EVERY task MUST be fully implemented
NO exceptions for "MVP scope" or complexity
If blocked: STOP and report specific blockers
NEVER mark complete without doing the work
Step 2.4: Update Plan After EACH Task
⛔ CRITICAL: Task Completion Tracking is MANDATORY
After completing EACH task, you MUST:
IMMEDIATELY edit the plan file to change [ ] to [x] for that task
Update the Progress Tracking counts (Completed/Remaining)
DO NOT proceed to next task until the checkbox is updated
This is NON-NEGOTIABLE.
Example - After completing Task 5:
code
Edit the plan file:
- [ ] Task 5: Implement X → - [x] Task 5: Implement X
Update counts:
**Completed:** 4 | **Remaining:** 8 → **Completed:** 5 | **Remaining:** 7
Step 2.5: All Tasks Complete → Verification
⚠️ CRITICAL: Follow these steps exactly:
Quick verification: Check diagnostics and run the project's test suite
FOR MIGRATIONS ONLY - Feature Parity Check:
Run the NEW code and verify it produces expected output
Compare behavior with OLD code (if still available)
Check Feature Inventory - every feature should now be implemented
If ANY feature is missing: DO NOT mark complete - add tasks for missing features
MANDATORY: Update plan status to COMPLETE
code
Edit the plan file and change the Status line:
Status: PENDING → Status: COMPLETE
Register status change:~/.pilot/bin/pilot register-plan "<plan_path>" "COMPLETE" 2>/dev/null || true
⛔ Phase Transition Context Guard: Run ~/.pilot/bin/pilot check-context --json. If >= 80%, hand off instead (see spec.md Section 0.3).
AskUserQuestion:
question: "Worktree creation requires a clean working tree. How should we handle your uncommitted changes?"
header: "Dirty tree"
options:
- "Commit changes" (Recommended) — Commit current changes before creating the worktree
- "Stash changes" — Stash changes (restore later with `git stash pop`)
- "Skip worktree" — Work directly on the current branch instead (no isolation)
If "Commit changes": Run git add for the changed files, commit with an appropriate message, then retry pilot worktree create.
If "Stash changes": Run git stash push -m "auto-stash before spec worktree", then retry pilot worktree create.
If "Skip worktree": Continue without worktree isolation — implementation happens on the current branch. Log a note to the user.
Do NOT proceed with worktree creation until the working tree is clean or the user chooses to skip.
If creation fails due to old git version (error contains "git >= 2.15 required"): Log a warning and continue without worktree isolation. Implementation will happen directly on the current branch. This is a graceful fallback for systems with older git versions.
Verify worktree is active: Run git branch --show-current in the worktree to confirm you're on the spec/<plan_slug> branch.
⚠️ All subsequent implementation steps happen inside the worktree directory (when worktree is active). The plan file exists at the same relative path in the worktree (e.g., docs/plans/...). Commits within the worktree are expected and allowed.