Skip to content

Commit 6f4c7ab

Browse files
authored
Merge pull request #478 from raifdmueller/feat/socratic-recovery-skill-473
feat: socratic-code-theory-recovery Claude Code Skill (#473)
2 parents cb9abbe + c57e929 commit 6f4c7ab

21 files changed

Lines changed: 1282 additions & 0 deletions

docs/agentskill.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,7 @@ The full catalog with descriptions, proponents, and core concepts is available a
133133
When you add a new anchor to the catalog, please also update the AgentSkill catalog at `skill/semantic-anchor-translator/references/catalog.md` so AI agents can discover it.
134134

135135
See link:#/contributing[Contributing] for the full contribution workflow.
136+
137+
== See also
138+
139+
* link:#/socratic-recovery-skill[Socratic Code-Theory Recovery Skill] -- packages the brownfield documentation-recovery workflow as an installable skill that classifies every claim as code-derivable or open-to-the-team

docs/agentskill.de.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,7 @@ Der vollständige Katalog mit Beschreibungen, Vertretern und Kernkonzepten ist u
133133
Wenn du einen neuen Anker zum Katalog hinzufügst, aktualisiere bitte auch den AgentSkill-Katalog unter `skill/semantic-anchor-translator/references/catalog.md`, damit KI-Agenten ihn finden können.
134134

135135
Siehe link:#/contributing[Mitwirken] für den vollständigen Beitrags-Workflow.
136+
137+
== Siehe auch
138+
139+
* link:#/socratic-recovery-skill[Socratic Code-Theory Recovery Skill] -- verpackt den Brownfield-Dokumentations-Recovery-Workflow als installierbaren Skill, der jede Aussage als aus-Code-ableitbar oder ans-Team-offen klassifiziert

docs/brownfield-workflow.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ Before changing anything, you need to recover the "theory" of the bounded contex
5959

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

62+
[TIP]
63+
====
64+
The prompts in this phase are also packaged as an installable Claude Code Skill. See link:#/socratic-recovery-skill[the Socratic Code-Theory Recovery Skill page] for installation instructions across Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and Amazon Kiro.
65+
====
66+
6267
=== Phase 1: Build the Question Tree
6368

6469
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.

docs/brownfield-workflow.de.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Vor jeder Änderung muss die "Theorie" des Bounded Context rekonstruiert werden
5757

5858
Diese Phase nutzt *Socratic Code-Theory Recovery*: einen zweiphasigen Workflow, der Verständnis durch rekursive Frageverfeinerung aufbaut, bevor Dokumentation erzeugt wird.
5959

60+
[TIP]
61+
====
62+
Die Prompts dieser Phase sind auch als installierbarer Claude Code Skill verpackt. Installations-Anleitungen für Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI und Amazon Kiro auf der link:#/socratic-recovery-skill[Skill-Seite Socratic Code-Theory Recovery].
63+
====
64+
6065
=== Phase 1: Question Tree aufbauen
6166

6267
Mit fünf Top-Level-Fragen zum Bounded Context starten und sie rekursiv zerlegen. Semantic Anchors als Zerlegungs-Heuristiken einsetzen: *arc42* für Architektur, *Cockburn Use Cases* für Spezifikation, *ISO 25010* für Qualität, *Nygard ADRs* für Entscheidungen.

docs/socratic-recovery-skill.adoc

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
= Skill: Socratic Code-Theory Recovery
2+
:toc:
3+
4+
The Semantic Anchors project ships a **Claude Code Skill** that packages the link:#/brownfield[brownfield workflow] as an installable artifact. Once installed, the skill guides any compatible AI coding assistant through the two-phase recovery of a program's "theory" (Naur 1985) from source code.
5+
6+
== What it does
7+
8+
Recovers documentation from a brownfield codebase without hallucinating the parts the code cannot tell you. The skill enforces an auditable separation between *code-derivable facts* and *open questions* that must be answered by humans.
9+
10+
=== Phase 1 — Build the Question Tree
11+
12+
The skill prompts the LLM to recursively decompose five questions about a bounded context (Problem/Users, Specification, Architecture, Quality Goals, Risks). Each leaf is classified:
13+
14+
* `[ANSWERED]` -- the LLM found it in the code, with `<file>:<line>` evidence
15+
* `[OPEN]` -- the answer is not derivable from code; tagged with a Category and the role that must answer (Product Owner, Architect, Developer, Domain Expert, Operations)
16+
17+
Outputs two AsciiDoc files: `QUESTION_TREE.adoc` (full reasoning trace) and `OPEN_QUESTIONS.adoc` (handoff, grouped by role).
18+
19+
=== Between phases — Team answers the OPEN leaves
20+
21+
`OPEN_QUESTIONS.adoc` is routed to humans by role. They write answers directly into the file. Deferred questions get an explicit `(deferred)` marker, not invention.
22+
23+
=== Phase 2 — Synthesize documentation
24+
25+
The skill takes the answered tree and produces a PRD, Cockburn use cases, an arc42 architecture document, and Nygard ADRs with Pugh matrices. Every claim cites a Q-ID; team-supplied facts are marked `(team answer)`.
26+
27+
== When to use it
28+
29+
Use this skill when:
30+
31+
* Documentation is missing, outdated, or untrusted, and a change is about to be made.
32+
* You want documentation that an auditor or new team member can trust -- every claim traces back to either code or a named team answer.
33+
* You want to surface the *open questions* in the system, not just synthesize plausible-sounding prose over them.
34+
35+
Do **not** use it when:
36+
37+
* You are doing greenfield development -- use the link:#/spec-driven-development[spec-driven workflow] instead.
38+
* You want to reverse-engineer the whole system at once -- the skill is designed to work one bounded context at a time.
39+
* The code is not runnable -- fix that first.
40+
41+
== Installation
42+
43+
The skill follows the https://agentskills.io[agentskills.io] specification. Reference it from your project's instruction file for any compatible AI tool.
44+
45+
=== link:https://docs.anthropic.com/en/docs/claude-code/memory[Claude Code]
46+
47+
Reference the skill directly in `CLAUDE.md`:
48+
49+
[source,markdown]
50+
----
51+
## Skills
52+
53+
Use the socratic-code-theory-recovery skill from
54+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
55+
when recovering documentation from a brownfield bounded context.
56+
57+
Phase 1 prompt:
58+
https://github.com/LLM-Coding/Semantic-Anchors/blob/main/skill/socratic-code-theory-recovery/prompts/phase-1-question-tree.md
59+
60+
Phase 2 prompt:
61+
https://github.com/LLM-Coding/Semantic-Anchors/blob/main/skill/socratic-code-theory-recovery/prompts/phase-2-synthesize.md
62+
----
63+
64+
Or place the `skill/socratic-code-theory-recovery/SKILL.md` in your project's skills directory if your Claude Code setup uses a custom skills location.
65+
66+
=== link:https://openai.com/codex/[Codex]
67+
68+
Codex supports `AGENTS.md` for repository instructions:
69+
70+
[source,markdown]
71+
----
72+
## Documentation Recovery
73+
74+
When working on a brownfield bounded context without documentation, use
75+
the Socratic Code-Theory Recovery skill:
76+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
77+
78+
The skill enforces a two-phase workflow: build a Question Tree first
79+
([ANSWERED] with code evidence vs [OPEN] with role), let the team answer
80+
the OPEN leaves, then synthesize documentation with full Q-ID traceability.
81+
----
82+
83+
=== link:https://github.com/google-gemini/gemini-cli[Gemini CLI]
84+
85+
Add to `GEMINI.md`:
86+
87+
[source,markdown]
88+
----
89+
## Brownfield Documentation Recovery
90+
91+
For recovering documentation from existing code, follow the
92+
Socratic Code-Theory Recovery workflow:
93+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
94+
95+
Build a Question Tree before writing any documentation. Mark each leaf
96+
[ANSWERED] (with file:line evidence) or [OPEN] (with Category and Ask role).
97+
Synthesize docs from the answered tree only after the team has filled in
98+
the OPEN leaves. Cite Q-IDs in every claim.
99+
----
100+
101+
=== link:https://docs.cursor.com/[Cursor]
102+
103+
Add to `.cursor/rules` or `.cursorrules` in your project:
104+
105+
[source,markdown]
106+
----
107+
## Brownfield Documentation Recovery
108+
109+
When asked to document an existing module without docs, use the
110+
Socratic Code-Theory Recovery workflow:
111+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
112+
113+
Build a Question Tree first. Each leaf must be [ANSWERED] (with code
114+
evidence) or [OPEN] (with Category and Ask role). Do not write
115+
documentation until the team has answered the [OPEN] leaves.
116+
----
117+
118+
=== link:https://docs.github.com/copilot[GitHub Copilot]
119+
120+
Add to `.github/copilot-instructions.md`:
121+
122+
[source,markdown]
123+
----
124+
## Brownfield Recovery
125+
126+
For brownfield documentation tasks, follow the Socratic Code-Theory
127+
Recovery workflow at
128+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
129+
130+
Two phases: first a Question Tree separating code-derivable facts from
131+
open questions routed by role; second, synthesis with Q-ID traceability
132+
after the team fills the gaps.
133+
----
134+
135+
=== link:https://kiro.dev/[Amazon Kiro]
136+
137+
Kiro builds on spec-driven development; this skill is the brownfield counterpart. Add to your project's `specs/` directory or to a spec file:
138+
139+
[source,markdown]
140+
----
141+
## Brownfield Documentation Recovery (Spec Onboarding)
142+
143+
When onboarding an existing bounded context that has no spec, use the
144+
Socratic Code-Theory Recovery skill:
145+
https://github.com/LLM-Coding/Semantic-Anchors/tree/main/skill/socratic-code-theory-recovery
146+
147+
The skill produces a Question Tree that classifies every claim as
148+
[ANSWERED] (code evidence) or [OPEN] (role-routed). The synthesized
149+
outputs are compatible with Kiro's spec format: a PRD, Cockburn use
150+
cases (User Goal level), an arc42 architecture description, and Nygard
151+
ADRs with Pugh matrices. Use these as the starting point for the
152+
generated spec.
153+
----
154+
155+
=== Other AI tools
156+
157+
Any AI assistant that accepts a system prompt or custom instructions can use this skill. Point it to:
158+
159+
* `SKILL.md` (overview) -- https://github.com/LLM-Coding/Semantic-Anchors/blob/main/skill/socratic-code-theory-recovery/SKILL.md
160+
* Phase 1 prompt -- https://github.com/LLM-Coding/Semantic-Anchors/blob/main/skill/socratic-code-theory-recovery/prompts/phase-1-question-tree.md
161+
* Phase 2 prompt -- https://github.com/LLM-Coding/Semantic-Anchors/blob/main/skill/socratic-code-theory-recovery/prompts/phase-2-synthesize.md
162+
163+
== What's inside the skill
164+
165+
[cols="1,3"]
166+
|===
167+
| File | Role
168+
169+
| `SKILL.md`
170+
| Frontmatter, when-to-use, two-phase workflow overview, what the LLM can and cannot recover, drift handling
171+
172+
| `prompts/phase-1-question-tree.md`
173+
| The copy-paste Phase 1 prompt plus post-prompt sanity-check and team-routing instructions
174+
175+
| `prompts/phase-2-synthesize.md`
176+
| The Phase 2 prompt producing PRD, Cockburn use cases, arc42, and Nygard ADRs
177+
178+
| `references/arc42.md`
179+
| arc42's 12 sections as Q3 decomposition heuristic
180+
181+
| `references/cockburn-use-cases.md`
182+
| Fully Dressed fields as Q2 sub-questions; persona vs system use cases
183+
184+
| `references/iso-25010.md`
185+
| 8 quality characteristics as Q4 sub-questions; mechanism-vs-target split
186+
187+
| `references/nygard-adrs.md`
188+
| ADR fields as Q3.9 sub-tree; what makes a decision architecturally significant; Pugh-matrix guidance
189+
190+
| `references/output-schema.md`
191+
| Strict format for `QUESTION_TREE.adoc` and `OPEN_QUESTIONS.adoc`; Q-ID scheme; `[ANSWERED]`/`[OPEN]` block formats; Phase 2 traceability rules
192+
193+
| `references/examples.md`
194+
| Worked `[ANSWERED]` and `[OPEN]` leaves for each major branch (Q1-Q5)
195+
|===
196+
197+
== Further reading
198+
199+
* link:#/brownfield[Brownfield Workflow] -- the full methodology that this skill packages
200+
* link:#/brownfield-experiment-report[Brownfield Experiment Report] -- controlled experiment behind the methodology
201+
* link:#/brownfield-fair-comparison[Fair Comparison Report] -- three recovery approaches with identical team answers
202+
* Peter Naur, "Programming as Theory Building" (1985) -- https://pages.cs.wisc.edu/~remzi/Naur.pdf
203+
204+
== See also
205+
206+
* link:#/agentskill[Semantic Anchor Translator Skill] -- recognises verbose concept descriptions and suggests the established anchor term

0 commit comments

Comments
 (0)