Recovers a codebase's implicit theory via recursive questioning, producing a Question Tree that separates code-derived facts from team-required context, then synthesizes PRD, use cases, architecture, and ADRs.
Ships in semantic-anchors. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Reverse-engineer a bounded context into documentation without hallucinating the parts the code cannot tell you.
When this skill is invoked:
Check whether the user named a bounded context. Look at the same message that invoked the skill and at the immediately preceding messages. A valid bounded-context pointer is a path (relative or absolute) to a directory, plus a short human-readable name for what the context is (e.g. src/auth, "Authentication"). If both are present, proceed to Phase 1.
If no bounded context is named, ask for it before doing anything else. Do not start Phase 1 against the current working directory by default — Phase 1 produces files (QUESTION_TREE-<context-name>.adoc, OPEN_QUESTIONS-<context-name>.adoc) and running it on the wrong directory wastes work. Ask exactly:
Which bounded context should I apply Socratic Code-Theory Recovery to? Give me a directory path (the bounded context's code root) and a short human-readable name. If you want the whole current repo treated as one bounded context, say so explicitly.
Once you have the pointer, run Phase 1. Use prompts/phase-1-question-tree.md — substitute [bounded context path] with the user's path and [context-name] with the kebab-cased human-readable name. Do not change the leaf classification, Q-ID scheme, or the output-file naming scheme.
Stop after Phase 1. Tell the user that Phase 1 is complete, where the two output files are, and that the next step is routing OPEN_QUESTIONS-<context-name>.adoc to the team. Phase 2 is gated on the file, not on being asked: before starting Phase 2 — even when the user explicitly requests it — check that every [OPEN] leaf in OPEN_QUESTIONS-<context-name>.adoc has either a team answer or an explicit (deferred) marker. If any leaf has neither, do not run Phase 2; list the unanswered leaves instead.
Use this skill on a brownfield codebase when:
Do not use this skill when:
This skill implements the Socratic Code-Theory Recovery contract from the Semantic Anchors project. The methodology rests on Peter Naur's 1985 paper Programming as Theory Building: a program's theory lives in the heads of its developers and cannot be fully captured in code alone. A documentation-recovery process that ignores this produces confident-looking prose that fills in the gaps with invention.
The fix: model the gaps explicitly. Every question about the system is either [ANSWERED] from code (with file:line evidence) or [OPEN] (with a category and the role that must answer it). The OPEN leaves are the handoff to humans.
┌────────────────────────────────┐
Phase 1 │ CODE ──► Question Tree │
│ ├─ [ANSWERED] leaves│
│ └─ [OPEN] leaves │
└────────────────┬───────────────┘
▼
┌────────────────────────────────┐
Between │ OPEN_QUESTIONS-<context>.adoc │
│ ──► team (routed by role) │
│ ──► answers fill in OPENs │
└────────────────┬───────────────┘
▼
┌────────────────────────────────┐
Phase 2 │ Answered tree ──► Docs │
│ PRD · Cockburn UCs · arc42 · │
│ Nygard ADRs (claims cite code) │
└────────────────────────────────┘
Use prompts/phase-1-question-tree.md. Adapt the bounded-context path and the Q1-Q5 wording; do not change the fixed second level, the leaf classification, the Q-ID scheme, or the output-file naming scheme.
Outputs (named after the context so sequential runs on different bounded contexts never overwrite each other):
QUESTION_TREE-<context-name>.adoc — the full hierarchical reasoning traceOPEN_QUESTIONS-<context-name>.adoc — only the [OPEN] leaves, grouped by Ask roleThe five root questions decompose into a fixed second level — the same enumerated node set on every run, so Q-IDs are stable and trees from different runs can be diffed node-by-node. Adaptive, code-driven decomposition applies only below the fixed level. The fixed nodes:
CLAUDE.md/AGENTS.md, CONTRIBUTING files, CI workflows, and linter configs are valid evidence sources.Every fixed node is emitted even when its only leaf is [OPEN] or [ANSWERED: not applicable].
Depth below the fixed level is adaptive, not fixed. A node is a leaf only when its question can be answered with specific file:line evidence or definitively marked [OPEN]. If the honest answer would still be coarse — a whole directory as evidence, one paragraph for an entire arc42 chapter — the node decomposes further (under a four-level cap below each fixed node). Tree depth therefore tracks code density: a small bounded context yields a shallow tree, a large one a deep tree. The fixed skeleton stays diffable; only the depth varies. This prevents the thin-documentation failure where a large context produces one leaf per arc42 chapter and Phase 2 cannot synthesize a substantial chapter without inventing detail.
Leaf classification rules and Q-ID scheme: references/output-schema.md.
Worked examples — one [ANSWERED] and one [OPEN] leaf for each major branch: references/examples.md.
Route OPEN_QUESTIONS-<context-name>.adoc to the people whose role appears in each section: Product Owner, Architect, Developer, Domain Expert, Operations. In one controlled experiment with a 13,000-line Go codebase, 11 targeted OPEN questions were enough to close the gap to the original documentation.
Team answers are written directly into OPEN_QUESTIONS-<context-name>.adoc under each question, marked clearly. Do not call Phase 2 until every OPEN leaf has either an answer or an explicit (deferred) marker.
Use prompts/phase-2-synthesize.md. The Phase 2 LLM reads the answered tree and produces:
Code-derived claims cite the file:line evidence from their [ANSWERED] leaf — a reference to the code, the only durable, canonical artifact. Team-supplied information is marked (team answer). The Question Tree is temporary scaffolding, so its Q-IDs are not written into the final documents; during synthesis every claim is still traced back to a leaf as a build-time check. This dual traceability — code evidence plus team input — is the difference from a simple reverse-engineering prompt that fills in gaps silently.
A controlled experiment (deleting documentation from a greenfield project and regenerating it from code) showed:
Derivable from code: functional requirements, acceptance criteria, building-block views, glossary, security mechanisms, crosscutting concepts.
NOT derivable from code: business context, design rationale (the ADR "why"), quality-goal priorities, stakeholder concerns, aspirational features, performance budgets, tutorials, review results.
If your synthesized documentation contains a claim from the second list without a (team answer) marker, the LLM hallucinated it. Mark it [OPEN] and ask the team.
After this skill produces documentation, the implementation LLM will add security hardening, validation rules, and edge cases that are not in the spec. This is structural, not a discipline problem. Re-run Phase 1 against the current code periodically — before a release, after a security review, before onboarding — and diff against the existing spec. The diff reveals NEW (in code, not in spec), CHANGED (diverged), and DEAD (in spec, not in code).
prompts/phase-1-question-tree.md (opens in a new tab)prompts/phase-2-synthesize.md (opens in a new tab)references/arc42.md (opens in a new tab)references/cockburn-use-cases.md (opens in a new tab)references/examples.md (opens in a new tab)references/iso-25010.md (opens in a new tab)references/nygard-adrs.md (opens in a new tab)references/output-schema.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/semantic-anchors:socratic-code-theory-recoveryfrom semantic-anchors
npx claudepluginhub llm-coding/semantic-anchors --plugin semantic-anchors6 skills in this plugin
/anchor-prior-testEmpirically test whether a candidate term qualifies as a semantic anchor by probing how densely it sits in LLM training data — across several model tiers in a clean room — before proposing it. Use when triaging an anchor proposal, deciding anchor vs contract, or vetting a rename. Produces a verdict against the criteria (Precise, Rich, Consistent; Attributable if the bare term is ambiguous), a tier rating, and a ready-to-paste proposal or rejection./arc42-documentationAuthor an arc42 architecture document with the project's cross-section traceability rules. Use when producing or extending an arc42 document — it carries the procedure the "Architecture Documentation" contract deliberately leaves out: scaffolding the with-help template, the five traceability rules arc42 does not enforce, the Chapter 11 Risks-vs-Technical-Debt structure, the ADR-to-risk-ID wiring, the Chapter 1.2-vs-10 quality-goal marking, and the six-part Quality Attribute Scenario form. The contract pins the vocabulary (arc42, C4/PlantUML, Nygard ADRs, Pugh); this skill is the how-to./semantic-anchor-onboardingDEPRECATED alias of semantic-contracts-installer. Renamed because the skill's high-value job is installing Semantic Contracts (compositions the LLM cannot guess), not bare anchor lists. Use semantic-contracts-installer instead; this alias forwards to it and will be removed after one release.Other plugins' skills for the same job