@sienklogic/plan-build-run 2.54.0 → 2.55.0

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.
Files changed (127) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/plugins/codex-pbr/agents/audit.md +223 -0
  4. package/plugins/codex-pbr/agents/codebase-mapper.md +196 -0
  5. package/plugins/codex-pbr/agents/debugger.md +245 -0
  6. package/plugins/codex-pbr/agents/dev-sync.md +142 -0
  7. package/plugins/codex-pbr/agents/executor.md +429 -0
  8. package/plugins/codex-pbr/agents/general.md +131 -0
  9. package/plugins/codex-pbr/agents/integration-checker.md +178 -0
  10. package/plugins/codex-pbr/agents/plan-checker.md +253 -0
  11. package/plugins/codex-pbr/agents/planner.md +343 -0
  12. package/plugins/codex-pbr/agents/researcher.md +253 -0
  13. package/plugins/codex-pbr/agents/synthesizer.md +183 -0
  14. package/plugins/codex-pbr/agents/verifier.md +352 -0
  15. package/plugins/codex-pbr/commands/audit.md +5 -0
  16. package/plugins/codex-pbr/commands/begin.md +5 -0
  17. package/plugins/codex-pbr/commands/build.md +5 -0
  18. package/plugins/codex-pbr/commands/config.md +5 -0
  19. package/plugins/codex-pbr/commands/continue.md +5 -0
  20. package/plugins/codex-pbr/commands/dashboard.md +5 -0
  21. package/plugins/codex-pbr/commands/debug.md +5 -0
  22. package/plugins/codex-pbr/commands/discuss.md +5 -0
  23. package/plugins/codex-pbr/commands/do.md +5 -0
  24. package/plugins/codex-pbr/commands/explore.md +5 -0
  25. package/plugins/codex-pbr/commands/health.md +5 -0
  26. package/plugins/codex-pbr/commands/help.md +5 -0
  27. package/plugins/codex-pbr/commands/import.md +5 -0
  28. package/plugins/codex-pbr/commands/milestone.md +5 -0
  29. package/plugins/codex-pbr/commands/note.md +5 -0
  30. package/plugins/codex-pbr/commands/pause.md +5 -0
  31. package/plugins/codex-pbr/commands/plan.md +5 -0
  32. package/plugins/codex-pbr/commands/quick.md +5 -0
  33. package/plugins/codex-pbr/commands/resume.md +5 -0
  34. package/plugins/codex-pbr/commands/review.md +5 -0
  35. package/plugins/codex-pbr/commands/scan.md +5 -0
  36. package/plugins/codex-pbr/commands/setup.md +5 -0
  37. package/plugins/codex-pbr/commands/status.md +5 -0
  38. package/plugins/codex-pbr/commands/statusline.md +5 -0
  39. package/plugins/codex-pbr/commands/test.md +5 -0
  40. package/plugins/codex-pbr/commands/todo.md +5 -0
  41. package/plugins/codex-pbr/commands/undo.md +5 -0
  42. package/plugins/codex-pbr/references/agent-contracts.md +324 -0
  43. package/plugins/codex-pbr/references/agent-teams.md +54 -0
  44. package/plugins/codex-pbr/references/common-bug-patterns.md +13 -0
  45. package/plugins/codex-pbr/references/config-reference.md +552 -0
  46. package/plugins/codex-pbr/references/continuation-format.md +212 -0
  47. package/plugins/codex-pbr/references/deviation-rules.md +112 -0
  48. package/plugins/codex-pbr/references/git-integration.md +256 -0
  49. package/plugins/codex-pbr/references/integration-patterns.md +117 -0
  50. package/plugins/codex-pbr/references/model-profiles.md +99 -0
  51. package/plugins/codex-pbr/references/model-selection.md +31 -0
  52. package/plugins/codex-pbr/references/pbr-tools-cli.md +400 -0
  53. package/plugins/codex-pbr/references/plan-authoring.md +246 -0
  54. package/plugins/codex-pbr/references/plan-format.md +313 -0
  55. package/plugins/codex-pbr/references/questioning.md +235 -0
  56. package/plugins/codex-pbr/references/reading-verification.md +127 -0
  57. package/plugins/codex-pbr/references/signal-files.md +41 -0
  58. package/plugins/codex-pbr/references/stub-patterns.md +160 -0
  59. package/plugins/codex-pbr/references/ui-formatting.md +444 -0
  60. package/plugins/codex-pbr/references/wave-execution.md +95 -0
  61. package/plugins/codex-pbr/skills/audit/SKILL.md +346 -0
  62. package/plugins/codex-pbr/skills/begin/SKILL.md +800 -0
  63. package/plugins/codex-pbr/skills/build/SKILL.md +958 -0
  64. package/plugins/codex-pbr/skills/config/SKILL.md +267 -0
  65. package/plugins/codex-pbr/skills/continue/SKILL.md +172 -0
  66. package/plugins/codex-pbr/skills/dashboard/SKILL.md +44 -0
  67. package/plugins/codex-pbr/skills/debug/SKILL.md +530 -0
  68. package/plugins/codex-pbr/skills/discuss/SKILL.md +355 -0
  69. package/plugins/codex-pbr/skills/do/SKILL.md +68 -0
  70. package/plugins/codex-pbr/skills/explore/SKILL.md +407 -0
  71. package/plugins/codex-pbr/skills/health/SKILL.md +300 -0
  72. package/plugins/codex-pbr/skills/help/SKILL.md +229 -0
  73. package/plugins/codex-pbr/skills/import/SKILL.md +538 -0
  74. package/plugins/codex-pbr/skills/milestone/SKILL.md +620 -0
  75. package/plugins/codex-pbr/skills/note/SKILL.md +215 -0
  76. package/plugins/codex-pbr/skills/pause/SKILL.md +258 -0
  77. package/plugins/codex-pbr/skills/plan/SKILL.md +650 -0
  78. package/plugins/codex-pbr/skills/quick/SKILL.md +417 -0
  79. package/plugins/codex-pbr/skills/resume/SKILL.md +403 -0
  80. package/plugins/codex-pbr/skills/review/SKILL.md +669 -0
  81. package/plugins/codex-pbr/skills/scan/SKILL.md +325 -0
  82. package/plugins/codex-pbr/skills/setup/SKILL.md +169 -0
  83. package/plugins/codex-pbr/skills/shared/commit-planning-docs.md +35 -0
  84. package/plugins/codex-pbr/skills/shared/config-loading.md +102 -0
  85. package/plugins/codex-pbr/skills/shared/context-budget.md +77 -0
  86. package/plugins/codex-pbr/skills/shared/context-loader-task.md +86 -0
  87. package/plugins/codex-pbr/skills/shared/digest-select.md +79 -0
  88. package/plugins/codex-pbr/skills/shared/domain-probes.md +125 -0
  89. package/plugins/codex-pbr/skills/shared/error-reporting.md +59 -0
  90. package/plugins/codex-pbr/skills/shared/gate-prompts.md +388 -0
  91. package/plugins/codex-pbr/skills/shared/phase-argument-parsing.md +45 -0
  92. package/plugins/codex-pbr/skills/shared/revision-loop.md +81 -0
  93. package/plugins/codex-pbr/skills/shared/state-update.md +169 -0
  94. package/plugins/codex-pbr/skills/shared/universal-anti-patterns.md +43 -0
  95. package/plugins/codex-pbr/skills/status/SKILL.md +449 -0
  96. package/plugins/codex-pbr/skills/statusline/SKILL.md +149 -0
  97. package/plugins/codex-pbr/skills/test/SKILL.md +210 -0
  98. package/plugins/codex-pbr/skills/todo/SKILL.md +281 -0
  99. package/plugins/codex-pbr/skills/undo/SKILL.md +172 -0
  100. package/plugins/codex-pbr/templates/CONTEXT.md.tmpl +52 -0
  101. package/plugins/codex-pbr/templates/INTEGRATION-REPORT.md.tmpl +167 -0
  102. package/plugins/codex-pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  103. package/plugins/codex-pbr/templates/ROADMAP.md.tmpl +47 -0
  104. package/plugins/codex-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  105. package/plugins/codex-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  106. package/plugins/codex-pbr/templates/SUMMARY.md.tmpl +81 -0
  107. package/plugins/codex-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  108. package/plugins/codex-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  109. package/plugins/codex-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  110. package/plugins/codex-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  111. package/plugins/codex-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  112. package/plugins/codex-pbr/templates/codebase/STACK.md.tmpl +78 -0
  113. package/plugins/codex-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  114. package/plugins/codex-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  115. package/plugins/codex-pbr/templates/continue-here.md.tmpl +73 -0
  116. package/plugins/codex-pbr/templates/pr-body.md.tmpl +22 -0
  117. package/plugins/codex-pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  118. package/plugins/codex-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  119. package/plugins/codex-pbr/templates/research/STACK.md.tmpl +71 -0
  120. package/plugins/codex-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  121. package/plugins/codex-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  122. package/plugins/codex-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  123. package/plugins/codex-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  124. package/plugins/copilot-pbr/plugin.json +1 -1
  125. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  126. package/plugins/jules-pbr/AGENTS.md +600 -0
  127. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,620 @@
