@sienklogic/plan-build-run 2.53.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 (165) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/package.json +2 -2
  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/commands/setup.md +1 -1
  125. package/plugins/copilot-pbr/commands/undo.md +5 -0
  126. package/plugins/copilot-pbr/plugin.json +1 -1
  127. package/plugins/copilot-pbr/skills/begin/SKILL.md +170 -17
  128. package/plugins/copilot-pbr/skills/build/SKILL.md +73 -8
  129. package/plugins/copilot-pbr/skills/plan/SKILL.md +67 -17
  130. package/plugins/copilot-pbr/skills/review/SKILL.md +12 -1
  131. package/plugins/copilot-pbr/skills/setup/SKILL.md +66 -214
  132. package/plugins/copilot-pbr/skills/shared/context-budget.md +27 -0
  133. package/plugins/copilot-pbr/skills/status/SKILL.md +44 -2
  134. package/plugins/copilot-pbr/skills/undo/SKILL.md +172 -0
  135. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  136. package/plugins/cursor-pbr/commands/setup.md +1 -1
  137. package/plugins/cursor-pbr/commands/undo.md +5 -0
  138. package/plugins/cursor-pbr/skills/begin/SKILL.md +170 -17
  139. package/plugins/cursor-pbr/skills/build/SKILL.md +73 -8
  140. package/plugins/cursor-pbr/skills/plan/SKILL.md +67 -17
  141. package/plugins/cursor-pbr/skills/review/SKILL.md +12 -1
  142. package/plugins/cursor-pbr/skills/setup/SKILL.md +66 -214
  143. package/plugins/cursor-pbr/skills/shared/context-budget.md +27 -0
  144. package/plugins/cursor-pbr/skills/status/SKILL.md +44 -2
  145. package/plugins/cursor-pbr/skills/undo/SKILL.md +173 -0
  146. package/plugins/jules-pbr/AGENTS.md +600 -0
  147. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
  148. package/plugins/pbr/commands/setup.md +1 -1
  149. package/plugins/pbr/commands/undo.md +5 -0
  150. package/plugins/pbr/scripts/config-schema.json +5 -1
  151. package/plugins/pbr/scripts/lib/alternatives.js +203 -0
  152. package/plugins/pbr/scripts/lib/preview.js +174 -0
  153. package/plugins/pbr/scripts/lib/skill-section.js +99 -0
  154. package/plugins/pbr/scripts/lib/step-verify.js +149 -0
  155. package/plugins/pbr/scripts/pbr-tools.js +122 -2
  156. package/plugins/pbr/scripts/validate-commit.js +2 -2
  157. package/plugins/pbr/skills/begin/SKILL.md +170 -17
  158. package/plugins/pbr/skills/begin/templates/config.json.tmpl +5 -1
  159. package/plugins/pbr/skills/build/SKILL.md +73 -8
  160. package/plugins/pbr/skills/plan/SKILL.md +67 -17
  161. package/plugins/pbr/skills/review/SKILL.md +12 -1
  162. package/plugins/pbr/skills/setup/SKILL.md +66 -214
  163. package/plugins/pbr/skills/shared/context-budget.md +27 -0
  164. package/plugins/pbr/skills/status/SKILL.md +44 -2
  165. package/plugins/pbr/skills/undo/SKILL.md +174 -0
