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
+83-3Lines changed: 83 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,18 @@ pb-spec is a set of [Agent Skills Specification](https://agentskills.io) complia
14
14
15
15
Compared to letting AI "just write code", pb-spec provides a hardened execution harness (guardrails). It requires context-first design, contract-based architecture, and dual-loop verification through logging and health checks.
16
16
17
+
### Design Standards
18
+
19
+
`design.md` artifacts conform to four industry-standard specification formats:
20
+
21
+
| Standard | Purpose | pb-spec Application |
22
+
|---|---|---|
23
+
|**EARS Notation**| Eliminate ambiguous requirements with 5 sentence patterns (Ubiquitous, State-driven, Event-driven, Unwanted, Exception) | Every requirement in `design.md` uses EARS syntax with `[REQ-XX]` IDs |
24
+
|**C4 Model + Mermaid**| Architecture topology in parseable text (Context, Container, Component diagrams) | Architecture sections use `` ```mermaid `` blocks with C4 hierarchy |
25
+
|**DBML / Prisma Schema**| Structured data models with strict types, relationships, and indexes | Data model sections use DBML or Prisma Schema DSL — natural language forbidden |
26
+
|**MADR (ADR Records)**| Architecture decision records with Context/Decision/Consequences | Every AD has `[Context]`, `[Decision]`, `[Consequences]` subsections |
27
+
|**API-First Type Signatures**| Contracts defined before implementation (OpenAPI, Protocol, Trait) | Interface sections use type signatures — narrative descriptions forbidden |
28
+
17
29
### Best-Practice Alignment
18
30
19
31
| Source | Core Idea | How pb-spec Applies It |
@@ -29,6 +41,8 @@ Compared to letting AI "just write code", pb-spec provides a hardened execution
29
41
|[Harness Design for Long-Running Application Development](https://www.anthropic.com/engineering/harness-design-long-running-apps)| Generator/Evaluator separation; adversarial evaluation with MCP-driven live verification |`pb-build` dual-persona: Generator builds, independent Evaluator audits with fresh context; adaptive evaluation by task complexity |
30
42
|[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 |
31
43
|[Ensuring Correctness Through the Type System](https://lindbakk.com/blog/ensuring-correctness-through-the-type-system)| Use the type system to encode invariants and catch errors early | Encode contracts as type-level assertions in `design.md` and add type checks to verification; `pb-plan` adds type guidance and `pb-build` runs the type checker when applicable |
44
+
|[shadcn/improve](https://github.com/shadcn/improve)| Audit codebase, write self-contained plans for cheaper executors |`/pb-improve` surveys codebase, produces prioritized findings and handoff plans |
*(After installation, skills will be placed in `.agents/skills/` or the compatible local directory for your environment, and automatically indexed by your AI.)*
@@ -56,15 +71,35 @@ Invoke these skills directly in your IDE / Agent terminal:
56
71
2.**/pb-plan "requirement description"**: For example `/pb-plan Add WebSocket auth`, AI will generate `design.md`, `tasks.md`, and `.feature` test specs with Architecture Decisions.
57
72
3.**/pb-build "feature-name"**: Automatically reads `tasks.md`, starts the outer BDD and inner TDD dual-loop with Subagents, closing and verifying each task one by one.
58
73
4.**/pb-refine "feature-name"**: *(Optional)* When encountering design blocks (Build Blocked) or architectural flaws, iteratively modify specs based on feedback.
74
+
5.**/pb-improve**: Audit the codebase and generate prioritized implementation plans for other agents to execute.
59
75
60
76
## Skills Overview
61
77
78
+
### Workflow Skills
79
+
62
80
| Skill | Trigger | Output | Description |
63
81
|---|---|---|---|
64
82
|`pb-init`|`/pb-init`|`AGENTS.md`| Audit repo and safely update/append a managed snapshot block without rewriting user-authored constraints |
-**Architecture Decisions**: Explicit `Architecture Decisions` section with SRP, DIP, and pattern evaluation
163
+
-**EARS Requirements**: All acceptance criteria use 5 sentence patterns for machine-checkable verification
164
+
-**C4 + Mermaid Architecture**: Architecture diagrams in parseable Mermaid syntax
165
+
-**MADR Decisions**: Architecture decisions with Context/Decision/Consequences
166
+
-**DBML Data Models**: Structured data models in DSL (natural language forbidden)
167
+
-**API-First Contracts**: Type signatures before implementation (OpenAPI, Protocol, Trait)
117
168
-**Risk-based testing**: Property tests by default for broad input domains; fuzzing and benchmarks conditional
118
169
-**Template identity alignment**: Renames generic scaffold names to project-matching identifiers
119
170
-**Source requirement normalization**: Converts arbitrary-format input into a structured requirement ledger
@@ -146,9 +197,35 @@ Key principles:
146
197
-**Architecture decisions are binding**: Executes the approved design; does not invent a different architecture
147
198
-**Escalation over thrashing**: 3 consecutive failures → suspend task + DCR packet to `/pb-refine`
148
199
200
+
### 5. `/pb-improve` — Codebase Audit & Plan Generation
201
+
202
+
Audits any codebase and writes self-contained implementation plans for other agents to execute. The skill never modifies source code — only produces plans under `plans/`.
203
+
204
+
```text
205
+
/pb-improve full audit → prioritized findings → plans
206
+
/pb-improve quick cheap pass: hotspots, top findings only
207
+
/pb-improve deep exhaustive: every package, every category
2.**Audit** — Fans out parallel subagents across 9 categories: correctness, security, performance, test coverage, tech debt, dependencies, DX, docs, direction.
222
+
3.**Vet** — Re-reads every cited location to drop false positives and correct mis-attributions.
223
+
4.**Prioritize** — Findings ordered by leverage (impact ÷ effort, weighted by confidence).
224
+
5.**Plan** — One file per selected finding in `plans/` with self-contained context, verification gates, and STOP conditions.
225
+
149
226
## Design Philosophy: Agent Harness
150
227
151
-
pb-spec's design is inspired by Anthropic's research on [Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents). Core idea: place AI agents inside a strict, observable, recoverable execution environment.
228
+
pb-spec's design is inspired by Anthropic's research on [Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents) and the [Superpowers](https://github.com/obra/superpowers) methodology. Core idea: place AI agents inside a strict, observable, recoverable execution environment.
152
229
153
230
| Principle | How pb-spec Implements It |
154
231
|---|---|
@@ -161,6 +238,9 @@ pb-spec's design is inspired by Anthropic's research on [Effective Harnesses for
161
238
|**Observability as Context**| Task verification includes runtime signals (logs/health) |
162
239
|**Escalation Loop**| 3 consecutive failures → DCR handoff to `pb-refine`|
163
240
|**Generator/Evaluator Isolation**| Generator builds; Evaluator judges with fresh context |
241
+
|**Evidence Before Claims**|`pb-verification-before-completion`: no success claims without fresh verification |
242
+
|**Systematic Debugging**|`pb-systematic-debugging`: root cause before fixes, scientific method |
243
+
|**Skill Auto-Triggering**|`using-pb-spec` bootstrap ensures skills activate at the right moments |
Copy file name to clipboardExpand all lines: docs/contract.md
+19-6Lines changed: 19 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,11 +105,14 @@ Note: Complexity levels (lightweight, medium, high) are orthogonal to mode. Both
105
105
The following sections are required for a build-eligible full-mode `design.md`:
106
106
107
107
1.`Executive Summary`
108
-
2.`Requirements & Goals`
109
-
3.`Architecture Overview`
110
-
4.`Detailed Design`
111
-
5.`Verification & Testing Strategy`
112
-
6.`Implementation Plan`
108
+
2.`Requirements & Goals` — must use **EARS (Easy Approach to Requirements Syntax)** notation with 5 sentence patterns (Ubiquitous, State-driven, Event-driven, Unwanted, Exception)
109
+
3.`Architecture Overview` — must use **C4 Model** rendered in **Mermaid.js** syntax (Context, Container, Component diagrams)
110
+
4.`Architecture Decisions` — must use **MADR (Markdown Any Decision Records)** format with `[Context]`, `[Decision]`, `[Consequences]`
111
+
5.`Data Models` — must use **DBML** or **Prisma Schema** DSL (natural language table descriptions forbidden)
112
+
6.`Interface Contracts` — must use **API-First** type signatures (OpenAPI YAML for external APIs, language-native type syntax for internal modules)
113
+
7.`Detailed Design`
114
+
8.`Verification & Testing Strategy`
115
+
9.`Implementation Plan`
113
116
114
117
### 6.3 Conditional Sections for Full Mode
115
118
@@ -131,7 +134,7 @@ A lightweight `design.md` must still include:
131
134
132
135
1.`Summary`
133
136
2.`Approach`
134
-
3.`Architecture Decisions`
137
+
3.`Architecture Decisions` — must use **MADR** format even in lightweight mode
135
138
4.`BDD/TDD Strategy`
136
139
5.`Code Simplification Constraints`
137
140
6.`BDD Scenario Inventory`
@@ -140,6 +143,8 @@ A lightweight `design.md` must still include:
140
143
141
144
Lightweight mode may omit the full-mode `Detailed Design` and `Implementation Plan` sections as standalone top-level sections if the same information is captured compactly in the required lightweight sections.
142
145
146
+
Lightweight mode may also omit C4 diagrams, DBML/Prisma schemas, and full API contracts when the change is too small to warrant them — but Architecture Decisions must still use MADR format.
147
+
143
148
### 6.5 Lightweight-to-Full Mapping
144
149
145
150
For validation purposes, lightweight mode satisfies the full contract through the following mapping:
@@ -166,6 +171,14 @@ For validation purposes:
166
171
- a section may satisfy a conditional requirement by explicitly stating why it is `N/A`
167
172
- repo-specific standards must be grounded in actual repo docs or code, not generic boilerplate
168
173
174
+
**Format-specific validation rules:**
175
+
176
+
-**EARS Requirements:** Each requirement must use one of the 5 EARS patterns (Ubiquitous, State-driven, Event-driven, Unwanted, Exception). Requirements written as vague goals ("the system should be fast") are invalid.
177
+
-**C4/Mermaid Architecture:** Architecture sections must contain at least one ````mermaid` code block. Natural language architecture descriptions alone do not satisfy the Architecture Overview requirement.
178
+
-**MADR Decisions:** Each Architecture Decision must have `Context`, `Decision`, and `Consequences` subsections. Decisions without consequences are incomplete.
179
+
-**DBML/Prisma Data Models:** Data model sections must use DBML or Prisma Schema syntax inside a fenced code block. Natural language table descriptions ("users table has an id and name") are invalid.
180
+
-**API-First Contracts:** Interface sections must use type signatures (OpenAPI YAML, TypeScript interfaces, Python Protocols, Rust traits). Narrative API descriptions without type definitions are invalid.
0 commit comments