opencode-plugin-coding 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of opencode-plugin-coding might be problematic. Click here for more details.

@@ -0,0 +1,452 @@
1
+ ---
2
+ name: orchestrate
3
+ description: Full multi-agent software development workflow — implement, review, merge, and retrospective — with parallel reviewer coordination and adaptive scoring.
4
+ ---
5
+
6
+ # Orchestrate
7
+
8
+ The central orchestration skill. You coordinate the full software development lifecycle: plan → implement → review → merge → retrospect.
9
+
10
+ You dispatch subagents (`@<coreCoder>`, `@<coreReviewers[i]>`, `@<reviewers[i]>`, optionally `@<securityReviewers[i]>`) and manage the flow between them. All project-specific settings come from `.opencode/workflow.json`. Agents are dynamically registered by the plugin from workflow.json — models come from `{ name, model }` objects in the agents section, permissions and prompts from the guide files.
11
+
12
+ Consolidates the best patterns from app-annie (template-driven), admin (non-blocking reviewer wait), and stone-guardian (reviewer scoring, conciseness rules, JSON heredoc posting).
13
+
14
+ ---
15
+
16
+ ## When to Activate
17
+
18
+ - User assigns a coding task (feature, bug fix, refactor)
19
+ - User says "orchestrate", "implement", "build this"
20
+ - After a `plan` skill produces an approved plan
21
+ - Any task that requires implementation + review
22
+
23
+ ---
24
+
25
+ ## Configuration
26
+
27
+ Read `.opencode/workflow.json` at the start of every orchestration. Key fields:
28
+
29
+ - `project.repo` — GitHub repo (e.g. `Org/repo-name`). Hardcode in all `gh` commands.
30
+ - `project.defaultBranch` — typically `main` or `master`
31
+ - `commands.*` — verification commands (typecheck, lint, test, build)
32
+ - `agents.coreCoder` — `{ name, model }` object for the core implementation agent. Use `.name` as the agent name for `@<name>` invocations.
33
+ - `agents.coreReviewers` — array of `{ name, model }` objects for core reviewers (blocking quorum)
34
+ - `agents.reviewers` — array of `{ name, model }` objects for normal reviewers (non-blocking)
35
+ - `agents.securityReviewers` — array of `{ name, model }` objects for security reviewers (empty array = disabled)
36
+ - `docsToRead` — files all agents must read before working
37
+ - `reviewFocus` — array of short emphasis labels (e.g., `"type safety"`, `"module boundaries"`); reviewers look up detailed rules in `docsToRead` files
38
+
39
+ ---
40
+
41
+ ## Worktree Setup (One-Time)
42
+
43
+ Before the first task, ensure persisted worktrees exist for the core-coder and all core reviewers:
44
+
45
+ ```bash
46
+ # Core coder worktree
47
+ ls .worktrees/core-coder 2>/dev/null || git worktree add --detach .worktrees/core-coder
48
+
49
+ # Core reviewer worktrees — create one per name in agents.coreReviewers
50
+ # Example for the default 2-reviewer config:
51
+ ls .worktrees/core-reviewer-1 2>/dev/null || git worktree add --detach .worktrees/core-reviewer-1
52
+ ls .worktrees/core-reviewer-2 2>/dev/null || git worktree add --detach .worktrees/core-reviewer-2
53
+ ```
54
+
55
+ Read `agents.coreCoder.name` and each `agents.coreReviewers[i].name` from `workflow.json`. Create a worktree at `.worktrees/<name>` for each.
56
+
57
+ `.worktrees/` must be in `.gitignore`. The `/zooplankton-coding-init` command handles this automatically.
58
+
59
+ ---
60
+
61
+ ## Small-Change Fast Path
62
+
63
+ If the change is < 20 lines, straightforward, and low-risk, skip Phases 1–2:
64
+
65
+ 1. Edit files directly
66
+ 2. Create branch: `git checkout -b <username>--<name>`
67
+ 3. Commit (Conventional Commits) and push
68
+ 4. `gh pr create`
69
+ 5. Run Phase 3 (all reviewers in parallel)
70
+ 6. Run Phase 4 (evaluate)
71
+ - Blocking issues → hand off to `@<coreCoder>`; continue review loop
72
+ - Advisory-only → orchestrator addresses directly
73
+ 7. Post pre-merge summary → ask user to approve → merge
74
+
75
+ ---
76
+
77
+ ## Phase 1: Setup
78
+
79
+ 1. Read `.opencode/workflow.json`, `AGENTS.md`, and all `docsToRead` files
80
+ 2. Run cleanup policy (see Cleanup Policy section below)
81
+ 3. Check for stale plans and report alerts
82
+ 4. Verify worktrees exist (create if missing)
83
+ 5. If a plan file exists at `.opencode/plans/<branch>.md`, read it. Otherwise, invoke `@<coreCoder>` to produce a plan first (see Phase 2 planning step).
84
+
85
+ ---
86
+
87
+ ## Phase 2: Implement
88
+
89
+ ### 2a. Planning (if no plan exists)
90
+
91
+ Invoke `@<coreCoder>` with the planning template (see Invocation Templates). It must return a structured plan — files to change, approach, risks, scope. **No implementation yet.**
92
+
93
+ Present the plan to the user for approval. If user requests changes, re-invoke `@<coreCoder>` with feedback.
94
+
95
+ Write the approved plan to `.opencode/plans/<branch>.md` and set status to `not_started`.
96
+
97
+ ### 2b. Implementation
98
+
99
+ 1. Set plan status to `in_progress`
100
+ 2. Invoke `@<coreCoder>` with the implementation template
101
+ 3. Core-coder must work in `.worktrees/<coreCoder.name>`, create a feature branch from `origin/<defaultBranch>`, implement, run all verification commands, commit, push, and create a PR
102
+ 4. Core-coder returns: **PR number, PR URL, branch name**
103
+ 5. Record these for Phase 3
104
+
105
+ ---
106
+
107
+ ## Phase 3: Review
108
+
109
+ ### 3a. Parallel Code Review
110
+
111
+ Invoke **all reviewers in a single parallel message** (one Task call per reviewer).
112
+
113
+ Read `agents.coreReviewers` and `agents.reviewers` arrays from `workflow.json`. Each entry is a `{ name, model }` object — use `.name` for `@<name>` invocations.
114
+
115
+ **Core reviewers** (blocking quorum — must wait for all):
116
+
117
+ For each entry in `agents.coreReviewers`, invoke `@<entry.name>`:
118
+ - Assign worktree `.worktrees/<name>`
119
+
120
+ **Normal reviewers** (non-blocking — include if available):
121
+
122
+ For each entry in `agents.reviewers`, invoke `@<entry.name>`:
123
+ - Assign 1-2 review areas via adaptive round-robin (see Reviewer Assignment Strategy)
124
+
125
+ Each reviewer follows their respective guide (`guides/core-reviewer-guide.md` or `guides/reviewer-guide.md`).
126
+
127
+ ### 3b. Collect Results (Non-Blocking Wait)
128
+
129
+ **Proceed to Phase 4 as soon as both core reviewers have returned results.** Include results from any normal reviewers that have already completed; treat non-returned normal reviewers as having raised no issues for that round.
130
+
131
+ This is the "admin-style" non-blocking wait — core reviewers form the quorum, normal reviewers contribute opportunistically.
132
+
133
+ **Implementation rule (important):**
134
+ - Do not block Phase 4 waiting for slow/stuck normal reviewers.
135
+ - Dispatch normal reviewers independently, but only gate on `agents.coreReviewers` entries' completion.
136
+ - If a normal reviewer task hangs/fails, retry once; if still unavailable, mark as no result for this round and continue.
137
+
138
+ ### 3c. Session Reuse Across Rounds
139
+
140
+ When invoking the same reviewer agent in a subsequent round, **reuse the Task session** by passing the `task_id` returned from the previous round's invocation. This continues the subagent's conversation with full history (prior messages and tool outputs), so the reviewer retains context about their own earlier findings and can efficiently track resolution status.
141
+
142
+ **Rules:**
143
+ - Store each reviewer's `task_id` after Round 1 dispatch
144
+ - On Round 2+, pass the stored `task_id` to resume the session instead of creating a fresh one
145
+ - **Fallback:** if a resumed session fails (error, timeout, or unexpected state), discard the `task_id` and start a fresh session — include the round number and a note that the prior session was lost so the reviewer re-reads the diff
146
+ - Session reuse is **optional but recommended** — a fresh session per round also works, just with more redundant diff reading
147
+
148
+ ---
149
+
150
+ ## Phase 4: Evaluate and Address
151
+
152
+ Count unique blocking and advisory issues across all reviewers.
153
+
154
+ | Condition | Action |
155
+ |-----------|--------|
156
+ | No issues at all | Proceed to **Phase 4a (Security Gate)** |
157
+ | Blocking issues exist, round < 3 | Increment round; send all feedback to `@<coreCoder>`; if new round = 3 add final-round signal; go to Phase 3 |
158
+ | Advisory-only (no blocking), round < 3 | **Always final round.** Increment round; send advisories to `@<coreCoder>` with final-round signal; go to Phase 3 |
159
+ | Round >= 3 | Stop. If previous round was blocking (not advisory-only), send final-round signal to `@<coreCoder>` for TODO.md. Proceed to **Phase 4a (Security Gate)** |
160
+
161
+ **Critical rules:**
162
+ - **Never merge without explicit user confirmation.**
163
+ - **Always post the pre-merge PR summary comment before asking the user to merge.**
164
+ - **Security review (Phase 4a) always runs before any merge path** — even if code review found zero issues.
165
+
166
+ ### 4a. Security Gate (if configured)
167
+
168
+ This phase runs **only when code-review rounds have fully converged** — i.e., no more revision loops remain. It is the last gate before pre-merge summary and merge decision.
169
+
170
+ If `workflow.json` → `agents.securityReviewers` is empty, skip directly to pre-merge summary → ask user → merge.
171
+
172
+ If `workflow.json` → `agents.securityReviewers` is non-empty:
173
+
174
+ 1. Invoke each `@<entry.name>` in `agents.securityReviewers` with the PR number (see `guides/security-reviewer-guide.md`)
175
+ 2. If any verdict is **BLOCK**: send critical/high findings to `@<coreCoder>` for fixes, then return to Phase 3 (code review restarts from a new round)
176
+ 3. If all verdicts are **PASS**: post pre-merge summary → ask user → merge
177
+
178
+ ### Address Feedback
179
+
180
+ When sending feedback to `@<coreCoder>`, use the revision template (see Invocation Templates). Core-coder must:
181
+
182
+ 1. Fix all blocking issues
183
+ 2. Address advisory issues at discretion (justify skips)
184
+ 3. On **final round**: evaluate all unaddressed advisories for `doc/TODO.md`
185
+ 4. Commit, push, re-run all verification commands
186
+ 5. Return results to orchestrator
187
+
188
+ ---
189
+
190
+ ## Phase 5: Retrospective
191
+
192
+ After merge, produce a retrospective:
193
+
194
+ 1. **Write retrospective file** to `.opencode/retrospectives/<branch>.md` using `templates/retrospective.md`
195
+ 2. **Update reviewer knowledge** — write/merge scores into `.opencode/reviewer-knowledge.json` (see Reviewer Assignment Strategy)
196
+ 3. **Propose AGENTS.md updates** — if the task revealed new gotchas, conventions, or architecture patterns, suggest changes as a diff. The user reviews and applies manually.
197
+ 4. **Set plan status to `completed`**
198
+ 5. **Run cleanup** (see Cleanup Policy)
199
+
200
+ ### Reviewer Scoring (for retrospective)
201
+
202
+ Score each reviewer on their contribution quality:
203
+
204
+ | Score | Meaning |
205
+ |-------|---------|
206
+ | 3 stars | Found at least one **blocking** issue that was valid and fixed |
207
+ | 2 stars | Found only **advisory** issues that were valid and acted on |
208
+ | 1 star | Participated but all findings were invalid, duplicates, or noise |
209
+ | 0 | Did not post a review (technical failure, timeout, etc.) |
210
+
211
+ ---
212
+
213
+ ## Round Tracking
214
+
215
+ - Round starts at 1 (first review = Round 1)
216
+ - Increment each time you send core-coder back for revisions
217
+ - Maximum round = 3
218
+ - Advisory-only rounds are always final — core-coder must evaluate unaddressed advisories for `doc/TODO.md`
219
+ - On the final round, include the final-round signal in the core-coder invocation
220
+
221
+ ---
222
+
223
+ ## Reviewer Assignment Strategy
224
+
225
+ ### Review Areas
226
+
227
+ Canonical areas (defined in plugin, NOT per-project config):
228
+
229
+ - **logic** — correctness, edge cases
230
+ - **types** — type safety, unsafe casts
231
+ - **architecture** — separation of concerns, boundaries
232
+ - **error handling** — input validation, null safety, security
233
+ - **tests** — coverage, regression risk
234
+ - **docs** — AGENTS.md, README, inline docs
235
+
236
+ ### Assignment Rules
237
+
238
+ - **Core reviewers:** always review **all 6 areas**
239
+ - **Normal reviewers:** assigned **1–2 areas** each via adaptive round-robin
240
+
241
+ ### Round-Robin with Adaptive Weighting
242
+
243
+ 1. **Baseline:** randomly assign 1–2 areas to each normal reviewer, ensuring all 6 areas are covered across the pool
244
+ 2. **Adaptation:** if `.opencode/reviewer-knowledge.json` exists, weight the assignment:
245
+ - Read per-model, per-area historical scores (model IDs come from `workflow.json` → `agents` → `<entry>.model`)
246
+ - Models with higher scores for an area are more likely to be assigned that area
247
+ - Keep assignment **stochastic** (soft weighting) — not deterministic
248
+ 3. **Fallback:** if no knowledge file exists, use pure random round-robin
249
+
250
+ ### Knowledge File Format
251
+
252
+ `.opencode/reviewer-knowledge.json`:
253
+
254
+ ```json
255
+ {
256
+ "models": {
257
+ "alibaba-coding-plan-cn/glm-5": {
258
+ "areas": {
259
+ "logic": { "totalScore": 12, "reviewCount": 5 },
260
+ "types": { "totalScore": 8, "reviewCount": 4 }
261
+ }
262
+ }
263
+ },
264
+ "lastUpdated": "2026-03-30"
265
+ }
266
+ ```
267
+
268
+ This file is gitignored. Accept loss on fresh clone.
269
+
270
+ ---
271
+
272
+ ## Invocation Templates
273
+
274
+ ### Core-coder: Planning
275
+
276
+ ```
277
+ Explore the codebase and produce a plan for:
278
+
279
+ <task description>
280
+
281
+ Read AGENTS.md and these docs first: <docsToRead list>
282
+
283
+ Include: files to modify/create, approach, risks, estimated scope (small/medium/large).
284
+ Do NOT implement — planning only.
285
+ ```
286
+
287
+ ### Core-coder: Implementation
288
+
289
+ ```
290
+ Implement the approved plan in .worktrees/<coreCoder.name>.
291
+
292
+ Plan:
293
+ <approved plan>
294
+
295
+ Steps:
296
+ 1. Clean worktree (abort in-progress ops, discard uncommitted changes)
297
+ 2. git fetch origin
298
+ 3. git checkout -B <username>--<branch-name> origin/<defaultBranch>
299
+ 4. Implement
300
+ 5. Run full verification: <commands from workflow.json>
301
+ 6. Commit (Conventional Commits) and push
302
+ 7. gh pr create
303
+
304
+ Return: PR number, PR URL, branch name.
305
+ ```
306
+
307
+ ### Core Reviewer
308
+
309
+ ```
310
+ Review PR #$PR_NUMBER on branch $BRANCH. This is Round $ROUND.
311
+
312
+ Your worktree: $WORKTREE_PATH.
313
+
314
+ Follow guides/core-reviewer-guide.md for the full workflow.
315
+
316
+ Additional docs to read: <docsToRead from workflow.json>
317
+ Review focus for this project: <reviewFocus from workflow.json>
318
+ Additional files relevant to this PR: <task-specific files>
319
+
320
+ Return: verification results (pass/fail each command), issue count, blocking vs advisory.
321
+ ```
322
+
323
+ ### Normal Reviewer
324
+
325
+ ```
326
+ Review PR #$PR_NUMBER in repo <REPO>. This is Round $ROUND.
327
+ Your assigned review areas: <assigned 1-2 areas>
328
+
329
+ Follow guides/reviewer-guide.md for the full workflow.
330
+
331
+ Additional docs to read: <docsToRead from workflow.json>
332
+ Review focus for this project: <reviewFocus from workflow.json>
333
+ Additional files relevant to this PR: <task-specific files>
334
+
335
+ Return: issue count, blocking vs advisory.
336
+ ```
337
+
338
+ ### Core-coder: Revisions
339
+
340
+ ```
341
+ Address review feedback on PR #$PR_NUMBER (branch: $BRANCH).
342
+
343
+ Read full review comments:
344
+ gh api repos/<REPO>/pulls/$PR_NUMBER/reviews
345
+ gh api repos/<REPO>/pulls/$PR_NUMBER/comments
346
+
347
+ Blocking (must fix):
348
+ <list>
349
+
350
+ Advisory (fix at your discretion; justify any skipped):
351
+ <list>
352
+
353
+ [Include when advisory-only OR round = 3:]
354
+ This is the final revision round. After addressing the above, evaluate ALL
355
+ unaddressed advisories from all rounds. Add a doc/TODO.md entry for each that
356
+ is a real, non-trivial improvement. Report: which were added (with TODO numbers)
357
+ and which were dismissed (with justification).
358
+
359
+ Steps: fix → commit → push → full verification (<commands from workflow.json>).
360
+
361
+ Return: verification results, advisories fixed/skipped (with reasons),
362
+ [final round] doc/TODO.md additions and dismissals.
363
+ ```
364
+
365
+ ---
366
+
367
+ ## Pre-Merge PR Summary
368
+
369
+ Post this as a PR comment **before** asking the user to merge. Use the JSON heredoc method for reliability:
370
+
371
+ ```bash
372
+ gh pr comment $PR_NUMBER --repo <REPO> --body "$(cat <<'EOF'
373
+ ## Pre-Merge PR Summary
374
+
375
+ ### Purpose
376
+ <1-2 sentences>
377
+
378
+ ### Review Findings
379
+
380
+ **Round N:**
381
+ | Reviewer | Blocking | Advisory |
382
+ |----------|----------|----------|
383
+ | `<model-id>` | <issues or "None"> | <issues or "None"> |
384
+
385
+ ### Issues Fixed
386
+ <list, or "All issues addressed." or "N/A — no issues raised.">
387
+
388
+ ### Issues Not Fixed
389
+ <unresolved blockers, skipped advisories with justification, doc/TODO.md entries.
390
+ Or "All issues addressed." or "N/A — no issues raised.">
391
+
392
+ ### Reviewer Scores
393
+
394
+ | Reviewer | Round | Score | Notable Finding |
395
+ |----------|-------|-------|-----------------|
396
+ | `<model-id>` | R1 | ⭐⭐⭐ | <finding> |
397
+
398
+ ### Final Verification
399
+
400
+ | Command | Result |
401
+ |---------|--------|
402
+ | `<typecheck>` | PASS / FAIL |
403
+ | `<lint>` | PASS / FAIL |
404
+ | `<test>` | PASS (N tests) / FAIL |
405
+ | `<build>` | PASS / FAIL / N/A |
406
+ EOF
407
+ )"
408
+ ```
409
+
410
+ ---
411
+
412
+ ## Merge and Branch Cleanup
413
+
414
+ After the user approves, merge and clean up:
415
+
416
+ ```bash
417
+ BRANCH=$(gh pr view $PR_NUMBER --json headRefName -q ".headRefName")
418
+ gh pr merge $PR_NUMBER --squash --admin --repo <REPO>
419
+ git checkout <defaultBranch> && git pull --ff-only origin <defaultBranch>
420
+ # Detach all worktrees (coreCoder.name + each entry.name in agents.coreReviewers)
421
+ git -C .worktrees/<coreCoder.name> checkout --detach HEAD
422
+ # For each entry in agents.coreReviewers:
423
+ git -C .worktrees/<entry.name> checkout --detach HEAD
424
+ git branch -D $BRANCH
425
+ git push origin --delete $BRANCH 2>/dev/null || true
426
+ git remote prune origin
427
+ ```
428
+
429
+ If `--ff-only` fails: `git reset --hard origin/<defaultBranch>`.
430
+
431
+ **Note:** For projects that require a pre-merge build (e.g., Electron apps), check the project's `AGENTS.md` for build-before-merge instructions. The orchestrator should follow project-specific merge rules when they exist.
432
+
433
+ ---
434
+
435
+ ## Cleanup Policy
436
+
437
+ Run at orchestration start and end:
438
+
439
+ ### Plans
440
+ - Delete `.opencode/plans/*.md` files older than 7 days **only if** status is `completed`
441
+ - For plans older than 7 days with non-completed status, alert the user:
442
+ ```
443
+ ⚠ Stale plan: .opencode/plans/<name>.md (status: <status>, created: <date>)
444
+ ```
445
+ - Do **not** auto-delete non-completed plans
446
+
447
+ ### Retrospectives
448
+ - Delete `.opencode/retrospectives/*.md` files older than 7 days (unconditional)
449
+
450
+ ### Reviewer Knowledge
451
+ - Never delete `.opencode/reviewer-knowledge.json` — it accumulates over time
452
+ - Accept that it resets on fresh clones (gitignored)
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: plan
3
+ description: Decompose a design into bite-sized implementation tasks with exact file paths, acceptance criteria, and verification steps. Writes plan to disk.
4
+ ---
5
+
6
+ # Plan
7
+
8
+ Decomposes an approved design (from `brainstorm` or a direct user request) into a concrete, ordered implementation plan. The plan is written to disk before any implementation begins — this is a hard guarantee.
9
+
10
+ Inspired by the writing-plans and executing-plans skills from Superpowers.
11
+
12
+ ---
13
+
14
+ ## When to Activate
15
+
16
+ - After brainstorm produces a design document
17
+ - User says "plan", "break this down", "create tasks"
18
+ - The orchestrator requests a plan before implementation
19
+ - A complex task needs decomposition before coding
20
+
21
+ ---
22
+
23
+ ## Inputs
24
+
25
+ One of:
26
+
27
+ 1. A design document at `.opencode/designs/<feature-name>.md`
28
+ 2. A direct task description from the user or orchestrator
29
+ 3. A PR description or issue to implement
30
+
31
+ ---
32
+
33
+ ## Process
34
+
35
+ ### Step 1: Read Context
36
+
37
+ ```bash
38
+ cat AGENTS.md
39
+ cat .opencode/workflow.json
40
+ # Read design doc if it exists
41
+ # Read any files passed by the user/orchestrator
42
+ ```
43
+
44
+ Understand the project structure, conventions, and verification commands.
45
+
46
+ ### Step 2: Explore the Codebase
47
+
48
+ Investigate the files that will be affected:
49
+
50
+ - Read existing source files to understand current patterns
51
+ - Identify dependencies between files
52
+ - Note any gotchas or constraints from `AGENTS.md`
53
+
54
+ ### Step 3: Decompose into Tasks
55
+
56
+ Break the work into ordered, atomic tasks. Each task should be:
57
+
58
+ - **Small** — completable in one focused session
59
+ - **Testable** — has clear acceptance criteria
60
+ - **Ordered** — dependencies are explicit
61
+
62
+ For each task, specify:
63
+
64
+ ```markdown
65
+ - [ ] Task N: <title>
66
+ - **Files:** <exact file paths to create/modify>
67
+ - **What:** <1-2 sentence description of the change>
68
+ - **Acceptance:** <concrete criteria — what must be true when done>
69
+ - **Dependencies:** <which prior tasks must be complete>
70
+ ```
71
+
72
+ ### Step 4: Define Verification
73
+
74
+ Map `workflow.json` → `commands` to the plan:
75
+
76
+ ```markdown
77
+ ## Verification
78
+
79
+ After all tasks are complete, run:
80
+ - Typecheck: `<typecheck command>`
81
+ - Lint: `<lint command>`
82
+ - Test: `<test command>`
83
+ - Build: `<build command>`
84
+ ```
85
+
86
+ ### Step 5: Self-Review
87
+
88
+ Before writing to disk, verify:
89
+
90
+ - [ ] Every file path is real (exists or will be created by a prior task)
91
+ - [ ] No placeholder text like "TBD" or "TODO" in acceptance criteria
92
+ - [ ] Tasks are ordered correctly — no task depends on a later task
93
+ - [ ] Type consistency — if Task 1 changes a type, Tasks 2+ that use it are listed
94
+ - [ ] Scope is realistic — no task tries to do too much
95
+ - [ ] Verification commands match what's in `workflow.json`
96
+
97
+ ### Step 6: Write Plan to Disk
98
+
99
+ Write the plan to `.opencode/plans/<branch-name>.md`:
100
+
101
+ ```markdown
102
+ ---
103
+ status: not_started
104
+ branch: <branch-name>
105
+ created: <YYYY-MM-DD>
106
+ design: <path to design doc, if any>
107
+ ---
108
+
109
+ # Plan: <Title>
110
+
111
+ ## Context
112
+
113
+ <1-3 sentences — what this plan accomplishes and why>
114
+
115
+ ## Tasks
116
+
117
+ - [ ] Task 1: <title>
118
+ - **Files:** `src/path/to/file.ts`
119
+ - **What:** <description>
120
+ - **Acceptance:** <criteria>
121
+
122
+ - [ ] Task 2: <title>
123
+ - **Files:** `src/path/to/other.ts`
124
+ - **What:** <description>
125
+ - **Acceptance:** <criteria>
126
+ - **Dependencies:** Task 1
127
+
128
+ ## Verification
129
+
130
+ | Command | Expected |
131
+ |---------|----------|
132
+ | `<typecheck>` | 0 errors |
133
+ | `<lint>` | clean |
134
+ | `<test>` | all pass |
135
+ | `<build>` | success |
136
+
137
+ ## Risks
138
+
139
+ - <risk 1>
140
+ - <risk 2>
141
+
142
+ ## Learnings (updated during execution)
143
+
144
+ - (none yet)
145
+ ```
146
+
147
+ Create the directory if needed:
148
+
149
+ ```bash
150
+ mkdir -p .opencode/plans
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Output
156
+
157
+ Return to the user (or orchestrator):
158
+
159
+ 1. **Plan file path** — `.opencode/plans/<branch-name>.md`
160
+ 2. **Task count** — number of tasks
161
+ 3. **Estimated scope** — small / medium / large
162
+ 4. **Risks** — key risks identified
163
+ 5. **Recommendation** — "Ready to implement" or "Needs design clarification on X"
164
+
165
+ ---
166
+
167
+ ## Plan Lifecycle
168
+
169
+ The plan status field tracks progression:
170
+
171
+ | Status | Meaning |
172
+ |--------|---------|
173
+ | `not_started` | Plan written, not yet being implemented |
174
+ | `in_progress` | Core-coder is actively implementing |
175
+ | `completed` | All tasks done, PR merged |
176
+
177
+ The `orchestrate` skill manages status transitions.
178
+
179
+ ---
180
+
181
+ ## Cleanup Rules
182
+
183
+ Plan cleanup runs at orchestration start/end:
184
+
185
+ - Delete plans older than 7 days **only if** status is `completed`
186
+ - For plans older than 7 days with non-completed status, raise a **stale alert** (do not auto-delete)