@sienklogic/plan-build-run 2.54.0 → 2.56.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 (130) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +1 -1
  3. package/plugins/codex-pbr/.codex/config.toml +101 -0
  4. package/plugins/codex-pbr/AGENTS.md +653 -0
  5. package/plugins/codex-pbr/README.md +116 -0
  6. package/plugins/codex-pbr/agents/audit.md +223 -0
  7. package/plugins/codex-pbr/agents/codebase-mapper.md +196 -0
  8. package/plugins/codex-pbr/agents/debugger.md +245 -0
  9. package/plugins/codex-pbr/agents/dev-sync.md +142 -0
  10. package/plugins/codex-pbr/agents/executor.md +429 -0
  11. package/plugins/codex-pbr/agents/general.md +131 -0
  12. package/plugins/codex-pbr/agents/integration-checker.md +178 -0
  13. package/plugins/codex-pbr/agents/plan-checker.md +253 -0
  14. package/plugins/codex-pbr/agents/planner.md +343 -0
  15. package/plugins/codex-pbr/agents/researcher.md +253 -0
  16. package/plugins/codex-pbr/agents/synthesizer.md +183 -0
  17. package/plugins/codex-pbr/agents/verifier.md +352 -0
  18. package/plugins/codex-pbr/commands/audit.md +5 -0
  19. package/plugins/codex-pbr/commands/begin.md +5 -0
  20. package/plugins/codex-pbr/commands/build.md +5 -0
  21. package/plugins/codex-pbr/commands/config.md +5 -0
  22. package/plugins/codex-pbr/commands/continue.md +5 -0
  23. package/plugins/codex-pbr/commands/dashboard.md +5 -0
  24. package/plugins/codex-pbr/commands/debug.md +5 -0
  25. package/plugins/codex-pbr/commands/discuss.md +5 -0
  26. package/plugins/codex-pbr/commands/do.md +5 -0
  27. package/plugins/codex-pbr/commands/explore.md +5 -0
  28. package/plugins/codex-pbr/commands/health.md +5 -0
  29. package/plugins/codex-pbr/commands/help.md +5 -0
  30. package/plugins/codex-pbr/commands/import.md +5 -0
  31. package/plugins/codex-pbr/commands/milestone.md +5 -0
  32. package/plugins/codex-pbr/commands/note.md +5 -0
  33. package/plugins/codex-pbr/commands/pause.md +5 -0
  34. package/plugins/codex-pbr/commands/plan.md +5 -0
  35. package/plugins/codex-pbr/commands/quick.md +5 -0
  36. package/plugins/codex-pbr/commands/resume.md +5 -0
  37. package/plugins/codex-pbr/commands/review.md +5 -0
  38. package/plugins/codex-pbr/commands/scan.md +5 -0
  39. package/plugins/codex-pbr/commands/setup.md +5 -0
  40. package/plugins/codex-pbr/commands/status.md +5 -0
  41. package/plugins/codex-pbr/commands/statusline.md +5 -0
  42. package/plugins/codex-pbr/commands/test.md +5 -0
  43. package/plugins/codex-pbr/commands/todo.md +5 -0
  44. package/plugins/codex-pbr/commands/undo.md +5 -0
  45. package/plugins/codex-pbr/references/agent-contracts.md +324 -0
  46. package/plugins/codex-pbr/references/agent-teams.md +54 -0
  47. package/plugins/codex-pbr/references/common-bug-patterns.md +13 -0
  48. package/plugins/codex-pbr/references/config-reference.md +552 -0
  49. package/plugins/codex-pbr/references/continuation-format.md +212 -0
  50. package/plugins/codex-pbr/references/deviation-rules.md +112 -0
  51. package/plugins/codex-pbr/references/git-integration.md +256 -0
  52. package/plugins/codex-pbr/references/integration-patterns.md +117 -0
  53. package/plugins/codex-pbr/references/model-profiles.md +99 -0
  54. package/plugins/codex-pbr/references/model-selection.md +31 -0
  55. package/plugins/codex-pbr/references/pbr-tools-cli.md +400 -0
  56. package/plugins/codex-pbr/references/plan-authoring.md +246 -0
  57. package/plugins/codex-pbr/references/plan-format.md +313 -0
  58. package/plugins/codex-pbr/references/questioning.md +235 -0
  59. package/plugins/codex-pbr/references/reading-verification.md +127 -0
  60. package/plugins/codex-pbr/references/signal-files.md +41 -0
  61. package/plugins/codex-pbr/references/stub-patterns.md +160 -0
  62. package/plugins/codex-pbr/references/ui-formatting.md +444 -0
  63. package/plugins/codex-pbr/references/wave-execution.md +95 -0
  64. package/plugins/codex-pbr/skills/audit/SKILL.md +346 -0
  65. package/plugins/codex-pbr/skills/begin/SKILL.md +800 -0
  66. package/plugins/codex-pbr/skills/build/SKILL.md +958 -0
  67. package/plugins/codex-pbr/skills/config/SKILL.md +267 -0
  68. package/plugins/codex-pbr/skills/continue/SKILL.md +172 -0
  69. package/plugins/codex-pbr/skills/dashboard/SKILL.md +44 -0
  70. package/plugins/codex-pbr/skills/debug/SKILL.md +530 -0
  71. package/plugins/codex-pbr/skills/discuss/SKILL.md +355 -0
  72. package/plugins/codex-pbr/skills/do/SKILL.md +68 -0
  73. package/plugins/codex-pbr/skills/explore/SKILL.md +407 -0
  74. package/plugins/codex-pbr/skills/health/SKILL.md +300 -0
  75. package/plugins/codex-pbr/skills/help/SKILL.md +229 -0
  76. package/plugins/codex-pbr/skills/import/SKILL.md +538 -0
  77. package/plugins/codex-pbr/skills/milestone/SKILL.md +620 -0
  78. package/plugins/codex-pbr/skills/note/SKILL.md +215 -0
  79. package/plugins/codex-pbr/skills/pause/SKILL.md +258 -0
  80. package/plugins/codex-pbr/skills/plan/SKILL.md +650 -0
  81. package/plugins/codex-pbr/skills/quick/SKILL.md +417 -0
  82. package/plugins/codex-pbr/skills/resume/SKILL.md +403 -0
  83. package/plugins/codex-pbr/skills/review/SKILL.md +669 -0
  84. package/plugins/codex-pbr/skills/scan/SKILL.md +325 -0
  85. package/plugins/codex-pbr/skills/setup/SKILL.md +169 -0
  86. package/plugins/codex-pbr/skills/shared/commit-planning-docs.md +35 -0
  87. package/plugins/codex-pbr/skills/shared/config-loading.md +102 -0
  88. package/plugins/codex-pbr/skills/shared/context-budget.md +77 -0
  89. package/plugins/codex-pbr/skills/shared/context-loader-task.md +86 -0
  90. package/plugins/codex-pbr/skills/shared/digest-select.md +79 -0
  91. package/plugins/codex-pbr/skills/shared/domain-probes.md +125 -0
  92. package/plugins/codex-pbr/skills/shared/error-reporting.md +59 -0
  93. package/plugins/codex-pbr/skills/shared/gate-prompts.md +388 -0
  94. package/plugins/codex-pbr/skills/shared/phase-argument-parsing.md +45 -0
  95. package/plugins/codex-pbr/skills/shared/revision-loop.md +81 -0
  96. package/plugins/codex-pbr/skills/shared/state-update.md +169 -0
  97. package/plugins/codex-pbr/skills/shared/universal-anti-patterns.md +43 -0
  98. package/plugins/codex-pbr/skills/status/SKILL.md +449 -0
  99. package/plugins/codex-pbr/skills/statusline/SKILL.md +149 -0
  100. package/plugins/codex-pbr/skills/test/SKILL.md +210 -0
  101. package/plugins/codex-pbr/skills/todo/SKILL.md +281 -0
  102. package/plugins/codex-pbr/skills/undo/SKILL.md +172 -0
  103. package/plugins/codex-pbr/templates/CONTEXT.md.tmpl +52 -0
  104. package/plugins/codex-pbr/templates/INTEGRATION-REPORT.md.tmpl +167 -0
  105. package/plugins/codex-pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  106. package/plugins/codex-pbr/templates/ROADMAP.md.tmpl +47 -0
  107. package/plugins/codex-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  108. package/plugins/codex-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  109. package/plugins/codex-pbr/templates/SUMMARY.md.tmpl +81 -0
  110. package/plugins/codex-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  111. package/plugins/codex-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  112. package/plugins/codex-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  113. package/plugins/codex-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  114. package/plugins/codex-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  115. package/plugins/codex-pbr/templates/codebase/STACK.md.tmpl +78 -0
  116. package/plugins/codex-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  117. package/plugins/codex-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  118. package/plugins/codex-pbr/templates/continue-here.md.tmpl +73 -0
  119. package/plugins/codex-pbr/templates/pr-body.md.tmpl +22 -0
  120. package/plugins/codex-pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  121. package/plugins/codex-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  122. package/plugins/codex-pbr/templates/research/STACK.md.tmpl +71 -0
  123. package/plugins/codex-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  124. package/plugins/codex-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  125. package/plugins/codex-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  126. package/plugins/codex-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  127. package/plugins/copilot-pbr/plugin.json +1 -1
  128. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  129. package/plugins/jules-pbr/AGENTS.md +600 -0
  130. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,653 @@