@@ -0,0 +1,246 @@
1
+ # Plan Authoring Guide
2
+
3
+ Quality guidelines for writing executable plans. Used by planner and plan-checker.
4
+
5
+ ---
6
+
7
+ ## Action Writing Guidelines
8
+
9
+ The `<action>` element is the most important part of the plan. It must be specific enough that the executor agent can follow it mechanically without making design decisions.
10
+
11
+ ### Good Action
12
+ ```xml
13
+ <action>
14
+ 1. Create file `src/auth/discord.ts`
15
+ 2. Import `OAuth2Client` from `discord-oauth2` package
16
+ 3. Export async function `authenticateWithDiscord(code: string): Promise<User>`
17
+ - Create OAuth2Client with env vars: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET
18
+ - Exchange authorization code for access token
19
+ - Fetch user profile from Discord API: GET /api/users/@me
20
+ - Return User object with fields: id, username, avatar, email
21
+ 4. Export function `getDiscordAuthUrl(): string`
22
+ - Build OAuth2 authorization URL with scopes: identify, email
23
+ - Include redirect URI from env: DISCORD_REDIRECT_URI
24
+ - Return the URL string
25
+ 5. Add to `.env.example`:
26
+ DISCORD_CLIENT_ID=
27
+ DISCORD_CLIENT_SECRET=
28
+ DISCORD_REDIRECT_URI=http://localhost:3000/auth/callback
29
+ </action>
30
+ ```
31
+
32
+ ### Bad Action
33
+ ```xml
34
+ <action>
35
+ Set up Discord OAuth authentication.
36
+ </action>
37
+ ```
38
+
39
+ ### Action Rules
40
+
41
+ 1. **Number the steps** -- executor follows them in order
42
+ 2. **Name specific files** -- never say "create necessary files"
43
+ 3. **Name specific functions/exports** -- never say "implement the auth logic"
44
+ 4. **Include type signatures** -- when the project uses TypeScript
45
+ 5. **Reference existing code** -- when modifying files, say what to modify
46
+ 6. **Include code snippets** -- for complex patterns or configurations
47
+ 7. **Specify environment variables** -- with example values
48
+ 8. **Note error handling** -- only when it's a critical part of the task
49
+
50
+ ---
51
+
52
+ ## Verify Command Guidelines
53
+
54
+ The `<verify>` element must contain commands that the executor can run to check the task is complete.
55
+
56
+ ### Good Verify
57
+ ```xml
58
+ <verify>
59
+ npx tsc --noEmit
60
+ npm run test -- --grep "discord auth"
61
+ ls -la src/auth/discord.ts
62
+ </verify>
63
+ ```
64
+
65
+ ### Bad Verify
66
+ ```xml
67
+ <verify>
68
+ Check that authentication works.
69
+ </verify>
70
+ ```
71
+
72
+ ### Verify Rules
73
+
74
+ 1. **Must be executable** -- actual shell commands, not descriptions
75
+ 2. **Must be deterministic** -- same result every time if code is correct
76
+ 3. **Prefer automated checks** -- type checking, tests, linting
77
+ 4. **Include existence checks** -- `ls` for created files
78
+ 5. **Include build checks** -- `npx tsc --noEmit` for TypeScript
79
+ 6. **Avoid interactive commands** -- no commands requiring user input
80
+
81
+ ---
82
+
83
+ ## Done Condition Guidelines
84
+
85
+ The `<done>` element describes the observable outcome, not the implementation activity.
86
+
87
+ ### Good Done
88
+ - "User can authenticate via Discord OAuth and is redirected to dashboard"
89
+ - "Auth middleware rejects invalid tokens and passes valid tokens"
90
+ - "All 12 unit tests pass for the auth module"
91
+
92
+ ### Bad Done
93
+ - "Code was written"
94
+ - "File was created"
95
+ - "Feature is implemented"
96
+
97
+ ### Done Rules
98
+
99
+ 1. **Maps to a must-have** -- every done condition traces back to a frontmatter must-have
100
+ 2. **Observable** -- describes a state of the system, not an activity
101
+ 3. **Falsifiable** -- you can check whether it's true or false
102
+ 4. **User-oriented** -- prefer "user can..." over "code does..."
103
+
104
+ ---
105
+
106
+ ## Scope Limits
107
+
108
+ ### Per-Plan Limits
109
+
110
+ | Constraint | Limit | Rationale |
111
+ |-----------|-------|-----------|
112
+ | Tasks per plan | **2-3** | Keeps plans atomic and recoverable |
113
+ | Files per plan | **5-8** | Limits blast radius of failures |
114
+ | Dependencies | **3 max** | Avoids deep dependency chains |
115
+
116
+ ### When to Split
117
+
118
+ - More than 3 tasks? Split.
119
+ - More than 8 files? Split.
120
+ - Tasks in different functional areas? Split.
121
+ - Some tasks need human checkpoints, others don't? Split into autonomous and checkpoint plans.
122
+
123
+ ### Split Signals
124
+
125
+ | Signal | Action |
126
+ |--------|--------|
127
+ | >3 tasks needed | Split by subsystem -- one plan per subsystem |
128
+ | Multiple unrelated subsystems | One plan per subsystem |
129
+ | >5 files per task | Task is too big -- break it down |
130
+ | Checkpoint + implementation in same plan | Separate the checkpoint into its own plan |
131
+ | Discovery research + implementation | Separate plans -- research plan first |
132
+
133
+ ---
134
+
135
+ ## Discovery Levels
136
+
137
+ When a plan requires research before execution, set the `discovery` field in plan frontmatter. Default is 1 for most plans.
138
+
139
+ | Level | Name | Description | Executor Behavior |
140
+ |-------|------|-------------|-------------------|
141
+ | 0 | Skip | No research needed | Execute immediately |
142
+ | 1 | Quick | Fast verification | Check official docs for 1-2 specific questions |
143
+ | 2 | Standard | Normal research | Spawn researcher for phase research |
144
+ | 3 | Deep | Extensive investigation | Full research cycle before execution |
145
+
146
+ ### Level 0 -- Skip
147
+ **When to use**: Simple refactors, documentation updates, file renames, configuration tweaks, or any task where the implementation approach is unambiguous from the plan's `<action>` steps alone.
148
+
149
+ ### Level 1 -- Quick (default)
150
+ **When to use**: Standard feature work where the technology is known but specific API signatures, config options, or version-specific behavior need a quick check.
151
+
152
+ ### Level 2 -- Standard
153
+ **When to use**: Work involving unfamiliar libraries, new integration patterns, or approaches the executor hasn't seen in this codebase before.
154
+
155
+ ### Level 3 -- Deep
156
+ **When to use**: High-risk or architecturally significant work where getting the approach wrong would require substantial rework.
157
+
158
+ ---
159
+
160
+ ## TDD Decision Heuristic
161
+
162
+ When assigning `tdd="true"` or `tdd="false"` on a task, apply this test:
163
+
164
+ > **Can you write `expect(fn(input)).toBe(output)` before writing `fn`?**
165
+ > Yes → `tdd="true"`. No → `tdd="false"`.
166
+
167
+ ### When TDD Adds Value
168
+
169
+ - Pure functions and data transformations
170
+ - Business logic with defined inputs/outputs
171
+ - API response parsing and validation
172
+ - State machines and workflow transitions
173
+ - Utility functions and helpers
174
+
175
+ ### When to Skip TDD
176
+
177
+ - UI rendering and layout (test after)
178
+ - Configuration and environment setup
179
+ - Glue code wiring modules together
180
+ - Simple CRUD with no business logic
181
+ - File system operations and I/O plumbing
182
+ - One-off scripts and migrations
183
+
184
+ When the global config `features.tdd_mode: true` is set, all tasks default to TDD. The planner should still set `tdd="false"` on tasks matching the skip list above — the global flag is a project preference, not a mandate for every task.
185
+
186
+ ---
187
+
188
+ ## Dependency Graph Rules
189
+
190
+ ### File Conflict Detection
191
+
192
+ Two plans CONFLICT if their `files_modified` lists overlap. Conflicting plans:
193
+ - MUST be in different waves (cannot run in parallel)
194
+ - MUST have explicit `depends_on` relationship
195
+ - Later plan's `<action>` must reference what the earlier plan produces
196
+
197
+ ### Circular Dependencies
198
+
199
+ **NEVER create circular dependencies.** If you detect a potential cycle, restructure the plans to break it. Common resolution: merge the circular plans into one, or extract the shared dependency into its own plan.
200
+
201
+ ---
202
+
203
+ ## @file: Output Pattern (Large Payloads)
204
+
205
+ When a `pbr-tools` CLI command produces output exceeding 50,000 characters, the tool writes
206
+ the JSON payload to a temporary file instead of emitting it inline. It then prints a single
207
+ line of the form:
208
+
209
+ ```
210
+ @file:/tmp/pbr-1234567890.json
211
+ ```
212
+
213
+ This prevents stdout overflow in environments with limited buffer sizes (hooks, Task() runners).
214
+
215
+ ### Verify Step Pattern
216
+
217
+ If a plan's `<verify>` step calls `pbr-tools` and inspects the output, guard against the
218
+ `@file:` case:
219
+
220
+ ```bash
221
+ OUT=$(node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state load)
222
+ if echo "$OUT" | grep -q '^@file:'; then
223
+ OUT=$(cat "${OUT#@file:}")
224
+ fi
225
+ echo "$OUT" | grep '"status"'
226
+ ```
227
+
228
+ ### Agent Prompt Handling
229
+
230
+ When an agent receives `@file:` output from a spawned tool call, it must read the referenced
231
+ file to obtain the actual JSON payload. The `@file:` prefix is a signal — not a path fragment
232
+ to be appended to another command.
233
+
234
+ Plan actions that spawn `pbr-tools` subcommands should instruct the agent:
235
+
236
+ > If the output starts with `@file:`, read the file at that path to get the full JSON response.
237
+
238
+ ---
239
+
240
+ ## Context Fidelity Checklist
241
+
242
+ Before writing plan files, verify context compliance:
243
+
244
+ 1. **Locked decision coverage**: For each locked decision in CONTEXT.md, identify the task that implements it.
245
+ 2. **Deferred idea exclusion**: Scan all tasks -- no task should implement a deferred idea.
246
+ 3. **Discretion area handling**: Each "Claude's Discretion" item should be addressed in at least one task.
@@ -0,0 +1,313 @@
1
+ # Plan Format Reference
2
+
3
+ Complete reference for the XML task specification used in Plan-Build-Run plan files.
4
+
5
+ ---
6
+
7
+ ## Plan File Structure
8
+
9
+ Every plan file has two sections:
10
+ 1. **YAML Frontmatter** — metadata about the plan
11
+ 2. **XML Tasks** — the executable task specifications
12
+
13
+ ---
14
+
15
+ ## YAML Frontmatter
16
+
17
+ ```yaml
18
+ ---
19
+ phase: "02-authentication"
20
+ plan: "02-01"
21
+ type: "feature"
22
+ wave: 1
23
+ depends_on: []
24
+ files_modified:
25
+ - "src/auth/discord.ts"
26
+ - "src/middleware/auth.ts"
27
+ autonomous: true
28
+ discovery: 1
29
+ gap_closure: false
30
+ must_haves:
31
+ truths:
32
+ - "User can authenticate via Discord OAuth"
33
+ - "JWT token is set in httpOnly cookie"
34
+ artifacts:
35
+ - "src/auth/discord.ts: >50 lines"
36
+ - "src/middleware/auth.ts: >30 lines"
37
+ key_links:
38
+ - "Auth middleware applied to protected routes"
39
+ - "Login button calls authenticateWithDiscord()"
40
+ provides:
41
+ - "AuthService class"
42
+ - "POST /api/auth/login endpoint"
43
+ - "requireAuth() middleware"
44
+ consumes:
45
+ - "Database connection (from plan 01-01)"
46
+ requirement_ids:
47
+ - "P02-G1"
48
+ - "P02-G2"
49
+ closes_issues:
50
+ - 42
51
+ - 57
52
+ ---
53
+ ```
54
+
55
+ ### Frontmatter Fields
56
+
57
+ | Field | Required | Type | Description |
58
+ |-------|----------|------|-------------|
59
+ | `phase` | YES | string | Phase directory name (e.g., "02-authentication") |
60
+ | `plan` | YES | string | Plan ID: `{phase_num}-{plan_num}` (e.g., "02-01") |
61
+ | `type` | YES | enum | `feature`, `bugfix`, `refactor`, `infrastructure`, `docs` |
62
+ | `wave` | YES | int | Execution wave (1 = independent, 2+ = has deps) |
63
+ | `depends_on` | YES | array | Plan IDs that must complete first. `[]` if Wave 1. |
64
+ | `files_modified` | YES | array | All files this plan creates or modifies |
65
+ | `autonomous` | YES | bool | `true` if no human checkpoints |
66
+ | `discovery` | NO | int | Research level: 0=skip, 1=quick, 2=standard, 3=deep. Default: 1 |
67
+ | `gap_closure` | NO | bool | `true` if this is a gap-closure plan. Default: false |
68
+ | `must_haves` | YES | object | Goal-backward derivation |
69
+ | `must_haves.truths` | YES | array | Observable truths that must be true when done |
70
+ | `must_haves.artifacts` | YES | array | Files/modules that must exist. Append `: >N lines` for size hints. |
71
+ | `must_haves.key_links` | YES | array | Connections between components. Append `: grep command` for verification. |
72
+ | `provides` | NO | array | What this plan exports for other plans to consume (classes, endpoints, modules) |
73
+ | `consumes` | NO | array | What this plan needs from prior plans. Format: `"Thing (from plan XX-YY)"` |
74
+ | `requirement_ids` | NO | array | Requirement IDs from REQUIREMENTS.md or ROADMAP.md goal IDs that this plan addresses. Enables bidirectional traceability between plans and requirements/goals. |
75
+ | `dependency_fingerprints` | NO | object | Hashes of dependency phase SUMMARY.md files at plan-creation time. Used to detect stale plans. |
76
+ | `data_contracts` | NO | array | Cross-boundary parameter mappings for calls where arguments originate from external boundaries. Format: `"param: source (context) [fallback]"` |
77
+ | `closes_issues` | NO | number[] | GitHub issue numbers to close when this plan's final commit lands. Default: `[]` |
78
+
79
+ ### Data Contracts
80
+
81
+ When a task's `<action>` includes calls across module boundaries where arguments come from external sources (hook stdin, env vars, API params, config files), document the parameter-to-source mapping in `data_contracts` frontmatter and in the `<action>` step itself.
82
+
83
+ Example frontmatter:
84
+
85
+ ```yaml
86
+ data_contracts:
87
+ - "sessionId: data.session_id (hook stdin) [undefined in CLI context]"
88
+ - "config: configLoad(planningDir) (disk) [resolveConfig(undefined)]"
89
+ ```
90
+
91
+ Example in `<action>`:
92
+
93
+ ```
94
+ 3. Call classifyArtifact(llmConfig, planningDir, content, fileType, data.session_id)
95
+ Data contract: sessionId ← data.session_id from hook stdin (undefined in CLI context)
96
+ ```
97
+
98
+ **When to apply:** Any call where caller and callee are in different modules AND at least one argument originates from an external boundary. Internal helper calls within the same module do not need contracts.
99
+
100
+ ---
101
+
102
+ ## Summary Section
103
+
104
+ Every plan file MUST end with a `## Summary` section after all XML tasks. This section provides a compact overview (~500 tokens) for injection into executor prompts, avoiding the need to inline the full plan (~1,500 tokens).
105
+
106
+ Format:
107
+
108
+ ```
109
+ ## Summary
110
+
111
+ **Plan {plan_id}**: {1-sentence description of what this plan does}
112
+
113
+ **Tasks:**
114
+ 1. {task_id}: {task name} -- {files touched}
115
+ 2. {task_id}: {task name} -- {files touched}
116
+ 3. {task_id}: {task name} -- {files touched}
117
+
118
+ **Key files:** {comma-separated list of all files_modified}
119
+
120
+ **Must-haves:** {comma-separated list of truths from frontmatter}
121
+
122
+ **Provides:** {comma-separated list from provides field}
123
+
124
+ **Consumes:** {comma-separated list from consumes field, or "None"}
125
+ ```
126
+
127
+ The Summary section is generated by the planner agent at plan creation time. It is a denormalized view of plan metadata -- if the plan is revised, the Summary must also be updated.
128
+
129
+ ---
130
+
131
+ ## Task Types
132
+
133
+ ### Standard Auto Task
134
+
135
+ ```xml
136
+ <task id="02-01-T1" type="auto" complexity="medium">
137
+ <name>Create Discord OAuth client module</name>
138
+ <files>
139
+ src/auth/discord.ts
140
+ src/auth/types.ts
141
+ </files>
142
+ <action>
143
+ 1. Create file `src/auth/types.ts`
144
+ - Export interface `DiscordUser` with fields: id, username, avatar, email
145
+ - Export interface `AuthTokens` with fields: accessToken, refreshToken, expiresAt
146
+
147
+ 2. Create file `src/auth/discord.ts`
148
+ - Import `OAuth2Client` from `discord-oauth2`
149
+ - Import `DiscordUser`, `AuthTokens` from `./types`
150
+ - Export async function `authenticateWithDiscord(code: string): Promise<DiscordUser>`
151
+ - Create OAuth2Client with DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET from env
152
+ - Exchange authorization code for access token
153
+ - Fetch user profile: GET /api/users/@me
154
+ - Return DiscordUser object
155
+ - Export function `getDiscordAuthUrl(): string`
156
+ - Build OAuth2 URL with scopes: identify, email
157
+ - Include DISCORD_REDIRECT_URI from env
158
+
159
+ 3. Add to `.env.example`:
160
+ DISCORD_CLIENT_ID=
161
+ DISCORD_CLIENT_SECRET=
162
+ DISCORD_REDIRECT_URI=http://localhost:3000/auth/callback
163
+ </action>
164
+ <verify>
165
+ npx tsc --noEmit
166
+ ls src/auth/discord.ts
167
+ ls src/auth/types.ts
168
+ </verify>
169
+ <done>Discord OAuth client module exists and compiles without errors</done>
170
+ </task>
171
+ ```
172
+
173
+ ### TDD Task
174
+
175
+ ```xml
176
+ <task id="02-01-T2" type="auto" tdd="true" complexity="medium">
177
+ <name>Implement auth middleware with TDD</name>
178
+ <files>
179
+ src/middleware/auth.ts
180
+ tests/middleware/auth.test.ts
181
+ </files>
182
+ <action>
183
+ RED:
184
+ 1. Create `tests/middleware/auth.test.ts`
185
+ - Test: "rejects request without token" — expect 401
186
+ - Test: "rejects request with invalid token" — expect 401
187
+ - Test: "passes request with valid token" — expect next() called
188
+
189
+ GREEN:
190
+ 2. Create `src/middleware/auth.ts`
191
+ - Export function `requireAuth(req, res, next)`
192
+ - Extract JWT from httpOnly cookie
193
+ - Verify token with jsonwebtoken
194
+ - If valid: attach user to req, call next()
195
+ - If invalid: respond 401
196
+
197
+ REFACTOR:
198
+ 3. Extract token verification into `verifyToken()` helper
199
+ </action>
200
+ <verify>
201
+ npm test -- --grep "auth middleware"
202
+ </verify>
203
+ <done>Auth middleware rejects invalid tokens and passes valid tokens</done>
204
+ </task>
205
+ ```
206
+
207
+ ### Checkpoint: Human Verify
208
+
209
+ ```xml
210
+ <task id="03-02-T3" type="checkpoint:human-verify">
211
+ <name>Verify OAuth callback flow</name>
212
+ <files>
213
+ src/pages/auth/callback.ts
214
+ </files>
215
+ <action>
216
+ 1. Create the OAuth callback page at `src/pages/auth/callback.ts`
217
+ 2. Wire it to call `authenticateWithDiscord()` with the authorization code
218
+ 3. On success: set JWT cookie and redirect to dashboard
219
+ 4. On failure: redirect to login with error message
220
+ </action>
221
+ <verify>
222
+ what-built: OAuth callback page that exchanges Discord auth code for JWT
223
+ how-to-verify: |
224
+ 1. Click "Login with Discord" button
225
+ 2. Authorize the application in Discord
226
+ 3. Verify you are redirected to the dashboard
227
+ 4. Check browser cookies for JWT token
228
+ resume-signal: "User confirms OAuth flow works end-to-end"
229
+ </verify>
230
+ <done>User can complete full Discord OAuth login flow</done>
231
+ </task>
232
+ ```
233
+
234
+ ### Checkpoint: Decision
235
+
236
+ ```xml
237
+ <task id="04-01-T1" type="checkpoint:decision">
238
+ <name>Choose database migration strategy</name>
239
+ <files></files>
240
+ <action>
241
+ Present the user with the migration strategy options after research.
242
+ </action>
243
+ <verify>
244
+ decision: "Which migration strategy to use for production database?"
245
+ context: "We need to decide how to handle schema changes in production."
246
+ options: |
247
+ A) Prisma Migrate — automatic migrations, good for development, requires care in production
248
+ B) Manual SQL — full control, more work, explicit about what changes
249
+ C) TypeORM migrations — auto-generated from entities, reversible
250
+ resume-signal: "User selects option A, B, or C"
251
+ </verify>
252
+ <done>Database migration strategy decided and documented in CONTEXT.md</done>
253
+ </task>
254
+ ```
255
+
256
+ ### Checkpoint: Human Action
257
+
258
+ ```xml
259
+ <task id="05-03-T2" type="checkpoint:human-action">
260
+ <name>Configure production environment</name>
261
+ <files>
262
+ .env.production
263
+ </files>
264
+ <action>
265
+ 1. Create `.env.production.example` with all required variables listed
266
+ 2. Document each variable's purpose in comments
267
+ </action>
268
+ <verify>
269
+ what-needed: "Production environment variables must be set"
270
+ how-to-do: |
271
+ 1. Copy `.env.production.example` to `.env.production`
272
+ 2. Fill in production values for:
273
+ - DATABASE_URL (production database connection string)
274
+ - DISCORD_CLIENT_ID (production Discord app)
275
+ - DISCORD_CLIENT_SECRET (production Discord app)
276
+ - JWT_SECRET (generate with: openssl rand -base64 32)
277
+ resume-signal: "User confirms .env.production is configured"
278
+ </verify>
279
+ <done>Production environment is configured with real credentials</done>
280
+ </task>
281
+ ```
282
+
283
+ ---
284
+
285
+ ## The 5 Mandatory Elements
286
+
287
+ Every task MUST have ALL 5. No exceptions.
288
+
289
+ | Element | Purpose | Rules |
290
+ |---------|---------|-------|
291
+ | `<name>` | What the task does | Imperative verb phrase. Short. |
292
+ | `<files>` | Files touched | One per line. Actual file paths. |
293
+ | `<action>` | How to do it | Numbered steps. Specific. Code snippets for complex work. |
294
+ | `<verify>` | How to check | Executable shell commands. Or checkpoint format. |
295
+ | `<done>` | How to know it worked | Observable user/system behavior. Maps to a must-have. |
296
+
297
+ ---
298
+
299
+ ## Task ID Format
300
+
301
+ ```
302
+ {plan_id}-T{sequential_number}
303
+
304
+ Examples:
305
+ 02-01-T1 — Phase 02, Plan 01, Task 1
306
+ 02-01-T2 — Phase 02, Plan 01, Task 2
307
+ 03-02-T1 — Phase 03, Plan 02, Task 1
308
+ ```
309
+
310
+ Task IDs are unique within a phase. They are used for:
311
+ - Commit message references
312
+ - Checkpoint continuation references
313
+ - SUMMARY.md task result tracking