Skip to content

Commit 2152eba

Browse files
committed
Updated overall specs approach
1 parent c69fd05 commit 2152eba

12 files changed

+466
-440
lines changed

scripts/output/podcasts/manifest.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
},
6868
"practical-techniques/lesson-11-agent-friendly-code.md": {
6969
"scriptPath": "practical-techniques/lesson-11-agent-friendly-code.md",
70-
"size": 8141,
71-
"tokenCount": 1958,
72-
"generatedAt": "2025-12-12T08:55:23.116Z"
70+
"size": 8262,
71+
"tokenCount": 1998,
72+
"generatedAt": "2026-02-12T08:05:49.415Z"
7373
},
7474
"fundamentals/lesson-2-how-agents-work.md": {
7575
"scriptPath": "fundamentals/lesson-2-how-agents-work.md",
@@ -85,14 +85,14 @@
8585
},
8686
"practical-techniques/lesson-12-spec-driven-development.md": {
8787
"scriptPath": "practical-techniques/lesson-12-spec-driven-development.md",
88-
"size": 8051,
89-
"tokenCount": 1931,
90-
"generatedAt": "2025-12-31T15:05:31.026Z"
88+
"size": 9214,
89+
"tokenCount": 2223,
90+
"generatedAt": "2026-02-12T09:01:36.118Z"
9191
},
9292
"practical-techniques/lesson-13-systems-thinking-specs.md": {
9393
"scriptPath": "practical-techniques/lesson-13-systems-thinking-specs.md",
94-
"size": 19294,
95-
"tokenCount": 4727,
96-
"generatedAt": "2026-02-11T17:10:39.070Z"
94+
"size": 20013,
95+
"tokenCount": 4912,
96+
"generatedAt": "2026-02-12T12:23:59.537Z"
9797
}
9898
}