1
+ ---
2
+ name: milestone
3
+ description: "Manage milestones: new, complete, audit, gaps."
4
+ ---
5
+ <!-- markdownlint-disable MD012 MD046 -->
6
+
7
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
8
+
9
+ ## Step 0 — Immediate Output
10
+
11
+ **Before ANY tool calls**, display this banner:
12
+
13
+ ```
14
+ ╔══════════════════════════════════════════════════════════════╗
15
+ ║ PLAN-BUILD-RUN ► MILESTONE ║
16
+ ╚══════════════════════════════════════════════════════════════╝
17
+ ```
18
+
19
+ Then proceed to Step 1.
20
+
21
+ # $pbr-milestone — Milestone Management
22
+
23
+ You are running the **milestone** skill. Milestones represent significant project checkpoints — a set of phases that together deliver a cohesive chunk of functionality. This skill handles the full milestone lifecycle: creation, completion, auditing, and gap analysis.
24
+
25
+ This skill runs **inline** for most subcommands, but spawns agents for `audit`.
26
+
27
+ ---
28
+
29
+ ## Context Budget
30
+
31
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
32
+
33
+ Additionally for this skill:
34
+ - **Never** perform integration checks yourself — delegate to the integration-checker subagent
35
+ - **Minimize** reading audit and verification outputs — read only frontmatter and status fields
36
+ - **Delegate** all cross-phase integration analysis to the integration-checker subagent
37
+
38
+ ---
39
+
40
+ ## Core Principle
41
+
42
+ **Milestones are the rhythm of the project.** They force you to step back, verify everything works together, and create a clean snapshot before moving on. Never skip the audit — integration issues hide at milestone boundaries.
43
+
44
+ ---
45
+
46
+ ## Argument Parsing
47
+
48
+ Parse `$ARGUMENTS` for the subcommand and optional version:
49
+
50
+ ```
51
+ $ARGUMENTS format: {subcommand} [{version/name}]
52
+
53
+ Examples:
54
+ "new" → subcommand=new, arg=none
55
+ "new User Auth" → subcommand=new, arg="User Auth"
56
+ "complete v1.0" → subcommand=complete, arg="v1.0"
57
+ "complete 1.0" → subcommand=complete, arg="v1.0" (auto-prefix v)
58
+ "preview v1.0" → subcommand=preview, arg="v1.0"
59
+ "audit v1.0" → subcommand=audit, arg="v1.0"
60
+ "audit" → subcommand=audit, arg=current milestone
61
+ "gaps" → subcommand=gaps, arg=most recent audit
62
+ ```
63
+
64
+ **If no subcommand recognized:** Show usage:
65
+ ```
66
+ Usage: $pbr-milestone <subcommand> [version]
67
+
68
+ Subcommands:
69
+ new [name] — Start a new milestone cycle
70
+ complete [ver] — Archive completed milestone
71
+ preview [ver] — Dry-run of complete (show what would happen)
72
+ audit [ver] — Verify milestone completion
73
+ gaps — Create phases to close audit gaps
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Subcommand: `new`
79
+
80
+ Start a new milestone cycle with new phases.
81
+
82
+ ### Flow
83
+
84
+ 1. **Read current state:**
85
+ - Read ROADMAP.md to see existing phases
86
+ - Read STATE.md for current position
87
+ - Read PROJECT.md if it exists (milestone history)
88
+
89
+ 2. **Get milestone details** via AskUserQuestion:
90
+ - "What's the name/goal for this new milestone?"
91
+ - "What are the major features or capabilities it should deliver?"
92
+ - If the user provided a name in `$ARGUMENTS`, use it and skip the name question
93
+
94
+ 3. **Determine phase numbering:**
95
+ - Find the highest phase number in the current ROADMAP.md
96
+ - New phases start at highest + 1
97
+ - Example: if phases 1-5 exist, new milestone starts at phase 6
98
+
99
+ 4. **Mini roadmap session:**
100
+ Run a condensed version of the `$pbr-begin` questioning flow:
101
+
102
+ a. Ask about major components needed (via AskUserQuestion):
103
+ - "What are the 2-5 major areas of work for this milestone?"
104
+
105
+ b. For each area, ask:
106
+ - "Any specific requirements or constraints for {area}?"
107
+
108
+ c. Generate phases from the areas:
109
+ - Each major area becomes a phase
110
+ - Order by dependency (foundations first)
111
+ - Include brief description and success criteria
112
+
113
+ 5. **Update ROADMAP.md:**
114
+ Append new milestone section:
115
+
116
+ ```markdown
117
+ ---
118
+
119
+ ## Milestone: {name}
120
+
121
+ **Goal:** {goal statement}
122
+ **Phases:** {start_num} - {end_num}
123
+
124
+ ### Phase {N}: {name}
125
+ **Goal:** {goal}
126
+ **Requirements:** {list}
127
+ **Success criteria:** {criteria}
128
+ **Depends on:** {prior phases}
129
+
130
+ ### Phase {N+1}: {name}
131
+ ...
132
+ ```
133
+
134
+ 6. **Create phase directories:**
135
+ For each new phase:
136
+ ```
137
+ .planning/phases/{NN}-{slug}/
138
+ ```
139
+
140
+ 7. **Update PROJECT.md** (create if needed):
141
+ Add milestone to the active milestones list:
142
+
143
+ ```markdown
144
+ ## Active Milestones
145
+
146
+ ### {name}
147
+ - **Phases:** {start} - {end}
148
+ - **Created:** {date}
149
+ - **Status:** In progress
150
+ ```
151
+
152
+ **CRITICAL (no hook) -- DO NOT SKIP: Update STATE.md frontmatter AND body with new milestone info.**
153
+
154
+ 8. **Update STATE.md:**
155
+ - Set current phase to the first new phase
156
+ - Update milestone info
157
+
158
+ 9. **Commit** if `planning.commit_docs: true`:
159
+ ```
160
+ docs(planning): start milestone "{name}" (phases {start}-{end})
161
+ ```
162
+
163
+ 10. **Confirm** with branded output — read `skills/milestone/templates/new-output.md.tmpl` and fill in `{name}` (milestone name), `{count}` (phase count), `{N}` (first phase number).
164
+
165
+ ---
166
+
167
+ ## Subcommand: `preview`
168
+
169
+ Dry-run of milestone completion — shows what would happen without making any changes.
170
+
171
+ ### Flow
172
+
173
+ 1. **Determine version:**
174
+ - Same logic as `complete`: use `$ARGUMENTS` or ask via AskUserQuestion
175
+
176
+ 2. **Identify milestone phases:**
177
+ - Read ROADMAP.md to find phases belonging to this milestone
178
+ - List each phase with its current status (from STATE.md or VERIFICATION.md)
179
+
180
+ 3. **Verification status check:**
181
+ - For each milestone phase, check if VERIFICATION.md exists and its `result` frontmatter
182
+ - Flag phases that are unverified or have stale verification (SUMMARY.md newer than VERIFICATION.md)
183
+
184
+ 4. **Preview archive structure:**
185
+ - Show what the archive directory would look like:
186
+ ```
187
+ .planning/milestones/v{version}/
188
+ ├── ROADMAP.md (snapshot)
189
+ ├── STATS.md (would be generated)
190
+ ├── REQUIREMENTS.md (snapshot)
191
+ └── phases/
192
+ ├── {NN}-{slug}/ (moved from .planning/phases/)
193
+ │ ├── PLAN-01.md
194
+ │ ├── SUMMARY.md
195
+ │ └── VERIFICATION.md
196
+ └── ...
197
+ ```
198
+
199
+ 5. **Show what would change:**
200
+ - Which phase directories would be moved
201
+ - What ROADMAP.md section would be collapsed
202
+ - What STATE.md updates would occur
203
+ - What git tag would be created
204
+
205
+ 6. **Display summary:**
206
+ ```
207
+ ╔══════════════════════════════════════════════════════════════╗
208
+ ║ PLAN-BUILD-RUN ► MILESTONE PREVIEW — v{version} ║
209
+ ╚══════════════════════════════════════════════════════════════╝
210
+
211
+ Phases to archive: {count}
212
+ ✓ Verified: {verified_count}
213
+ ⚠ Unverified: {unverified_count}
214
+ ⚠ Stale verification: {stale_count}
215
+
216
+ Archive location: .planning/milestones/v{version}/
217
+ Git tag: v{version}
218
+
219
+ Ready to complete? Run: $pbr-milestone complete v{version}
220
+ ```
221
+
222
+ **CRITICAL (no hook)**: This subcommand is READ-ONLY. Do not create directories, move files, modify STATE.md, modify ROADMAP.md, or create git tags. Only read and display.
223
+
224
+ ---
225
+
226
+ ## Subcommand: `complete`
227
+
228
+ Archive a completed milestone and prepare for the next one.
229
+
230
+ ### Flow
231
+
232
+ 1. **Determine version:**
233
+ - If provided in `$ARGUMENTS`: use it (auto-prefix `v` if missing)
234
+ - If not provided: ask via AskUserQuestion: "What version number for this milestone? (e.g., v1.0)"
235
+
236
+ 2. **Verify all phases are complete:**
237
+ - Read ROADMAP.md to find milestone phases
238
+ - For each phase, check for VERIFICATION.md
239
+ - If any phase lacks VERIFICATION.md:
240
+
241
+ Present the warning context:
242
+ Unverified phases:
243
+ - Phase {N}: {name}
244
+ - Phase {M}: {name}
245
+
246
+ Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
247
+ question: "{count} phases haven't been verified. Continue with milestone completion?"
248
+ header: "Unverified"
249
+ options:
250
+ - label: "Continue anyway" description: "Proceed despite unverified phases (not recommended)"
251
+ - label: "Stop and review" description: "Run $pbr-review for unverified phases first"
252
+ - If "Stop and review" or "Other": stop and suggest the review commands for each unverified phase
253
+ - If "Continue anyway": proceed with warning noted
254
+
255
+ **Timestamp freshness check:**
256
+ For each phase that has a VERIFICATION.md, compare its `checked_at` frontmatter timestamp against the most recent SUMMARY.md file modification date in that phase directory (use `ls -t` or file stats).
257
+ If any SUMMARY.md is newer than its VERIFICATION.md `checked_at`:
258
+ - Warn: "Phase {N} ({name}) was modified after verification. The VERIFICATION.md may not reflect the current code state."
259
+ - List affected phases with their freshness details
260
+
261
+ Use AskUserQuestion (pattern: stale-continue from `skills/shared/gate-prompts.md`):
262
+ question: "{count} phases were modified after verification. Re-verify or continue?"
263
+ header: "Stale"
264
+ options:
265
+ - label: "Re-verify" description: "Run $pbr-review for affected phases (recommended)"
266
+ - label: "Continue anyway" description: "Proceed with potentially outdated verification"
267
+ - If "Re-verify" or "Other": suggest the review commands for affected phases and stop
268
+ - If "Continue anyway": proceed with warning noted
269
+
270
+ 3. **Gather milestone stats:**
271
+
272
+ ```bash
273
+ # Get commit range for this milestone's phases
274
+ git log --oneline --since="{milestone start date}" --until="now"
275
+
276
+ # Count files changed
277
+ git diff --stat {first_milestone_commit}..HEAD
278
+ ```
279
+
280
+ Collect:
281
+ - Total commits in milestone
282
+ - Total files changed
283
+ - Lines added / removed
284
+ - Duration (start date to now)
285
+ - Number of phases completed
286
+ - Number of plans executed
287
+ - Number of quick tasks
288
+
289
+ 4. **Extract accomplishments:**
290
+ Read all SUMMARY.md files for milestone phases:
291
+ - Collect `provides` fields (what was built)
292
+ - Collect `key_decisions` fields
293
+ - Collect `patterns` fields
294
+ - Collect `tech_stack` union
295
+
296
+ 5. **Archive milestone documents:**
297
+
298
+ **CRITICAL (no hook): Pre-flight safety checks BEFORE archiving. Do NOT skip this step.**
299
+
300
+ Before creating or moving anything, verify the destination is safe:
301
+ - Check if `.planning/milestones/{version}/` already exists
302
+ - If it exists AND contains files (phases/, STATS.md, etc.), STOP and display:
303
+ ```
304
+ ╔══════════════════════════════════════════════════════════════╗
305
+ ║ ERROR ║
306
+ ╚══════════════════════════════════════════════════════════════╝
307
+
308
+ Archive destination `.planning/milestones/{version}/` already contains files.
309
+ Completing this milestone would overwrite the existing archive.
310
+
311
+ **To fix:** Run `$pbr-health` or manually inspect `.planning/milestones/{version}/`.
312
+ Use a different version number (e.g., {version}.1) or remove the existing archive first.
313
+ ```
314
+ Ask the user via AskUserQuestion whether to use a different version or abort.
315
+ - Verify each source phase directory exists before attempting to move it
316
+ - If any source phase directory is missing, warn but continue with the phases that do exist
317
+
318
+ **CRITICAL (no hook): Create the archive directory .planning/milestones/{version}/ NOW. Do NOT skip this step.**
319
+
320
+ Create a versioned archive directory and move phase directories into it:
321
+ - `.planning/milestones/{version}/ROADMAP.md` — snapshot of ROADMAP.md at completion
322
+ - `.planning/milestones/{version}/REQUIREMENTS.md` — **CRITICAL (no hook): Copy REQUIREMENTS.md to archive NOW. Do NOT skip this step.** Snapshot of REQUIREMENTS.md
323
+ - `.planning/milestones/{version}/STATS.md` — milestone statistics
324
+ - `.planning/milestones/{version}/phases/{NN}-{slug}/` — move each milestone phase directory from `.planning/phases/` into the archive
325
+
326
+ **CRITICAL (no hook): Move phase directories from .planning/phases/ to archive NOW. Do NOT skip this step.**
327
+
328
+ **Move phases:** For each phase belonging to this milestone, move (not copy) its directory from `.planning/phases/{NN}-{slug}/` to `.planning/milestones/{version}/phases/{NN}-{slug}/`. This keeps the active phases directory clean for the next milestone.
329
+
330
+ **CRITICAL (no hook): Write STATS.md to .planning/milestones/{version}/STATS.md NOW. Do NOT skip this step.**
331
+
332
+ **Stats file content:**
333
+
334
+ Read `skills/milestone/templates/stats-file.md.tmpl` for the stats file format. Fill in all `{variable}` placeholders with actual data gathered in Steps 3-4.
335
+
336
+ 6. **Update PROJECT.md:**
337
+ - Move milestone from "Active" to "Completed"
338
+ - Add completion date and version tag
339
+
340
+ ```markdown
341
+ ## Completed Milestones
342
+
343
+ ### {name} ({version})
344
+ - **Completed:** {date}
345
+ - **Phases:** {start} - {end}
346
+ - **Key deliverables:** {summary}
347
+ ```
348
+
349
+ - Move validated requirements from active to completed section
350
+
351
+ **CRITICAL (no hook): Update ROADMAP.md with collapsed milestone section NOW. Do NOT skip this step.**
352
+
353
+ 7. **Collapse completed phases in ROADMAP.md:**
354
+ Replace detailed phase entries with collapsed summaries:
355
+
356
+ ```markdown
357
+ ## Milestone: {name} ({version}) -- COMPLETED
358
+
359
+ Phases {start}-{end} completed on {date}. See `.planning/milestones/{version}/ROADMAP.md` for details.
360
+
361
+ | Phase | Status |
362
+ |-------|--------|
363
+ | {N}. {name} | Completed |
364
+ | {N+1}. {name} | Completed |
365
+ ```
366
+
367
+ **CRITICAL (no hook): Update STATE.md to mark milestone as complete NOW. Do NOT skip this step.**
368
+
369
+ 7b. **Update STATE.md:**
370
+ - Update `.planning/STATE.md` to mark the milestone as complete
371
+ - Clear the current milestone field or set status to "completed"
372
+ - Update last activity timestamp
373
+ - Record the milestone version in the history/completed section
374
+
375
+ 7c. **Update HISTORY.md:**
376
+ - Append a milestone completion entry to `.planning/HISTORY.md`:
377
+ ```markdown
378
+ ## {date} — Milestone {version} Completed
379
+
380
+ - Milestone: {name}
381
+ - Phases: {start} - {end}
382
+ - Duration: {duration} days
383
+ - Key deliverables: {summary from Step 4}
384
+ ```
385
+
386
+ 7d. **Aggregate learnings from milestone phases:**
387
+
388
+ **CRITICAL (no hook): Run learnings aggregation NOW. Do NOT skip this step.**
389
+
390
+ ```bash
391
+ node ${PLUGIN_ROOT}/scripts/milestone-learnings.js .planning/milestones/{version} --project {project-name-from-STATE.md}
392
+ ```
393
+
394
+ - If the script outputs an error, log it but do NOT abort milestone completion — learnings aggregation is advisory.
395
+ - Display the aggregation summary line to the user (e.g., "Learnings aggregated: 12 new, 3 updated, 0 errors").
396
+ - After aggregation, check for triggered deferral thresholds:
397
+
398
+ ```bash
399
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js learnings check-thresholds
400
+ ```
401
+
402
+ If any thresholds are triggered, display each as a notification:
403
+
404
+ ```
405
+ Note: Learnings threshold met — {key}: {trigger}. Consider implementing the deferred feature.
406
+ ```
407
+
408
+ 8. **Git tag:**
409
+ ```bash
410
+ git tag -a {version} -m "Milestone: {name}"
411
+ ```
412
+
413
+ 9. **Commit:**
414
+ ```bash
415
+ git add .planning/milestones/ .planning/phases/ .planning/ROADMAP.md .planning/PROJECT.md .planning/STATE.md .planning/HISTORY.md
416
+ git commit -m "docs(planning): complete milestone {version}"
417
+ ```
418
+
419
+ 9b. **Push milestone to remote:**
420
+
421
+ Use AskUserQuestion to ask the user how they want to publish the milestone:
422
+
423
+ ```
424
+ question: "How should this milestone be published to GitHub?"
425
+ header: "Publish"
426
+ options:
427
+ - label: "Push tag + commits" description: "Push the v{version} tag and any unpushed commits to origin"
428
+ - label: "Skip for now" description: "Keep everything local — push later manually"
429
+ ```
430
+
431
+ - If "Push tag + commits": run `git push origin main --follow-tags` to push both commits and the annotated tag in one command. Display success or error.
432
+ - If "Skip for now": display reminder: "Tag v{version} is local only. Push when ready: `git push origin main --follow-tags`"
433
+ - If "Other": follow user instructions (e.g., create a PR, push to a different branch, etc.)
434
+
435
+ ### Post-Completion Smoke Test
436
+
437
+ If `config.deployment.smoke_test_command` is set and non-empty:
438
+
439
+ 1. Run the command via Bash
440
+ 2. If exit code 0: display "Smoke test passed" with command output
441
+ 3. If exit code non-zero: display advisory warning:
442
+
443
+ ```
444
+ ⚠ Smoke test failed (exit code {N})
445
+ Command: {smoke_test_command}
446
+ Output: {first 20 lines of output}
447
+ ```
448
+
449
+ This is advisory only — the milestone is already archived. Surface it as a potential issue for the user to investigate.
450
+
451
+ 10. **Confirm** with branded output — read `skills/milestone/templates/complete-output.md.tmpl` and fill in `{version}`, `{count}` (phases, plans, commits), `{lines}`, `{duration}`.
452
+
453
+ ---
454
+
455
+ ## Subcommand: `audit`
456
+
457
+ Verify milestone completion with cross-phase integration checks.
458
+
459
+ ### Flow
460
+
461
+ 1. **Determine target:**
462
+ - If version provided: audit that specific milestone
463
+ - If no version: audit the current milestone (most recent active)
464
+
465
+ 2. **Read all VERIFICATION.md files** for milestone phases:
466
+ - Collect verification results
467
+ - Note any `gaps_found` statuses
468
+ - Note any phases without verification
469
+
470
+ 3. **Spawn integration checker:**
471
+
472
+ Display to the user: `◐ Spawning integration checker...`
473
+
474
+ Spawn `Task(subagent_type: "pbr:integration-checker")`. Read `skills/milestone/templates/integration-checker-prompt.md.tmpl`, fill in `{version or "current"}`, `{list of phase directories}`, and `{phase SUMMARY.md paths}`, then use the filled template as the Task() prompt.
475
+
476
+ 4. **Check integration-checker completion:**
477
+
478
+ After the integration-checker completes, check for `## INTEGRATION CHECK COMPLETE` in the Task() output. If the marker is absent, warn: `⚠ Integration checker did not return completion marker — results may be incomplete.` Proceed with whatever findings were returned but note the incomplete status in the audit report.
479
+
480
+ 5. **Check requirements coverage:**
481
+ - Read REQUIREMENTS.md
482
+ - For each requirement tagged for this milestone:
483
+ - Search VERIFICATION.md files for coverage
484
+ - Search SUMMARY.md `provides` fields
485
+ - Flag uncovered requirements
486
+
487
+ 6. **Write audit report:**
488
+
489
+ Create `.planning/{version}-MILESTONE-AUDIT.md` using the template:
490
+
491
+ Read `skills/milestone/templates/audit-report.md.tmpl` for the audit report format. Fill in all `{variable}` placeholders with actual data from the audit.
492
+
493
+ **Spot-check:** After writing, verify `.planning/{version}-MILESTONE-AUDIT.md` exists on disk using Glob. If missing, re-attempt the write. If still missing, display an error and include findings inline.
494
+
495
+ 7. **Report to user** using branded banners — read `skills/milestone/templates/audit-output.md.tmpl`. The template contains all 3 variants (PASSED, GAPS FOUND, TECH DEBT). Select the appropriate section based on audit result. Fill in `{version}`, `{count}`, `{gap 1}`, `{gap 2}` as applicable.
496
+
497
+ ---
498
+
499
+ ## Subcommand: `gaps`
500
+
501
+ Create phases to close gaps found during an audit.
502
+
503
+ ### Flow
504
+
505
+ 1. **Find most recent audit:**
506
+ - Search for `*-MILESTONE-AUDIT.md` in `.planning/`
507
+ - If multiple, use the most recent
508
+ - If none: "No audit found. Run `$pbr-milestone audit` first."
509
+
510
+ 2. **Read audit report:**
511
+ - Extract all gaps and tech debt items
512
+ - Parse severity levels
513
+
514
+ 3. **Prioritize gaps:**
515
+
516
+ Group by priority:
517
+ - **Must fix** (critical/high): Blocking issues, broken integration, uncovered requirements
518
+ - **Should fix** (medium): Non-critical integration issues, important tech debt
519
+ - **Nice to fix** (low): Minor tech debt, optimization opportunities
520
+
521
+ 4. **Present to user:**
522
+
523
+ ```
524
+ Gaps from milestone audit:
525
+
526
+ Must fix ({count}):
527
+ - {gap}: {description}
528
+
529
+ Should fix ({count}):
530
+ - {gap}: {description}
531
+
532
+ Nice to fix ({count}):
533
+ - {gap}: {description}
534
+
535
+ Use AskUserQuestion (pattern: multi-option-priority from `skills/shared/gate-prompts.md`):
536
+ question: "Which gaps should we address? ({must_count} must-fix, {should_count} should-fix, {nice_count} nice-to-fix)"
537
+ header: "Priority"
538
+ options:
539
+ - label: "Must-fix only" description: "Address {must_count} critical/high gaps"
540
+ - label: "Must + should" description: "Address {must_count + should_count} critical through medium gaps"
541
+ - label: "Everything" description: "Address all {total_count} gaps including low priority"
542
+ - label: "Let me pick" description: "Choose specific gaps to address"
543
+ - If "Must-fix only": filter to must-fix gaps for phase creation
544
+ - If "Must + should": filter to must-fix + should-fix gaps
545
+ - If "Everything": include all gaps
546
+ - If "Let me pick" or "Other": present individual gaps for selection
547
+
548
+ 5. **Group into logical phases:**
549
+ - Group related gaps together (same subsystem, same files)
550
+ - Each group becomes a phase
551
+ - Name phases descriptively: "{N+1}. Fix {area} integration" or "{N+1}. Address {component} gaps"
552
+
553
+ 6. **Update ROADMAP.md:**
554
+ Add gap-closure phases after the current milestone phases:
555
+
556
+ ```markdown
557
+ ### Phase {N}: Fix {area} (gap closure)
558
+ **Goal:** Address gaps found in milestone audit
559
+ **Gaps addressed:**
560
+ - {gap 1}
561
+ - {gap 2}
562
+ **Success criteria:** All addressed gaps pass verification
563
+ ```
564
+
565
+ 7. **Create phase directories:**
566
+ ```
567
+ .planning/phases/{NN}-fix-{slug}/
568
+ ```
569
+
570
+ 8. **Commit:**
571
+ ```
572
+ docs(planning): add gap-closure phases from milestone audit
573
+ ```
574
+
575
+ 9. **Confirm** with branded output — read `skills/milestone/templates/gaps-output.md.tmpl` and fill in `{count}` (gap-closure phases created), `{N}` (first gap phase number), `{name}` (phase name).
576
+
577
+ ---
578
+
579
+ ## State Integration
580
+
581
+ All subcommands update STATE.md:
582
+ - `new`: Sets current milestone, resets phase
583
+ - `complete`: Clears current milestone, updates history
584
+ - `audit`: Notes audit status and date
585
+ - `gaps`: Updates phase count and roadmap info
586
+
587
+ ---
588
+
589
+ ## Git Integration
590
+
591
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
592
+
593
+ All subcommands commit if `planning.commit_docs: true`:
594
+ - `new`: `docs(planning): start milestone "{name}" (phases {start}-{end})`
595
+ - `complete`: `docs(planning): complete milestone {version}`
596
+ - `audit`: `docs(planning): audit milestone {version} - {status}`
597
+ - `gaps`: `docs(planning): add gap-closure phases from milestone audit`
598
+
599
+ Tags (complete only):
600
+ - `git tag -a {version} -m "Milestone: {name}"`
601
+
602
+ ---
603
+
604
+ ## Edge Cases
605
+
606
+ For all edge case handling, see `skills/milestone/templates/edge-cases.md`.
607
+ Key scenarios: no ROADMAP.md, no phases, no gaps found, version collision, partially verified, large milestone (8+ phases).
608
+
609
+ ---
610
+
611
+ ## Anti-Patterns
612
+
613
+ 1. **DO NOT** skip the audit before completing — integration issues hide at boundaries
614
+ 2. **DO NOT** auto-complete milestones without user confirmation
615
+ 3. **DO NOT** create gap phases without user approval of priorities
616
+ 4. **DO NOT** delete audit reports — they're historical records
617
+ 5. **DO NOT** reuse version numbers — each milestone gets a unique version
618
+ 6. **DO NOT** modify code during milestone operations — this is project management only
619
+ 7. **DO NOT** collapse phases in ROADMAP.md before archiving — archive first, collapse second
620
+ 8. **DO NOT** skip the git tag — tags make milestone boundaries findable