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: README.md
+23-12Lines changed: 23 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ pb-spec follows a **harness-first** philosophy: reliability comes from process d
24
24
|[Reflexion](https://arxiv.org/abs/2303.11366)| Learn from failure signals via iterative retries | Retry/skip/abort and DCR flow in `pb-build`|
25
25
|[Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents)| Grounding, context hygiene, recovery, observability | State checks, minimal context handoff, task-local rollback guidance |
26
26
|[Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents)| Prefer simple composable workflows over framework complexity | Small adapter-based CLI + explicit workflow prompts |
27
-
|[Stop Using /init for AGENTS.md](https://addyosmani.com/blog/agents-md/)|Prefer minimal AGENTS.md (only undiscoverable facts)|`/pb-init`audits repo and generates minimal AGENTS.md with strict three-part filter (not inferrable, operationally decisive, not guessable)|
27
+
|[Stop Using /init for AGENTS.md](https://addyosmani.com/blog/agents-md/)|Keep AGENTS.md focused and maintainable|`/pb-init`updates a managed snapshot block in `AGENTS.md` while preserving all user-authored constraints outside that block|
28
28
29
29
### Practical Principles in pb-spec
30
30
@@ -61,7 +61,7 @@ pb-spec init --ai claude # or: copilot, opencode, gemini, codex, all
61
61
pb-spec init --ai all -g # install globally to each agent's home/config dir
62
62
63
63
# 2. Open the project in your AI coding assistant and use the installed commands/prompts:
Audits your project and produces an **extremely minimal**`AGENTS.md` at the project root. Instead of dumping project overview info that agents can discover themselves, it applies a strict three-part filter: each entry must be (1) not inferrable from code, (2) operationally decisive, and (3) not guessable from industry conventions. Every entry in AGENTS.md represents a codebase smell — the goal is to fix root causes and drive AGENTS.md toward zero entries over time. **Preserves user-added context** across re-runs.
116
+
Audits your project and writes a `pb-init` snapshot into `AGENTS.md` using managed markers:
117
+
118
+
-`<!-- BEGIN PB-INIT MANAGED BLOCK -->`
119
+
-`<!-- END PB-INIT MANAGED BLOCK -->`
120
+
121
+
Merge behavior is non-destructive:
122
+
123
+
- If markers exist, only that managed block is replaced.
124
+
- If markers do not exist, the managed block is appended.
125
+
- All existing content outside the managed block is preserved verbatim.
126
+
127
+
This design avoids relying on any fixed `AGENTS.md` section layout and protects user-maintained constraints across re-runs.
└── tasks.md # Ordered implementation tasks (logical units of work)
126
137
```
127
138
128
-
The spec directory follows the naming format `YYYY-MM-DD-NO-feature-name` (e.g., `2026-02-15-01-add-websocket-auth`). The feature-name part must be unique across all specs.
139
+
The spec directory follows the naming format `YYYY-MM-DD-NO-feature-name` (e.g., `2026-02-15-01-add-websocket-auth`). The feature-name part must be unique across all specs. During planning, `AGENTS.md` is treated as read-only policy context (free-form, no fixed layout assumptions).
Reads user feedback or Design Change Requests (from failed builds) and intelligently updates `design.md` and `tasks.md`. It maintains a revision history and cascades design changes to the task list without overwriting completed work.
143
+
Reads user feedback or Design Change Requests (from failed builds) and intelligently updates `design.md` and `tasks.md`. It maintains a revision history and cascades design changes to the task list without overwriting completed work.`AGENTS.md` remains read-only in this phase.
Reads `specs/<YYYY-MM-DD-NO-feature-name>/tasks.md` and implements each task sequentially. Every task is executed by a fresh subagent following strict TDD (Red → Green → Refactor). Supports **Design Change Requests** if the planned design proves infeasible during implementation. Only the `<feature-name>` part is needed when invoking — the agent resolves the full directory automatically.
147
+
Reads `specs/<YYYY-MM-DD-NO-feature-name>/tasks.md` and implements each task sequentially. Every task is executed by a fresh subagent following strict TDD (Red → Green → Refactor). Supports **Design Change Requests** if the planned design proves infeasible during implementation. Only the `<feature-name>` part is needed when invoking — the agent resolves the full directory automatically.`AGENTS.md` is read-only unless the user explicitly requests an `AGENTS.md` change.
137
148
138
149
## Skills Overview
139
150
140
151
| Skill | Trigger | Output | Description |
141
152
|---|---|---|---|
142
-
|`pb-init`|`/pb-init`|`AGENTS.md`| Audit repo for undiscoverable gotchas, produce minimal agent context|
153
+
|`pb-init`|`/pb-init`|`AGENTS.md`| Audit repo and safely update/append a managed snapshot block without rewriting user-authored constraints|
@@ -155,16 +166,16 @@ pb-spec's prompt design is inspired by Anthropic's research on [Effective Harnes
155
166
|**State Grounding**| Subagents must verify workspace state (`ls`, `find`, `read_file`) before writing any code — preventing path hallucination |
156
167
|**Error Quoting**| Subagents must quote specific error messages before attempting fixes — preventing blind debugging |
157
168
|**Context Hygiene**| Orchestrator passes only minimal, relevant context to each subagent — preventing context window pollution |
158
-
|**Recovery Loop**| Failed tasks trigger `git checkout .` (workspace revert) before retry — ensuring each attempt starts from a known-good state|
169
+
|**Recovery Loop**| Failed tasks use pre-task snapshots + file-scoped recovery (`git restore` + task-local cleanup), and avoid workspace-wide restore in dirty trees|
159
170
|**Verification Harness**| Design docs define explicit verification commands at planning time — subagents execute, not invent, verification |
160
-
|**Agent Rules**|`AGENTS.md`contains only undiscoverable gotchas and hard constraints — not project overview info that agents can infer from code|
171
+
|**Agent Rules**|`AGENTS.md`is treated as free-form policy context: `pb-init` manages only its marker block; `pb-plan`/`pb-refine`/`pb-build` read it without rewriting|
161
172
162
173
### Where Each Principle Lives
163
174
164
175
-**Worker (Implementer):**`implementer_prompt.md` enforces grounding-first workflow and error quoting
165
176
-**Architect (Planner):**`design_template.md` includes Critical Path Verification table
166
-
-**Orchestrator (Builder):**`pb-build` SKILL enforces context hygiene and workspace revert on failure
167
-
-**Foundation (Init):**`AGENTS.md` captures only non-obvious gotchas, hard constraints, and traps that agents cannot infer from code — not a full project overview
177
+
-**Orchestrator (Builder):**`pb-build` SKILL enforces context hygiene and task-local recovery with safe rollback rules
178
+
-**Foundation (Init):**`pb-init` updates only the managed marker block in `AGENTS.md`, preserving all external user-authored constraints
Copy file name to clipboardExpand all lines: src/pb_spec/templates/prompts/pb-build.prompt.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,12 +61,12 @@ If all tasks are checked (`- [x]`), report:
61
61
For each unfinished task, in order:
62
62
63
63
1.**Extract** the full task block (Context, Steps, Verification).
64
-
2.**Gather context** — read `design.md` and `AGENTS.md` (if it exists).
64
+
2.**Gather context** — read `design.md` and `AGENTS.md` (if it exists). Treat `AGENTS.md` as read-only policy context.
65
65
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists) for safe rollback.
66
66
3.**Spawn a fresh subagent** with the Implementer Prompt (below), filled in with the task content and project context.
67
67
**Context Hygiene:** Do NOT pass the entire chat history. Pass ONLY:
68
68
- The specific Task Description from `tasks.md`.
69
-
- The `AGENTS.md` (non-obvious gotchas and hard constraints — intentionally minimal).
69
+
- The `AGENTS.md` (project constraints and hard rules; do not assume any fixed template layout).
70
70
- The `design.md` (Feature Spec).
71
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.
72
72
4.**Subagent executes** the TDD cycle (see Implementer Prompt section).
@@ -180,6 +180,7 @@ Update `tasks.md` in-place after each task using **precise edits** (target the s
180
180
- Let a subagent implement more than its assigned task.
181
181
- Carry in-memory state between subagents.
182
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.
183
184
- Rewrite the entire `tasks.md` file — use targeted edits only.
184
185
- Mark a task as done without satisfying its Verification criteria.
185
186
- Claim tests passed without running them.
@@ -230,7 +231,7 @@ You are implementing **Task {{TASK_NUMBER}}: {{TASK_NAME}}**.
230
231
231
232
{{PROJECT_CONTEXT}}
232
233
233
-
> From `AGENTS.md` (non-obvious gotchas and constraints) and `design.md` (feature design decisions).
234
+
> From `AGENTS.md` (project constraints and rules) and `design.md` (feature design decisions).
234
235
235
236
### Your Job
236
237
@@ -307,6 +308,7 @@ Fix any "no" answers before submitting.
307
308
- Follow YAGNI — no speculative features.
308
309
- Use existing patterns — match project style.
309
310
- Do not modify `design.md` or `tasks.md`.
311
+
- Do not modify, delete, or reformat `AGENTS.md` unless the user explicitly requests an `AGENTS.md` change.
310
312
- Do not modify unrelated code.
311
313
- Tests are mandatory — never submit without them.
312
314
-**No Blind Edits:** Always read a file before editing it.
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.
Copy file name to clipboardExpand all lines: src/pb_spec/templates/prompts/pb-plan.prompt.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ Count the words in the requirement description (excluding the `/pb-plan` trigger
51
51
52
52
Gather context to inform the design. **Always perform live codebase analysis** — do not rely on any static file.
53
53
54
-
1.**Read `AGENTS.md`** (if it exists) — check for non-obvious gotchas, hard constraints, and traps that you cannot infer from code. AGENTS.md intentionally omits discoverable info (language, structure, test commands) — you must find those yourself.
54
+
1.**Read `AGENTS.md`** (if it exists) — capture explicit project constraints, team rules, and gotchas. Do not assume any fixed section layout; treat it as free-form user-authored policy text.
55
55
2.**Search the live codebase directly** — this is **mandatory** regardless of whether `AGENTS.md` exists:
56
56
- Use grep / file search / semantic search to find modules, directories, and files affected by the requirement.
57
57
- Search for keywords from the requirement across the codebase.
@@ -200,7 +200,7 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
200
200
1.**One-shot output.** Complete design + tasks in a single pass. No mid-way confirmation.
201
201
2.**Optimal solution first.** Output the best design. Developer requests changes after review if needed.
202
202
3.**Right-sized output (YAGNI).** Match output detail to requirement complexity. Simple changes get compact specs; complex features get full specs.
203
-
4.**Live codebase analysis.** Always search the actual codebase —`AGENTS.md`contains only non-obvious gotchas, not project overview info.
203
+
4.**Live codebase analysis.** Always search the actual codebase. Use`AGENTS.md`as complementary policy context, not a replacement for code inspection.
204
204
5.**Task granularity: Logical Unit of Work.** Each task is a self-contained, meaningful change. Do not split based on arbitrary time estimates.
205
205
6.**Verification per task.** Every task defines how to prove it is done.
206
206
7.**Dependency order.** Phases and tasks flow foundational → dependent.
@@ -218,6 +218,7 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
218
218
-**No code implementation.** Design docs and task lists only.
219
219
-**Scope-appropriate templates.** In lightweight mode, only fill the compact template. In full mode, fill the complete template. Every included section must have substantive content.
220
220
-**Write only to `specs/<spec-dir>/`.** Do not modify project source code.
221
+
-**`AGENTS.md` is read-only in this phase.** Do not modify, delete, or reformat it unless the user explicitly asks for an `AGENTS.md` update.
221
222
-**No invented references.** Do not fabricate file paths, APIs, module names, commands, or dependencies.
222
223
-**No unresolved placeholders.** Final `design.md` and `tasks.md` must not contain template example markers like `[Goal A]` or `[Task Name]`.
Copy file name to clipboardExpand all lines: src/pb_spec/templates/prompts/pb-refine.prompt.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Run this when the user invokes `/pb-refine <feature-name>` with feedback or chan
25
25
26
26
1.`specs/<spec-dir>/design.md` — the current design.
27
27
2.`specs/<spec-dir>/tasks.md` — the current task breakdown.
28
-
3.`AGENTS.md` (if it exists) — non-obvious constraints and gotchas.
28
+
3.`AGENTS.md` (if it exists) — read-only source of constraints and gotchas.
29
29
30
30
## Step 2: Parse User Feedback
31
31
@@ -123,6 +123,7 @@ Next steps:
123
123
-**Do not modify project source code.** Refinement is planning only.
124
124
-**Do not re-run the entire planning process.** This is an incremental update, not a fresh plan.
125
125
-**Preserve formatting and structure** of both files.
126
+
-**`AGENTS.md` is read-only in this phase.** Do not modify, delete, or reformat it unless the user explicitly asks for an `AGENTS.md` update.
126
127
-**No interactive multi-turn probing.** Apply the feedback given. If the feedback is ambiguous, state your interpretation in the Revision History and proceed.
0 commit comments