arch-doc
FreeRuns bundled scriptsNot checkedWrites an architecture document for a package, subsystem, or pipeline in any codebase: a map of who owns what and how control and data flow, built from…
by Roasbeef★ 33 GitHub starsAbout this skill
Architecture document
The deliverable is one Markdown file under docs/ that lets an engineer who
knows the domain but not this code answer three questions: which component
owns which state, which goroutine (thread, process) touches it, and what
happens, message by message, between a request arriving and a durable result.
The reference example is docs/sync-architecture.md in
lightninglabs/neutrino (PR 407). Read its structure in
references/worked-example.md before writing.
The document describes the code as it is at one commit. It is not a design proposal, a changelog, or a tutorial, and it does not restate godoc.
1. Scope and anchor
Parse $ARGUMENTS. Fix four things before reading code, asking with
AskUserQuestion only for what the arguments and the repo do not settle:
- Subject. The package, subsystem, or pipeline. If it is a pipeline that crosses packages, list the packages.
- Anchor. The commit, tag, or PR range the document reflects. Record the
output of
git rev-parse --short HEADnow, and say in the intro which commit or series the text is true of. - Reader. An engineer new to this code who knows the domain (for example, Bitcoin or Lightning, a database engine, a web framework). Do not explain the domain; explain this code.
- Output.
docs/<subject>-architecture.mdunless--outsays otherwise. Read the repo's existingdocs/, README, and any CLAUDE.md first, and match heading style and link conventions. Link related docs instead of repeating them.
Then read the subject's top-level files yourself: the entry constructor, the main types, the package list. You need this to cut the work into subsystems and to judge the subagent summaries later.
2. Gather raw material in parallel
Cut the subject into three to six subsystems along ownership lines (one
actor, one store, one scheduler), not along directories. Spawn one reader
subagent per subsystem in a single message so they run concurrently. Use
references/reader-brief.md as the prompt template; fill in the subsystem,
the files, the anchor commit, and the names of the neighbouring subsystems so
that each reader describes its boundary.
Each reader returns a structured summary with six parts: type
responsibilities (including what each type does not own), flows message by
message, every state machine with exact states and the function or event that
causes each transition, the owner of each piece of mutable state, constants
with values and file:line, and open questions. The summaries are inputs.
Do not paste them into the document, and do not accept a claim from one
without a grep: readers paraphrase, and a paraphrased constant is the most
common error in these documents.
When two summaries disagree about a boundary (both claim to own a map, or neither mentions who closes a channel), resolve it by reading the code yourself before writing the Components table.
3. Write to the skeleton
Write the document yourself, in one pass, from the summaries. The skeleton
below is fixed in order but adapted in content: drop a section the subject
lacks, add one pipeline section per real pipeline. references/skeleton.md
has the Mermaid templates and the exact shape of each table.
| Section | Contents |
|---|---|
| Title and intro | One paragraph: what the subsystem keeps in step, its scope, the anchor (commit or series), and links to related docs. |
| Components | A flowchart with one subgraph per component and labeled edges, one paragraph of lead-in, then a Responsibilities table with Owns and Does not own columns. |
| Startup (or lifecycle) | A sequenceDiagram of construction and start, with alt and opt blocks for configuration branches. One sentence on why the order matters. |
| One section per pipeline | Intro paragraph; a stateDiagram-v2 where state exists; a flowchart from start to durable result, including failure branches; a numbered list of steps with bold leads. |
| Shared state machines | Peer, connection, or session states used by more than one pipeline, as a stateDiagram-v2, then the rule that the diagram cannot show. |
| Storage | A backend comparison table, an erDiagram with PK and UK markers and short comments, one paragraph on transactions and caching, and a sequenceDiagram for any migration or import. |
| Concurrency | A table of goroutine against what it owns, then prose rules: what timers may do, and the gotchas a caller must know. |
| Known gaps | What the document does not cover or could not verify. |
Section by section:
- State diagrams carry the most value. Transition labels name the real function or event, and say what changes on the transition (epoch, lease, owner, counter). Include terminal states and failure states. Follow the diagram with prose for what the diagram cannot show: terminal transitions that bypass the machine, invariants over the whole machine.
- Flowcharts run from the trigger to the durable result and show every failure br
Install arch-doc in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
TaskReadWriteEditGrepGlobBashSkillAskUserQuestionBundled files
FAQ
What does the arch-doc skill do?
Writes an architecture document for a package, subsystem, or pipeline in any codebase: a map of who owns what and how control and data flow, built from mermaid diagrams (component flowchart, startup sequence, state diagrams, per-pipeline flowcharts, ER schema) plus Owns / Does-not-own and goroutine-ownership tables, at a fixed prose weight. Gathers facts with one reader subagent per subsystem, writes the document itself, greps every quoted number against the code, renders every diagram, and opens a docs-only PR. Modeled on lightninglabs/neutrino docs/sync-architecture.md (PR 407). Use when the user wants an architecture overview, a design map, or onboarding docs for existing code, or invoke via /arch-doc.
How do I install the arch-doc skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the arch-doc skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
by AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
by Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
by Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
by Anthropic