website/docs/practical-techniques/lesson-11-agent-friendly-code.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function createUser(password: string) {
124124

125125
// Critical section (agent barrier)
126126
// === CRITICAL SECURITY SECTION ===
127-
// NEVER store passwords in plain text or weak hashing (MD5, SHA1)
127+
// C-001: NEVER store passwords in plain text or weak hashing (MD5, SHA1)
128128
// MUST hash with bcrypt (10+ rounds) BEFORE persistence
129129
// Do NOT modify hashing algorithm without security review
130130
// Violations create CVE-level vulnerabilities
@@ -139,6 +139,8 @@ function createUser(password: string) {
139139

140140
This creates deliberate friction. An agent tasked with "add OAuth login" will work slower around password hashing code with heavy constraints—it must navigate all those NEVER/MUST directives carefully. That's the protection mechanism: forced caution for critical paths. But overuse is counterproductive. Mark too many functions as CRITICAL and agents struggle with routine work, slowing down legitimate changes as much as dangerous ones. Reserve this technique for code where accidental modification genuinely costs more than the development slowdown.
141141

142+
These constraint IDs (C-001, I-001) originate in [spec tables](/docs/practical-techniques/lesson-13-systems-thinking-specs#constraints-and-invariants-defining-correctness) and migrate into code during implementation. Once inlined, the code carries the constraint—not just the implementation, but the *rule* it enforces. This is what makes it safe to [delete the spec](/docs/practical-techniques/lesson-12-spec-driven-development) after implementation: the WHY has migrated into the codebase.
143+
142144
## The Knowledge Cache Anti-Pattern
143145

144146
You've extracted architectural knowledge from your codebase with an agent—clean diagrams, comprehensive API documentation, detailed component relationships. You save it as `ARCHITECTURE.md` and commit it. Now you have a cache invalidation problem: code changes (always), documentation doesn't (usually), and future agents find both during code research ([Lesson 5](/docs/methodology/lesson-5-grounding)). The diagram below shows the divergence.
@@ -181,7 +183,7 @@ sequenceDiagram
181183
end
182184
```
183185

184-
The moment you commit extracted knowledge, every code change requires documentation updates you'll forget. Source code is your single source of truth—code research tools (ChunkHound, semantic search, Explore) extract architectural knowledge dynamically every time, fresh and accurate. Document decisions and WHY (ADRs, high-level overviews, business domain concepts), not extracted WHAT that code research can regenerate on demand.
186+
The moment you commit extracted knowledge, every code change requires documentation updates you'll forget. Source code is your single source of truth—code research tools (ChunkHound, semantic search, Explore) extract architectural knowledge dynamically every time, fresh and accurate. The distinction: **HOW** knowledge (implementation details, data flows, component relationships) is redundant with code—code research regenerates it on demand. **WHY** knowledge (rejected alternatives, business rationale, compliance mandates) can't be expressed in code. Commit the WHY as decision records—short documents capturing what was decided, why, and what alternatives were rejected. Let code research handle the HOW.
185187

186188
## Key Takeaways
187189

@@ -191,6 +193,8 @@ The moment you commit extracted knowledge, every code change requires documentat
191193

192194
- **Comments as agent-critical sections (use sparingly)** - For genuinely high-risk code (authentication, cryptography, payments, PII), write comments as prompts using imperative directives (NEVER, MUST, ALWAYS) to create deliberate friction. This protection mechanism guards sensitive code from accidental modification. **Overuse is counterproductive**—if everything is marked CRITICAL, the signal becomes noise and legitimate work slows down.
193195

196+
- **Constraint IDs migrate from spec to code** — When specs use IDs like C-001 or I-001 ([Lesson 13](/docs/practical-techniques/lesson-13-systems-thinking-specs#constraints-and-invariants-defining-correctness)), agents inline them into code comments during implementation. The code then carries the constraint rule, making it safe to delete the spec ([Lesson 12](/docs/practical-techniques/lesson-12-spec-driven-development)).
197+
194198
- **You are the quality circuit breaker** - Code review ([Lesson 9](/docs/practical-techniques/lesson-9-reviewing-code)) prevents negative compounding. Accepting bad patterns lets them enter pattern context for future agents. Rejecting them breaks the negative feedback loop.
195199

196200
- **Avoid knowledge cache anti-patterns** - Code research tools (Explore, ChunkHound, semantic search) extract architectural knowledge dynamically from source code every time you need it. Saving extracted knowledge to .md files creates unnecessary caches that become stale, pollute future grounding with duplicated information, and create impossible cache invalidation problems. Trust the grounding process ([Lesson 5](/docs/methodology/lesson-5-grounding)) to re-extract knowledge on-demand from the single source of truth.

website/docs/practical-techniques/lesson-12-spec-driven-development.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ This is exactly the [Knowledge Cache Anti-Pattern](/docs/practical-techniques/le
3434

3535
Here's the key insight from [Lesson 5](/docs/methodology/lesson-5-grounding): **grounding tools already perform knowledge extraction.** When ChunkHound's [code research](https://chunkhound.github.io/code-research) processes 50,000 tokens of raw code and returns a 3,000-token synthesis, that synthesis IS a spec—extracted on-demand from the source of truth. You don't need to maintain spec files because you can regenerate them from code whenever needed.
3636

37-
**The solution: DELETE spec files after implementation.** The code is now the single source of truth. Specs are temporary scaffolding, not permanent artifacts.
37+
But not all spec knowledge is equal. **HOW** knowledge—implementation details, data flows, edge cases—gets fully encoded in code during implementation. Once the code exists, the spec's HOW is redundant. **WHY** knowledge—rejected alternatives, business rationale for a constraint, compliance mandates—can't be expressed in code. A constraint comment like `// C-001: NEVER process duplicate webhook` ([Lesson 11](/docs/practical-techniques/lesson-11-agent-friendly-code#comments-as-context-engineering-critical-sections-for-agents)) tells the agent *what* to enforce, but not *why* you chose idempotency-via-database over idempotency-via-cache. That rationale is the **residual**—the part of the spec that doesn't migrate into code.
38+
39+
**The solution: DELETE the HOW spec after implementation.** The code is the single source of truth for implementation. For the small WHY residual (rejected alternatives, business context that drove constraints), have the agent diff the original spec against the final code—what's expressed in code is now redundant. The residual gets committed as a decision record ([Lesson 11](/docs/practical-techniques/lesson-11-agent-friendly-code#the-knowledge-cache-anti-pattern)). Everything else is regenerable from code via grounding tools.
3840

3941
## Mainstream SDD vs This Approach
4042

@@ -90,6 +92,8 @@ If you've followed this course, you've been practicing SDD all along. Every time
9092

9193
...you were doing Spec Driven Development. The spec lived in your context window—RAM, not disk.
9294

95+
What makes this safe is [constraint migration](/docs/practical-techniques/lesson-11-agent-friendly-code#comments-as-context-engineering-critical-sections-for-agents): during implementation, the agent inlines spec constraints—with their IDs—into code comments. The WHY moves from spec to code. When you close the conversation, nothing is lost.
96+
9397
### When to Persist Specs
9498

9599
For single-session tasks, the context window is your spec file. But larger tasks need coordination across sessions:

website/docs/practical-techniques/lesson-13-systems-thinking-specs.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ Constraints limit *actions* (NEVER do X). Invariants describe *state* (X is alwa
208208

209209
The **Data** and **Stress** columns transform a constraint from a wish into a testable requirement. "NEVER process duplicates" is a policy. "NEVER process duplicates, verified with 10K events at 100 concurrent deliveries" is an engineering requirement with a verification plan. (Note that C-001 and C-002 trace back to [third-party assumptions](#third-party-assumptions)—they exist *because* of Stripe's delivery semantics and signing behavior, not as arbitrary security choices.)
210210

211+
During implementation, these IDs migrate into code as structured comments ([Lesson 11](/docs/practical-techniques/lesson-11-agent-friendly-code#comments-as-context-engineering-critical-sections-for-agents)):
212+
213+
```typescript
214+
// C-001: NEVER process duplicate webhook — idempotency via unique constraint on stripe_event_id
215+
// C-002: NEVER trust unsigned webhook — HMAC-SHA256 validation before any processing
216+
export async function handleWebhook(req: Request): Promise<Response> {
217+
verifySignature(req) // C-002
218+
if (await isDuplicate(req.body.id)) return new Response(null, { status: 200 }) // C-001
219+
// ...
220+
}
221+
```
222+
223+
The spec table is the authoritative source during design. The code comments become the authoritative source after implementation. This is what makes [deleting the spec](/docs/practical-techniques/lesson-12-spec-driven-development) safe—the constraints have migrated.
224+
211225
### Invariants
212226

213227
| ID | Condition | Scope | Manifested By |
@@ -334,7 +348,7 @@ Each loop through this cycle reveals what the spec missed. The first pass might
334348

335349
**You're done when the loop produces no new gaps:** the code passes all behavioral scenarios, the spec accounts for all constraints the code revealed, and the last pass surfaces nothing new. That's a testable termination condition. A simple feature converges in one loop. A complex architectural change might take five. But you discover which you're dealing with *by running the loop*, not by predicting it.
336350

337-
**Iteration speed is the multiplier.** Code generation is approaching post-scarcity[^1]—the scarce resource is your judgment about *what* to build. The engineer who runs ten hypothesis→experiment→verify loops per day outperforms the one who runs two with a more thorough upfront spec[^4][^5]. This is the same insight that made Agile outperform Waterfall, compressed from weeks-per-iteration to minutes. Use [exploration planning](/docs/methodology/lesson-3-high-level-methodology#phase-2-plan-strategic-decision) (Lesson 3) and [ArguSeek](/docs/methodology/lesson-5-grounding#arguseek-isolated-context--state) (Lesson 5) to research before each loop. For system-level work, start from the [full template](/prompts/specifications/spec-template). Validate through the [SDD workflow](/docs/practical-techniques/lesson-12-spec-driven-development)—gap-analyze, implement, then delete the spec.
351+
**Iteration speed is the multiplier.** Code generation is approaching post-scarcity[^1]—the scarce resource is your judgment about *what* to build. The engineer who runs ten hypothesis→experiment→verify loops per day outperforms the one who runs two with a more thorough upfront spec[^4][^5]. This is the same insight that made Agile outperform Waterfall, compressed from weeks-per-iteration to minutes. Use [exploration planning](/docs/methodology/lesson-3-high-level-methodology#phase-2-plan-strategic-decision) (Lesson 3) and [ArguSeek](/docs/methodology/lesson-5-grounding#arguseek-isolated-context--state) (Lesson 5) to research before each loop. For system-level work, start from the [full template](/prompts/specifications/spec-template). Validate through the [SDD workflow](/docs/practical-techniques/lesson-12-spec-driven-development)—gap-analyze, implement, then delete the spec. What survives deletion: constraint IDs inlined in code ([Lesson 11](/docs/practical-techniques/lesson-11-agent-friendly-code#comments-as-context-engineering-critical-sections-for-agents)), and the small WHY residual (rejected alternatives, business rationale) committed as decision records.
338352

339353
:::info Template Sections Not Covered
340354
The [full spec template](/prompts/specifications/spec-template) includes sections not taught in this lesson: **Background** (problem statement + baseline metrics), **Caching** (strategy/TTL/invalidation), **Endpoints** (REST contract details), **Cleanup Flows** (teardown/rollback sequences), **Code Traceability** (file:line evidence columns). Use these when the code pulls them from you—not before.

website/static/audio/manifest.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,29 @@
100100
},
101101
"practical-techniques/lesson-11-agent-friendly-code.md": {
102102
"audioUrl": "/audio/practical-techniques/lesson-11-agent-friendly-code.mp3",
103-
"size": 24139336,
103+
"size": 4873292,
104104
"format": "audio/mp3",
105-
"tokenCount": 1619,
105+
"tokenCount": 1622,
106106
"chunks": 2,
107-
"generatedAt": "2025-12-12T09:01:32.009Z",
107+
"generatedAt": "2026-02-12T08:11:57.545Z",
108108
"scriptSource": "practical-techniques/lesson-11-agent-friendly-code.md"
109109
},
110110
"practical-techniques/lesson-12-spec-driven-development.md": {
111111
"audioUrl": "/audio/practical-techniques/lesson-12-spec-driven-development.mp3",
112-
"size": 4556444,
112+
"size": 5543540,
113113
"format": "audio/mp3",
114-
"tokenCount": 1645,
115-
"chunks": 2,
116-
"generatedAt": "2025-12-31T15:10:46.451Z",
114+
"tokenCount": 1863,
115+
"chunks": 3,
116+
"generatedAt": "2026-02-12T09:08:29.379Z",
117117
"scriptSource": "practical-techniques/lesson-12-spec-driven-development.md"
118118
},
119119
"practical-techniques/lesson-13-systems-thinking-specs.md": {
120120
"audioUrl": "/audio/practical-techniques/lesson-13-systems-thinking-specs.mp3",
121-
"size": 11087924,
121+
"size": 13040972,
122122
"format": "audio/mp3",
123-
"tokenCount": 3903,
124-
"chunks": 5,
125-
"generatedAt": "2026-02-11T17:25:11.016Z",
123+
"tokenCount": 4135,
124+
"chunks": 6,
125+
"generatedAt": "2026-02-12T12:39:51.837Z",
126126
"scriptSource": "practical-techniques/lesson-13-systems-thinking-specs.md"
127127
}
128128
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

website/static/presentations/manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
},
2323
"practical-techniques/lesson-12-spec-driven-development.md": {
2424
"presentationUrl": "/presentations/practical-techniques/lesson-12-spec-driven-development.json",
25-
"slideCount": 11,
25+
"slideCount": 10,
2626
"estimatedDuration": "30-40 minutes",
2727
"title": "Spec Driven Development",
28-
"generatedAt": "2025-12-31T15:12:18.125Z"
28+
"generatedAt": "2026-02-12T08:11:09.970Z"
2929
},
3030
"methodology/lesson-4-prompting-101.md": {
3131
"presentationUrl": "/presentations/methodology/lesson-4-prompting-101.json",
@@ -67,7 +67,7 @@
6767
"slideCount": 11,
6868
"estimatedDuration": "30-40 minutes",
6969
"title": "Agent-Friendly Code",
70-
"generatedAt": "2026-01-05T07:09:20.248Z"
70+
"generatedAt": "2026-02-12T08:07:49.310Z"
7171
},
7272
"practical-techniques/lesson-6-project-onboarding.md": {
7373
"presentationUrl": "/presentations/practical-techniques/lesson-6-project-onboarding.json",
@@ -92,9 +92,9 @@
9292
},
9393
"practical-techniques/lesson-13-systems-thinking-specs.md": {
9494
"presentationUrl": "/presentations/practical-techniques/lesson-13-systems-thinking-specs.json",
95-
"slideCount": 13,
95+
"slideCount": 12,
9696
"estimatedDuration": "35-45 minutes",
9797
"title": "Systems Thinking for Specs",
98-
"generatedAt": "2026-02-11T14:42:29.088Z"
98+
"generatedAt": "2026-02-12T08:14:20.380Z"
9999
}
100100
}

0 commit comments

Comments
 (0)