living-docs-kit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +85 -0
  3. package/agents/docs-reviewer.md +33 -0
  4. package/agents/docs-writer.md +31 -0
  5. package/bin/cli.mjs +68 -0
  6. package/package.json +21 -0
  7. package/skills/docs-design/SKILL.md +91 -0
  8. package/skills/docs-design/references/theme-schema.md +108 -0
  9. package/skills/docs-guide/SKILL.md +83 -0
  10. package/skills/docs-init/SKILL.md +136 -0
  11. package/skills/docs-init/assets/DOCS-GUIDE.template.md +81 -0
  12. package/skills/docs-init/assets/agents-snippet.md +7 -0
  13. package/skills/docs-init/assets/deploy-github-pages.yml +43 -0
  14. package/skills/docs-init/assets/site-template/content/index.md +4 -0
  15. package/skills/docs-init/assets/site-template/docs.config.json +36 -0
  16. package/skills/docs-init/assets/site-template/engine/assets/app.js +414 -0
  17. package/skills/docs-init/assets/site-template/engine/assets/base.css +229 -0
  18. package/skills/docs-init/assets/site-template/engine/build.mjs +432 -0
  19. package/skills/docs-init/assets/site-template/engine/check.mjs +100 -0
  20. package/skills/docs-init/assets/site-template/engine/dev.mjs +49 -0
  21. package/skills/docs-init/assets/site-template/engine/facts.mjs +157 -0
  22. package/skills/docs-init/assets/site-template/engine/i18n.mjs +99 -0
  23. package/skills/docs-init/assets/site-template/engine/lib.mjs +368 -0
  24. package/skills/docs-init/assets/site-template/engine/palette.mjs +149 -0
  25. package/skills/docs-init/assets/site-template/engine/theme-tool.mjs +201 -0
  26. package/skills/docs-init/assets/site-template/engine/vendor/mermaid.min.js +3636 -0
  27. package/skills/docs-init/assets/site-template/package.json +24 -0
  28. package/skills/docs-init/assets/site-template/themes/atlas.json +40 -0
  29. package/skills/docs-init/assets/site-template/themes/fjord.json +40 -0
  30. package/skills/docs-init/assets/site-template/themes/graphite.json +45 -0
  31. package/skills/docs-write/SKILL.md +109 -0
  32. package/skills/docs-write/references/authoring.md +125 -0
  33. package/skills/docs-write/references/page-types.md +104 -0
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "living-docs-site",
3
+ "private": true,
4
+ "type": "module",
5
+ "description": "Static documentation site maintained by the living-docs skills.",
6
+ "scripts": {
7
+ "build": "node engine/build.mjs",
8
+ "build:hosted": "node engine/build.mjs --hosted",
9
+ "dev": "node engine/dev.mjs",
10
+ "check": "node engine/check.mjs",
11
+ "facts": "node engine/facts.mjs",
12
+ "theme": "node engine/theme-tool.mjs",
13
+ "palette": "node engine/palette.mjs"
14
+ },
15
+ "dependencies": {
16
+ "gray-matter": "^4.0.3",
17
+ "jimp": "^1.6.0",
18
+ "js-yaml": "^4.1.0",
19
+ "marked": "^15.0.12"
20
+ },
21
+ "engines": {
22
+ "node": ">=20"
23
+ }
24
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "id": "atlas",
3
+ "label": "Atlas (serif, light)",
4
+ "mode": "light",
5
+ "source": "preset",
6
+ "colors": {
7
+ "bg": "#f4f6f1",
8
+ "surface": "#fcfdfa",
9
+ "surfaceAlt": "#e9eee5",
10
+ "text": "#252f29",
11
+ "textMuted": "#56625a",
12
+ "heading": "#18231d",
13
+ "border": "#d3dacf",
14
+ "accent": "#2e6b4f",
15
+ "accentText": "#ffffff",
16
+ "link": "#245f86",
17
+ "codeBg": "#ebefe6",
18
+ "codeText": "#252f29",
19
+ "highlight": "#dce9df",
20
+ "success": "#2b7148",
21
+ "warning": "#855a06",
22
+ "danger": "#a83221"
23
+ },
24
+ "fonts": {
25
+ "body": "'Literata', Georgia, 'Times New Roman', serif",
26
+ "heading": "'Literata', Georgia, 'Times New Roman', serif",
27
+ "mono": "'Fira Code', ui-monospace, Menlo, Consolas, monospace",
28
+ "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Literata:ital,opsz,wght@0,7..72,400;0,7..72,700;1,7..72,400&family=Fira+Code:wght@400;500&display=swap"
29
+ },
30
+ "typography": {
31
+ "baseSize": 17,
32
+ "lineHeight": 1.75,
33
+ "headingWeight": 700
34
+ },
35
+ "layout": {
36
+ "contentMaxWidth": 720,
37
+ "sidebarWidth": 280,
38
+ "radius": 4
39
+ }
40
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "id": "fjord",
3
+ "label": "Fjord (light)",
4
+ "mode": "light",
5
+ "source": "preset",
6
+ "colors": {
7
+ "bg": "#f6f8f9",
8
+ "surface": "#ffffff",
9
+ "surfaceAlt": "#eaf0f3",
10
+ "text": "#1c2830",
11
+ "textMuted": "#52606a",
12
+ "heading": "#0f1d26",
13
+ "border": "#d3dce1",
14
+ "accent": "#1d5f86",
15
+ "accentText": "#ffffff",
16
+ "link": "#1a5a82",
17
+ "codeBg": "#edf2f5",
18
+ "codeText": "#1c2830",
19
+ "highlight": "#d8e8f2",
20
+ "success": "#1f7a4d",
21
+ "warning": "#8a5a00",
22
+ "danger": "#b42318"
23
+ },
24
+ "fonts": {
25
+ "body": "'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif",
26
+ "heading": "'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif",
27
+ "mono": "'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace",
28
+ "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;600&display=swap"
29
+ },
30
+ "typography": {
31
+ "baseSize": 17,
32
+ "lineHeight": 1.65,
33
+ "headingWeight": 700
34
+ },
35
+ "layout": {
36
+ "contentMaxWidth": 760,
37
+ "sidebarWidth": 280,
38
+ "radius": 8
39
+ }
40
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "id": "graphite",
3
+ "label": "Graphite (dark)",
4
+ "mode": "dark",
5
+ "source": "preset",
6
+ "colors": {
7
+ "bg": "#1b2027",
8
+ "surface": "#222932",
9
+ "surfaceAlt": "#2b333e",
10
+ "text": "#e3e8ee",
11
+ "textMuted": "#a6b0bc",
12
+ "heading": "#f4f7fa",
13
+ "border": "#3a4450",
14
+ "accent": "#e0a43a",
15
+ "accentText": "#1b2027",
16
+ "link": "#8fc6f0",
17
+ "codeBg": "#161a20",
18
+ "codeText": "#dfe6ee",
19
+ "highlight": "#3b3526",
20
+ "success": "#6cc79a",
21
+ "warning": "#e8b454",
22
+ "danger": "#f08a8a"
23
+ },
24
+ "fonts": {
25
+ "body": "'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif",
26
+ "heading": "'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif",
27
+ "mono": "'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace",
28
+ "googleFontsUrl": "https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap"
29
+ },
30
+ "typography": {
31
+ "baseSize": 16,
32
+ "lineHeight": 1.65,
33
+ "headingWeight": 600
34
+ },
35
+ "layout": {
36
+ "contentMaxWidth": 760,
37
+ "sidebarWidth": 280,
38
+ "radius": 6
39
+ },
40
+ "diagram": {
41
+ "nodeBg": "#2b333e",
42
+ "nodeBorder": "#e0a43a",
43
+ "clusterBg": "#1f252d"
44
+ }
45
+ }
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: docs-write
3
+ description: Write and maintain the pages of the living-docs documentation site for people - overviews, architecture drill-downs, flows, business rules, state machines, edge cases, data model, change log - verified against the code, with clickable diagrams and code links. Use whenever the user asks to generate, update, refresh or fix the docs site, to document a module, flow, rule or feature there, after code changes that alter behaviour when the project's AGENTS.md or DOCS-GUIDE.md asks for it, and whenever the docs-writer subagent runs.
4
+ ---
5
+
6
+ # docs-write
7
+
8
+ Writes `<site>/content/**/*.md`. The build turns these pages into the documentation site. The readers are people, so every page must be quick to scan, correct, and one click away from both more detail and the code.
9
+
10
+ ## Before anything
11
+
12
+ 1. **Locate the site.** It is the folder with `docs.config.json` next to `engine/`, usually `docs-site/`. Run all commands from there.
13
+ 2. **Check the guide is approved.** If `state.guideApproved` in `docs.config.json` is not `true`, stop and say that `docs-init` (or `docs-guide`) must finish first.
14
+ 3. **Read `DOCS-GUIDE.md` completely.** Its sections, topics, limits, language and tone override everything below.
15
+ 4. **Read the references.** Read `references/authoring.md` (page syntax: frontmatter, links, code links, callouts, diagrams, decision tables) and `references/page-types.md` (what each kind of page contains) the first time in a session.
16
+
17
+ Do not edit `engine/`, `themes/` (owned by docs-design) or `DOCS-GUIDE.md` (owned by docs-guide). If the guide seems to be missing something, say so in your report.
18
+
19
+ ## Principles
20
+
21
+ - **Top-down.** Home says what the system is in a few sentences, with a map. Section pages give an overview and a map. Detail pages explain one thing. The reader chooses how deep to go.
22
+ - **One page, one subject.** When a page grows past the guide's limit, split it and turn the parent into an overview.
23
+ - **Verified, not imagined.** Read the code before describing it. Every statement about behaviour links to the code that implements it with a `code:` link. If you could not confirm something, write it inside an `> [!UNVERIFIED]` callout rather than stating it.
24
+ - **Intent and consequences over mechanics.** Say why something exists, what rule it enforces and what happens in each case. Do not narrate the code line by line.
25
+ - **Pick the right form.**
26
+ - A flow is a sequence diagram plus numbered steps.
27
+ - A rule with conditions is a decision table.
28
+ - Anything with statuses is a state diagram.
29
+ - Structure is a flowchart with clickable nodes.
30
+ - Only what is left is prose.
31
+ - **Concrete over abstract.** Use real field names, real values and a typical example request or record.
32
+ - **Edge cases are first-class.** Put each one on the page where it matters and in the edge-case catalogue, linked to the code and to its test (or marked "not covered by tests").
33
+ - **Write for a newcomer.** Define domain terms on first use or link the glossary. Avoid internal jargon from the AI-oriented READMEs.
34
+
35
+ ## Tools
36
+
37
+ ```bash
38
+ node engine/facts.mjs # stack, structure, entry points, tests, docs coverage (JSON)
39
+ node engine/facts.mjs changes # files changed since the last generation and the pages they affect
40
+ node engine/facts.mjs stamp <page.md> [...] # mark pages as verified against their current sources
41
+ node engine/facts.mjs mark # record HEAD as the last generation point (end of plan+pages or update)
42
+ npm run check # frontmatter, broken links, missing code files and lines, limits
43
+ npm run build # build dist/ (the dev server rebuilds on its own)
44
+ ```
45
+
46
+ **Stamping.** `stamp` writes `sourcesHash`, `updated` and `commit` into a page. It is how the site knows whether a page is still current: when the files listed in `sources` change, the page shows "possibly outdated". So:
47
+
48
+ - Stamp a page only after you have actually checked it against those sources.
49
+ - Never write those three fields by hand.
50
+
51
+ ## Modes
52
+
53
+ The caller (docs-init, the user, or the main agent delegating to `docs-writer`) says which mode to use. If none is given, infer it: no pages yet means `plan` and then `pages`, "update the docs" means `update`, and "document X" means `topic`.
54
+
55
+ ### plan: build the skeleton
56
+
57
+ 1. Run `facts.mjs`. Read the entry points, the manifests, the existing READMEs and the main folders until you can name the modules, the main flows, the rules, the stateful entities and the data stores.
58
+ 2. Design the site map from the guide's enabled sections and priority topics:
59
+ - C4-style drill-down for Architecture: context, then containers, then components.
60
+ - One page per main flow, rule set, state machine and important module.
61
+ - Section paths come from the guide; page file names are short lowercase-hyphen slugs.
62
+ 3. Write the home page and every section `index.md` completely, including their map diagrams with `click` links to the planned pages. They are short, and writing them first fixes the vocabulary.
63
+ 4. Create every other page as a stub. The frontmatter holds `title`, `summary`, `order` and `sources` (the files or folders the page will describe), and the body is only `<!-- stub -->`. Summaries matter even for stubs: they appear in overviews and search.
64
+ 5. Run `npm run check`. Broken links to planned pages must not exist, because the stubs exist.
65
+ 6. Return the site map as an indented list (path, title, sources) grouped by section. That lets the caller split the `pages` work.
66
+
67
+ ### pages: write or rewrite given pages
68
+
69
+ For each file you are given:
70
+
71
+ 1. Read its frontmatter, then read every file in `sources` completely, plus whatever they call that matters for the page's subject. Extend `sources` if the page really depends on more files, and trim it if it lists files the page does not describe.
72
+ 2. Write the body following the page type in `references/page-types.md` and the guide's limits.
73
+ 3. Add links to related pages (site-absolute paths such as `/flows/checkout/`), and make sure the parent overview links here, either through its map diagram or through the automatic "Go deeper" list.
74
+ 4. Stamp the page: `node engine/facts.mjs stamp content/<path>.md`.
75
+
76
+ When all pages are done, run `npm run check` and fix every error. Warnings about length should also be fixed by splitting the page.
77
+
78
+ ### update: bring the site in line with the code
79
+
80
+ 1. **Collect the changes.** Run `facts.mjs changes`. It lists the changed files, the affected pages (by `sources`), stale pages, changes not covered by any page, and deleted files. Read `git log` and `git diff <since>` for the affected files to understand what changed in behaviour.
81
+ 2. **Handle affected and stale pages.** Re-read the sources and update only what changed: text, diagrams, decision tables, code links (line numbers move!) and edge cases. If nothing about behaviour changed, fix the code links only. Stamp every page you verified, even when its text did not change.
82
+ 3. **Handle uncovered changes.** If a change adds a module, flow, rule or edge case worth documenting under the guide, add it to an existing page's `sources` and content, or create a new page and link it from its parent. Ignore changes the guide puts out of scope.
83
+ 4. **Handle deleted files.** Remove or rewrite the pages that described them, and fix the links pointing to them.
84
+ 5. **Record the change.** If the guide enables "What changed", add one entry at the top of `content/changes/index.md`. Use the date as the heading, then 1–5 bullets in plain language about behaviour, each linking to the updated page. Skip it for pure refactors.
85
+ 6. **Finish.** Run `npm run check` with no errors, then `facts.mjs mark`.
86
+
87
+ ### topic: document one thing the user asked for
88
+
89
+ Find where the topic belongs in the existing site map. Then extend that page, or add a page and link it from the parent and from related pages. After that, continue as in `pages`. Mention in your report if the topic deserves a line under Priority topics in the guide.
90
+
91
+ ## Quality bar before you finish
92
+
93
+ - Home still gives the whole picture in under a minute of reading, and its map is up to date.
94
+ - Every page has a `summary` that works on its own in search results and overview lists.
95
+ - Every behaviour statement has a code link. No `code:` link points to a missing file or line (the checker verifies this).
96
+ - The diagrams stay under ~12 nodes each, use the guide's language, and link their nodes to detail pages where those exist.
97
+ - Edge cases have an `> [!EDGE]` callout and a catalogue entry.
98
+ - `npm run check` reports 0 errors.
99
+
100
+ ## Report
101
+
102
+ End with a short report for the caller:
103
+
104
+ - pages created, updated and stamped, as paths;
105
+ - checker warnings left and why;
106
+ - anything you could not verify;
107
+ - suggested guide changes, if any.
108
+
109
+ Keep it brief. The caller will show it to the user.
@@ -0,0 +1,125 @@
1
+ # Authoring reference
2
+
3
+ Pages are Markdown (GitHub-flavoured) with YAML frontmatter, stored under `content/`. The URL follows the file path:
4
+
5
+ - `content/index.md` → `/`
6
+ - `content/flows/index.md` → `/flows/`
7
+ - `content/flows/checkout.md` → `/flows/checkout/`
8
+
9
+ A folder without `index.md` gets an empty generated section page (and a checker warning), so always write one.
10
+
11
+ ## Frontmatter
12
+
13
+ ```yaml
14
+ ---
15
+ title: Checkout # required; menu, breadcrumbs, search
16
+ summary: How a cart becomes a paid order, and what can stop it. # required; 1–2 sentences
17
+ order: 2 # optional; position among siblings (lower first, default 1000)
18
+ sources: # optional but expected on every page describing code
19
+ - src/checkout/ # folders include all files inside
20
+ - src/payments/charge.ts
21
+ nav: false # optional; hide from the menu (page still built and searchable)
22
+ navOpen: true # optional; top-level section expanded in the menu by default
23
+ children: false # optional; hide the automatic "Go deeper" list on an index page
24
+ search: false # optional; exclude from search
25
+ # written by `facts.mjs stamp`, never by hand:
26
+ sourcesHash: 1d67b83b63b72b0c
27
+ updated: '2026-09-23'
28
+ commit: b3cbaab
29
+ ---
30
+ ```
31
+
32
+ The page title is rendered as the `<h1>` and the summary right under it, so the body starts at `##`.
33
+
34
+ ## Links
35
+
36
+ - **Other pages.** Always use site-absolute paths: `[Checkout](/flows/checkout/)`, or with an anchor, `[limits](/rules/discounts/#limits)`. The build rewrites them to relative links, so the site works from any host path and straight from disk. Relative paths like `../x/` are flagged by the checker.
37
+ - **Code.** Use `code:` links:
38
+ - `[createOrder](code:src/orders/order.ts#L12)`: one line (`:12` also works);
39
+ - `[the retry loop](code:src/jobs/retry.ts#L40-58)`: a range;
40
+ - `[](code:src/api/server.ts)`: empty text shows the path as the label.
41
+
42
+ They open the file in the editor (Cursor/VS Code) locally and on GitHub/GitLab when the site is hosted, depending on `codeLinks` in `docs.config.json`. The checker fails on missing files and on line numbers past the end of the file. Re-check line numbers during updates.
43
+ - **External.** Normal Markdown links; they open in a new tab.
44
+
45
+ ## Callouts
46
+
47
+ ```markdown
48
+ > [!EDGE] Empty cart
49
+ > A cart without items cannot become an order; `createOrder` throws `EmptyCart`. Covered by [order.test.ts](code:tests/order.test.ts#L8).
50
+ ```
51
+
52
+ Types: `NOTE`, `TIP`, `WARNING`, `EDGE` (edge case), `RISK`, `UNVERIFIED`, `DECISION`. Text after the marker on the first line becomes the callout title.
53
+
54
+ ## Diagrams (Mermaid)
55
+
56
+ ````markdown
57
+ ```mermaid
58
+ %% caption: System map. Click a box for details.
59
+ flowchart LR
60
+ U([Customer]) --> W[Web app]
61
+ W --> A[Orders API]
62
+ A --> DB[(Postgres)]
63
+ A --> P[Payment provider]
64
+ click A "/architecture/orders-api/" "Orders API"
65
+ click P "/architecture/payments/" "Payments"
66
+ ```
67
+ ````
68
+
69
+ Rules:
70
+
71
+ - The first line is the diagram type: `flowchart LR|TD`, `sequenceDiagram`, `stateDiagram-v2`, `erDiagram`, `classDiagram`, `journey`, `timeline`, `mindmap`, …
72
+ - `%% caption: …` adds a caption above the diagram.
73
+ - `click NodeId "/site/path/" "tooltip"` makes a flowchart node open another page. This is the main drill-down device: use it on every map. The checker verifies the targets exist.
74
+ - Keep diagrams at ~12 nodes or fewer; split into levels instead of drawing everything at once. Readers can enlarge any diagram with the ⤢ button (zoom and pan).
75
+ - Node ids are short ASCII (`A`, `api`); labels are human text in the documentation language. Quote labels with special characters: `A["Orders API (v2)"]`.
76
+ - Colours come from the active theme; do not add `style`/`classDef` colours.
77
+
78
+ Useful shapes:
79
+
80
+ | Syntax | Use for |
81
+ |---|---|
82
+ | `id([Label])` | people and actors |
83
+ | `id[(Label)]` | databases |
84
+ | `id{{Label}}` | external systems |
85
+ | `id{Label?}` | decisions in flows |
86
+
87
+ Use `subgraph Name … end` to group parts.
88
+
89
+ ## Decision tables (interactive)
90
+
91
+ A fenced block with language `decision` and YAML inside. Readers pick values and see which rule applies. Rules are listed in the order the code evaluates them; the first match wins. A condition left out of `when` means "any value".
92
+
93
+ ````markdown
94
+ ```decision
95
+ title: Which discount applies
96
+ inputs:
97
+ - id: customer
98
+ label: Customer type
99
+ values: [new, loyal, occasional] # optional; values used in rules are added automatically
100
+ - id: total
101
+ label: Order total
102
+ values: ["> 100", "≤ 100"]
103
+ output: Discount
104
+ rules:
105
+ - when: { customer: new, total: "> 100" }
106
+ then: "10%"
107
+ code: src/pricing/discount.ts#L2
108
+ - when: { customer: loyal }
109
+ then: "5%"
110
+ note: Any total
111
+ code: src/pricing/discount.ts#L3
112
+ - when: {}
113
+ then: "0%"
114
+ note: Everything else
115
+ ```
116
+ ````
117
+
118
+ Put the important boundary cases in `EDGE` callouts under the table, for example what happens at exactly 100.
119
+
120
+ ## Other Markdown
121
+
122
+ - **Tables:** these scroll horizontally on small screens.
123
+ - **Collapsible details:** use `<details><summary>Full payload example</summary> … </details>` for long examples that most readers skip.
124
+ - **Images and attachments:** put them under `content/` (e.g. `content/flows/img/checkout.png`) and link them site-absolutely: `![Checkout screen](/flows/img/checkout.png)`.
125
+ - **Code blocks:** use fenced blocks with a language. Keep them short: a signature, a sample payload, a config snippet. Link to the code for the rest.
@@ -0,0 +1,104 @@
1
+ # Page types
2
+
3
+ Each type lists what the page must contain, in order. Section paths come from DOCS-GUIDE.md; the defaults are shown. Adapt the headings to the documentation language.
4
+
5
+ ## Home (`content/index.md`)
6
+
7
+ 1. **Summary** in the frontmatter: what the application does, for whom, in 1–2 sentences.
8
+ 2. **A short paragraph** (≤120 words in total with the summary): the main capabilities and the main technical shape (e.g. "a Next.js app and a Python worker sharing a Postgres database").
9
+ 3. **System map.** A `flowchart LR` with the actors, the main parts and the external systems, each clickable to its page. At most ~10 nodes.
10
+ 4. **What to know in 30 seconds.** 3–5 bullets with the things people most often get wrong or need first, each linking deeper.
11
+ 5. **Where to start.** 2–4 links, for example: to understand a request, read [Checkout](/flows/checkout/).
12
+
13
+ The build appends the section cards ("Go deeper") and "Recently updated".
14
+
15
+ ## Section overview (`content/<section>/index.md`)
16
+
17
+ - `summary` plus at most ~200 words saying what this section covers and how its pages relate.
18
+ - A map diagram when the section has structure (modules, flow families, entity lifecycles), with clickable nodes.
19
+ - No detail content: that goes into child pages. The build lists the children with their summaries.
20
+ - Set `order` so the sections follow the guide's order.
21
+
22
+ ## Architecture pages
23
+
24
+ - **Context** (`/architecture/context/` or inside the section index): the system as one box, the people and external systems around it, with arrows labelled by purpose ("sends invoices", "reads prices").
25
+ - **Containers**: the deployable or runnable parts (apps, services, workers, databases, queues). For each part, give its responsibility in one line, its technology, and how it talks to the others (protocol, sync or async). Include one diagram.
26
+ - **Module or component page** (one per important module):
27
+ 1. **Purpose.** What it is responsible for, and just as important, what it is not responsible for.
28
+ 2. **Public surface.** The functions, endpoints, events or commands other code uses, each with a code link. Show a table for endpoints: method, path, purpose, auth.
29
+ 3. **How it works.** The key idea in a few paragraphs, with a small diagram if it helps.
30
+ 4. **Dependencies.** What it calls and what calls it, linked to those pages.
31
+ 5. **Edge cases and limits**, as `EDGE` callouts.
32
+ 6. **Where to change things.** For typical modifications, the files to touch.
33
+
34
+ ## Flow page (`/flows/<name>/`)
35
+
36
+ 1. **Trigger and outcome** in the summary: who starts it, and what is true at the end.
37
+ 2. **Sequence diagram** of the main path, with 4–8 participants.
38
+ 3. **Numbered steps**, one per meaningful action, each with a code link. Numbering fits here because a flow is a sequence.
39
+ 4. **Alternative and failure paths.** What happens when validation fails, a dependency is down, a timeout hits, or the user retries. Use `EDGE` callouts for the non-obvious ones.
40
+ 5. **Side effects.** Data written, events emitted, emails sent, and whether they are idempotent.
41
+ 6. **Related.** Links to the rules and states that the flow uses.
42
+
43
+ ## Rule page (`/rules/<name>/`)
44
+
45
+ - A summary stating the rule in one sentence.
46
+ - A **decision table** (a `decision` block) when the rule depends on two or more conditions. Otherwise, one clear sentence plus an example.
47
+ - Boundary values and precedence as `EDGE` callouts: exactly at the limit, conflicting rules, missing data.
48
+ - Where the rule lives in the code, and which tests cover it.
49
+
50
+ ## State machine page (`/rules/<entity>-states/`)
51
+
52
+ - A `stateDiagram-v2` whose transitions are labelled with the triggering action or event.
53
+ - A table with the columns state, meaning, allowed next states, and who or what triggers the move.
54
+ - Forbidden transitions and what happens if they are attempted.
55
+ - Timeouts or automatic transitions, if any.
56
+
57
+ ## Glossary (`/rules/glossary/`)
58
+
59
+ One line per domain term: the term, its meaning in this system, and where it appears in the code (entity, table, module). Link other pages to glossary anchors (`/rules/glossary/#tenant`).
60
+
61
+ ## Edge-case catalogue (`/edge-cases/`)
62
+
63
+ A table, grouped with `##` headings by area:
64
+
65
+ | Situation | What happens | Why | Code | Test |
66
+ |---|---|---|---|---|
67
+ | Empty cart at checkout | Request rejected with 422 `EMPTY_CART` | An order needs at least one item | [createOrder](code:src/orders/order.ts#L2) | [order.test.ts](code:tests/order.test.ts#L8) |
68
+ | Payment provider timeout | Order stays `pending`; retried 3× | Avoid double charges | [retry](code:src/jobs/retry.ts#L40) | not covered by tests |
69
+
70
+ Every edge case mentioned on another page appears here too, and each row links back to that page.
71
+
72
+ ## Data page (`/data/`)
73
+
74
+ - An `erDiagram` of the main entities with their key fields only.
75
+ - One subsection per entity that matters: what it represents, its important fields and constraints, and who writes it and who reads it.
76
+ - Data flow: where data enters (forms, imports, APIs), how it is transformed, and where it goes (exports, analytics, other systems).
77
+ - Retention, deletion and privacy rules, if they exist.
78
+
79
+ ## Decision record (`/decisions/NNNN-title/`)
80
+
81
+ Sections: Context, Decision, Alternatives considered (and why they were rejected), Consequences, Status (accepted, superseded by …). Keep it under 400 words. Use `sources` for the code the decision shaped.
82
+
83
+ ## What changed (`/changes/index.md`)
84
+
85
+ Newest entries first:
86
+
87
+ ```markdown
88
+ ## 2026-09-23
89
+
90
+ - New customers now get 10% only above 100 (it was 50). See [Discounts](/rules/discounts/).
91
+ - Added the [refund flow](/flows/refund/).
92
+ ```
93
+
94
+ Write about behaviour, in plain language. Skip pure refactors.
95
+
96
+ ## Risks page (`/risks/`)
97
+
98
+ One entry per risk:
99
+
100
+ - where it is (with a code link);
101
+ - why it is risky: no tests, high complexity, frequent changes, an implicit contract;
102
+ - what would reduce it.
103
+
104
+ Rank the entries by impact.