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
@@ -28,6 +35,8 @@ Read `specs/<spec-dir>/tasks.md`. If not found, stop and report:
28
35
Run /pb-plan <requirement> first to generate the spec.
29
36
```
30
37
38
+
Never guess `<spec-dir>` from memory. Always resolve from actual directory names under `specs/`.
39
+
31
40
## Step 2: Parse Unfinished Tasks
32
41
33
42
Scan for all unchecked items (`- [ ]`). Build an ordered list preserving Phase → Task number order.
@@ -39,6 +48,8 @@ Scan for all unchecked items (`- [ ]`). Build an ordered list preserving Phase
39
48
- If `tasks.md` has malformed structure (missing task headings, inconsistent checkbox format), report the parsing issue to the user and ask them to fix the format before continuing.
40
49
- If a task is marked `⏭️ SKIPPED`, treat it as unfinished but deprioritize — skip it unless the user explicitly requests a retry.
41
50
51
+
For execution reliability, represent the queue as explicit task units: `Task ID`, `Task Name`, `Status`, `Verification`.
52
+
42
53
If all tasks are checked (`- [x]`), report:
43
54
44
55
```text
@@ -50,17 +61,18 @@ If all tasks are checked (`- [x]`), report:
50
61
For each unfinished task, in order:
51
62
52
63
1.**Extract** the full task block (Context, Steps, Verification).
53
-
2.**Gather context** — read `design.md` and `AGENTS.md`.
64
+
2.**Gather context** — read `design.md` and `AGENTS.md` (if it exists). Treat `AGENTS.md` as read-only policy context.
54
65
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists) for safe rollback.
55
66
3.**Spawn a fresh subagent** with the Implementer Prompt (below), filled in with the task content and project context.
56
67
**Context Hygiene:** Do NOT pass the entire chat history. Pass ONLY:
57
68
- The specific Task Description from `tasks.md`.
58
-
- The `AGENTS.md` (Project Rules & Conventions).
69
+
- The `AGENTS.md` (project constraints and hard rules; do not assume any fixed template layout).
59
70
- The `design.md` (Feature Spec).
60
71
-**Summary of previous tasks** — a one-line-per-task summary (e.g., "Task 1.1 created `models.py` with `User` class."). Do NOT pass raw logs or full outputs.
61
72
4.**Subagent executes** the TDD cycle (see Implementer Prompt section).
62
73
5.**Mark completed** — update `- [ ]` to `- [x]` and Status to `🟢 DONE` in `tasks.md`.
63
74
-**Use precise editing:** Use `sed`, string-replacement, or line-targeted edits to update the specific Task ID heading and its checkboxes. Do NOT rewrite the entire `tasks.md` file — this risks truncation and content loss in large files.
75
+
-**Completion gate:** Mark done only when task Verification is satisfied and tests are green.
64
76
65
77
> **⚠️ 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."
66
78
@@ -74,6 +86,7 @@ If a subagent fails:
74
86
- 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
87
- If pre-task workspace was dirty: do NOT run workspace-wide restore commands. Report file-level cleanup options and wait for user choice.
76
88
4.**Report** the failure — which task, what went wrong, specific error output.
89
+
- Include the exact failing command and a short quoted error excerpt.
77
90
5. Prompt the user:
78
91
-**Retry** — new subagent, fresh context, pass previous error as a hint constraint. Maximum 2 retries per task.
79
92
-**Skip** — mark as `⏭️ SKIPPED`, move to next task.
@@ -121,15 +134,18 @@ Next steps:
121
134
- If tasks were skipped: /pb-build <feature-name>
122
135
```
123
136
137
+
Summary must be factual and command-backed: do not claim "passed" or "completed" without corresponding execution evidence from this run.
138
+
124
139
---
125
140
126
141
## Subagent Rules
127
142
128
143
1.**One subagent per task.** Never combine tasks.
129
-
2.**Fresh context per subagent.** Only: task description, project context (AGENTS.md + design.md), summary of completed tasks, files on disk.
144
+
2.**Fresh context per subagent.** Only: task description, non-obvious constraints (AGENTS.md) + design (design.md), summary of completed tasks, files on disk.
130
145
3.**Sequential execution.** Strict `tasks.md` order. No parallelism.
131
146
4.**Independence.** Cross-task state lives in files, not memory.
132
147
5.**Grounding first.** Every subagent verifies workspace state before writing code.
148
+
6.**Verifiable closure.** A task closes only after explicit verification evidence.
133
149
134
150
---
135
151
@@ -164,7 +180,10 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
164
180
- Let a subagent implement more than its assigned task.
165
181
- Carry in-memory state between subagents.
166
182
- Modify `design.md` (file a Design Change Request instead).
183
+
- Modify, delete, or reformat `AGENTS.md` unless the user explicitly requests an `AGENTS.md` change.
167
184
- Rewrite the entire `tasks.md` file — use targeted edits only.
185
+
- Mark a task as done without satisfying its Verification criteria.
186
+
- Claim tests passed without running them.
168
187
169
188
### ALWAYS
170
189
@@ -176,6 +195,7 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
176
195
- Follow YAGNI — only implement what the task requires.
177
196
- Use existing project patterns and conventions.
178
197
- File a Design Change Request if the design is infeasible.
198
+
- Report command-backed outcomes (what ran, what failed, what passed).
179
199
180
200
---
181
201
@@ -189,6 +209,7 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
189
209
6.**State lives on disk.** Checkboxes and code are the only persistent state.
190
210
7.**Fail fast, recover cleanly.** Use task-local rollback from the pre-task snapshot. Avoid workspace-wide resets in dirty trees.
Write the following content to `AGENTS.md` at the project root.
85
+
Write or update `AGENTS.md` at the project root using a **marker-based managed block**. Do NOT parse or rewrite user sections based on heading names.
86
86
87
-
**Preserving User Content — Merge Strategy:** Before writing, check if `AGENTS.md` already exists. If it does:
87
+
**Managed block markers (fixed):**
88
88
89
-
1. Read the existing file and identify **all user-edited sections** — any section that is NOT one of the auto-generated sections listed below.
90
-
2.**Auto-generated sections** (will be regenerated): `## Project Overview`, `## Project Structure`, `## Key Files`, `## Active Specs`.
91
-
3.**Preserved sections** (will be kept as-is): `## Conventions`, `## User Context`, and any **custom sections** the user has added (e.g., `## Database Schema`, `## API Notes`, `## Team Conventions`).
92
-
4.**Merge procedure:**
93
-
a. Regenerate auto-generated sections with fresh data.
94
-
b. For `## Conventions`: if it exists in the old file, keep the user's version. If not, generate the default.
95
-
c. Append all preserved/custom sections after the auto-generated sections, maintaining their original order.
96
-
d. Always ensure `## User Context` appears at the end (create it with the default placeholder if it didn't exist).
89
+
-`<!-- BEGIN PB-INIT MANAGED BLOCK -->`
90
+
-`<!-- END PB-INIT MANAGED BLOCK -->`
97
91
98
-
This ensures ALL user-added content survives re-initialization — not just `## User Context`.
92
+
**Merge procedure (strict):**
93
+
94
+
1. Build a fresh managed block that contains only pb-init generated snapshot content.
95
+
2. If `AGENTS.md` does not exist: create it with the managed block.
96
+
3. If `AGENTS.md` exists and markers are present: replace only the marker-delimited block (inclusive).
97
+
4. If `AGENTS.md` exists but markers are absent: append the managed block at the end, separated by blank lines.
98
+
5. Do NOT delete, reorder, or rewrite any pre-existing content outside the managed block.
99
+
6. Never assume a specific `AGENTS.md` format, section name, or template structure.
100
+
101
+
This strategy is format-agnostic and prevents accidental loss of user-maintained constraints.
99
102
100
103
```markdown
101
104
# AGENTS.md
102
105
106
+
<!-- Existing user-authored constraints can live anywhere in this file. -->
107
+
<!-- BEGIN PB-INIT MANAGED BLOCK -->
108
+
## pb-init Snapshot
109
+
103
110
> Auto-generated by pb-init. Last updated: YYYY-MM-DD
104
111
105
-
## Project Overview
112
+
###Project Overview
106
113
107
114
-**Language**: <detectedlanguage>
108
115
-**Framework**: <detected framework, or "None detected">
109
116
-**Build Tool**: <detectedbuildtool>
110
117
-**Test Command**: `<detected test command>`
111
118
112
-
## Project Structure
119
+
###Project Structure
113
120
```
114
121
115
122
<directorytreefromadaptivetraversal>
116
123
```
117
124
118
-
## Key Files
125
+
### Key Files
119
126
120
127
- Entry point: <path>
121
128
- Config: <path>
122
129
- Tests: <path>
123
130
124
-
##Conventions
131
+
### Suggested Conventions (Optional Defaults)
125
132
126
133
- Commit style: conventional commits
127
134
- Branch strategy: feature branches
@@ -132,13 +139,10 @@ This ensures ALL user-added content survives re-initialization — not just `##
132
139
4. **Quote Errors:** When debugging, always quote the specific error message before attempting a fix.
133
140
5. **Grounding First:** Verify file paths and workspace state before writing code. Use `ls` / `find` / file search.
134
141
135
-
## Active Specs
142
+
### Active Specs
136
143
137
144
<list of specs/<YYYY-MM-DD-NO-feature-name> directories with dynamic status, or "No active specs found.">
138
-
139
-
## User Context
140
-
141
-
<!-- Add your project-specific notes below. This section is preserved across pb-init runs. -->
145
+
<!-- END PB-INIT MANAGED BLOCK -->
142
146
143
147
```text
144
148
@@ -150,7 +154,7 @@ Replace `YYYY-MM-DD` with today's date.
150
154
151
155
- **Read-only analysis.** Do NOT modify any project source code, config files, or tests.
152
156
- **Only write `AGENTS.md`.** That is the sole file you create or modify.
153
-
- **Incremental merge.** Each run regenerates auto-generated sections but preserves ALL user-edited sections — not just `## User Context`. Custom sections added by the user are kept intact.
157
+
- **Non-destructive merge.** Never delete, normalize, or reorder existing `AGENTS.md` content outside the pb-init managed block.
154
158
- **No interactive questions.** Analyze and produce output in a single pass.
155
159
156
160
## Edge Cases
@@ -160,3 +164,4 @@ Replace `YYYY-MM-DD` with today's date.
160
164
- **Monorepo:** If multiple `package.json` / `Cargo.toml` exist in subdirectories, note it as a monorepo and list each workspace member under Project Overview.
161
165
- **Empty project:** Generate a minimal `AGENTS.md` with "Empty project — no source files detected" in the overview.
162
166
- **`specs/` does not exist:** Write "No active specs found." in the Active Specs section.
167
+
- **Legacy `AGENTS.md` without markers:** Do not attempt structural parsing. Append the managed block once; preserve all existing text verbatim.
0 commit comments