Skip to content

Commit 7b4c00a

Browse files
committed
docs(init): clarify AGENTS.md minimization and context hygiene
1 parent be8dffb commit 7b4c00a

12 files changed

Lines changed: 32 additions & 31 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pb-spec follows a **harness-first** philosophy: reliability comes from process d
2424
| [Reflexion](https://arxiv.org/abs/2303.11366) | Learn from failure signals via iterative retries | Retry/skip/abort and DCR flow in `pb-build` |
2525
| [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 |
2626
| [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) | |
2728

2829
### Practical Principles in pb-spec
2930

@@ -60,7 +61,7 @@ pb-spec init --ai claude # or: copilot, opencode, gemini, codex, all
6061
pb-spec init --ai all -g # install globally to each agent's home/config dir
6162

6263
# 2. Open the project in your AI coding assistant and use the installed commands/prompts:
63-
# /pb-init → Generate AGENTS.md project context
64+
# /pb-init → Audit repo, produce minimal AGENTS.md (only undiscoverable facts)
6465
# /pb-plan Add WebSocket auth → Generate specs/YYYY-MM-DD-01-add-websocket-auth/
6566
# /pb-refine add-websocket-auth → (Optional) Refine design based on feedback
6667
# /pb-build add-websocket-auth → Implement tasks via TDD subagents
@@ -110,9 +111,9 @@ four agent skills that chain together:
110111
/pb-init → /pb-plan → [/pb-refine] → /pb-build
111112
```
112113

113-
### 1. `/pb-init`Project Initialization
114+
### 1. `/pb-init`AGENTS.md Audit & Minimization
114115

115-
Analyzes your project and generates an `AGENTS.md` file at the project root. This file captures the tech stack, directory structure, conventions, and testing patterns. **Preserves user-added context** so manual notes aren't lost on re-runs.
116+
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.
116117

117118
### 2. `/pb-plan <requirement>` — Design & Task Planning
118119

@@ -138,7 +139,7 @@ Reads `specs/<YYYY-MM-DD-NO-feature-name>/tasks.md` and implements each task seq
138139

139140
| Skill | Trigger | Output | Description |
140141
|---|---|---|---|
141-
| `pb-init` | `/pb-init` | `AGENTS.md` | Detect stack, scan structure, generate project context |
142+
| `pb-init` | `/pb-init` | `AGENTS.md` | Audit repo for undiscoverable gotchas, produce minimal agent context |
142143
| `pb-plan` | `/pb-plan <requirement>` | `specs/<YYYY-MM-DD-NO-feature-name>/design.md` + `tasks.md` | Design proposal + ordered task breakdown |
143144
| `pb-refine` | `/pb-refine <feature>` | Revised spec files | Apply feedback or Design Change Requests |
144145
| `pb-build` | `/pb-build <feature-name>` | Code + tests | TDD implementation via subagents |
@@ -156,14 +157,14 @@ pb-spec's prompt design is inspired by Anthropic's research on [Effective Harnes
156157
| **Context Hygiene** | Orchestrator passes only minimal, relevant context to each subagent — preventing context window pollution |
157158
| **Recovery Loop** | Failed tasks trigger `git checkout .` (workspace revert) before retry — ensuring each attempt starts from a known-good state |
158159
| **Verification Harness** | Design docs define explicit verification commands at planning time — subagents execute, not invent, verification |
159-
| **Agent Rules** | `AGENTS.md` embeds project-specific "laws of physics" that all subagents inherit as system-level constraints |
160+
| **Agent Rules** | `AGENTS.md` contains only undiscoverable gotchas and hard constraints — not project overview info that agents can infer from code |
160161

161162
### Where Each Principle Lives
162163

163164
- **Worker (Implementer):** `implementer_prompt.md` enforces grounding-first workflow and error quoting
164165
- **Architect (Planner):** `design_template.md` includes Critical Path Verification table
165166
- **Orchestrator (Builder):** `pb-build` SKILL enforces context hygiene and workspace revert on failure
166-
- **Foundation (Init):** `AGENTS.md` template includes Agent Harness Rules as global conventions
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
167168

168169
## Development
169170

docs/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Behavior guarantees:
101101

102102
### 6.1 pb-init
103103

104-
Generates/merges `AGENTS.md` from live repository state. It preserves user-authored sections while refreshing generated sections.
104+
Audits the repository and produces a **minimal** `AGENTS.md` containing only information that agents cannot discover from the codebase itself. 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. The ideal AGENTS.md is empty — every entry represents a codebase smell that should eventually be fixed at the root cause. Re-runs audit existing entries and flag any that are now discoverable.
105105

106106
### 6.2 pb-plan
107107

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "pb-spec"
7-
version = "0.4.4"
7+
version = "0.4.5"
88
description = "Plan-Build Spec (pb-spec): A CLI tool for managing AI coding assistant skills"
99
readme = "README.md"
1010
license = "Apache-2.0"

src/pb_spec/platforms/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Skill metadata: name -> description
77
SKILL_METADATA: dict[str, str] = {
88
"pb-init": (
9-
"Use when onboarding a repo or after major structural changes to regenerate AGENTS.md "
10-
"project context."
9+
"Use to audit the repo and produce a minimal AGENTS.md containing only "
10+
"undiscoverable gotchas, hard constraints, and non-obvious conventions."
1111
),
1212
"pb-plan": (
1313
"Use when converting a requirement into a design proposal and executable tasks before coding."

src/pb_spec/templates/prompts/pb-build.prompt.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ If all tasks are checked (`- [x]`), report:
6161
For each unfinished task, in order:
6262

6363
1. **Extract** the full task block (Context, Steps, Verification).
64-
2. **Gather context** — read `design.md` and `AGENTS.md`.
64+
2. **Gather context** — read `design.md` and `AGENTS.md` (if it exists).
6565
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists) for safe rollback.
6666
3. **Spawn a fresh subagent** with the Implementer Prompt (below), filled in with the task content and project context.
6767
**Context Hygiene:** Do NOT pass the entire chat history. Pass ONLY:
6868
- The specific Task Description from `tasks.md`.
69-
- The `AGENTS.md` (Project Rules & Conventions).
69+
- The `AGENTS.md` (non-obvious gotchas and hard constraints — intentionally minimal).
7070
- The `design.md` (Feature Spec).
7171
- **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.
7272
4. **Subagent executes** the TDD cycle (see Implementer Prompt section).
@@ -141,7 +141,7 @@ Summary must be factual and command-backed: do not claim "passed" or "completed"
141141
## Subagent Rules
142142

143143
1. **One subagent per task.** Never combine tasks.
144-
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.
145145
3. **Sequential execution.** Strict `tasks.md` order. No parallelism.
146146
4. **Independence.** Cross-task state lives in files, not memory.
147147
5. **Grounding first.** Every subagent verifies workspace state before writing code.
@@ -230,7 +230,7 @@ You are implementing **Task {{TASK_NUMBER}}: {{TASK_NAME}}**.
230230

231231
{{PROJECT_CONTEXT}}
232232

233-
> From `AGENTS.md` and `design.md` — tech stack, conventions, design decisions.
233+
> From `AGENTS.md` (non-obvious gotchas and constraints) and `design.md` (feature design decisions).
234234
235235
### Your Job
236236

@@ -268,7 +268,7 @@ Before writing any code, verify the current workspace state:
268268

269269
- [ ] Completeness — everything the task requires is implemented
270270
- [ ] Nothing extra — no work beyond this task
271-
- [ ] Conventions — code follows project style from `AGENTS.md`
271+
- [ ] Conventions — code follows project style (discover from codebase; check `AGENTS.md` for non-obvious constraints)
272272
- [ ] Test coverage — tests meaningfully verify requirements
273273
- [ ] No regressions — all pre-existing tests pass
274274
- [ ] YAGNI — no over-engineering

src/pb_spec/templates/prompts/pb-plan.prompt.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ Count the words in the requirement description (excluding the `/pb-plan` trigger
4949

5050
## Step 2: Collect Project Context
5151

52-
Gather context to inform the design. **Do not rely solely on `AGENTS.md`**always perform live codebase analysis.
52+
Gather context to inform the design. **Always perform live codebase analysis**do not rely on any static file.
5353

54-
1. **Read `AGENTS.md`** (if it exists) — use as a starting reference. **Treat as supplementary, not authoritative** — verify against actual project state.
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.
5555
2. **Search the live codebase directly** — this is **mandatory** regardless of whether `AGENTS.md` exists:
5656
- Use grep / file search / semantic search to find modules, directories, and files affected by the requirement.
5757
- Search for keywords from the requirement across the codebase.
@@ -66,7 +66,7 @@ Gather context to inform the design. **Do not rely solely on `AGENTS.md`** — a
6666

6767
**This audit is mandatory.** List reusable components in `design.md` Section 3.3 and reference them in `tasks.md` task context.
6868

69-
If `AGENTS.md` does not exist, search the codebase directly for project context. Recommend running `/pb-init` first in your summary.
69+
If `AGENTS.md` does not exist, that's fine — scan the project root directly (config files, directory structure) to infer project context. You can recommend running `/pb-init` to surface any hidden gotchas, but its absence should not block planning.
7070

7171
**Evidence precedence (highest to lowest):**
7272

@@ -200,7 +200,7 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
200200
1. **One-shot output.** Complete design + tasks in a single pass. No mid-way confirmation.
201201
2. **Optimal solution first.** Output the best design. Developer requests changes after review if needed.
202202
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 — never rely solely on `AGENTS.md` which may be stale.
203+
4. **Live codebase analysis.** Always search the actual codebase — `AGENTS.md` contains only non-obvious gotchas, not project overview info.
204204
5. **Task granularity: Logical Unit of Work.** Each task is a self-contained, meaningful change. Do not split based on arbitrary time estimates.
205205
6. **Verification per task.** Every task defines how to prove it is done.
206206
7. **Dependency order.** Phases and tasks flow foundational → dependent.
@@ -228,7 +228,7 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
228228
- **Ambiguous requirements:** Make reasonable assumptions. State them in the design's Assumptions section.
229229
- **Large scope (>40h of tasks):** Split into phases. First phase = viable MVP. Note in summary.
230230
- **Same feature-name exists:** The uniqueness check in Step 3 prevents creating a spec with a feature-name that already exists in `specs/`. Stop and report the conflict. The developer should choose a different name or use `/pb-refine` to update the existing spec.
231-
- **No `AGENTS.md`:** Proceed anyway — search codebase directly. Recommend running `/pb-init` first.
231+
- **No `AGENTS.md`:** Proceed anyway — search codebase directly. Recommend `/pb-init` to surface hidden gotchas.
232232
- **Bug fix, not feature:** Use same process. Design focuses on root cause + fix approach.
233233
- **External systems/APIs:** Document assumptions about external interfaces in design.
234234
- **Borderline word count (~50 words):** Use lightweight mode. Developer can run `/pb-refine` to expand.

src/pb_spec/templates/prompts/pb-refine.prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Run this when the user invokes `/pb-refine <feature-name>` with feedback or chan
2525

2626
1. `specs/<spec-dir>/design.md` — the current design.
2727
2. `specs/<spec-dir>/tasks.md` — the current task breakdown.
28-
3. `AGENTS.md` (if it exists) — project context.
28+
3. `AGENTS.md` (if it exists) — non-obvious constraints and gotchas.
2929

3030
## Step 2: Parse User Feedback
3131

src/pb_spec/templates/skills/pb-build/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Extract the full task block from `tasks.md` — including Context, Steps, and Ve
7171
#### 3b. Gather Project Context
7272

7373
- Read `specs/<spec-dir>/design.md` for design context.
74-
- Read `AGENTS.md` (if it exists) for project conventions.
74+
- Read `AGENTS.md` (if it exists) for non-obvious gotchas and hard constraints.
7575
- Identify files most relevant to this task.
7676
- Record a pre-task workspace snapshot (`git status --porcelain` + tracked/untracked file lists). This baseline is used for safe recovery if the task fails.
7777

@@ -80,14 +80,14 @@ Extract the full task block from `tasks.md` — including Context, Steps, and Ve
8080
Create a **fresh subagent** for this task. Pass it the implementer prompt template from `references/implementer_prompt.md`, filled with:
8181

8282
- The full task description from `tasks.md`.
83-
- Project context from `AGENTS.md` and `design.md`.
83+
- Non-obvious constraints from `AGENTS.md` and design context from `design.md`.
8484
- The task number and name.
8585

8686
**Context Hygiene (Critical):**
8787
When spawning the subagent, do NOT pass the entire chat history. Pass ONLY:
8888

8989
1. The specific Task Description from `tasks.md`.
90-
2. The `AGENTS.md` (Project Rules & Conventions).
90+
2. The `AGENTS.md` (non-obvious gotchas and hard constraints — intentionally minimal).
9191
3. The `design.md` (Feature Spec).
9292
4. **Summary of previous tasks** — a one-line-per-task summary of what was done (e.g., "Task 1.1 created `models.py` with `User` and `Session` classes which you should now use."). Do NOT pass raw logs or full outputs from previous subagents.
9393

src/pb_spec/templates/skills/pb-build/references/implementer_prompt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You are implementing **Task {{TASK_NUMBER}}: {{TASK_NAME}}**.
1616

1717
{{PROJECT_CONTEXT}}
1818

19-
> The above is assembled from `AGENTS.md` (project conventions) and `design.md` (feature design). Use it to understand the tech stack, coding style, project structure, and design decisions.
19+
> The above is assembled from `AGENTS.md` (non-obvious gotchas and hard constraints) and `design.md` (feature design). AGENTS.md is intentionally minimal — discover tech stack, structure, and conventions directly from the codebase.
2020
2121
---
2222

@@ -104,7 +104,7 @@ Before submitting, answer each question honestly:
104104

105105
- [ ] **Completeness:** Did I implement everything the task requires?
106106
- [ ] **Nothing extra:** Did I avoid implementing things not in this task?
107-
- [ ] **Conventions:** Does the code follow project conventions from `AGENTS.md`?
107+
- [ ] **Conventions:** Does the code follow project conventions (discovered from codebase; `AGENTS.md` for non-obvious constraints)?
108108
- [ ] **Test coverage:** Do the tests meaningfully verify the task's requirements?
109109
- [ ] **No regressions:** Do all pre-existing tests still pass?
110110
- [ ] **YAGNI:** Is there any over-engineering I should remove?

src/pb_spec/templates/skills/pb-plan/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Count the words in the requirement description (excluding the `/pb-plan` trigger
5353

5454
### Step 2: Collect Project Context
5555

56-
Gather context to inform the design. **Do not rely solely on `AGENTS.md`**always perform live codebase analysis.
56+
Gather context to inform the design. **Always perform live codebase analysis**do not rely on any static file.
5757

58-
1. **Read `AGENTS.md`** (if it exists at project root) — use as a starting reference for language, framework, build tool, project structure, and conventions. **Treat as supplementary, not authoritative** — verify against actual project state.
58+
1. **Read `AGENTS.md`** (if it exists at project root) — 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.
5959
2. **Search the live codebase directly** — this is **mandatory** regardless of whether `AGENTS.md` exists:
6060
- Use grep / file search / semantic search to find modules, directories, and files affected by the requirement.
6161
- Search for keywords from the requirement across the codebase (function names, class names, module names, config keys).
@@ -70,7 +70,7 @@ Gather context to inform the design. **Do not rely solely on `AGENTS.md`** — a
7070

7171
**This audit is mandatory.** List reusable components in `design.md` Section 3.3 and reference them in `tasks.md` task context.
7272

73-
If `AGENTS.md` does not exist, scan the project root directly (config files, directory structure) to infer project context. Recommend running `/pb-init` first in your summary.
73+
If `AGENTS.md` does not exist, that's fine — scan the project root directly (config files, directory structure) to infer project context. You can recommend running `/pb-init` to surface any hidden gotchas, but its absence should not block planning.
7474

7575
**Evidence precedence (highest to lowest):**
7676

0 commit comments

Comments
 (0)