The problem: Your project-local settings file at .claude/settings.local.json has accumulated 292 permission rules, most of which are Bash commands that were individually approved during past sessions. 93 of these are over 200 characters long, and one is 16,406 characters (the entire Python script you can see at line 37 in the file).
This file is where Claude Code stores "always allow" permissions you've granted interactively. Over time it has become bloated with one-off commands, full scripts, and git commit messages embedded as permission patterns.
Fix: Reset it to only the permissions you actually need:
bash
# Back up first
cp .claude/settings.local.json .claude/settings.local.json.bak
# Replace with clean permissions
cat > .claude/settings.local.json << 'EOF'
{
"permissions": {
"allow": [],
"deny": []
}
}
EOF
This won't break anything — you'll just get prompted to approve Bash commands again, and they'll accumulate more cleanly. Alternatively, you could curate the list down to just the general patterns you actually want (like Bash(docker:*), Bash(curl:*), etc.) rather than keeping 292 one-off approvals.
2. YAML parse error in /spec command
code
[WARN] Failed to parse YAML frontmatter in ~/.claude/commands/spec.md
The frontmatter in spec.md starts correctly with --- and has valid fields. This warning may be caused by the argument-hint field containing special characters (< and >). This is likely cosmetic and doesn't affect functionality since Claude Code still loads the command. You can ignore it or try quoting the value:
yaml
argument-hint: "'<task description>' or '<path/to/plan.md>'"
3. Missing SONATYPE_GUIDE_TOKEN env var
code
[WARN] Missing environment variables in plugin MCP config: SONATYPE_GUIDE_TOKEN
User
spec
/spec
Refine implementation with lasting solutions.
User
/spec - Unified Spec-Driven Development
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.
Context at 33% — plenty of room. Invoking the planning phase.
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)
ARGUMENTS: Refine implementation with lasting solutions.
User
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.
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: Refine implementation with lasting solutions.
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 1 of the /spec workflow. Explores the codebase, designs an implementation plan, verifies it, and gets user approval.
Input: Task description (new plan) or plan path (continue unapproved plan)
Output: Approved plan file at docs/plans/YYYY-MM-DD-<slug>.mdNext phase: On approval → Skill(skill='spec-implement', args='<plan-path>')
⛔ KEY CONSTRAINTS (Rules Summary)
#
Rule
1
NO sub-agents during planning - Use direct tools only. Exception: Step 1.7 launches plan-verifier + plan-challenger via the Task tool (subagent_type="pilot:plan-verifier" and "pilot:plan-challenger").
2
NEVER SKIP verification - Plan verification (Step 1.7) is 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
Quality over speed - Never rush due to context pressure
10
Plan file is source of truth - Survives session clears
WARNING: DO NOT use the built-in ExitPlanMode or EnterPlanMode tools.
Using AskUserQuestion - Core Planning Tool
Questions are grouped into batches for smooth user experience:
Batch
When
Purpose
Batch 1
Assistant
Starting the planning phase. Let me create the plan file header first, then understand what needs refining.
Assistant
Now, the task description "Refine implementation with lasting solutions" is quite broad. Before I explore, I need to understand what you're referring to.
My understanding: You want to address the issues we identified in the debug session — specifically the bloated settings.local.json (608KB, 292 accumulated permission rules) and potentially the other warnings (YAML parse error in spec.md, missing SONATYPE_GUIDE_TOKEN). "Lasting solutions" suggests you want structural fixes, not just one-time cleanups.
However, this could also refer to other aspects of the vault or codebase that need refinement.
Assistant
Good - both settings fixes and vault infrastructure improvements, with curated patterns plus hooks to prevent recurrence. Let me explore the current state.
Assistant
That confirms it — the settings.local.json has entire scripts and multi-page markdown documents embedded as permission strings. Let me now explore the hooks and vault infrastructure.
Assistant
Now let me understand the hook system and check if there's a way to add a PostToolUse hook for Bash that could manage permissions.
Assistant
Good — hooks can't intercept permission saves, but pre-defined wildcard patterns in settings files DO prevent bloat because matching commands don't create new entries. The solution is to extract patterns and build a cleanup mechanism.
Let me analyze what useful patterns exist in the bloated file and check the vault infrastructure.
Assistant
Now I have a complete picture. Let me design the plan.
Assistant
Now let me write the full plan based on everything I've discovered.
Assistant
Now launching plan verification with both agents in parallel.
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.
Write to ~/.pilot/sessions/$PILOT_SESSION_ID/continuation.md:
markdown
# Session Continuation (/spec)
**Plan:** <plan-path>
**Phase:** planning
**Current Task:** [description of where you are in planning]
**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>
ARGUMENTS: Refine implementation with lasting solutions. --worktree=yes
User
Step 1.2: Task Understanding, Discuss & Clarify
First, clearly state your understanding of the task.
Before any exploration:
Restate what the user is asking for in your own words
Identify the core problem being solved
List any assumptions you're making
Then identify gray areas using domain-aware analysis:
Analyze the task description to find ambiguities that NEED resolution before planning. Different types of work have different gray areas:
Domain
Typical Gray Areas
Something users SEE (UI/frontend)
Layout density, interaction patterns, responsive breakpoints, empty states, loading states
Audience level, structure, examples needed, update frequency
Scope guardrail: Questions should clarify HOW to implement the task, not WHETHER to expand scope. If discussion surfaces new feature ideas, capture them as "Deferred Ideas" in the plan's Open Questions section — don't add them to scope.
Then gather clarifications if needed (Question Batch 1):
If gray areas exist, use AskUserQuestion to ask focused questions per area in a single interaction. Present your interpretation as options when possible — "Should the API return paginated results (recommended for large datasets) or all results at once?" is better than "How should the API handle large result sets?"
If the task is clear and unambiguous with no meaningful gray areas, skip directly to Step 1.3.
Step 1.3: Exploration
Explore the codebase systematically. Run explorations one at a time (sequentially, not in parallel).
🔧 Tools for Exploration
Tool
When to Use
Example
Context7
Library/framework docs
User
Creating New Plans
Step 1.1: Create Plan File Header (FIRST)
Immediately upon starting planning, create the plan file header for status bar detection.
Parse worktree choice from arguments:
Look for --worktree=yes or --worktree=no at the end of the arguments
Strip the --worktree=... flag from the task description
Default to Yes if no flag is present (backward compatibility)
This tells the statusline which plan belongs to THIS session. Without it, parallel sessions show the wrong plan.
Why this matters:
Status bar shows "Spec: [/plan]" immediately
User sees progress even during exploration phase
Plan file exists for continuation if session clears
Plan is correctly associated with this specific terminal
CRITICAL: Do this FIRST, before any exploration or questions.
User
WARNING: DO NOT use the built-in ExitPlanMode or EnterPlanMode tools.
Using AskUserQuestion - Core Planning Tool
Questions are grouped into batches for smooth user experience:
Batch
When
Purpose
Batch 1
Phase 0 (before exploration)
Clarify task, scope, priorities
Batch 2
Phase 2 (after exploration)
Architecture choices, design decisions
When to Use AskUserQuestion:
Situation
Example Question
Unclear requirements
"Should this feature support batch processing or single items only?"
Multiple valid approaches
Present 2-3 options with trade-offs for user to choose
Ambiguous scope
"Should we include error recovery, or fail fast?"
Technology choices
"Prefer async/await or callbacks for this integration?"
Priority decisions
"Performance or simplicity - which matters more here?"
Missing domain knowledge
"How does the existing auth flow work in production?"
Questioning philosophy — Dream extraction, not requirements gathering:
Start open, then narrow — Begin with "What does success look like?" before diving into specifics
Follow energy — If the user is excited about a detail, explore it; if they're vague, they may not care about the specifics
Challenge vagueness — "Fast" means what? Sub-100ms? Under 2 seconds? Make abstract concrete
Present interpretations as options — "I think you mean X — should we do X (simple, covers 80%) or Y (comprehensive, handles edge cases)?" is better than "What do you want?"
Anti-patterns to avoid:
Checklist walking — Don't ask every possible question; focus on genuine ambiguities
Canned questions — Adapt questions to the specific task, not generic templates
User
⛔ KEY CONSTRAINTS (Rules Summary)
#
Rule
1
NO sub-agents during planning - Use direct tools only. Exception: Step 1.7 launches plan-verifier + plan-challenger via the Task tool (subagent_type="pilot:plan-verifier" and "pilot:plan-challenger").
2
NEVER SKIP verification - Plan verification (Step 1.7) is 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
Quality over speed - Never rush due to context pressure
10
Plan file is source of truth - Survives session clears
The Sonatype Guide plugin is enabled in your user settings (enabledPlugins) but its required environment variable isn't set. Either:
Set SONATYPE_GUIDE_TOKEN in your shell profile or in settings.json env
Or disable the plugin if you don't use it by setting "sonatype-guide@claude-plugins-official": false in settings
4. High write ratio debug spam
The repeated High write ratio messages in the debug log are a rendering optimization warning — not an error. It means the terminal is doing more full writes than incremental blits, likely because of the small terminal size (18x78). Harmless noise.
The biggest actionable item is #1 — the 608KB settings.local.json. It's not causing crashes, but it's unnecessary bloat that Claude Code has to parse on every startup. Would you like me to clean it up?
Status-Based Flow
code
PENDING (Not Approved) → spec-plan → User approves
PENDING (Approved) → spec-implement → All tasks done → COMPLETE
COMPLETE → spec-verify → All checks pass → VERIFIED
VERIFIED → Done!
/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: Refine implementation with lasting solutions.
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)
ARGUMENTS: Refine implementation with lasting solutions.
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?
Phase 0 (before exploration)
Clarify task, scope, priorities
Batch 2
Phase 2 (after exploration)
Architecture choices, design decisions
When to Use AskUserQuestion:
Situation
Example Question
Unclear requirements
"Should this feature support batch processing or single items only?"
Multiple valid approaches
Present 2-3 options with trade-offs for user to choose
Ambiguous scope
"Should we include error recovery, or fail fast?"
Technology choices
"Prefer async/await or callbacks for this integration?"
Priority decisions
"Performance or simplicity - which matters more here?"
Missing domain knowledge
"How does the existing auth flow work in production?"
Questioning philosophy — Dream extraction, not requirements gathering:
Start open, then narrow — Begin with "What does success look like?" before diving into specifics
Follow energy — If the user is excited about a detail, explore it; if they're vague, they may not care about the specifics
Challenge vagueness — "Fast" means what? Sub-100ms? Under 2 seconds? Make abstract concrete
Present interpretations as options — "I think you mean X — should we do X (simple, covers 80%) or Y (comprehensive, handles edge cases)?" is better than "What do you want?"
Anti-patterns to avoid:
Checklist walking — Don't ask every possible question; focus on genuine ambiguities
Canned questions — Adapt questions to the specific task, not generic templates
Shallow acceptance — Don't accept "it should work well" — ask what "well" means concretely
Interrogation — 1-2 focused questions are better than 4 vague ones
Key principles:
Present options, not open-ended questions when possible
Include trade-offs for each option
Batch related questions together — don't interrupt user flow
Don't proceed with assumptions — ASK
Scope guardrail — Questions clarify HOW to implement, not WHETHER to expand scope
Audience level, structure, examples needed, update frequency
Scope guardrail: Questions should clarify HOW to implement the task, not WHETHER to expand scope. If discussion surfaces new feature ideas, capture them as "Deferred Ideas" in the plan's Open Questions section — don't add them to scope.
Then gather clarifications if needed (Question Batch 1):
If gray areas exist, use AskUserQuestion to ask focused questions per area in a single interaction. Present your interpretation as options when possible — "Should the API return paginated results (recommended for large datasets) or all results at once?" is better than "How should the API handle large result sets?"
If the task is clear and unambiguous with no meaningful gray areas, skip directly to Step 1.3.
Step 1.3: Exploration
Explore the codebase systematically. Run explorations one at a time (sequentially, not in parallel).
🔧 Tools for Exploration
Tool
When to Use
Example
Context7
Library/framework docs
resolve-library-id(query="your question", libraryName="lib") then query-docs(libraryId, query)
Architecture - Project structure, entry points, how components connect
Similar Features - Existing patterns that relate to the task, what can be reused
Dependencies - Imports, modules, what will be impacted
Tests - Test infrastructure, existing patterns, available fixtures
For each area:
Document hypotheses (not conclusions)
Note full file paths for relevant code
Track questions that remain unanswered
After explorations complete:
Read each identified file to verify hypotheses
Build a complete mental model of current architecture
Identify integration points and potential risks
Note reusable patterns
Step 1.4: Design Decisions
Present findings and gather all design decisions (Question Batch 2).
Summarize what you found, then use AskUserQuestion with all decisions at once.
After user answers:
Incorporate their choices into the plan design
Proceed to Step 1.5 — the user will review the full plan at Step 1.8
Step 1.5: Implementation Planning
Task Granularity
Each task should be:
Independently testable — has its own tests that pass without other tasks being complete
Focused — touches 2-4 files max; more means it should be split
Verifiable — produces an observable result (test output, API response, UI change)
Split a task if it has multiple unrelated DoD criteria. Merge tasks if one can't be tested without the other. Don't create tasks for setup/boilerplate that have no standalone value — fold them into the first task that uses them.
For each task, populate:
Dependencies — Which tasks must complete first? Use None for tasks with no ordering requirements.
Verify — What concrete commands prove this task is done? Include test commands, build commands, or curl/CLI invocations. The implementation phase runs these after completing each task.
Task Structure:
markdown
### Task N: [Component Name]
**Objective:** [1-2 sentences describing what to build]
**Dependencies:** [None | Task X, Task Y — tasks that must complete before this one]
**Files:**
- Create: `exact/path/to/file.py`
- Modify: `exact/path/to/existing.py`
- Test: `tests/exact/path/to/test.py`
**Key Decisions / Notes:**
- [Technical approach or algorithm to use]
- [Which existing pattern to follow, with file:line reference]
- [Integration points with other tasks or existing code]
**Definition of Done:**
- [ ] All tests pass (unit, integration if applicable)
- [ ] No diagnostics errors (linting, type checking)
- [ ] [Task-specific criterion with observable outcome]
- [ ] [Task-specific criterion with observable outcome]
**Verify:**
- `uv run pytest tests/path/to/test.py -q` — task-specific tests pass
- [Additional verification command or check]
⚠️ DoD criteria must be verifiable. The verification phase checks each criterion against the actual code and running program. Replace the [Task-specific criterion] placeholders with criteria that can be checked with a specific test, command, or observation.
✅ Good DoD examples:
"GET /api/users?role=admin returns only admin users"
"Form shows validation error when email field is empty"
"CLI exits with code 1 and prints usage when no arguments given"
"Retry logic attempts 3 times with exponential backoff before failing"
❌ Bad DoD (never use these):
"Feature works correctly"
"Edge cases handled appropriately"
"Error messages are clear and actionable"
Zero-context assumption:
Assume implementer knows nothing about codebase
Provide exact file paths
Explain domain concepts
List integration points
Reference similar patterns in codebase
Step 1.6: Write Full Plan
Save plan to:docs/plans/YYYY-MM-DD-<feature-name>.md
Required plan template:
markdown
# [Feature Name] Implementation Plan
Created: [Date]
Status: PENDING
Approved: No
Iterations: 0
Worktree: Yes
> **Status Lifecycle:** PENDING → COMPLETE → VERIFIED
> **Iterations:** Tracks implement→verify cycles (incremented by verify phase)
>
> - PENDING: Initial state, awaiting implementation
> - COMPLETE: All tasks implemented
> - VERIFIED: All checks passed
>
> **Approval Gate:** Implementation CANNOT proceed until `Approved: Yes`
> **Worktree:** Set at plan creation (from dispatcher). `Yes` uses git worktree isolation; `No` works directly on current branch
## Summary
**Goal:** [One sentence describing what this builds]
**Architecture:** [2-3 sentences about chosen approach]
**Tech Stack:** [Key technologies/libraries]
## Scope
### In Scope
- [What WILL be changed/built]
- [Specific components affected]
### Out of Scope
- [What will NOT be changed]
- [Explicit boundaries]
## Prerequisites
- [Any requirements before starting]
- [Dependencies that must exist]
- [Environment setup needed]
## Context for Implementer
> This section is critical for cross-session continuity. Write it for an implementer who has never seen the codebase.
- **Patterns to follow:** [Reference existing file:line that demonstrates the pattern, e.g., "Follow the route handler pattern in `src/routes/users.ts:45`"]
- **Conventions:** [Naming, file organization, error handling approach used in this project]
- **Key files:** [Important files the implementer must read first, with brief description of each]
- **Gotchas:** [Non-obvious dependencies, quirks, things that look wrong but are intentional]
- **Domain context:** [Business logic or domain concepts needed to understand the task]
## Runtime Environment (if applicable)
> Include this section when the project has a running service, API, or UI.
> Delete if the project is a library or CLI tool with no long-running process.
- **Start command:** [How to start the service, e.g., `bun worker-service.cjs`]
- **Port:** [What port it listens on]
- **Deploy path:** [Where built artifacts are installed, if different from source]
- **Health check:** [How to verify the service is running, e.g., `curl http://localhost:PORT/health`]
- **Restart procedure:** [How to restart after code changes]
## Feature Inventory (FOR MIGRATION/REFACTORING ONLY)
> **Include this section when replacing existing code. Delete if not applicable.**
### Files Being Replaced
| Old File | Functions/Classes | Mapped to Task |
| -------------- | ---------------------- | -------------- |
| `old/file1.py` | `func_a()`, `func_b()` | Task 3 |
| `old/file2.py` | `ClassX`, `func_c()` | Task 4, Task 5 |
### Feature Mapping Verification
- [ ] All old files listed above
- [ ] All functions/classes identified
- [ ] Every feature has a task number
- [ ] No features accidentally omitted
**⚠️ If any feature shows "❌ MISSING", add a task before implementation!**
## Progress Tracking
**MANDATORY: Update this checklist as tasks complete. Change `[ ]` to `[x]`.**
- [ ] Task 1: [Brief summary]
- [ ] Task 2: [Brief summary]
- [ ] ...
**Total Tasks:** [Number] | **Completed:** 0 | **Remaining:** [Number]
## Implementation Tasks
### Task 1: [Component Name]
**Objective:** ...
**Dependencies:** None
**Files:** ...
**Key Decisions / Notes:** ...
**Definition of Done:** ...
**Verify:** [Concrete commands to verify this task]
### Task 2: [Component Name]
**Objective:** ...
**Dependencies:** Task 1
**Files:** ...
**Key Decisions / Notes:** ...
**Definition of Done:** ...
**Verify:** [Concrete commands to verify this task]
## Testing Strategy
- Unit tests: [What to test in isolation]
- Integration tests: [What to test together]
- Manual verification: [Steps to verify manually]
## Risks and Mitigations
> Consider: breaking changes, backward compatibility, data loss/migration, performance regression, security implications, state management complexity, cross-component coupling, external dependency failures.
| Risk | Likelihood | Impact | Mitigation |
| -------- | ------------ | ------------ | ------------------------------------ |
| [Risk 1] | Low/Med/High | Low/Med/High | [Concrete, implementable mitigation] |
**⚠️ Risk mitigations are commitments.** The verification phase (spec-reviewer-compliance) will check that every mitigation listed here is actually implemented in code. Write mitigations as concrete, implementable behaviors, not vague statements.
✅ Good: "If selected project not in available list, reset to null (All Projects)"
❌ Bad: "Handle edge cases appropriately"
## Open Questions
- [Any remaining questions for the user]
- [Decisions deferred to implementation]
### Deferred Ideas
- [Ideas surfaced during discussion that are out of scope for this plan]
Step 1.7: Plan Verification
⛔ THIS STEP IS NON-NEGOTIABLE. You MUST run plan verification before asking for approval.
Before presenting the plan to the user, verify it with TWO dedicated reviewer agents running in parallel. This provides both alignment checking (plan-verifier) and adversarial review (plan-challenger) BEFORE the user sees the plan.
Resolve Session Path for Findings Persistence
bash
echo $PILOT_SESSION_ID
Define output paths (replace <session-id> with the resolved value):
⛔ CRITICAL: You MUST send BOTH Task calls in a SINGLE message. Set run_in_background=true on both so they run in parallel. If you send them in separate messages, the first blocks and the second waits — defeating the purpose.
Agent 1: plan-verifier (alignment and completeness)
code
Task(
subagent_type="pilot:plan-verifier",
run_in_background=true,
prompt="""
**Plan file:** <plan-path>
**User request:** <original task description from user>
**Clarifications:** <any Q&A that clarified requirements>
**Output path:** <absolute path to findings-plan-verifier.json>
Verify this plan correctly captures the user's requirements.
Check for missing features, scope issues, and ambiguities.
**IMPORTANT:** Write your final findings JSON to the output_path using the Write tool.
"""
)
Agent 2: plan-challenger (adversarial review)
code
Task(
subagent_type="pilot:plan-challenger",
run_in_background=true,
prompt="""
**Plan file:** <plan-path>
**User request:** <original task description from user>
**Clarifications:** <any Q&A that clarified requirements>
**Output path:** <absolute path to findings-plan-challenger.json>
Challenge this plan from an adversarial perspective.
Find untested assumptions, missing failure modes, and hidden dependencies.
**IMPORTANT:** Write your final findings JSON to the output_path using the Write tool.
"""
)
The verifiers work in parallel:
plan-verifier: Reviews plan against original user request, checks if clarification answers are incorporated, identifies missing requirements or scope issues
Both agents persist their findings JSON to the session directory for reliable retrieval.
Collect and Fix Findings (Progressive)
⛔ NEVER use TaskOutput to retrieve agent results. TaskOutput dumps the full verbose agent transcript (all JSON messages, hook progress, tool calls) into context, wasting thousands of tokens. Instead, poll the output files with the Read tool.
Progressive polling — fix findings as each agent completes:
Attempt to read BOTH findings files using the Read tool on the paths defined above
If one file exists but the other doesn't → start fixing findings from the ready agent immediately (by severity: must_fix → should_fix → suggestion). Track which findings you fixed.
After fixing the first batch, poll for the second file (retry if not yet ready)
If a file is still missing after 2-3 retries, re-launch that specific agent synchronously (without run_in_background) with the same prompt
When the second file is ready, skip findings that overlap with already-fixed items from the first batch (same file + same issue), then fix the remaining findings
If both files are ready simultaneously, deduplicate first (keep higher severity for duplicates on same file + line), then fix all
Severity actions:
Severity
Action
must_fix
Fix immediately - update plan before proceeding
should_fix
Fix immediately - update plan before proceeding
suggestion
Incorporate if reasonable, or note in Open Questions
Only proceed to Step 1.8 after all must_fix and should_fix issues are resolved.
Step 1.8: Get User Approval
⛔ MANDATORY APPROVAL GATE - This is NON-NEGOTIABLE
After saving plan:
Summarize the plan - Provide a brief overview of:
What will be built (goal)
Key tasks (numbered list)
Tech stack / approach
Use AskUserQuestion to request approval:
code
Question: "Do you approve this plan for implementation?"
Header: "Plan Review"
Options:
- "Yes, proceed with implementation" - I've reviewed the plan and it looks good
- "No, I need to make changes" - I want to edit the plan first
Note: The Worktree: field was already set at plan creation time (Step 1.1) based on the user's choice from the dispatcher. It does NOT need to be asked again here.
Based on user response:
If user approves (selects "Yes" or any approval option):
Update Approved: No → Approved: Yes in the plan file
⛔ Phase Transition Context Guard: Run ~/.pilot/bin/pilot check-context --json. If >= 80%, hand off instead (see spec.md Section 0.3).
Tell user: "Please edit the plan file at <plan-path>, then say 'ready' when done"
Wait for user to confirm they're done editing
Re-read the plan file to see their changes
Ask for approval again using AskUserQuestion
If user provides OTHER feedback (corrections, config values, clarifications):
This is NOT approval - they're giving you changes to incorporate
Update the plan with their feedback
Ask for approval AGAIN with a fresh AskUserQuestion
DO NOT proceed to implementation until user explicitly selects "Yes, proceed"
⚠️ CRITICAL: Any response other than selecting "Yes, proceed with implementation" is NOT approval. Config feedback, threshold changes, clarifications = update plan, then re-ask.
⚠️ CRITICAL: Claude handles the Approved: field update - user never edits it manually
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
**Current Task:** [description of where you are in planning]
**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>
ARGUMENTS: Refine implementation with lasting solutions. --worktree=yes
resolve-library-id(query="your question", libraryName="lib") then query-docs(libraryId, query)
Architecture - Project structure, entry points, how components connect
Similar Features - Existing patterns that relate to the task, what can be reused
Dependencies - Imports, modules, what will be impacted
Tests - Test infrastructure, existing patterns, available fixtures
For each area:
Document hypotheses (not conclusions)
Note full file paths for relevant code
Track questions that remain unanswered
After explorations complete:
Read each identified file to verify hypotheses
Build a complete mental model of current architecture
Identify integration points and potential risks
Note reusable patterns
Step 1.4: Design Decisions
Present findings and gather all design decisions (Question Batch 2).
Summarize what you found, then use AskUserQuestion with all decisions at once.
After user answers:
Incorporate their choices into the plan design
Proceed to Step 1.5 — the user will review the full plan at Step 1.8
Step 1.5: Implementation Planning
Task Granularity
Each task should be:
Independently testable — has its own tests that pass without other tasks being complete
Focused — touches 2-4 files max; more means it should be split
Verifiable — produces an observable result (test output, API response, UI change)
Split a task if it has multiple unrelated DoD criteria. Merge tasks if one can't be tested without the other. Don't create tasks for setup/boilerplate that have no standalone value — fold them into the first task that uses them.
For each task, populate:
Dependencies — Which tasks must complete first? Use None for tasks with no ordering requirements.
Verify — What concrete commands prove this task is done? Include test commands, build commands, or curl/CLI invocations. The implementation phase runs these after completing each task.
Task Structure:
markdown
### Task N: [Component Name]
**Objective:** [1-2 sentences describing what to build]
**Dependencies:** [None | Task X, Task Y — tasks that must complete before this one]
**Files:**
- Create: `exact/path/to/file.py`
- Modify: `exact/path/to/existing.py`
- Test: `tests/exact/path/to/test.py`
**Key Decisions / Notes:**
- [Technical approach or algorithm to use]
- [Which existing pattern to follow, with file:line reference]
- [Integration points with other tasks or existing code]
**Definition of Done:**
- [ ] All tests pass (unit, integration if applicable)
- [ ] No diagnostics errors (linting, type checking)
- [ ] [Task-specific criterion with observable outcome]
- [ ] [Task-specific criterion with observable outcome]
**Verify:**
- `uv run pytest tests/path/to/test.py -q` — task-specific tests pass
- [Additional verification command or check]
⚠️ DoD criteria must be verifiable. The verification phase checks each criterion against the actual code and running program. Replace the [Task-specific criterion] placeholders with criteria that can be checked with a specific test, command, or observation.
✅ Good DoD examples:
"GET /api/users?role=admin returns only admin users"
"Form shows validation error when email field is empty"
"CLI exits with code 1 and prints usage when no arguments given"
"Retry logic attempts 3 times with exponential backoff before failing"
❌ Bad DoD (never use these):
"Feature works correctly"
"Edge cases handled appropriately"
"Error messages are clear and actionable"
Zero-context assumption:
Assume implementer knows nothing about codebase
Provide exact file paths
Explain domain concepts
List integration points
Reference similar patterns in codebase
Step 1.6: Write Full Plan
Save plan to:docs/plans/YYYY-MM-DD-<feature-name>.md
Required plan template:
markdown
# [Feature Name] Implementation Plan
Created: [Date]
Status: PENDING
Approved: No
Iterations: 0
Worktree: Yes
> **Status Lifecycle:** PENDING → COMPLETE → VERIFIED
> **Iterations:** Tracks implement→verify cycles (incremented by verify phase)
>
> - PENDING: Initial state, awaiting implementation
> - COMPLETE: All tasks implemented
> - VERIFIED: All checks passed
>
> **Approval Gate:** Implementation CANNOT proceed until `Approved: Yes`
> **Worktree:** Set at plan creation (from dispatcher). `Yes` uses git worktree isolation; `No` works directly on current branch
## Summary
**Goal:** [One sentence describing what this builds]
**Architecture:** [2-3 sentences about chosen approach]
**Tech Stack:** [Key technologies/libraries]
## Scope
### In Scope
- [What WILL be changed/built]
- [Specific components affected]
### Out of Scope
- [What will NOT be changed]
- [Explicit boundaries]
## Prerequisites
- [Any requirements before starting]
- [Dependencies that must exist]
- [Environment setup needed]
## Context for Implementer
> This section is critical for cross-session continuity. Write it for an implementer who has never seen the codebase.
- **Patterns to follow:** [Reference existing file:line that demonstrates the pattern, e.g., "Follow the route handler pattern in `src/routes/users.ts:45`"]
- **Conventions:** [Naming, file organization, error handling approach used in this project]
- **Key files:** [Important files the implementer must read first, with brief description of each]
- **Gotchas:** [Non-obvious dependencies, quirks, things that look wrong but are intentional]
- **Domain context:** [Business logic or domain concepts needed to understand the task]
## Runtime Environment (if applicable)
> Include this section when the project has a running service, API, or UI.
> Delete if the project is a library or CLI tool with no long-running process.
- **Start command:** [How to start the service, e.g., `bun worker-service.cjs`]
- **Port:** [What port it listens on]
- **Deploy path:** [Where built artifacts are installed, if different from source]
- **Health check:** [How to verify the service is running, e.g., `curl http://localhost:PORT/health`]
- **Restart procedure:** [How to restart after code changes]
## Feature Inventory (FOR MIGRATION/REFACTORING ONLY)
> **Include this section when replacing existing code. Delete if not applicable.**
### Files Being Replaced
| Old File | Functions/Classes | Mapped to Task |
| -------------- | ---------------------- | -------------- |
| `old/file1.py` | `func_a()`, `func_b()` | Task 3 |
| `old/file2.py` | `ClassX`, `func_c()` | Task 4, Task 5 |
### Feature Mapping Verification
- [ ] All old files listed above
- [ ] All functions/classes identified
- [ ] Every feature has a task number
- [ ] No features accidentally omitted
**⚠️ If any feature shows "❌ MISSING", add a task before implementation!**
## Progress Tracking
**MANDATORY: Update this checklist as tasks complete. Change `[ ]` to `[x]`.**
- [ ] Task 1: [Brief summary]
- [ ] Task 2: [Brief summary]
- [ ] ...
**Total Tasks:** [Number] | **Completed:** 0 | **Remaining:** [Number]
## Implementation Tasks
### Task 1: [Component Name]
**Objective:** ...
**Dependencies:** None
**Files:** ...
**Key Decisions / Notes:** ...
**Definition of Done:** ...
**Verify:** [Concrete commands to verify this task]
### Task 2: [Component Name]
**Objective:** ...
**Dependencies:** Task 1
**Files:** ...
**Key Decisions / Notes:** ...
**Definition of Done:** ...
**Verify:** [Concrete commands to verify this task]
## Testing Strategy
- Unit tests: [What to test in isolation]
- Integration tests: [What to test together]
- Manual verification: [Steps to verify manually]
## Risks and Mitigations
> Consider: breaking changes, backward compatibility, data loss/migration, performance regression, security implications, state management complexity, cross-component coupling, external dependency failures.
| Risk | Likelihood | Impact | Mitigation |
| -------- | ------------ | ------------ | ------------------------------------ |
| [Risk 1] | Low/Med/High | Low/Med/High | [Concrete, implementable mitigation] |
**⚠️ Risk mitigations are commitments.** The verification phase (spec-reviewer-compliance) will check that every mitigation listed here is actually implemented in code. Write mitigations as concrete, implementable behaviors, not vague statements.
✅ Good: "If selected project not in available list, reset to null (All Projects)"
❌ Bad: "Handle edge cases appropriately"
## Open Questions
- [Any remaining questions for the user]
- [Decisions deferred to implementation]
### Deferred Ideas
- [Ideas surfaced during discussion that are out of scope for this plan]
Step 1.7: Plan Verification
⛔ THIS STEP IS NON-NEGOTIABLE. You MUST run plan verification before asking for approval.
Before presenting the plan to the user, verify it with TWO dedicated reviewer agents running in parallel. This provides both alignment checking (plan-verifier) and adversarial review (plan-challenger) BEFORE the user sees the plan.
Resolve Session Path for Findings Persistence
bash
echo $PILOT_SESSION_ID
Define output paths (replace <session-id> with the resolved value):
⛔ CRITICAL: You MUST send BOTH Task calls in a SINGLE message. Set run_in_background=true on both so they run in parallel. If you send them in separate messages, the first blocks and the second waits — defeating the purpose.
Agent 1: plan-verifier (alignment and completeness)
code
Task(
subagent_type="pilot:plan-verifier",
run_in_background=true,
prompt="""
**Plan file:** <plan-path>
**User request:** <original task description from user>
**Clarifications:** <any Q&A that clarified requirements>
**Output path:** <absolute path to findings-plan-verifier.json>
Verify this plan correctly captures the user's requirements.
Check for missing features, scope issues, and ambiguities.
**IMPORTANT:** Write your final findings JSON to the output_path using the Write tool.
"""
)
Agent 2: plan-challenger (adversarial review)
code
Task(
subagent_type="pilot:plan-challenger",
run_in_background=true,
prompt="""
**Plan file:** <plan-path>
**User request:** <original task description from user>
**Clarifications:** <any Q&A that clarified requirements>
**Output path:** <absolute path to findings-plan-challenger.json>
Challenge this plan from an adversarial perspective.
Find untested assumptions, missing failure modes, and hidden dependencies.
**IMPORTANT:** Write your final findings JSON to the output_path using the Write tool.
"""
)
The verifiers work in parallel:
plan-verifier: Reviews plan against original user request, checks if clarification answers are incorporated, identifies missing requirements or scope issues
Both agents persist their findings JSON to the session directory for reliable retrieval.
Collect and Fix Findings (Progressive)
⛔ NEVER use TaskOutput to retrieve agent results. TaskOutput dumps the full verbose agent transcript (all JSON messages, hook progress, tool calls) into context, wasting thousands of tokens. Instead, poll the output files with the Read tool.
Progressive polling — fix findings as each agent completes:
Attempt to read BOTH findings files using the Read tool on the paths defined above
If one file exists but the other doesn't → start fixing findings from the ready agent immediately (by severity: must_fix → should_fix → suggestion). Track which findings you fixed.
After fixing the first batch, poll for the second file (retry if not yet ready)
If a file is still missing after 2-3 retries, re-launch that specific agent synchronously (without run_in_background) with the same prompt
When the second file is ready, skip findings that overlap with already-fixed items from the first batch (same file + same issue), then fix the remaining findings
If both files are ready simultaneously, deduplicate first (keep higher severity for duplicates on same file + line), then fix all
Severity actions:
Severity
Action
must_fix
Fix immediately - update plan before proceeding
should_fix
Fix immediately - update plan before proceeding
suggestion
Incorporate if reasonable, or note in Open Questions
Only proceed to Step 1.8 after all must_fix and should_fix issues are resolved.
Step 1.8: Get User Approval
⛔ MANDATORY APPROVAL GATE - This is NON-NEGOTIABLE
After saving plan:
Summarize the plan - Provide a brief overview of:
What will be built (goal)
Key tasks (numbered list)
Tech stack / approach
Use AskUserQuestion to request approval:
code
Question: "Do you approve this plan for implementation?"
Header: "Plan Review"
Options:
- "Yes, proceed with implementation" - I've reviewed the plan and it looks good
- "No, I need to make changes" - I want to edit the plan first
Note: The Worktree: field was already set at plan creation time (Step 1.1) based on the user's choice from the dispatcher. It does NOT need to be asked again here.
Based on user response:
If user approves (selects "Yes" or any approval option):
Update Approved: No → Approved: Yes in the plan file
⛔ Phase Transition Context Guard: Run ~/.pilot/bin/pilot check-context --json. If >= 80%, hand off instead (see spec.md Section 0.3).
Tell user: "Please edit the plan file at <plan-path>, then say 'ready' when done"
Wait for user to confirm they're done editing
Re-read the plan file to see their changes
Ask for approval again using AskUserQuestion
If user provides OTHER feedback (corrections, config values, clarifications):
This is NOT approval - they're giving you changes to incorporate
Update the plan with their feedback
Ask for approval AGAIN with a fresh AskUserQuestion
DO NOT proceed to implementation until user explicitly selects "Yes, proceed"
⚠️ CRITICAL: Any response other than selecting "Yes, proceed with implementation" is NOT approval. Config feedback, threshold changes, clarifications = update plan, then re-ask.
⚠️ CRITICAL: Claude handles the Approved: field update - user never edits it manually
Shallow acceptance — Don't accept "it should work well" — ask what "well" means concretely
Interrogation — 1-2 focused questions are better than 4 vague ones
Key principles:
Present options, not open-ended questions when possible
Include trade-offs for each option
Batch related questions together — don't interrupt user flow
Don't proceed with assumptions — ASK
Scope guardrail — Questions clarify HOW to implement, not WHETHER to expand scope