Planning
Harness note. The plan is written with the Linear MCP (save_issue — Claude Code tool id mcp__plugin_linear_linear__save_issue). In Codex or Cursor without that server, print the finished plan in chat as one fenced markdown block and name the issue it belongs on. Never write a plan file into the repo (D4); docs/plans/ is gone and file-guard.sh warns after a write there (PostToolUse — it does not refuse).
Role
Create a detailed implementation plan: file paths, tasks, verify steps. Runs inline in the main thread — does NOT dispatch a subagent.
Initial issue (from invocation)
If $issue-id is provided (MXR-12), that issue is the plan's home. Otherwise derive it from the conversation or ask. get_issue + list_comments first: the description is the spec (D0), and a decision comment newer than the description wins.
When to use
- A spec exists in the issue (from
brainstorm, or written by the user) and the human has approved it in conversation.
- Or the task is clear enough and the user requests a plan directly.
W2: plan only when the work spans several commits or sessions, or the user asks. A one-commit task needs no plan — do it.
DO NOT use if WHAT/WHY is still unclear → go back to brainstorm first.
Workflow
- Read context:
get_issue the issue → the spec. list_comments → decisions that amend it.
- Search and read related files to verify current state.
- Clarify (only if needed): if the objective is ambiguous AND a wrong interpretation would produce a significantly different plan → state the assumption and ask ONE question.
- Choose the shape, by size:
- ≤ 6 tasks, one session → one
## Plan section in the issue description.
- Larger, or several sessions / people → one sub-issue per task (
save_issue { team, parentId: <issue>, title: "Task N: …", description }), plus a short ## Plan in the parent that lists them in order. A sub-issue holds exactly the Task block below.
- Write the plan. Show the full text in chat first (D14), then:
- Description has no
## Plan → save_issue { id, patch: [{ op: "append", text: "\n\n## Plan\n…" }] }.
- Description already has
## Plan → patch with replace_range from ## Plan to the next ## heading (or replace of the whole section). Rewrite in place; never leave two plans in one description.
- Self-review inline (no subagent).
get_issue again and re-read what Linear holds:
- Spec coverage: every Failure Mode + Done criterion in the spec must map to a task. List gaps if any.
- Placeholder scan: see the "No Placeholders" section below — no red flags allowed.
- Type consistency: function/method/property names used in later tasks must match earlier tasks.
clearLayers() in Task 3 but clearAllLayers() in Task 7 → bug.
- Fix inline with another
patch. No re-review needed.
- Hard gate: STOP. Present the issue URL + scope summary. Ask: "Approve this plan?". WAIT for user response — DO NOT auto-advance.
- After user approves → suggest
→ Next: plan-review (or /review <issue-id>).
Plan format
Constraints
- The plan body and section headings MUST be written in Vietnamese, independent of the active Output Style. Use English only for: file paths, commands, symbols, framework/library names.
- Inside an issue description the plan starts at
## Plan; its sections are ###. In a sub-issue the Task block is the whole description and starts at ## Task N: ….
- NO markdown tables, NO emoji, NO full code (shapes/key interfaces only).
- File paths are plain backticked repo-relative paths (
src/auth/session.ts) — a Linear description has no repo to resolve a relative link against.
- Each task is 2–10 minutes. A task touching > 3 files or > 2 concerns → split it.
- Checkboxes (
- [ ]) on tasks, so progress is visible in the issue.
Template
## Plan
**Goal**: {1 câu mô tả plan này build cái gì}
**Architecture**: {2-3 câu về approach kỹ thuật chính}
### 1. Kết quả mong đợi
{Trạng thái cuối cần đạt. Mỗi item phải verifiable bằng test/command/check cụ thể.}
- {outcome 1} — verify bằng `{command hoặc test name}`
- {outcome 2} — verify bằng `{command hoặc test name}`
### 2. Nguồn dữ liệu chuẩn
**Canonical data**: {data nào là nguồn gốc, lấy từ đâu}
**Lấy từ**: {nguồn được phép}
**KHÔNG lấy từ**: {nguồn bị cấm và lý do ngắn gọn}
### 3. Business rules & invariants
- **{Tên rule}**: {mô tả rule} — verify bằng `{cách kiểm tra}`
- **{Tên invariant}**: {guarantee kỹ thuật} — verify bằng `{cách kiểm tra}`
### 4. Phạm vi / Ngoài phạm vi
**Làm**:
- {việc cụ thể 1}
- {việc cụ thể 2}
**KHÔNG làm**:
- {việc cụ thể bị loại trừ 1}
- {việc cụ thể bị loại trừ 2}
<!-- Section 5 chỉ thêm khi có ≥3 open decisions HOẶC plan dự kiến >500 dòng -->
### 5. Rủi ro & Quyết định còn mở
**Đã chốt có rủi ro**:
- {decision đã chốt} — rủi ro: {consequence cụ thể}
**Chưa chốt cần resolve**:
- {câu hỏi cần trả lời trước khi implement}
### 6. Các task
- [ ] **Task 1: {tên task}**
**File(s)**:
- `path/to/exact-file.ts`
- `path/to/new-file.ts`
**Phụ thuộc**: Task X (chỉ thêm field này khi thực sự có dependency)
**Decision**: {WHAT đã chốt — không viết WHY ở đây}
**Build**:
- {action cụ thể 1}
- {action cụ thể 2}
**Verify**:
- `{command}` → output `{expected}`
- test `{test name}` pass
- [ ] **Task 2: …**
Field rules
Decision: WHAT only. WHY belongs in section 5 "Rủi ro & Quyết định còn mở".
Verify: MUST reference a test name / command output / specific file check — never vague.
Phụ thuộc: optional. Add only when the task genuinely depends on another task finishing first. Otherwise omit the field. For sub-issues, also set blockedBy on the sub-issue so Linear shows the order.
No Placeholders
The plan MUST NOT contain any of these patterns — they are plan failures, fix inline before the Hard gate:
TBD, TODO, "fill in later", "implement later"
- "Add appropriate error handling" / "add validation" / "handle edge cases" — must specify which error, what to validate
- "Write tests for the above" — no concrete test name
- "Similar to Task N" — repeat the content, the engineer may read tasks out of order
- Vague verify: "test it works", "check output looks right" — must give command + expected output
- Reference to a symbol/function/file not defined by any task in the plan
While executing
Tick the checkbox of each task as it lands (patch replace - [ ] **Task N → - [x] **Task N), or move the sub-issue's state. The issue is the progress record; do not keep a parallel checklist anywhere else.
1---2name: planning3description: Turn an approved spec (the Linear issue's description) into an implementation plan — a `## Plan` checklist in the issue for small work, sub-issues for work that spans several commits or sessions. Use after "what to build" is clear. Trigger phrases - "plan this", "break into tasks". Not for vague requests - go back to `brainstorm` first.4---56# Planning78> **Harness note.** The plan is written with the Linear MCP (`save_issue` — Claude Code tool id `mcp__plugin_linear_linear__save_issue`). In Codex or Cursor without that server, print the finished plan in chat as one fenced markdown block and name the issue it belongs on. **Never write a plan file into the repo** (D4); `docs/plans/` is gone and `file-guard.sh` warns after a write there (PostToolUse — it does not refuse).910## Role1112Create a detailed implementation plan: file paths, tasks, verify steps. Runs inline in the main thread — does NOT dispatch a subagent.1314## Initial issue (from invocation)1516If `$issue-id` is provided (`MXR-12`), that issue is the plan's home. Otherwise derive it from the conversation or ask. `get_issue` + `list_comments` first: the description is the spec (D0), and a decision comment newer than the description wins.1718## When to use1920- A spec exists in the issue (from `brainstorm`, or written by the user) and the human has approved it in conversation.21- Or the task is clear enough and the user requests a plan directly.2223W2: plan only when the work spans several commits or sessions, or the user asks. A one-commit task needs no plan — do it.2425DO NOT use if WHAT/WHY is still unclear → go back to `brainstorm` first.2627## Workflow28291. **Read context**:30 - `get_issue` the issue → the spec. `list_comments` → decisions that amend it.31 - Search and read related files to verify current state.322. **Clarify** (only if needed): if the objective is ambiguous AND a wrong interpretation would produce a significantly different plan → state the assumption and ask ONE question.333. **Choose the shape**, by size:34 - **≤ 6 tasks, one session** → one `## Plan` section in the issue description.35 - **Larger, or several sessions / people** → one sub-issue per task (`save_issue { team, parentId: <issue>, title: "Task N: …", description }`), plus a short `## Plan` in the parent that lists them in order. A sub-issue holds exactly the Task block below.364. **Write the plan**. Show the full text in chat first (D14), then:37 - Description has no `## Plan` → `save_issue { id, patch: [{ op: "append", text: "\n\n## Plan\n…" }] }`.38 - Description already has `## Plan` → `patch` with `replace_range` from `## Plan` to the next `## ` heading (or `replace` of the whole section). Rewrite in place; never leave two plans in one description.395. **Self-review inline** (no subagent). `get_issue` again and re-read what Linear holds:40 - **Spec coverage**: every Failure Mode + Done criterion in the spec must map to a task. List gaps if any.41 - **Placeholder scan**: see the "No Placeholders" section below — no red flags allowed.42 - **Type consistency**: function/method/property names used in later tasks must match earlier tasks. `clearLayers()` in Task 3 but `clearAllLayers()` in Task 7 → bug.43 - Fix inline with another `patch`. No re-review needed.446. **Hard gate**: STOP. Present the issue URL + scope summary. Ask: "Approve this plan?". WAIT for user response — DO NOT auto-advance.457. After user approves → suggest `→ Next: plan-review` (or `/review <issue-id>`).4647## Plan format4849### Constraints5051- The plan body and section headings MUST be written in **Vietnamese**, independent of the active Output Style. Use English only for: file paths, commands, symbols, framework/library names.52- Inside an issue description the plan starts at `## Plan`; its sections are `###`. In a sub-issue the Task block is the whole description and starts at `## Task N: …`.53- NO markdown tables, NO emoji, NO full code (shapes/key interfaces only).54- File paths are plain backticked repo-relative paths (`src/auth/session.ts`) — a Linear description has no repo to resolve a relative link against.55- Each task is 2–10 minutes. A task touching > 3 files or > 2 concerns → split it.56- Checkboxes (`- [ ]`) on tasks, so progress is visible in the issue.5758### Template5960```markdown61## Plan6263**Goal**: {1 câu mô tả plan này build cái gì}64**Architecture**: {2-3 câu về approach kỹ thuật chính}6566### 1. Kết quả mong đợi6768{Trạng thái cuối cần đạt. Mỗi item phải verifiable bằng test/command/check cụ thể.}6970- {outcome 1} — verify bằng `{command hoặc test name}`71- {outcome 2} — verify bằng `{command hoặc test name}`7273### 2. Nguồn dữ liệu chuẩn7475**Canonical data**: {data nào là nguồn gốc, lấy từ đâu}7677**Lấy từ**: {nguồn được phép}7879**KHÔNG lấy từ**: {nguồn bị cấm và lý do ngắn gọn}8081### 3. Business rules & invariants8283- **{Tên rule}**: {mô tả rule} — verify bằng `{cách kiểm tra}`84- **{Tên invariant}**: {guarantee kỹ thuật} — verify bằng `{cách kiểm tra}`8586### 4. Phạm vi / Ngoài phạm vi8788**Làm**:8990- {việc cụ thể 1}91- {việc cụ thể 2}9293**KHÔNG làm**:9495- {việc cụ thể bị loại trừ 1}96- {việc cụ thể bị loại trừ 2}9798<!-- Section 5 chỉ thêm khi có ≥3 open decisions HOẶC plan dự kiến >500 dòng -->99100### 5. Rủi ro & Quyết định còn mở101102**Đã chốt có rủi ro**:103104- {decision đã chốt} — rủi ro: {consequence cụ thể}105106**Chưa chốt cần resolve**:107108- {câu hỏi cần trả lời trước khi implement}109110### 6. Các task111112- [ ] **Task 1: {tên task}**113114 **File(s)**:115116 - `path/to/exact-file.ts`117 - `path/to/new-file.ts`118119 **Phụ thuộc**: Task X (chỉ thêm field này khi thực sự có dependency)120121 **Decision**: {WHAT đã chốt — không viết WHY ở đây}122123 **Build**:124125 - {action cụ thể 1}126 - {action cụ thể 2}127128 **Verify**:129130 - `{command}` → output `{expected}`131 - test `{test name}` pass132133- [ ] **Task 2: …**134```135136### Field rules137138- `Decision`: WHAT only. WHY belongs in section 5 "Rủi ro & Quyết định còn mở".139- `Verify`: MUST reference a test name / command output / specific file check — never vague.140- `Phụ thuộc`: optional. Add only when the task genuinely depends on another task finishing first. Otherwise omit the field. For sub-issues, also set `blockedBy` on the sub-issue so Linear shows the order.141142### No Placeholders143144The plan MUST NOT contain any of these patterns — they are plan failures, fix inline before the Hard gate:145146- `TBD`, `TODO`, "fill in later", "implement later"147- "Add appropriate error handling" / "add validation" / "handle edge cases" — must specify which error, what to validate148- "Write tests for the above" — no concrete test name149- "Similar to Task N" — repeat the content, the engineer may read tasks out of order150- Vague verify: "test it works", "check output looks right" — must give command + expected output151- Reference to a symbol/function/file not defined by any task in the plan152153## While executing154155Tick the checkbox of each task as it lands (`patch` `replace` `- [ ] **Task N` → `- [x] **Task N`), or move the sub-issue's state. The issue is the progress record; do not keep a parallel checklist anywhere else.