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: .github/prompts/pb-build.prompt.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,7 @@ For each unfinished task, in order:
51
51
52
52
1.**Extract** the full task block (Context, Steps, Verification).
53
53
2.**Gather context** — read `design.md` and `AGENTS.md`.
54
+
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists) for safe rollback.
54
55
3.**Spawn a fresh subagent** with the Implementer Prompt (below), filled in with the task content and project context.
55
56
**Context Hygiene:** Do NOT pass the entire chat history. Pass ONLY:
56
57
- The specific Task Description from `tasks.md`.
@@ -68,9 +69,12 @@ For each unfinished task, in order:
68
69
If a subagent fails:
69
70
70
71
1.**Analyze the diff:** Run `git diff` to see what the failed agent changed.
71
-
2.**Revert the workspace:** Run `git checkout .` to reset to the last known-good state (Harness Reset).
72
-
3.**Report** the failure — which task, what went wrong, specific error output.
73
-
4. Prompt the user:
72
+
2.**Compute task-local change set:** Compare against the pre-task snapshot to identify only files changed by this failed attempt.
73
+
3.**Safe recovery (file-scoped):**
74
+
- If pre-task workspace was clean: restore only changed tracked files with `git restore --worktree --staged -- <files>` and remove only newly created files from this task.
75
+
- If pre-task workspace was dirty: do NOT run workspace-wide restore commands. Report file-level cleanup options and wait for user choice.
76
+
4.**Report** the failure — which task, what went wrong, specific error output.
77
+
5. Prompt the user:
74
78
-**Retry** — new subagent, fresh context, pass previous error as a hint constraint. Maximum 2 retries per task.
75
79
-**Skip** — mark as `⏭️ SKIPPED`, move to next task.
76
80
-**Abort** — stop the build, report progress so far.
@@ -165,6 +169,7 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
165
169
### ALWAYS
166
170
167
171
- Mark completed tasks in `tasks.md` immediately.
172
+
- Capture a pre-task workspace snapshot before spawning subagents.
168
173
- Self-review before submitting each task.
169
174
- Run full test suite after each task.
170
175
- Report failures with retry/skip/abort options.
@@ -182,13 +187,11 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
182
187
4.**Grounding before action.** Verify workspace state before writing code.
183
188
5.**Self-review catches over-engineering.** Audit before submit.
184
189
6.**State lives on disk.** Checkboxes and code are the only persistent state.
185
-
7.**Fail fast, recover cleanly.**Revert workspace before retry. Each attempt starts from a known-good state.
190
+
7.**Fail fast, recover cleanly.**Use task-local rollback from the pre-task snapshot. Avoid workspace-wide resets in dirty trees.
Copy file name to clipboardExpand all lines: .github/prompts/pb-refine.prompt.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
````prompt
2
1
# pb-refine — Design & Plan Refinement
3
2
4
3
You are the **pb-refine** agent. Your job is to read user feedback on an existing spec (`design.md` and/or `tasks.md`) and update them accordingly. This closes the gap between one-shot planning and iterative refinement.
@@ -10,12 +9,14 @@ Run this when the user invokes `/pb-refine <feature-name>` with feedback or chan
2. Find the directory whose name ends with `-<feature-name>` (e.g., `2026-02-15-01-add-websocket-auth` for feature-name `add-websocket-auth`).
15
15
3. If exactly one match is found, use it as `<spec-dir>`. All `specs/<spec-dir>/` paths below refer to this resolved directory.
16
16
4. If multiple matches exist, use the most recent one (latest date prefix).
17
17
5. If no match is found, stop and report:
18
-
```
18
+
19
+
```text
19
20
❌ No spec directory found for feature "<feature-name>" in specs/.
20
21
Run /pb-plan <requirement> first to generate the spec.
21
22
```
@@ -37,6 +38,7 @@ The user's feedback may include:
37
38
-**General feedback** — "this approach won't work because..." or "we should use X instead of Y".
38
39
39
40
Categorize the feedback into:
41
+
40
42
1.**Design changes** — modifications to `design.md`.
41
43
2.**Task changes** — modifications to `tasks.md`.
42
44
3.**Both** — changes that affect design and cascade to tasks.
@@ -82,7 +84,7 @@ After making changes, verify:
82
84
83
85
## Step 6: Output Summary
84
86
85
-
```
87
+
```text
86
88
🔄 Spec refined: specs/<spec-dir>/
87
89
88
90
Changes to design.md:
@@ -131,5 +133,3 @@ Next steps:
131
133
-**Feedback invalidates completed tasks:** Flag this in the summary as a warning. Do not automatically undo completed tasks.
132
134
-**Feedback requires entirely new design:** Recommend the user run `/pb-plan <feature-name>` instead with the new requirements. Only use `/pb-refine` for incremental changes.
133
135
-**Multiple conflicting feedback items:** Apply them in the order given. Note conflicts in the Revision History.
Copy file name to clipboardExpand all lines: .opencode/skills/pb-build/SKILL.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: pb-build
3
-
description: "Subagent-Driven Implementation"
3
+
description: "Use when tasks.md is ready and you need sequential TDD implementation with recovery loops."
4
4
---
5
5
6
6
# pb-build — Subagent-Driven Implementation
@@ -67,6 +67,7 @@ Extract the full task block from `tasks.md` — including Context, Steps, and Ve
67
67
- Read `specs/<spec-dir>/design.md` for design context.
68
68
- Read `AGENTS.md` (if it exists) for project conventions.
69
69
- Identify files most relevant to this task.
70
+
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists). This baseline is used for safe recovery if the task fails.
70
71
71
72
#### 3c. Spawn Subagent
72
73
@@ -115,14 +116,17 @@ After the subagent succeeds, update `tasks.md`:
115
116
If a subagent fails (tests don't pass, implementation blocked, etc.):
116
117
117
118
1.**Analyze the diff:** Run `git diff` to see exactly what the failed agent changed. Understanding the attempted approach is essential before retrying.
118
-
2.**Revert the workspace:** Run `git checkout .` to clean the workspace back to the last known-good state. This is the "Harness Reset" — it prevents broken code from one attempt polluting the next.
119
-
3.**Report** the failure with details — which task, what went wrong, the specific error output.
120
-
4.**Prompt the user** to choose:
119
+
2.**Compute task-local change set:** Compare with the pre-task snapshot to identify only files changed by this failed attempt (tracked diffs + newly created untracked files).
120
+
3.**Safe recovery (file-scoped):**
121
+
- If the pre-task workspace was clean: restore only the task-local changed tracked files with `git restore --worktree --staged -- <files>` and remove only the new files created by this task.
122
+
- If the pre-task workspace was dirty: **do not run any workspace-wide restore command**. Report file-level cleanup steps and ask the user before reverting anything.
123
+
4.**Report** the failure with details — which task, what went wrong, the specific error output.
124
+
5.**Prompt the user** to choose:
121
125
-**Retry** — Spawn a new subagent with fresh context. Pass the previous failure's error message as a "Constraint" hint (e.g., "Previous attempt failed with 'circular import in auth.py'. Avoid importing types directly — use string annotations or TYPE_CHECKING block."). Maximum 2 retries per task.
122
126
-**Skip** — Mark the task as skipped (`⏭️ SKIPPED`) and continue to the next task.
123
127
-**Abort** — Stop the entire build. Report progress so far.
124
128
125
-
> **Why revert before retry:**If the failed agent left partially-written code, a new agent may try to build on top of broken foundations. A clean revert ensures each retry starts from a known-good state — this is the core principle of an observable, resettable harness.
129
+
> **Why file-scoped recovery before retry:**Failed attempts can leave broken partial edits, but global resets can wipe unrelated in-progress work. Task-local rollback preserves harness reliability without destroying user state.
126
130
127
131
#### Design Change Requests (DCR)
128
132
@@ -223,6 +227,7 @@ While executing, display progress after each task:
223
227
### ALWAYS
224
228
225
229
-**ALWAYS** mark completed tasks in `tasks.md` immediately after success.
230
+
-**ALWAYS** capture a pre-task workspace snapshot before spawning a subagent.
226
231
-**ALWAYS** self-review before submitting a task's work.
227
232
-**ALWAYS** run the full test suite after each task to catch regressions.
228
233
-**ALWAYS** report failures clearly with actionable options (retry/skip/abort).
@@ -240,7 +245,7 @@ While executing, display progress after each task:
240
245
4.**Grounding before action.** Every subagent verifies workspace state before writing code — preventing path hallucination and stale assumptions.
241
246
5.**Self-review catches over-engineering.** Every subagent audits its own work before submitting.
242
247
6.**State lives on disk.**`tasks.md` checkboxes and committed code are the only persistent state.
243
-
7.**Fail fast, recover cleanly.** Failures trigger workspace revert (`git checkout .`) before retry — ensuring each attempt starts from a known-good state.
248
+
7.**Fail fast, recover cleanly.** Failures trigger task-local rollback using the pre-task snapshot. Never run workspace-wide reset commands in a dirty tree.
244
249
8.**Context hygiene.** Only pass relevant, minimal context to subagents. Error logs from failed attempts are summarized as hints, not passed verbatim.
Copy file name to clipboardExpand all lines: .opencode/skills/pb-build/references/implementer_prompt.md
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Execute the following steps in strict order. **You must output your reasoning fo
33
33
3.**Check Dependencies:** Verify that any modules you plan to import actually exist. Check `pyproject.toml`, `package.json`, `Cargo.toml`, or equivalent before importing third-party libraries.
34
34
4.**Confirm Test Infrastructure:** Verify the test directory exists and check how existing tests are structured (test runner, naming conventions, fixture patterns).
35
35
36
-
> **Why this step is mandatory:** Long-running agents are prone to "path hallucination" — assuming files exist at locations they don't oratethat code has a structure it doesn't. This grounding step synchronizes your mental model with the actual workspace state.
36
+
> **Why this step is mandatory:** Long-running agents are prone to "path hallucination" — assuming files exist at locations they don't or that code has a structure it doesn't. This grounding step synchronizes your mental model with the actual workspace state.
37
37
38
38
### 2. TDD Cycle
39
39
@@ -149,6 +149,3 @@ These rules act as your safety harness — they prevent common failure modes in
149
149
4.**Quote Errors:** When a test or command fails, always quote the specific error message in your reasoning before attempting a fix.
150
150
5.**One Fix at a Time:** When debugging a failure, make exactly one change, then re-run. Do not stack multiple speculative fixes.
151
151
6.**Path Verification:** Never hardcode or assume file paths. Use `ls`, `find`, or file search to confirm paths before using them.
Copy file name to clipboardExpand all lines: .opencode/skills/pb-refine/SKILL.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
---
2
2
name: pb-refine
3
-
description: "Design & Plan Refinement"
3
+
description: "Use when feedback or a Design Change Request requires incremental updates to design.md and tasks.md."
4
4
---
5
5
6
-
````skill
7
6
# pb-refine — Design & Plan Refinement
8
7
9
8
You are the **pb-refine** agent. Your job is to read user feedback on an existing spec (`design.md` and/or `tasks.md`) and update them accordingly. This closes the gap between one-shot planning and iterative refinement.
@@ -19,12 +18,14 @@ Execute the following steps in order.
0 commit comments