Generating arc42 Documentation
Overview
Generate an arc42 architecture-documentation base for a repository, derived
from its source code, using Mermaid-only diagrams. Vendor-neutral: built
on the open arc42 template, usable on any project including
open-source.
Core principle: document only what the source supports. Generate as much as
the code, config, and history evidence; leave a TODO: everywhere the answer can
only come from a human. A flagged gap is better than a confident fabrication.
When to use
- "Generate / write / scaffold the arc42 docs for this repo."
- "Create the
doc/architecture chapters for this service or library."
- Bootstrapping architecture documentation for an undocumented codebase.
- Refreshing/extending an existing arc42 base from current source.
Not for: editing one existing chapter's prose, or non-arc42 documentation.
Workflow
- Read the conventions first. Read
arc42-conventions.md (in this skill
directory) IN FULL and follow it exactly — folder structure, chapter set,
style, Mermaid colour code, and per-chapter guidance. It is the source of
truth for how to write the docs.
- Study the real repository. README, build/config files, manifests, CI,
and the actual source folders. Derive components, external systems, actors,
protocols, and runtime scenarios from what you can point to in the code.
- Scale depth to the evidence. Rich codebase → full chapters; small library
→ the core chapters as short stubs (use the stub skeleton defined in
arc42-conventions.md). Don't pad.
- Write into
doc/architecture/, wrapping each generated chapter body in
<!-- arc42:generated --> / <!-- /arc42:generated --> markers. On a refresh,
replace only what's inside those markers; treat any prose outside them — or any
chapter that lacks them — as human-authored. Never overwrite it; report the
conflict instead. Stamp the generation provenance into README.md (see the
conventions).
- Verify, then report. Run the Quick checklist in
arc42-conventions.md
and fix every failure. Then end with a summary: what you generated, and every
TODO: a human must complete, grouped by chapter.
Quick reference
Chapters (note the intentional gaps): 01_introduction_and_goals,
03_context_and_scope, 04_solution_strategy, 05_building_block_view,
06_runtime_view, 07_deployment_view, 08_crosscutting_concepts/
(index + the concepts the system actually has, e.g. 001_security,
002_domain_model), 09_architecture_decision_records/ (index + template +
ADRs), 12_glossary. Plus README.md (index) and pdf.yaml. Core chapters
to always produce: 1, 3, 5, 12. Add 6/7/8 when the system warrants them.
Expect chapter 1's quality goals and stakeholders to be largely TODO: when only
the source is available — those aren't derivable from code, and a flagged gap
there is the correct outcome, not a failure.
Mermaid block colours via classDef: blue = developed here, green =
separately-released component with its own docs (link, don't zoom in),
white = 3rd-party / external dependency you don't own.
Common mistakes
- Inventing facts. Never fabricate requirement IDs, people's names/emails,
or owners/identifiers — leave
TODO:.
- Speculative ADRs. ADRs record history and rationale, which isn't in the
code. Author one only when its rationale is evidenced (commits, comments,
design docs, config that proves a choice); otherwise list it as a
TODO:
candidate topic in the ADR index. A made-up ADR reads as settled history.
- Wrong diagram tool. Mermaid only. No PlantUML, no draw.io, no
diagrams/
subfolder — diagrams are inline fenced ```mermaid blocks.
- Over-producing. Don't write chapters the source can't support; stub them.
- Skipping the reference. The per-chapter detail in
arc42-conventions.md
is required reading, not optional background.
1---2name: generating-arc423description: Use when asked to generate, create, write, scaffold, or bootstrap arc42 architecture documentation for any software codebase, repository, service, library, or component — including a doc/architecture folder or arc42 chapters derived from source code.4---56# Generating arc42 Documentation78## Overview910Generate an arc42 architecture-documentation **base** for a repository, derived11from its **source code**, using **Mermaid-only** diagrams. Vendor-neutral: built12on the open [arc42](https://arc42.org) template, usable on any project including13open-source.1415**Core principle:** document only what the source supports. Generate as much as16the code, config, and history evidence; leave a `TODO:` everywhere the answer can17only come from a human. A flagged gap is better than a confident fabrication.1819## When to use2021- "Generate / write / scaffold the arc42 docs for this repo."22- "Create the `doc/architecture` chapters for this service or library."23- Bootstrapping architecture documentation for an undocumented codebase.24- Refreshing/extending an existing arc42 base from current source.2526Not for: editing one existing chapter's prose, or non-arc42 documentation.2728## Workflow29301. **Read the conventions first.** Read `arc42-conventions.md` (in this skill31 directory) IN FULL and follow it exactly — folder structure, chapter set,32 style, Mermaid colour code, and per-chapter guidance. It is the source of33 truth for *how* to write the docs.342. **Study the real repository.** README, build/config files, manifests, CI,35 and the actual source folders. Derive components, external systems, actors,36 protocols, and runtime scenarios from what you can point to in the code.373. **Scale depth to the evidence.** Rich codebase → full chapters; small library38 → the core chapters as short stubs (use the stub skeleton defined in39 `arc42-conventions.md`). Don't pad.404. **Write into `doc/architecture/`**, wrapping each generated chapter body in41 `<!-- arc42:generated -->` / `<!-- /arc42:generated -->` markers. On a refresh,42 replace only what's inside those markers; treat any prose outside them — or any43 chapter that lacks them — as human-authored. Never overwrite it; report the44 conflict instead. Stamp the generation provenance into `README.md` (see the45 conventions).465. **Verify, then report.** Run the *Quick checklist* in `arc42-conventions.md`47 and fix every failure. Then end with a summary: what you generated, and every48 `TODO:` a human must complete, grouped by chapter.4950## Quick reference5152Chapters (note the intentional gaps): `01_introduction_and_goals`,53`03_context_and_scope`, `04_solution_strategy`, `05_building_block_view`,54`06_runtime_view`, `07_deployment_view`, `08_crosscutting_concepts/`55(index + the concepts the system actually has, e.g. `001_security`,56`002_domain_model`), `09_architecture_decision_records/` (index + template +57ADRs), `12_glossary`. Plus `README.md` (index) and `pdf.yaml`. **Core chapters58to always produce: 1, 3, 5, 12.** Add 6/7/8 when the system warrants them.59Expect chapter 1's quality goals and stakeholders to be largely `TODO:` when only60the source is available — those aren't derivable from code, and a flagged gap61there is the correct outcome, not a failure.6263Mermaid block colours via `classDef`: **blue** = developed here, **green** =64separately-released component with its own docs (link, don't zoom in),65**white** = 3rd-party / external dependency you don't own.6667## Common mistakes6869- **Inventing facts.** Never fabricate requirement IDs, people's names/emails,70 or owners/identifiers — leave `TODO:`.71- **Speculative ADRs.** ADRs record *history* and rationale, which isn't in the72 code. Author one only when its rationale is evidenced (commits, comments,73 design docs, config that proves a choice); otherwise list it as a `TODO:`74 candidate topic in the ADR index. A made-up ADR reads as settled history.75- **Wrong diagram tool.** Mermaid only. No PlantUML, no draw.io, no `diagrams/`76 subfolder — diagrams are inline fenced ```mermaid blocks.77- **Over-producing.** Don't write chapters the source can't support; stub them.78- **Skipping the reference.** The per-chapter detail in `arc42-conventions.md`79 is required reading, not optional background.