User describes a complex task
│
▼
Skill triggers → Claude creates .plan/ directory
│
▼
User confirms the plan (cannot be skipped)
│
▼
┌─── Work Loop ────────────────────────────────┐
│ │
│ UserPromptSubmit hook (when user sends msg) │
│ └─ If active phase → inject overview + spec │
│ + checklist │
│ │
│ PreToolUse hook (before all tool calls) │
│ └─ Inject overview.md (≤25 lines) │
│ │
│ Claude executes tool operations │
│ │
│ PostToolUse hook (after Write|Edit) │
│ └─ Remind to update checklist and overview │
│ │
│ Phase complete? │
│ ├─ No → Continue loop │
│ └─ Yes → Update current_phase, read new │
│ phase spec │
│ │
└───────────────────────────────────────────────┘
│
▼
Stop hook: Check all phase checkboxes
├─ All pending (awaiting confirmation) → exit 0 allow stop
├─ Partially complete → exit 2 block stop
└─ All complete → exit 0 allow stop
.plan/
├── overview.md ← Global summary (≤25 lines, repeatedly injected by hooks)
├── decisions.md ← All decision records
├── errors.md ← All error records
└── phases/
├── phase1_xxx/
│ ├── spec.md ← Detailed spec (≤60 lines)
│ ├── call_chain.md ← Call chain change diagram (optional)
│ └── checklist.md ← Item-by-item completion status
├── phase2_xxx/
│ └── ...
└── ...
| File | Role | Content | Update Timing |
|---|---|---|---|
| overview.md | Attention anchor | Goal + phase list + status | After each phase completes |
| spec.md | Work manual | File list, interfaces, data structures, acceptance criteria | At plan creation, when new requirements emerge |
| checklist.md | Progress tracker | Item-by-item checkboxes | After each subtask completes |
| call_chain.md | Architecture reference | Before/after call relationship comparison | At plan creation |
| decisions.md | Decision log | Decision, rationale, impact | After each important decision |
| errors.md | Error log | Error, attempt count, solution | After each error encountered |
Checks overview.md for active phases (DONE > 0 and DONE < TOTAL). If found, injects:
- overview.md full content
- Current phase spec.md full content
- Current phase checklist.md full content
Does NOT inject (exits silently) when:
.plan/does not exist (planning not enabled)- All phases are pending (awaiting user confirmation)
- All phases are complete
Injects overview.md full content (≤25 lines), maintaining goal and progress awareness.
Reminds to update checklist:
[hplan] File updated. If you completed a subtask in the current phase, please update the corresponding checklist.md and the progress in overview.md.
Calls check-complete.sh to check phase status in overview.md:
- All pending (DONE=0) → exit 0, allow stop to wait for user plan confirmation
- Partially complete (0 < DONE < TOTAL) → exit 2, block stop
- All complete → exit 0, allow stop
When a phase's checklist is fully checked:
- Update
checklist.md: all[ ]→[x] - Update
overview.md: mark the phase as[x] ... → complete - Update
overview.md: changecurrent_phaseto the next phase ID - Update next phase status to
in_progress - Record important findings from this phase in
decisions.md - Proactively read the new phase's spec.md and checklist.md
Run sh scripts/advance-phase.sh to assist with steps 2-4.
1st failure: Diagnose and fix → record in errors.md
2nd failure: Try a different approach → record in errors.md
3rd failure: Re-examine assumptions → update spec.md
After 3rd still failing: Explain the situation to user, request guidance
| Scenario | Action | Reason |
|---|---|---|
| Just wrote a file | Don't read | Content is still in context |
| Starting a new phase | Read spec.md + checklist.md | Fully understand work scope (cannot skip) |
| Before an important decision | Read overview.md + related spec | Ensure goal alignment |
| Encountered an error | Read errors.md | Avoid repeating failures |