Skip to content

Commit e893dcb

Browse files
authored
Merge pull request #476 from raifdmueller/feat/brownfield-prompt-block-472
docs: brownfield Phase 0.5 — copy-paste prompt block + hyphenate title (#472)
2 parents ce2c713 + 93fde91 commit e893dcb

1 file changed

Lines changed: 68 additions & 16 deletions

File tree

docs/brownfield-workflow.adoc

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,85 @@ Present as a table.
5353
Pick one bounded context to start with.
5454
Choose one that is small, well-isolated, and has a change request pending.
5555

56-
== Phase 0.5: Socratic Code Theory Recovery
56+
== Phase 0.5: Socratic Code-Theory Recovery
5757

5858
Before changing anything, you need to recover the "theory" of the bounded context -- what https://pages.cs.wisc.edu/~remzi/Naur.pdf[Peter Naur] called the mental model that lives in the heads of the original developers. In a brownfield project, this model is not documented. The code is the only source.
5959

60-
This phase uses *Socratic Code Theory Recovery*: a two-phase workflow that builds understanding through recursive question refinement before producing documentation.
60+
This phase uses *Socratic Code-Theory Recovery*: a two-phase workflow that builds understanding through recursive question refinement before producing documentation.
6161

6262
=== Phase 1: Build the Question Tree
6363

6464
Start with five high-level questions about the bounded context and decompose them recursively. Use Semantic Anchors as decomposition guides: *arc42* for architecture, *Cockburn Use Cases* for specification, *ISO 25010* for quality, *Nygard ADRs* for decisions.
6565

66-
.Starting Questions (adapt to your bounded context)
66+
Each leaf in the tree is either `[ANSWERED]` (with code evidence: file, function, line) or `[OPEN]` (with Category and Ask role). The output is two AsciiDoc files: `QUESTION_TREE.adoc` (full reasoning trace) and `OPEN_QUESTIONS.adoc` (handoff document, grouped by role).
67+
68+
Copy the prompt below into a session that has read access to the bounded context. Adapt `[bounded context path]` and the example questions if your domain warrants it; do not change the leaf classification, Q-ID scheme, or output files.
69+
70+
.Prompt: Phase 1 — Build the Question Tree
6771
[source,txt]
6872
----
69-
1. What problem does this bounded context solve and for whom?
70-
2. What is the specification of this bounded context?
71-
3. What is the architecture of this bounded context?
72-
4. What quality goals drive the design?
73-
5. What risks and technical debt exist?
73+
You are performing Socratic Code-Theory Recovery on a brownfield bounded
74+
context located at [bounded context path]. Phase 1 of two.
75+
76+
Goal: recover the program's theory (Naur, 1985) from source code through
77+
recursive question refinement, before any documentation is written.
78+
79+
Process:
80+
81+
1. Start with five high-level questions about the bounded context:
82+
Q1 What problem does this bounded context solve, and for whom?
83+
Q2 What is the specification of this bounded context?
84+
Q3 What is the architecture of this bounded context?
85+
Q4 What quality goals drive the design?
86+
Q5 What risks and technical debt exist?
87+
88+
2. Decompose each question recursively. Use these Semantic Anchors as
89+
decomposition guides:
90+
- arc42 — 12 sub-questions for architecture (Q3 branch)
91+
- Cockburn Use Cases — Primary Actor, Trigger, Main Success Scenario,
92+
Extensions, Postconditions for specification (Q2 branch)
93+
- ISO/IEC 25010 — 8 quality characteristics for quality goals (Q4 branch)
94+
- Nygard ADRs — Context, Decision, Status, Consequences for design
95+
rationale (Q3.9 branch)
96+
Stop decomposing when a question is precise enough to be answered with a
97+
single piece of code evidence or a single fact from a stakeholder.
98+
99+
3. Assign a hierarchical Q-ID to every node (Q1, Q1.2, Q1.2.3, ...) so that
100+
later documentation can cite back to it.
101+
102+
4. For each leaf, classify it:
103+
104+
[ANSWERED]
105+
- You found the answer in the code.
106+
- Cite the evidence as <file>:<line> or <file>::<function>.
107+
- Be exact. No "see X for details."
108+
109+
[OPEN]
110+
- The answer is not derivable from code alone.
111+
- Category: business-context | design-rationale | quality-goals |
112+
stakeholder-context | future-direction
113+
- Ask role: Product Owner | Architect | Developer | Domain Expert |
114+
Operations
115+
- State precisely what cannot be answered, and why.
116+
117+
5. Output two files in AsciiDoc:
118+
119+
QUESTION_TREE.adoc
120+
- Full hierarchical tree with all nodes and Q-IDs
121+
- Each leaf marked [ANSWERED] (with evidence) or [OPEN] (with Category
122+
and Ask role)
123+
- Includes all reasoning, not only the leaves
124+
125+
OPEN_QUESTIONS.adoc
126+
- Only the [OPEN] leaves, copied verbatim from QUESTION_TREE.adoc
127+
- Grouped by Ask role (one section per role)
128+
- Each question short enough to be answered in 1-3 sentences
129+
130+
Do not write any other documentation in this phase. Phase 2 will synthesize
131+
the answered tree into PRD, specification, arc42, and ADRs — only after the
132+
team has filled in the [OPEN] leaves.
74133
----
75134

76-
Each leaf in the tree is either `[ANSWERED]` (with code evidence: file, function, line) or `[OPEN]` (with Category and Ask role).
77-
78-
The output is two files:
79-
80-
* `QUESTION_TREE.adoc` -- the full reasoning trace
81-
* `OPEN_QUESTIONS.adoc` -- the handoff document, grouped by role (Product Owner, Architect, Developer, Domain Expert, Operations)
82-
83135
=== Between Phases: Team Answers the Open Questions
84136

85137
Route the Open Questions to the people who can answer them. In a controlled experiment with a 13,000-line Go codebase, *11 targeted questions* were sufficient to close the gap between reverse-engineered documentation and the original. The questions are precise because the recursive decomposition ensures they are specific, not vague.
@@ -233,6 +285,6 @@ If the system cannot be built or started, you have a different problem -- fix th
233285
* Simon Martinelli, https://unifiedprocess.ai/[AI Unified Process] -- the bounded-context approach to spec-driven development in existing systems.
234286
* Eric Evans, https://www.domainlanguage.com/ddd/[Domain-Driven Design] -- the foundational work on bounded contexts and strategic design.
235287
* Michael Feathers, _Working Effectively with Legacy Code_ -- techniques for establishing test coverage in systems without tests.
236-
* Peter Naur, "Programming as Theory Building" (1985) -- argues that programming is about building a mental model ("theory") that cannot be fully captured in documentation. Socratic Code Theory Recovery tests this claim in the context of LLM-generated code.
288+
* Peter Naur, "Programming as Theory Building" (1985) -- argues that programming is about building a mental model ("theory") that cannot be fully captured in documentation. Socratic Code-Theory Recovery tests this claim in the context of LLM-generated code.
237289
* link:#/brownfield-experiment-report[Brownfield Experiment Report] -- controlled experiment: delete documentation from a greenfield project, regenerate from code, compare. Full methodology and findings.
238290
* link:#/brownfield-fair-comparison[Fair Comparison Report] -- three approaches (Direct, Socratic, Two-Phase) with identical team answers. Measures the structural value of the Question Tree.

0 commit comments

Comments
 (0)