@pdlc-os/pdlc 0.1.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.
@@ -0,0 +1,383 @@
1
+ ---
2
+ description: Run the Construction phase (Build → Review → Test) for the current feature
3
+ ---
4
+
5
+ You are running the Construction phase. Follow every step in order. Do not skip steps.
6
+
7
+ ---
8
+
9
+ ## Pre-flight: Load state and context
10
+
11
+ ### Step 1 — Read current state
12
+
13
+ Read `docs/pdlc/memory/STATE.md` completely.
14
+
15
+ Extract:
16
+ - **Current Feature**: the `[feature-name]` slug
17
+ - **Current Phase**: must be `Inception Complete — Ready for /pdlc build` or `Construction`
18
+
19
+ If **Current Feature** is `none` or the phase is not set to a Construction-ready state, stop and tell the user:
20
+
21
+ > "No active feature found. Please run `/pdlc brainstorm [feature-name]` first to complete the Inception phase before building."
22
+
23
+ If STATE.md indicates Construction is already in progress (phase is `Construction`), resume from the last checkpoint. Read the **Last Checkpoint** field and continue from the appropriate step below.
24
+
25
+ ### Step 2 — Read CONSTITUTION.md
26
+
27
+ Read `docs/pdlc/memory/CONSTITUTION.md` completely. Note:
28
+ - Test gates (Section 7) — which layers must pass before Operation
29
+ - Architectural constraints (Section 3)
30
+ - Coding standards (Section 2)
31
+ - Definition of done (Section 5)
32
+
33
+ ### Step 3 — Create the feature branch
34
+
35
+ Check if the feature branch already exists:
36
+ ```bash
37
+ git branch --list feature/[feature-name]
38
+ ```
39
+
40
+ If it does not exist, create it:
41
+ ```bash
42
+ git checkout -b feature/[feature-name]
43
+ ```
44
+
45
+ If it already exists (resuming), check it out:
46
+ ```bash
47
+ git checkout feature/[feature-name]
48
+ ```
49
+
50
+ Update `docs/pdlc/memory/STATE.md`:
51
+ - **Current Phase**: `Construction`
52
+ - **Current Sub-phase**: `Build`
53
+ - **Last Checkpoint**: `Construction / Build / [now ISO 8601]`
54
+
55
+ ---
56
+
57
+ ## BUILD LOOP
58
+
59
+ Repeat Steps 4–12 until `bd ready` returns an empty list.
60
+
61
+ ### Step 4 — Get the ready queue
62
+
63
+ Run:
64
+ ```bash
65
+ bd ready --json
66
+ ```
67
+
68
+ Parse the JSON output to get the list of unblocked tasks.
69
+
70
+ If the list is empty: the build loop is complete. Skip to the REVIEW section below.
71
+
72
+ Display the ready queue to the user in a clear format:
73
+
74
+ ```
75
+ READY QUEUE ([N] tasks unblocked)
76
+ [bd-id] [task title] [labels]
77
+ ...
78
+ ```
79
+
80
+ ### Step 5 — Select the next task
81
+
82
+ Pick the highest-priority unblocked task. Priority order:
83
+ 1. Tasks labeled `backend` (infrastructure first)
84
+ 2. Tasks labeled `frontend`
85
+ 3. Tasks labeled `devops`
86
+ 4. Any remaining tasks
87
+
88
+ Show the selected task to the user:
89
+
90
+ > "Next task: `[bd-id]` — [task title]
91
+ > Labels: [labels]
92
+ > Description: [description]"
93
+
94
+ ### Step 6 — Claim the task
95
+
96
+ Run:
97
+ ```bash
98
+ bd update [task-id] --claim
99
+ ```
100
+
101
+ Update `docs/pdlc/memory/STATE.md`:
102
+ - **Active Beads Task**: `[task-id] — [task title]`
103
+ - **Last Checkpoint**: `Construction / Build / [now ISO 8601]`
104
+
105
+ ### Step 7 — Choose execution mode
106
+
107
+ Ask the user:
108
+
109
+ > "**Choose execution mode for `[task-id]`: [task title]**
110
+ >
111
+ > **(A) Agent Teams** — Neo, Echo, Phantom, and Jarvis always on, plus auto-selected specialists based on task labels. Best for complex tasks with multiple concerns.
112
+ >
113
+ > **(B) Sub-Agent** — single focused agent handles the task end-to-end. Best for well-defined, self-contained tasks.
114
+ >
115
+ > Type **A** or **B**:"
116
+
117
+ Wait for the user's answer.
118
+
119
+ ### Step 8 — Assemble the team (if Agent Teams selected)
120
+
121
+ If the user chose **A**:
122
+
123
+ Always include: **Neo** (Architect), **Echo** (QA Engineer), **Phantom** (Security Reviewer), **Jarvis** (Tech Writer)
124
+
125
+ Auto-select based on task labels:
126
+ - Label contains `backend` → include **Bolt** (Backend Engineer)
127
+ - Label contains `frontend` → include **Friday** (Frontend Engineer)
128
+ - Label contains `ux` → include **Muse** (UX Designer)
129
+ - Label contains `product` → include **Oracle** (PM)
130
+ - Label contains `devops` → include **Pulse** (DevOps)
131
+
132
+ Tell the user which agents are active for this task:
133
+
134
+ > "Agent team assembled: Neo, Echo, Phantom, Jarvis[, Bolt][, Friday][, Muse][, Oracle][, Pulse]"
135
+
136
+ Each agent's responsibilities are defined in `agents/[name].md`. Embody each agent's perspective as you work through the task.
137
+
138
+ If the user chose **B**: proceed as a single focused sub-agent.
139
+
140
+ ### Step 9 — TDD: Build the task
141
+
142
+ Follow the TDD protocol from `skills/tdd.md` exactly. The key steps:
143
+
144
+ **9a. Read the task context:**
145
+ - Run `bd show [task-id]` to get the full task with acceptance criteria
146
+ - Read the PRD at `docs/pdlc/prds/PRD_[feature-name]_[YYYY-MM-DD].md`
147
+ - Find the BDD user story that maps to this task via the `story:[US-id]` label
148
+ - Read the exact Given/When/Then language for that story
149
+ - Read the design docs at `docs/pdlc/design/[feature-name]/`
150
+
151
+ **9b. For each acceptance criterion, follow Red → Green → Refactor:**
152
+
153
+ 1. **Red**: Write a failing test named using the Given/When/Then language from the PRD. Run it. Confirm it fails for the right reason (logic not implemented, not a syntax error).
154
+ 2. **Green**: Write the minimal implementation to make the test pass. Run the test — it must pass. Run the full suite — no regressions.
155
+ 3. **Refactor**: Clean up without changing behavior. Run the full suite again.
156
+
157
+ **9c. Auto-fix loop:**
158
+ - If a test fails after implementation: attempt to fix.
159
+ - Maximum **3 automatic fix attempts** per failing test.
160
+ - After 3 failed attempts, stop immediately and present the human with:
161
+ - The test name and full test code
162
+ - The current implementation
163
+ - The exact error output from all 3 attempts
164
+ - Your hypothesis for why it is failing
165
+ - Two proposed approaches to resolve it
166
+ - Ask: "(A) Continue automatically with approach 1, (B) Continue automatically with approach 2, or (C) Take the wheel — I'll guide you."
167
+ - Wait for the human's choice before continuing.
168
+
169
+ **9d. Tier 1 hard blocks — stop and double-confirm (highlighted) before proceeding:**
170
+ - Force-pushing to `main`
171
+ - Dropping a database table without an explicit migration file
172
+ - Deleting files not created in the current feature branch
173
+ - Deploying with failing smoke tests
174
+
175
+ **9e. Tier 2 actions — pause and request explicit yes before proceeding:**
176
+ - Any `rm -rf` or bulk delete
177
+ - `git reset --hard`
178
+ - Running DB migrations in production
179
+ - Changing `CONSTITUTION.md`
180
+ - Closing all open Beads tasks at once
181
+ - Any external API call that writes/posts/sends (Slack, email, webhooks)
182
+
183
+ (Check `CONSTITUTION.md` §8 — any Tier 2 items the team has downgraded to Tier 3 should proceed with only a logged warning.)
184
+
185
+ **9f. After all acceptance criteria pass:**
186
+ - Run the full test suite one final time. Zero regressions.
187
+ - Commit to the feature branch:
188
+ ```bash
189
+ git add [relevant files]
190
+ git commit -m "feat([feature-name]): [task title description]"
191
+ ```
192
+
193
+ ### Step 10 — Mark task complete
194
+
195
+ Run:
196
+ ```bash
197
+ bd done [task-id]
198
+ ```
199
+
200
+ Update `docs/pdlc/memory/STATE.md`:
201
+ - **Active Beads Task**: `none`
202
+ - **Last Checkpoint**: `Construction / Build / [now ISO 8601]`
203
+ - Record completed task in Phase History
204
+
205
+ ### Step 11 — Loop
206
+
207
+ Return to **Step 4**. Continue until `bd ready` returns an empty list.
208
+
209
+ ---
210
+
211
+ ## REVIEW
212
+
213
+ Once `bd ready` is empty (all tasks complete):
214
+
215
+ ### Step 12 — Run the review protocol
216
+
217
+ Follow `skills/review.md` exactly.
218
+
219
+ **Context to load:**
220
+ - The full list of tasks completed (from Phase History in STATE.md)
221
+ - All commits on the feature branch since it diverged from main: `git log main..feature/[feature-name]`
222
+ - The full diff: `git diff main..feature/[feature-name]`
223
+ - `docs/pdlc/memory/CONSTITUTION.md`
224
+ - `docs/pdlc/memory/DECISIONS.md`
225
+ - `docs/pdlc/prds/PRD_[feature-name]_[YYYY-MM-DD].md`
226
+ - All files in `docs/pdlc/design/[feature-name]/`
227
+
228
+ **Run all four reviewer passes:**
229
+
230
+ - **Neo** (Architecture & PRD conformance): check design adherence, architectural constraints, cross-cutting concerns, ADR compliance
231
+ - **Phantom** (Security): OWASP Top 10, auth, input validation, secrets, access control
232
+ - **Echo** (Test coverage & quality): AC coverage, Given/When/Then traceability, edge cases, regression risk
233
+ - **Jarvis** (Documentation & API contracts): inline comments, API docs, CHANGELOG draft, README updates, PRD accuracy
234
+
235
+ Note: for this feature-level review, the "task ID" in the review filename should use the feature name: `REVIEW_[feature-name]_[YYYY-MM-DD].md`
236
+
237
+ Write the review file to:
238
+ ```
239
+ docs/pdlc/reviews/REVIEW_[feature-name]_[YYYY-MM-DD].md
240
+ ```
241
+
242
+ Follow the structure in `templates/review.md`.
243
+
244
+ ### Step 13 — Review approval gate
245
+
246
+ Tell the user:
247
+
248
+ > "Review complete. Please read `docs/pdlc/reviews/REVIEW_[feature-name]_[YYYY-MM-DD].md` and decide:
249
+ >
250
+ > - **Approve** — ship as-is; post PR comments (if GitHub integration active)
251
+ > - **Fix** — I address the listed issues, regenerate the review, then re-present
252
+ > - **Accept warning** — ship despite warnings (Tier 3 logged events)
253
+ > - **Defer** — move items to tech debt log
254
+ >
255
+ > What is your decision?"
256
+
257
+ Wait for explicit human decision. Do not proceed to Test without approval.
258
+
259
+ If the user requests fixes: address them, recommit to the feature branch, regenerate the review file, and re-present.
260
+
261
+ ### Step 14 — Post-approval actions
262
+
263
+ After approval:
264
+ - If GitHub integration is configured: push non-accepted findings as PR comments
265
+ - For any finding marked "Defer": append an entry to `docs/pdlc/memory/DECISIONS.md` under a Tech Debt section
266
+ - Log accepted Phantom security warnings as Tier 3 events in STATE.md
267
+ - Log accepted Echo coverage gaps as Tier 3 events in STATE.md
268
+
269
+ Update `docs/pdlc/memory/STATE.md`:
270
+ - **Current Sub-phase**: `Test`
271
+ - **Last Checkpoint**: `Construction / Test / [now ISO 8601]`
272
+
273
+ ---
274
+
275
+ ## TEST
276
+
277
+ ### Step 15 — Run each test layer
278
+
279
+ Run the test layers per `skills/test.md` (when available). Check CONSTITUTION.md §7 for which gates are required.
280
+
281
+ Run each layer in this order:
282
+
283
+ **Layer 1: Unit tests**
284
+ Run the project's unit test command (e.g. `npm test`, `yarn test`, `pytest`, as appropriate for the tech stack in CONSTITUTION.md). Record: passed, failed, skipped.
285
+
286
+ **Layer 2: Integration tests**
287
+ Run integration tests (e.g. `npm run test:integration`). If no integration test command exists, note: "No integration test command found — check package.json or Makefile." Record results.
288
+
289
+ **Layer 3: E2E tests (real Chromium)**
290
+ Run E2E tests (e.g. `npx playwright test`, `npm run test:e2e`). These use a real Chromium instance. Record results.
291
+
292
+ **Layer 4: Performance / load tests**
293
+ Run if a performance test command exists (e.g. `npm run test:perf`, `k6 run`). Skip with a logged Tier 3 warning if no command exists.
294
+
295
+ **Layer 5: Accessibility checks**
296
+ Run if an accessibility check command exists (e.g. `npm run test:a11y`, `axe`). Skip with a logged Tier 3 warning if no command exists.
297
+
298
+ **Layer 6: Visual regression tests**
299
+ Run if a visual regression test command exists (e.g. `npm run test:visual`, Percy, Chromatic). Skip with a logged Tier 3 warning if no command exists.
300
+
301
+ ### Step 16 — Check Constitution test gates
302
+
303
+ Compare results against the required gates in CONSTITUTION.md §7.
304
+
305
+ For each required gate (checkbox is checked in CONSTITUTION.md):
306
+ - If the layer **passed**: continue.
307
+ - If the layer **failed**: surface a warning. Human decides: fix, accept, or defer.
308
+
309
+ For each non-required layer that failed: surface a soft warning. Human decides — do not block.
310
+
311
+ ### Step 17 — Human decides on failures
312
+
313
+ For any failing layer (required or not), present:
314
+
315
+ > "[Layer] tests: [N] passed, [N] failed, [N] skipped.
316
+ >
317
+ > Failing tests: [list]
318
+ >
319
+ > This layer [IS / IS NOT] a required gate per CONSTITUTION.md.
320
+ >
321
+ > Options: **(A) Fix** — I address the failures and re-run, **(B) Accept** — ship with this known failure (Tier 3 logged), **(C) Defer** — log to tech debt, address in next episode."
322
+
323
+ Wait for the human's choice. Repeat until all failures are resolved or explicitly accepted/deferred.
324
+
325
+ ---
326
+
327
+ ## WRAP-UP
328
+
329
+ ### Step 18 — Draft the episode file
330
+
331
+ Using `templates/episode.md` as the structure, draft:
332
+
333
+ `docs/pdlc/memory/episodes/[NNN]_[feature-name]_[YYYY-MM-DD].md`
334
+
335
+ Determine the episode number `[NNN]` by reading `docs/pdlc/memory/episodes/index.md` and incrementing the last entry. If the index has no entries, start at `001`.
336
+
337
+ Fill in every section:
338
+ - **What Was Built**: a 3–6 sentence summary of what was designed, built, and shipped
339
+ - **Links**: PRD link, PR link (leave blank if not yet merged), review file link, design doc links
340
+ - **Key Decisions & Rationale**: list the significant decisions made during this feature, cross-referencing DECISIONS.md
341
+ - **Files Created**: list every new file added on the feature branch
342
+ - **Files Modified**: list every pre-existing file changed
343
+ - **Test Summary**: fill in the table from Step 15 results
344
+ - **Known Tradeoffs & Tech Debt**: from accepted/deferred findings in the review and test steps
345
+ - **Agent Team**: list which agents were active
346
+
347
+ Leave **Reflect Notes** blank — that section is filled during the Reflect sub-phase in `/pdlc ship`.
348
+
349
+ Set **Status**: `Draft`.
350
+
351
+ ### Step 19 — Update STATE.md
352
+
353
+ Update `docs/pdlc/memory/STATE.md`:
354
+ - **Current Phase**: `Construction Complete — Ready for /pdlc ship`
355
+ - **Current Sub-phase**: `none`
356
+ - **Active Beads Task**: `none`
357
+ - **Last Checkpoint**: `Construction / Complete / [now ISO 8601]`
358
+
359
+ Append to Phase History:
360
+ ```
361
+ | [now] | construction_complete | Construction Complete | — | [feature-name] |
362
+ ```
363
+
364
+ ### Step 20 — Tell the user
365
+
366
+ > "Construction complete for `[feature-name]`.
367
+ >
368
+ > - All [N] tasks done in Beads
369
+ > - Review approved: `docs/pdlc/reviews/REVIEW_[feature-name]_[YYYY-MM-DD].md`
370
+ > - Episode draft: `docs/pdlc/memory/episodes/[NNN]_[feature-name]_[YYYY-MM-DD].md`
371
+ >
372
+ > Review the episode draft, then run `/pdlc ship` to deploy."
373
+
374
+ ---
375
+
376
+ ## Rules
377
+
378
+ - TDD is enforced on every task. No implementation code without a failing test first. No exceptions without explicit human override.
379
+ - The auto-fix loop cap is 3 attempts per failing test. Never exceed this without human input.
380
+ - All review findings are soft warnings. Human decides: fix, accept, or defer. No finding auto-blocks the build.
381
+ - Human must approve the review file before PR comments are pushed. Never push automatically.
382
+ - Never merge to main during Construction. The feature branch is merged during `/pdlc ship`.
383
+ - If context is running low (≤35% remaining), update STATE.md immediately and wrap up the current task cleanly before context compacts.