1
+ # Plan-Build-Run Workflow for Codex
2
+
3
+ > This file teaches Codex the Plan-Build-Run (PBR) development methodology.
4
+ > Place it in your repository root so Codex reads it before starting any task.
5
+ >
6
+ > PBR prevents quality degradation on complex projects by enforcing a
7
+ > disciplined Plan → Build → Review cycle with file-based state tracking.
8
+
9
+ ---
10
+
11
+ ## Core Principle
12
+
13
+ **Never build without a plan. Never ship without a review.**
14
+
15
+ Every meaningful change flows through three stages:
16
+
17
+ 1. **Plan** — Research the problem, design the solution, define success criteria
18
+ 2. **Build** — Execute the plan with atomic commits, one task at a time
19
+ 3. **Review** — Verify the build achieved the plan's goals (goal-backward verification)
20
+
21
+ ---
22
+
23
+ ## Project State Directory
24
+
25
+ All workflow state lives in `.planning/` at the repository root. Codex should
26
+ create and maintain these files as it works:
27
+
28
+ ```
29
+ .planning/
30
+ ├── STATE.md # Current position in the workflow
31
+ ├── ROADMAP.md # Phase structure with goals and dependencies
32
+ ├── config.json # Workflow settings (optional)
33
+ ├── phases/
34
+ │ └── NN-slug/ # One directory per phase
35
+ │ ├── PLAN.md # What to build and how
36
+ │ ├── SUMMARY.md # What was built (written after execution)
37
+ │ └── VERIFICATION.md # Did the build match the plan?
38
+ ├── quick/ # Lightweight tasks outside the full cycle
39
+ │ └── NNN-slug/
40
+ │ ├── PLAN.md
41
+ │ └── SUMMARY.md
42
+ ├── debug/ # Persistent debug sessions
43
+ │ └── slug/
44
+ │ └── HYPOTHESIS.md
45
+ ├── notes/ # Captured ideas and decisions
46
+ ├── todos/
47
+ │ ├── pending/ # Active cross-session backlog
48
+ │ └── done/ # Completed todos
49
+ └── milestones/ # Archived milestone snapshots
50
+ └── v{version}/
51
+ ```
52
+
53
+ ### STATE.md Format
54
+
55
+ ```markdown
56
+ ---
57
+ current_phase: "01-setup"
58
+ current_plan: "01-01"
59
+ status: "Planning" # Planning | Planned | Building | Built | Verified
60
+ updated: "2025-01-15T10:30:00Z"
61
+ ---
62
+
63
+ ## Current Focus
64
+ Brief description of what's happening now.
65
+
66
+ ## Recently Completed
67
+ - Phase 01, Plan 01: Project scaffolding (Verified)
68
+
69
+ ## Next Steps
70
+ 1. Primary: Start planning phase 02
71
+ 2. Alternative: Review phase 01 verification results
72
+ ```
73
+
74
+ Valid status transitions: Planning → Planned → Building → Built → Verified
75
+
76
+ ---
77
+
78
+ ## Skill Invocation
79
+
80
+ PBR skills live in `.agents/skills/{name}/SKILL.md` in the plugin directory.
81
+ Codex discovers and runs them using the `$pbr-{name}` syntax.
82
+
83
+ ### Available Skills
84
+
85
+ | Skill | Command | When to Use |
86
+ |-------|---------|-------------|
87
+ | begin | `$pbr-begin` | Start a new project or onboard PBR to existing codebase |
88
+ | plan | `$pbr-plan` | Plan the next phase or plan item |
89
+ | build | `$pbr-build` | Execute the current plan |
90
+ | review | `$pbr-review` | Verify a completed build against its plan |
91
+ | status | `$pbr-status` | Show current workflow position |
92
+ | quick | `$pbr-quick` | Run a lightweight task outside the full cycle |
93
+ | continue | `$pbr-continue` | Resume from a checkpoint or interrupted session |
94
+ | pause | `$pbr-pause` | Pause with context preservation |
95
+ | resume | `$pbr-resume` | Resume a paused session |
96
+ | debug | `$pbr-debug` | Start or continue a debug investigation |
97
+ | explore | `$pbr-explore` | Research a domain or problem space |
98
+ | discuss | `$pbr-discuss` | Think through a design decision |
99
+ | do | `$pbr-do` | Execute a one-off instruction under PBR rules |
100
+ | scan | `$pbr-scan` | Audit codebase for issues |
101
+ | health | `$pbr-health` | Check project health and workflow hygiene |
102
+ | milestone | `$pbr-milestone` | Manage versioned milestone releases |
103
+ | todo | `$pbr-todo` | Manage cross-session task backlog |
104
+ | note | `$pbr-note` | Capture a decision or observation |
105
+ | import | `$pbr-import` | Import existing work into PBR structure |
106
+ | config | `$pbr-config` | Manage workflow configuration |
107
+ | setup | `$pbr-setup` | Configure or reconfigure PBR for this project |
108
+ | audit | `$pbr-audit` | Analyze session logs for workflow compliance |
109
+ | help | `$pbr-help` | Show available skills and usage |
110
+ | statusline | `$pbr-statusline` | Output a compact status summary |
111
+ | undo | `$pbr-undo` | Roll back the last plan or build step |
112
+
113
+ Skills can be invoked explicitly (`$pbr-plan`) or triggered implicitly when
114
+ your request description matches a skill's purpose. For example, saying
115
+ "plan the authentication phase" may implicitly trigger `$pbr-plan`.
116
+
117
+ ---
118
+
119
+ ## Phase Workflow
120
+
121
+ ### Step 1: Planning a Phase
122
+
123
+ Before writing any code for a phase, create a plan file:
124
+
125
+ **`.planning/phases/NN-slug/PLAN.md`**:
126
+
127
+ ```markdown
128
+ ---
129
+ phase: "01-setup"
130
+ plan: "01-01"
131
+ type: "feature"
132
+ files_modified:
133
+ - "src/config.ts"
134
+ - "src/database.ts"
135
+ must_haves:
136
+ truths:
137
+ - "Database connection is established on startup"
138
+ - "Configuration loads from environment variables"
139
+ artifacts:
140
+ - "src/config.ts: >30 lines, exports loadConfig()"
141
+ - "src/database.ts: >40 lines, exports connectDB()"
142
+ ---
143
+
144
+ ## Tasks
145
+
146
+ ### Task 1: Create configuration loader
147
+ - Read environment variables for DB_HOST, DB_PORT, DB_NAME
148
+ - Export a typed config object
149
+ - Throw on missing required variables
150
+
151
+ ### Task 2: Create database connection module
152
+ - Use the config from Task 1
153
+ - Implement connection pooling
154
+ - Export connectDB() and getDB() functions
155
+
156
+ ### Task 3: Add startup integration
157
+ - Call loadConfig() then connectDB() in main entry point
158
+ - Log connection success/failure
159
+ ```
160
+
161
+ **Planning rules:**
162
+ - Define `must_haves` with concrete, verifiable success criteria
163
+ - List all files that will be created or modified
164
+ - Break work into small, independently committable tasks
165
+ - Each task should produce a working, testable increment
166
+
167
+ ### Step 2: Building (Executing the Plan)
168
+
169
+ When executing a plan:
170
+
171
+ 1. **Read the plan first** — Load `.planning/phases/NN-slug/PLAN.md`
172
+ 2. **Update STATE.md** — Set status to "Building"
173
+ 3. **Execute tasks sequentially** — Follow the plan's task order
174
+ 4. **Commit after each task** — One atomic commit per task
175
+ 5. **Write SUMMARY.md** — Document what was actually built
176
+
177
+ **Commit message format:**
178
+
179
+ ```
180
+ {type}({phase}-{plan}): {description}
181
+ ```
182
+
183
+ Examples:
184
+ - `feat(01-01): implement configuration loader`
185
+ - `fix(01-01): handle missing DB_PORT with default value`
186
+ - `test(01-01): add unit tests for config validation`
187
+ - `refactor(02-01): extract auth middleware into separate module`
188
+
189
+ Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`
190
+
191
+ **SUMMARY.md format** (written after all tasks complete):
192
+
193
+ ```markdown
194
+ ---
195
+ phase: "01-setup"
196
+ plan: "01-01"
197
+ status: "complete"
198
+ commits:
199
+ - "abc1234: feat(01-01): implement configuration loader"
200
+ - "def5678: feat(01-01): create database connection module"
201
+ key_files:
202
+ - "src/config.ts"
203
+ - "src/database.ts"
204
+ requires:
205
+ - "Node.js 18+"
206
+ - "PostgreSQL 14+"
207
+ deferred:
208
+ - "Connection retry logic (moved to phase 03)"
209
+ ---
210
+
211
+ ## What Was Built
212
+ Brief narrative of what was accomplished and any deviations from the plan.
213
+ ```
214
+
215
+ ### Step 3: Verification
216
+
217
+ After building, verify the work against the plan's `must_haves`:
218
+
219
+ **VERIFICATION.md format:**
220
+
221
+ ```markdown
222
+ ---
223
+ phase: "01-setup"
224
+ plan: "01-01"
225
+ result: "PASS"
226
+ verified_at: "2025-01-15T14:00:00Z"
227
+ ---
228
+
229
+ ## Must-Have Verification
230
+
231
+ | # | Criterion | Status | Evidence |
232
+ |---|-----------|--------|----------|
233
+ | 1 | Database connection established on startup | PASS | `connectDB()` called in `src/index.ts:15` |
234
+ | 2 | Config loads from environment variables | PASS | `loadConfig()` reads DB_HOST, DB_PORT, DB_NAME |
235
+
236
+ ## Artifact Verification
237
+
238
+ | # | Artifact | Status | Evidence |
239
+ |---|----------|--------|----------|
240
+ | 1 | src/config.ts: >30 lines, exports loadConfig() | PASS | 47 lines, exports `loadConfig()` at line 12 |
241
+ | 2 | src/database.ts: >40 lines, exports connectDB() | PASS | 63 lines, exports `connectDB()` at line 28 |
242
+
243
+ ## Deviations
244
+ None — plan executed as written.
245
+ ```
246
+
247
+ ---
248
+
249
+ ## ROADMAP.md Structure
250
+
251
+ The roadmap defines the full project as a sequence of phases:
252
+
253
+ ```markdown
254
+ # Project Roadmap
255
+
256
+ ## Phase 01: Project Setup
257
+ **Goal:** Establish project foundation with configuration and database connectivity.
258
+ **Status:** Verified
259
+ **Depends on:** (none)
260
+
261
+ ## Phase 02: Authentication
262
+ **Goal:** Users can sign in via OAuth and receive a session token.
263
+ **Status:** Planning
264
+ **Depends on:** Phase 01
265
+
266
+ ## Phase 03: Core Features
267
+ **Goal:** Implement the primary user-facing features.
268
+ **Status:** Pending
269
+ **Depends on:** Phase 01, Phase 02
270
+ ```
271
+
272
+ **Rules:**
273
+ - Phases are numbered sequentially (`01`, `02`, `03`, ...)
274
+ - Each phase has a clear, measurable goal
275
+ - Dependencies between phases are explicit
276
+ - Status tracks the highest completed stage for that phase
277
+
278
+ ---
279
+
280
+ ## Enforcement Rules
281
+
282
+ Codex has no hook system, so these rules are self-enforced checkpoints.
283
+ Run through this checklist at every stage transition.
284
+
285
+ ### Gate 1: Commit Format
286
+
287
+ Before any `git commit`, verify the message matches:
288
+
289
+ ```
290
+ {type}({scope}): {description}
291
+ ```
292
+
293
+ - **Valid types**: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`
294
+ - **Valid scopes**: `NN-MM` (phase-plan), `quick-NNN`, `planning`, or a descriptive word
295
+ - **Block the commit** if the format doesn't match — fix the message first
296
+
297
+ ### Gate 2: Plan-Before-Build
298
+
299
+ Before writing any source code for a phase:
300
+
301
+ - Confirm `.planning/phases/NN-slug/PLAN.md` exists
302
+ - Confirm the plan has `must_haves` with at least one truth and one artifact
303
+ - **Never write production code without an approved plan**
304
+
305
+ ### Gate 3: Phase Boundary
306
+
307
+ Only modify `.planning/phases/NN-*/` files for the phase shown in `STATE.md`.
308
+
309
+ - Cross-phase edits require explicit justification in the commit body
310
+ - Don't refactor an old phase while building a new one
311
+
312
+ ### Gate 4: Format Validation
313
+
314
+ After writing any planning artifact, verify required frontmatter fields:
315
+
316
+ | File | Required fields |
317
+ |------|----------------|
318
+ | PLAN.md | `phase`, `plan`, `must_haves` (with `truths` and `artifacts`) |
319
+ | SUMMARY.md | `phase`, `plan`, `status`, `requires`, `key_files`, `deferred` |
320
+ | VERIFICATION.md | `phase`, `plan`, `result` (must be `PASS`, `FAIL`, `BLOCKED`, or `DEFERRED`) |
321
+
322
+ ### Gate 5: State Sync
323
+
324
+ After writing SUMMARY.md or VERIFICATION.md:
325
+
326
+ 1. Update `STATE.md` — set `status` to the new stage, update `updated` timestamp
327
+ 2. Update `ROADMAP.md` — update the phase's `**Status:**` line to match
328
+
329
+ Both files must stay in sync. Stale state causes confusion across sessions.
330
+
331
+ ---
332
+
333
+ ## Stage Transition Checkpoints
334
+
335
+ Use these checklists at each stage boundary.
336
+
337
+ ### Before Planning
338
+
339
+ - [ ] Read `.planning/STATE.md` — confirm current phase and status
340
+ - [ ] Read `.planning/ROADMAP.md` — confirm phase goal and dependencies
341
+ - [ ] Verify dependent phases are "Verified" before starting this phase
342
+ - [ ] Create `.planning/phases/NN-slug/` directory if it doesn't exist
343
+
344
+ ### After Planning (Before Building)
345
+
346
+ - [ ] PLAN.md has valid frontmatter (Gate 4)
347
+ - [ ] `must_haves.truths` are observable facts (not implementation notes)
348
+ - [ ] `must_haves.artifacts` specify file path, minimum size, and key exports
349
+ - [ ] Update STATE.md status to "Planned"
350
+
351
+ ### Before Building
352
+
353
+ - [ ] PLAN.md exists and is readable (Gate 2)
354
+ - [ ] Update STATE.md status to "Building"
355
+ - [ ] Note any pre-existing test failures — don't fix them unless the plan says to
356
+
357
+ ### After Each Commit
358
+
359
+ - [ ] Commit message matches `{type}({scope}): {description}` (Gate 1)
360
+ - [ ] Only files listed in the plan's `files_modified` were staged
361
+ - [ ] The commit represents a single logical change
362
+
363
+ ### After Building
364
+
365
+ - [ ] SUMMARY.md written with all required frontmatter fields (Gate 4)
366
+ - [ ] Every file listed in `key_files` exists on disk
367
+ - [ ] All commits listed in `commits` frontmatter actually exist in git log
368
+ - [ ] Update STATE.md status to "Built"
369
+ - [ ] Check `.planning/todos/pending/` — auto-close any todos satisfied by this work
370
+
371
+ ### After Verification
372
+
373
+ - [ ] VERIFICATION.md written with `result: PASS` or `result: FAIL`
374
+ - [ ] Every must-have has a row in the verification table with evidence
375
+ - [ ] Update STATE.md status to "Verified"
376
+ - [ ] Update ROADMAP.md phase status to "Verified" (Gate 5)
377
+ - [ ] Suggest next phase to the user
378
+
379
+ ---
380
+
381
+ ## Supplementary Workflows
382
+
383
+ ### Quick Tasks
384
+
385
+ For small changes that don't justify the full Plan-Build-Review cycle:
386
+
387
+ **Use quick tasks for:**
388
+ - Single-file changes
389
+ - Bug fixes with obvious solutions
390
+ - Documentation updates
391
+ - Configuration tweaks
392
+
393
+ **Use the full cycle for:**
394
+ - Changes spanning 3+ files
395
+ - New features requiring design decisions
396
+ - Anything that will take more than one commit
397
+
398
+ **Quick task structure:**
399
+
400
+ ```
401
+ .planning/quick/
402
+ └── NNN-slug/
403
+ ├── PLAN.md # Brief: what, why, files
404
+ └── SUMMARY.md # What was done, commit SHA
405
+ ```
406
+
407
+ Commit scope for quick tasks: `quick-NNN` (e.g., `fix(quick-001): correct typo in README`).
408
+
409
+ Quick PLAN.md only needs: one-sentence goal, files to touch, and definition of done.
410
+ Quick SUMMARY.md only needs: what was done and the commit hash.
411
+
412
+ ### Milestones
413
+
414
+ Milestones group phases into versioned releases.
415
+
416
+ **ROADMAP.md milestone syntax:**
417
+
418
+ ```markdown
419
+ ## Milestone v1.0: Initial Release
420
+ **Phases:** 01, 02, 03
421
+ **Status:** In Progress
422
+ ```
423
+
424
+ **Completing a milestone:**
425
+
426
+ 1. Verify all included phases have `status: Verified`
427
+ 2. Create `.planning/milestones/v{version}/`
428
+ 3. Copy (archive) `ROADMAP.md` and phase directories into it
429
+ 4. Create `STATS.md` with completion date, total commits, and phase count
430
+ 5. Collapse the milestone section in active ROADMAP.md to a single "COMPLETED" line
431
+ 6. Tag the commit: `git tag v{version}`
432
+
433
+ Archive structure:
434
+
435
+ ```
436
+ .planning/milestones/v1.0/
437
+ ├── ROADMAP.md # Snapshot of roadmap at completion
438
+ ├── STATS.md # Summary stats
439
+ └── phases/
440
+ ├── 01-setup/
441
+ └── 02-auth/
442
+ ```
443
+
444
+ ### Debug Workflow
445
+
446
+ For bugs requiring systematic investigation across sessions:
447
+
448
+ **Create a debug session:**
449
+
450
+ ```
451
+ .planning/debug/{slug}/
452
+ └── HYPOTHESIS.md
453
+ ```
454
+
455
+ **HYPOTHESIS.md format:**
456
+
457
+ ```markdown
458
+ ---
459
+ bug: "Brief bug description"
460
+ created: "2025-01-15"
461
+ status: "investigating" # investigating | confirmed | resolved
462
+ ---
463
+
464
+ ## Symptoms
465
+ What the user observes. Include error messages, reproduction steps.
466
+
467
+ ## Hypotheses
468
+
469
+ ### H1: [Hypothesis name]
470
+ **Test:** How to confirm or deny this
471
+ **Result:** (fill in after testing)
472
+ **Conclusion:** CONFIRMED / RULED OUT
473
+
474
+ ### H2: [Hypothesis name]
475
+ **Test:** ...
476
+ **Result:** ...
477
+ **Conclusion:** ...
478
+
479
+ ## Root Cause
480
+ (fill in when found)
481
+
482
+ ## Fix Applied
483
+ (fill in after resolution — commit SHA and description)
484
+ ```
485
+
486
+ Update `status` to `resolved` and record the fix. The file persists across sessions
487
+ so you never re-investigate the same root cause.
488
+
489
+ ### Notes System
490
+
491
+ Capture decisions, observations, and ideas between sessions:
492
+
493
+ ```
494
+ .planning/notes/{YYYY-MM-DD}-{slug}.md
495
+ ```
496
+
497
+ **Note frontmatter:**
498
+
499
+ ```markdown
500
+ ---
501
+ date: "2025-01-15"
502
+ promoted: false
503
+ ---
504
+
505
+ The note body goes here. Free-form markdown.
506
+ ```
507
+
508
+ Use `promoted: true` when a note has been acted on (turned into a phase or todo).
509
+ Notes are append-only — add new files rather than editing old ones.
510
+
511
+ ### Todo Management
512
+
513
+ Cross-session task backlog for items that don't yet have a phase:
514
+
515
+ ```
516
+ .planning/todos/pending/{NNN}-{slug}.md # Active
517
+ .planning/todos/done/{NNN}-{slug}.md # Completed
518
+ ```
519
+
520
+ **Todo format:**
521
+
522
+ ```markdown
523
+ ---
524
+ id: "001"
525
+ created: "2025-01-15"
526
+ priority: medium # high | medium | low
527
+ ---
528
+
529
+ What needs to be done and why.
530
+ ```
531
+
532
+ After completing any phase or quick task, check `.planning/todos/pending/` and
533
+ move satisfied todos to `done/` by renaming the file.
534
+
535
+ ### Session Continuity
536
+
537
+ Use `.planning/.continue-here.md` to preserve context between Codex sessions.
538
+
539
+ **When pausing (write `.planning/.continue-here.md`):**
540
+
541
+ ```markdown
542
+ ---
543
+ paused_at: "2025-01-15T16:00:00Z"
544
+ current_phase: "02-auth"
545
+ current_plan: "02-01"
546
+ ---
547
+
548
+ ## What Was In Progress
549
+ Which task was active, what had been done, what remained.
550
+
551
+ ## Blockers
552
+ Any external dependencies or decisions needed before resuming.
553
+
554
+ ## Next Action
555
+ The single most important thing to do when resuming. Be specific.
556
+
557
+ ## Context Notes
558
+ Anything Codex would need to know that isn't obvious from the files.
559
+ ```
560
+
561
+ **When resuming:**
562
+
563
+ 1. Read `.planning/.continue-here.md` first
564
+ 2. Read `STATE.md` to confirm current position
565
+ 3. Execute the "Next Action" listed
566
+ 4. Delete `.planning/.continue-here.md` once work resumes normally
567
+
568
+ ### Brownfield Onboarding
569
+
570
+ Introducing PBR to an existing project without a `.planning/` directory:
571
+
572
+ 1. **Scan the codebase** — understand the current structure, tech stack, and any existing docs
573
+ 2. **Create `.planning/`** — initialize the directory structure
574
+ 3. **Write ROADMAP.md** — identify logical phases based on what already exists
575
+ - Phase 01 is often "Baseline" — mark it Verified to acknowledge existing work
576
+ - Subsequent phases are planned work
577
+ 4. **Write STATE.md** — set `current_phase` to the first active phase, status "Planning"
578
+ 5. **Create PLAN.md for Phase 01 (if not trivial)** — document what exists as baseline
579
+ 6. **Proceed normally** — the next feature or bug fix becomes Phase 02+
580
+
581
+ Don't try to retroactively document every historical decision. A lightweight ROADMAP.md
582
+ that captures the current state is enough to enable PBR going forward.
583
+
584
+ ---
585
+
586
+ ## Configuration
587
+
588
+ PBR behavior can be customized via `.codex/config.toml` in your project.
589
+ See the sample config at `plugins/codex-pbr/.codex/config.toml` for all options.
590
+
591
+ Key configuration areas:
592
+ - **Agent profiles** — model selection per PBR agent role
593
+ - **Sandbox** — which commands are allowed during builds
594
+ - **Workflow** — timeouts and context limits
595
+
596
+ ---
597
+
598
+ ## Working Rules for Codex
599
+
600
+ ### Before Starting Any Task
601
+
602
+ 1. Check if `.planning/STATE.md` exists — if so, read it to understand current position
603
+ 2. Check if `.planning/ROADMAP.md` exists — if so, read it to understand phase structure
604
+ 3. If the user's request maps to an existing phase, follow the Plan-Build-Review cycle
605
+ 4. If no `.planning/` directory exists and the task is non-trivial, offer to create one
606
+ 5. Check `.planning/.continue-here.md` — if it exists, resume from there
607
+
608
+ ### During Execution
609
+
610
+ - **One task, one commit** — never bundle unrelated changes
611
+ - **Stage specific files** — never use `git add .` or `git add -A`
612
+ - **Follow the plan** — if you need to deviate, document why in SUMMARY.md
613
+ - **Update STATE.md** — keep it current as you transition between stages
614
+ - **Don't over-engineer** — build exactly what the plan specifies, nothing more
615
+
616
+ ### After Completing Work
617
+
618
+ - Write SUMMARY.md documenting what was built
619
+ - Run verification against the plan's must_haves
620
+ - Write VERIFICATION.md with pass/fail results and evidence
621
+ - Update STATE.md status to "Built" or "Verified"
622
+ - Check `.planning/todos/pending/` for any todos to close
623
+ - Suggest the next logical step to the user
624
+
625
+ ---
626
+
627
+ ## Context Management
628
+
629
+ Codex operates in interactive CLI sessions, so context management matters:
630
+
631
+ - **Write decisions to disk** — don't rely on conversation memory
632
+ - **STATE.md is the source of truth** — always read it at task start
633
+ - **Plans are contracts** — they define what "done" means
634
+ - **Summaries close the loop** — they record what actually happened
635
+ - **Use `.continue-here.md`** — for deliberate pauses between sessions
636
+
637
+ If a task is complex enough to span multiple sessions, the
638
+ `.planning/` directory ensures continuity between them.
639
+
640
+ ---
641
+
642
+ ## Anti-Patterns to Avoid
643
+
644
+ 1. **Building without a plan** — leads to scope creep and rework
645
+ 2. **Skipping verification** — you don't know if you succeeded
646
+ 3. **Giant commits** — impossible to review or revert
647
+ 4. **Modifying files outside the plan's scope** — creates hidden dependencies
648
+ 5. **Ignoring must_haves** — they exist to define "done" objectively
649
+ 6. **Re-reading entire files when summaries exist** — wastes context
650
+ 7. **Creating artifacts the user didn't approve** — always confirm first
651
+ 8. **Using `git add .`** — stages unintended files; always stage explicitly
652
+ 9. **Skipping STATE.md updates** — stale state causes confusion across sessions
653
+ 10. **Fixing pre-existing bugs while building a phase** — log to todos, stay focused