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: docs/spec-driven-workflow.adoc
+58-57Lines changed: 58 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,12 @@ This document describes how to build production-quality software with AI agents,
10
10
11
11
Semantic Anchors are compact terms that reliably activate rich knowledge domains in LLMs.
12
12
Instead of writing pages of instructions, you reference a concept the model already understands deeply.
13
-
"Use TDD" is shorter than explaining test-driven development.
14
-
"Follow arc42" is shorter than describing 12 architecture sections.
13
+
"Use link:#/anchor/tdd-london-school[TDD, London School]" is shorter than explaining test-driven development with mocks and outside-in design.
14
+
"Follow link:#/anchor/arc42[arc42]" is shorter than describing 12 architecture sections.
15
15
The prompts stay short, precise, and maintainable.
16
16
17
17
This workflow was used to build three open source projects, all 100% AI-generated.
18
-
The golden rule: I only prompt, I never touch the code myself.
18
+
*The golden rule: I only prompt, I never touch the code myself.*
19
19
Every line of code, every test, every documentation file was written by the AI under my guidance.
20
20
21
21
* https://github.com/docToolchain/dacli[*dacli*]: A full CLI tool with spec, architecture docs, tests, and user manual. Built by one AI, cross-reviewed by 5 different LLMs.
@@ -41,20 +41,40 @@ That is like asking a junior developer to build an entire application from a one
41
41
The result will be unpredictable at best.
42
42
43
43
This workflow takes the opposite approach: break the work into small, well-defined steps and let the AI handle each one autonomously.
44
-
Each step produces a concrete artifact that you can review before moving on.
44
+
Each step produces a concrete artifact that you can review if you see the need for it.
45
45
46
46
The paradox: the smaller you make each task, the more autonomy you can give the agent.
47
47
A vague "build me X" needs constant supervision.
48
-
A precise "implement issue #42 using TDD, respecting the spec in src/docs/specs/" can run on its own.
48
+
A precise "implement issue #42 using TDD, respecting the spec and architecture in src/docs/" can run on its own.
49
49
The phases described in this document are designed to produce exactly that kind of precise, self-contained task.
50
50
51
-
This connects directly to Shannon's theorem.
52
-
Each small step is a short transmission over the noisy channel.
53
-
Short transmissions with error correction (tests, linting, review) are far more reliable than one long, unchecked transmission.
54
-
LLM output is inherently non-deterministic -- the same prompt can produce different code each time.
55
-
TDD and reviews are the error correction that makes this noisy channel usable.
56
-
The agent works in a tight loop: implement, test, commit, check docs.
57
-
You review at the boundaries between phases, not after every line of code.
51
+
This connects directly to *Eichhorst's Principle*, which applies Shannon's noisy channel theorem to LLM coding.
52
+
An LLM is not a deterministic tool.
53
+
It is a noisy, non-deterministic channel.
54
+
It hallucinates, loses context, and is sometimes plain wrong.
55
+
But an agent in a loop corrects itself: the compiler reports an error, the agent reads it, fixes the code, runs the tests, reads the failure, fixes the logic, and repeats until green.
56
+
That is not magic -- that is error correction, exactly as Shannon described.
57
+
58
+
When you prompt an LLM and paste the result into your project, you run an *open loop*.
59
+
No compiler check, no test suite, no review.
60
+
The LLM guesses once and you hope it guessed right.
61
+
When an agent writes code, runs the compiler, runs the tests, and iterates until everything passes, that is a *closed loop*.
62
+
The same principle that makes a thermostat work.
63
+
64
+
Different tests correct different error classes.
65
+
The compiler catches syntax errors.
66
+
Unit tests catch logic errors.
67
+
BDD tests catch domain errors.
68
+
Each layer increases the reliability of the channel.
69
+
Untested code is an uncorrected channel -- the noise passes straight through.
70
+
71
+
The consequence: *better tests beat better prompts*.
72
+
A comprehensive test suite turns a mediocre model into a reliable coding partner.
73
+
And if the complexity of a specification exceeds the capacity of the LLM, more tokens will not help.
74
+
The answer is smaller specifications, clearer boundaries, and better tests.
75
+
76
+
Each small step in this workflow is a short transmission over the noisy channel.
77
+
Short transmissions with error correction are far more reliable than one long, unchecked transmission.
58
78
59
79
== Workflow Overview
60
80
@@ -68,7 +88,7 @@ These principles apply to all phases:
68
88
⚓ link:#/anchor/conventional-commits[*Conventional Commits*]:: All commits follow a standardized format for a clean, parseable git history.
69
89
⚓ link:#/anchor/docs-as-code[*Docs-as-Code according to Ralf D. Müller*]:: Documentation lives in the repository as AsciiDoc, built by https://doctoolchain.org[docToolchain].
70
90
Docs-as-Code treats documentation like source code: version-controlled, peer-reviewed, and built automatically.
71
-
*Definition of Done*:: Code passes all tests, feature branch is merged or PR is created, documentation is updated, architecture decisions are recorded.
91
+
⚓ link:#/anchor/definition-of-done[*Definition of Done*]:: Code passes all tests, feature branch is merged or PR is created, documentation is updated, architecture decisions are recorded.
72
92
73
93
== Prerequisites
74
94
@@ -77,6 +97,8 @@ Before starting, set up your project infrastructure:
77
97
. Initialize a git repository
78
98
. Install https://doctoolchain.org[docToolchain] and download the ⚓ link:#/anchor/arc42[*arc42*] template
79
99
. Configure your AI coding environment with an `AGENTS.md` (or tool-specific equivalent like `CLAUDE.md`)
100
+
. Give the AI agent access to GitHub or GitLab via the CLI (`gh` or `glab`). The agent will need this later to create issues, pull requests, and ADR discussions. Consider using a dedicated account for audit traceability.
101
+
. Following Eichhorst's Principle, set up error correction layers for your project: linters, pre-commit hooks, CI pipelines, and static analysis. Each layer catches a different class of error and makes the LLM channel more reliable. The https://github.com/LLM-Coding/vibe-coding-risk-radar[Vibe Coding Risk Radar] can help determine which checks are appropriate for your project's risk profile. These checks unfold their full effect once the first lines of runnable code exist -- set them up early, but revisit as the project grows.
80
102
81
103
.Installing docToolchain (Linux/macOS)
82
104
[source,bash]
@@ -112,20 +134,20 @@ A minimal `AGENTS.md` for this workflow:
112
134
## Conventions
113
135
- Documentation: Plain English according to Strunk & White
114
136
- Testing: TDD (London or Chicago School as appropriate)
137
+
- Code: DRY, SOLID, KISS, Ubiquitous Language (DDD)
115
138
- Commits: Conventional Commits, reference issue number
116
139
- Branches: feature/<issue-description>
117
140
118
-
## Current State
119
-
- Working on: EPIC #3
120
-
- Next issue: #42
121
141
----
122
142
123
-
Update this file as the project evolves.
143
+
As the project progresses, the AI agent will maintain this file itself.
124
144
When starting a new AI session, the agent reads `AGENTS.md` and immediately has the context it needs.
125
145
126
146
[TIP]
127
147
====
128
-
Start a new AI session for each EPIC or when the conversation becomes sluggish.
148
+
Compact the context before starting a new EPIC.
149
+
Within a session, keep an eye on the context window.
150
+
Compact the conversation manually at natural breakpoints (e.g. after completing an issue) rather than waiting for the model to auto-compact at an inconvenient moment and lose important context.
129
151
The agent picks up context from `AGENTS.md` and the spec files automatically.
130
152
====
131
153
@@ -153,8 +175,8 @@ Prompt the AI to use the ⚓ link:#/anchor/socratic-method[*Socratic Method*] to
153
175
[source]
154
176
----
155
177
Use the Socratic Method to help me clarify requirements for [your project].
156
-
Ask me at most 3 questions at a time. Challenge my assumptions before
157
-
documenting anything.
178
+
Ask me at most 3 questions at a time. Challenge my assumptions.
179
+
Keep asking until you fully understand the requirements.
158
180
----
159
181
160
182
This activates targeted questioning, assumption challenging, and productive use of not-knowing.
@@ -173,13 +195,12 @@ Continue the dialogue until both you and the AI are satisfied that the requireme
173
195
174
196
=== Step 3: Document as PRD
175
197
176
-
Ask the AI to write a *Product Requirements Document (PRD)* and save it as AsciiDoc.
198
+
Ask the AI to write a ⚓ link:#/anchor/prd[*Product Requirements Document (PRD)*] and save it as AsciiDoc.
177
199
A PRD captures the what and why, not the how: problem statement, goals, user personas, success criteria, and scope boundaries.
178
200
179
201
[source]
180
202
----
181
203
Write a PRD based on our discussion. Save it as src/docs/specs/prd.adoc.
182
-
Follow Plain English guidelines according to Strunk and White.
183
204
----
184
205
185
206
=== Step 4: Create Detailed Specification
@@ -198,7 +219,7 @@ Save as .adoc files in src/docs/specs/.
198
219
⚓ link:#/anchor/gherkin[*Gherkin*] (Given/When/Then) provides acceptance criteria that are both human-readable and machine-testable.
199
220
These criteria become the foundation for TDD later.
200
221
201
-
Activity Diagrams force you to think about error paths, edge cases, and alternative flows early.
222
+
Activity Diagrams are an important part of the specification because they define flows, error paths, and edge cases in a way the AI can follow during implementation.
202
223
203
224
== Phase 2: Architecture
204
225
@@ -208,16 +229,17 @@ Ask the AI to derive an architecture from the specification:
208
229
209
230
[source]
210
231
----
211
-
Create an arc42 architecture document based on the specification in src/docs/specs/.
212
-
Save it in src/docs/arc42/.
232
+
Fill the arc42 template in src/docs/arc42/ based on the specification in src/docs/specs/.
213
233
Use PlantUML C4 diagrams for architecture visualization.
214
234
----
215
235
236
+
The arc42 template was downloaded in the prerequisites step.
237
+
The AI knows the template structure and fills the 12 sections appropriately.
238
+
216
239
⚓ link:#/anchor/arc42[*arc42*] provides 12 sections covering everything from context to deployment.
217
-
The AI knows the template structure and fills it appropriately.
218
240
219
241
⚓ link:#/anchor/c4-diagrams[*C4 Diagrams*] combined with PlantUML provide text-based architecture visualization at four levels: Context, Container, Component, Code.
220
-
The AI can create and modify these diagrams without graphical tools.
242
+
Since the documentation uses AsciiDoc, PlantUML and other text-to-diagram tools are supported natively -- the AI generates diagrams as code, and the build renders them automatically.
221
243
222
244
==== Architecture Decision Records
223
245
@@ -238,7 +260,7 @@ The AI creates each ADR as a GitHub/GitLab issue first.
238
260
You review the issue, comment, or approve it.
239
261
Only after your approval is the ADR incorporated into the arc42 documentation.
240
262
This way, every architectural decision is traceable through the issue history.
241
-
All ADRs must align with the quality goals defined in arc42 Section 1.2.
263
+
All ADRs must align with the quality requirements defined in arc42 Section 10.
242
264
243
265
=== Step 6: Architecture Review (ATAM)
244
266
@@ -269,7 +291,7 @@ Use MoSCoW prioritization for the initial backlog order.
269
291
Mark dependencies between issues with labels or cross-references.
270
292
----
271
293
272
-
⚓ *INVEST* ensures User Stories are Independent, Negotiable, Valuable, Estimable, Small, and Testable.
294
+
⚓ link:#/anchor/invest[*INVEST*] ensures User Stories are Independent, Negotiable, Valuable, Estimable, Small, and Testable.
273
295
274
296
⚓ link:#/anchor/moscow[*MoSCoW*] (Must have, Should have, Could have, Won't have) provides clear prioritization.
275
297
@@ -281,20 +303,12 @@ As the project evolves, groom the backlog regularly to re-prioritize based on ne
281
303
282
304
=== Step 8: Implement Issue by Issue
283
305
284
-
Create a feature branch for each EPIC or logical group of issues:
Select the next logical issue from the backlog (respect dependencies).
296
310
Analyze it and document your analysis as a comment on the issue.
297
-
Implement it using TDD. Commit when done.
311
+
Implement it using TDD (choose London or Chicago School as appropriate). Commit when done.
298
312
Check if the spec or architecture docs need updating.
299
313
----
300
314
@@ -305,19 +319,13 @@ For each issue:
305
319
. *Commit*: After the issue is implemented and all tests pass, commit with a reference to the issue number
306
320
. *Check docs*: Ask whether the specification or architecture documentation needs updating based on what was learned during implementation
307
321
308
-
⚓ *TDD* (Test-Driven Development) comes in two schools:
322
+
TDD (Test-Driven Development) comes in two schools:
309
323
310
-
* ⚓ link:#/anchor/tdd-london-school[*London School*] (mockist): isolate the unit under test, mock dependencies. Good for interaction-heavy code.
311
-
* ⚓ link:#/anchor/tdd-chicago-school[*Chicago School*] (classicist): test behavior through the public API, use real collaborators. Good for state-based logic.
324
+
* ⚓ link:#/anchor/tdd-london-school[*TDD, London School*] (mockist): isolate the unit under test, mock dependencies. Good for interaction-heavy code.
325
+
* ⚓ link:#/anchor/tdd-chicago-school[*TDD, Chicago School*] (classicist): test behavior through the public API, use real collaborators. Good for state-based logic.
312
326
313
327
The AI selects the appropriate school based on the code's characteristics.
314
328
315
-
Each implementation follows the Red-Green-Refactor cycle and respects:
0 commit comments