You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pb_spec/templates/skills/pb-build/SKILL.md
+74-2Lines changed: 74 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,28 @@ Extract the full task block from `tasks.md` — including Context, Scenario Cove
100
100
- Identify files most relevant to this task.
101
101
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists). This baseline is used for safe recovery if the task fails.
102
102
103
+
#### 3b-i. Pre-Spawn State Gate (Mandatory)
104
+
105
+
Before spawning a subagent for the current task, **verify that all previously processed tasks are properly marked in `tasks.md`**. This catches any state drift carried over from earlier iterations.
106
+
107
+
1. Re-read `tasks.md` and scan all `### Task X.Y:` blocks that precede the current task.
108
+
2. For each previously processed task, confirm:
109
+
- If it was reported as completed: Status is `🟢 DONE` and all evidence checkboxes are `- [x]`.
110
+
- If it was reported as skipped: Status is `⏭️ SKIPPED`.
111
+
- If it was reported as DCR-blocked: Status is `🔄 DCR`.
112
+
3.**If any discrepancy is found** — a task was processed but not properly marked:
113
+
- Apply the correct mark immediately (update Status and checkboxes).
114
+
- Run `pb-spec sync specs/<spec-dir>`.
115
+
- Log the fix:
116
+
117
+
```text
118
+
🔧 Auto-fixed: Task X.Y status was [old state], corrected to [new state].
119
+
```
120
+
121
+
4. Only proceed to spawn the subagent after all prior tasks are in consistent state.
122
+
123
+
> **Why this gate exists:** If a previous subagent completed but the orchestrator failed to mark it (due to context loss, edit failure, etc.), this gate catches it before the next subagent starts. It ensures the orchestrator always has an accurate view of what's done.
124
+
103
125
#### 3c. Spawn Subagent
104
126
105
127
Create a **fresh subagent** for this task. Pass it the implementer prompt template from `references/implementer_prompt.md`, filled with:
@@ -168,6 +190,28 @@ The sync command will:
168
190
- Update Status to `🟡 IN PROGRESS` if some steps are checked
169
191
- Report any changes made
170
192
193
+
#### 3e-i. Post-Mark Verification (Mandatory)
194
+
195
+
After updating `tasks.md` and running `pb-spec sync`, **verify the mark actually took effect** before proceeding to the next task. This prevents silent state drift where the orchestrator believes it updated the file but the edit did not persist.
196
+
197
+
1.**Re-read** the specific `### Task X.Y` block from `tasks.md`.
198
+
2.**Confirm** that:
199
+
- The Status line shows `🟢 DONE` (not `🔴 TODO` or `🟡 IN PROGRESS`).
200
+
- All `- [ ]` evidence checkboxes in the block are now `- [x]`.
201
+
3.**If verification fails** — the task subagent reported success but `tasks.md` was not updated:
202
+
- Apply the mark immediately: update Status to `🟢 DONE` and all checkboxes to `- [x]`.
203
+
- Re-run `pb-spec sync specs/<spec-dir>`.
204
+
- Re-verify.
205
+
- If it still fails after a second attempt, report the discrepancy and halt:
206
+
207
+
```text
208
+
⚠️ Task State Drift — Task X.Y
209
+
Subagent reported success but tasks.md was not updated.
210
+
Auto-fix applied. If this recurs, inspect the file for write conflicts.
211
+
```
212
+
213
+
> **Why this step exists:** Long-running orchestrator sessions can lose track of whether they actually wrote the mark. This verification step closes the loop by checking disk state, not memory state.
214
+
>
171
215
> **⚠️ Context Reset:** After completing all tasks (or when context grows large), output: "Recommend starting a fresh session. Run `/pb-build <feature-name>` again to continue from where you left off."
172
216
173
217
### Step 4: Handle Failures (The Recovery Loop)
@@ -242,9 +286,37 @@ If during implementation a subagent discovers that the design is **infeasible or
242
286
-**Override** — user provides an alternative approach.
243
287
-**Abort** — stop the build.
244
288
245
-
### Step 5: Output Completion Summary
289
+
### Step 5: Final State Verification & Output Completion Summary
290
+
291
+
#### 5a. Final State Sweep (Mandatory)
292
+
293
+
Before outputting the summary, perform a **full reconciliation** of `tasks.md` against the build session's execution log. This catches any tasks that were processed but never marked.
294
+
295
+
1. Re-read the entire `tasks.md`.
296
+
2. Cross-check each `### Task X.Y:` block against the orchestrator's session record:
297
+
- If the session shows a task was **completed** (subagent reported success, tests passed) but `tasks.md` still shows `🔴 TODO` or `🟡 IN PROGRESS` with unchecked steps → **auto-fix**: update Status to `🟢 DONE`, mark all checkboxes `- [x]`.
298
+
- If the session shows a task was **skipped** but `tasks.md` does not show `⏭️ SKIPPED` → **auto-fix**: update Status to `⏭️ SKIPPED`.
299
+
- If the session shows a task triggered a **DCR** but `tasks.md` does not show `🔄 DCR` → **auto-fix**: update Status to `🔄 DCR`.
300
+
3. Run `pb-spec sync specs/<spec-dir>` after all fixes to ensure Status fields are consistent.
301
+
4. Report any auto-fixes applied:
302
+
303
+
```text
304
+
🔧 Final Sweep Auto-Fixes:
305
+
- Task X.Y: Status [old] → 🟢 DONE (subagent completed, mark was missing)
306
+
- Task A.B: Status [old] → ⏭️ SKIPPED (mark was missing)
307
+
```
308
+
309
+
5. If no fixes were needed, report:
310
+
311
+
```text
312
+
✅ Final Sweep: All task states in tasks.md are consistent with execution log.
313
+
```
314
+
315
+
> **Why this sweep exists:** Even with per-task verification (Step 3e-i) and pre-spawn gates (Step 3b-i), edge cases can still cause drift (e.g., context truncation, partial edits, session interruptions). This final sweep is the last line of defense before the user sees the summary.
316
+
317
+
#### 5b. Output Completion Summary
246
318
247
-
After all tasks are processed, output:
319
+
After all tasks are processed and the final sweep is complete, output:
0 commit comments