--- description: "Create, review, and persist project plans. Captures Claude Code Plan Mode state and writes to git-trackable docs/PLAN.md." --- # Plan - Persistent Project Planning Create, review, and update project plans. Automatically captures Claude Code's internal Plan Mode state and persists to `docs/PLAN.md`. ## Why This Exists Claude Code's native Plan Mode (Shift+Tab) is powerful for exploration, but **the plan state doesn't persist**. When your session ends, the strategic thinking is lost. This command bridges that gap: - **Captures** any active Plan Mode context - **Persists** to `docs/PLAN.md` (git-trackable) - **Survives** across sessions and machines - **Pairs** with `/save` + `/load` for complete session continuity ## Arguments $ARGUMENTS - `` - Create/update plan for a goal - `--review` - Display current plan - `--status` - Update progress on steps - `--capture` - Capture conversation context only (no new planning) - `--sync` - Auto-update status from recent git commits - `--diff` - Show what changed since last plan update - `--clear` - Archive current plan and start fresh ## Default Behavior: Capture First **Every invocation of `/plan` attempts to capture internal state first.** ``` /plan │ ├─→ Step 0: Capture internal state (ALWAYS RUNS) │ ├─ Detect if Plan Mode was recently active │ ├─ Extract plan-related context from conversation │ ├─ Check for temp files (.claude/plan*, docs/PLAN.md) │ ├─ Gather git context (uncommitted changes, recent commits) │ └─ Merge into working state │ ├─→ Step 1: Check existing docs/PLAN.md │ └─ Load and parse if exists │ └─→ Step 2: Execute requested action ├─ Create new plan ├─ Update existing plan └─ Review/display plan ``` This ensures you never lose Plan Mode thinking, even if you forget to explicitly save. ## Execution Steps ### Step 0: Capture Internal State (Always) ```bash # Check for Plan Mode artifacts ls -la .claude/plan* docs/PLAN.md 2>/dev/null # Gather git context git status --short git diff --stat git log --oneline -5 # Check conversation for plan-related discussion # (Analyze recent messages for: goals, approaches, decisions, steps) ``` **Extract from conversation:** - Goal statements ("I want to...", "We need to...") - Approach discussions ("Option A vs B", "We could...") - Decisions made ("Let's go with...", "The best approach is...") - Steps identified ("First... then... finally...") - Open questions ("Should we...", "What about...") **Git context to capture:** - Uncommitted changes (files, insertions, deletions) - Recent commits that may relate to plan steps - Current branch and status ### Step 1: Check Existing docs/PLAN.md ```bash # Read existing plan if present cat docs/PLAN.md 2>/dev/null ``` Parse structure: - Current goal - Completed steps - In-progress steps - Pending steps - Blockers - Open questions - Decision log ### Step 2: Merge and Execute Combine: 1. Captured conversation context 2. Existing docs/PLAN.md content 3. Git context (uncommitted changes, recent commits) 4. New goal/instructions from command ### Step 3: Write docs/PLAN.md ```markdown # Project Plan **Goal**: **Created**: **Last Updated**: **Status**: In Progress | Complete | Blocked ## Context ## Approach ### Alternatives Considered - **Option A**: - - **Option B**: - ## Implementation Steps ### Completed - ✓ Step 1: [S] - Completed: - Commit: `abc123` - Notes: ### In Progress - ◐ Step 2: [M] - Started: - Depends on: Step 1 - Notes: ### Pending - ○ Step 3: [L] - Depends on: Step 2 - ○ Step 4: [S] ### Blocked - ⚠ Step 5: [M] - Blocker: - Waiting on: ## Uncommitted Changes ``` 📊 Working Tree Status: Modified: X files (+Y/-Z lines) Staged: X files Unstaged: X files Untracked: X files Files: • path/to/file.ts +89/-12 (staged) • path/to/other.ts +38/-33 (unstaged) ``` ## Decision Log | Date | Decision | Rationale | |------|----------|-----------| | | | | ## Blockers - ⚠ : - ⚠ : ## Open Questions - ○ - ○ ## Success Criteria - ○ - ○ ## Directory Structure ``` project/ ├── src/ │ ├── core/ # Core functionality │ └── features/ # Feature modules ├── tests/ ├── docs/ │ └── PLAN.md # This file └── config/ ``` ## Sources & References - [Official Documentation](https://example.com/docs) - [API Reference](https://example.com/api) - [Related RFC/Spec](https://example.com/spec) ## Notes --- *Plan managed by `/plan` command. Last captured: * ``` ## Status Markers | Marker | Meaning | Usage | |--------|---------|-------| | ✓ | Completed | Task finished successfully | | ◐ | In Progress | Currently being worked on | | ○ | Pending | Not yet started | | ⚠ | Blocked | Cannot proceed, needs resolution | ## Effort Indicators | Tag | Meaning | Guidance | |-----|---------|----------| | `[S]` | Small | Quick task, minimal complexity | | `[M]` | Medium | Moderate effort, some complexity | | `[L]` | Large | Significant effort, high complexity | Effort is relative to the project, not absolute time. Avoid time estimates. ## Usage Examples ```bash # Create new plan (captures any Plan Mode context first) /plan "Add user authentication with OAuth2" # Just capture current conversation to plan (no new analysis) /plan --capture # Review current plan /plan --review # Update progress on steps /plan --status # Sync status from recent git commits /plan --sync # Show what changed since last update /plan --diff # Start fresh (archives old plan) /plan --clear "New feature: payment processing" ``` ## Workflow Integration ### With Native Plan Mode ``` 1. [Shift+Tab] Enter Plan Mode 2. [Explore codebase, discuss approaches] 3. /plan --capture # Persist the thinking 4. [Shift+Tab] Exit Plan Mode 5. [Implement] 6. /plan --status # Update progress ``` ### With /save + /load ``` Session 1: /plan "Feature X" # Strategic planning → docs/PLAN.md [work on implementation] /save "Completed step 2" # Tactical state → claude-state.json Session 2: /load # Restore TodoWrite tasks /plan --review # See the strategy [continue work] /plan --status # Update plan progress /save "Completed step 3" ``` ### Complete Session Continuity | Command | Captures | Persists To | |---------|----------|-------------| | `/plan` | Strategic thinking, decisions | `docs/PLAN.md` | | `/save` | TodoWrite tasks, git context | `.claude/claude-state.json` | | `/load` | - | Restores from `.claude/` | ## Flags | Flag | Effect | |------|--------| | `--review` | Display current plan without modifications | | `--status` | Interactive update of step progress | | `--capture` | Only capture conversation context, no new planning | | `--sync` | Auto-update step status from recent git commits | | `--diff` | Show what changed since last plan update | | `--clear` | Archive current plan to `docs/PLAN-.md` and start fresh | | `--verbose` | Show detailed capture/merge process | ## Output ``` 🔍 Capturing internal state... ✓ Plan Mode context detected (8 relevant messages) ✓ Existing docs/PLAN.md found (3 steps complete) ✓ Git context captured ✗ No temp plan files 📊 Uncommitted Changes: Modified: 2 files (+127/-45) • src/auth.ts +89/-12 • tests/auth.test.ts +38/-33 📋 Merging sources... → Goal: "Add user authentication with OAuth2" → Approach: JWT tokens with refresh rotation → Progress: 3 complete, 1 in progress, 2 pending 📝 Updated docs/PLAN.md Summary: ✓ Completed: 3 steps ◐ In Progress: 1 step ○ Pending: 2 steps ⚠ Blocked: 0 steps ? Open questions: 2 📋 Decisions: 4 logged Review with: /plan --review ``` ## Notes - Always captures internal state first—you can't lose Plan Mode thinking - Archives old plans when using `--clear` (never destructive) - Works across machines if docs/PLAN.md is committed - Pairs with `/save` + `/load` for complete session continuity - Human-readable format works without Claude Code - Git context helps track what's changed since last session - Effort indicators are relative, not time-based