Skip to content

Commit 9bf1a65

Browse files
committed
Docs: introduce the two-tier colocated docs convention (CLAUDE.md push tier + DETAILS.md pull tier)
Colocated `CLAUDE.md`s auto-inject into context whenever an agent reads files in their directory, so every word there costs tokens in every session touching the area; the repo carries ~206k words of them. The new contract caps the push tier at must-knows and gives depth a designated colocated home: - `CLAUDE.md`: invariants, gotchas, don't-do-X-because-Y, a 2–3 line module map, and a pointer; target ~400–600 words. Litmus: could an agent editing a random file here silently break something without this line? - `DETAILS.md`: the area's real docs (architecture narrative, data flows, decision rationale, edge-case catalogs), read on demand; in whole before structural changes. - Never `@`-import `DETAILS.md` from a `CLAUDE.md` (would rebuild the auto-load cost). Wired into `AGENTS.md` § File structure, `docs/architecture.md`'s framing, and the `docs-maintenance` rule (Gotcha/Why → CLAUDE.md, Decision/Why → DETAILS.md, evidence → docs/notes/).
1 parent e1cc9ba commit 9bf1a65

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

.claude/rules/docs-maintenance.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
When modifying code in a directory that contains a `CLAUDE.md` file, check whether your changes affect the documented
2-
architecture, key decisions, or gotchas. If they do, update the `CLAUDE.md` to stay in sync. If you notice a `CLAUDE.md`
3-
missing in a directory where there should be one, add it. Skip this for trivial changes (bug fixes, formatting, small
4-
refactors that don't change the architecture).
2+
architecture, key decisions, or gotchas. If they do, update the colocated docs to stay in sync: `CLAUDE.md` for
3+
must-knows, `DETAILS.md` for depth, per the litmus in `AGENTS.md` § File structure (could an agent editing a random
4+
file here silently break something without this line? Then `CLAUDE.md`, target ~400–600 words; everything else
5+
`DETAILS.md`). If you notice a `CLAUDE.md` missing in a directory where there should be one, add it. Skip this for
6+
trivial changes (bug fixes, formatting, small refactors that don't change the architecture).
57

68
If something failed due to a wrong assumption, add a `Gotcha/Why` entry to the nearest `CLAUDE.md`.
79

8-
Add `Decision/Why` entries to the nearest colocated `CLAUDE.md` for key decisions. If the decision has rich evidence
9-
(benchmarks, detailed analysis), put the evidence in `docs/notes/` and link from the CLAUDE.md.
10+
Add `Decision/Why` entries to the nearest colocated `DETAILS.md` (plus a one-line guardrail in `CLAUDE.md` only if
11+
ignoring the decision can silently break something). If the decision has rich evidence (benchmarks, detailed analysis),
12+
put the evidence in `docs/notes/` and link from the `DETAILS.md`.
1013

1114
When writing guides, see [this diff](https://github.com/vdavid/cmdr/commit/13ad8f3#diff-795210f) for the formatting
1215
standard. (Before: AI-written. After: matching our standards for conciseness and clarity.)
1316

1417
## Describe current behavior, not history
1518

16-
`CLAUDE.md` files describe the current state of the code and app; git history is for history. Drop narration of previous
19+
`CLAUDE.md` and `DETAILS.md` files describe the current state of the code and app; git history is for history. Drop narration of previous
1720
code shapes ("we originally tried X", "no longer applicable as of Z", date-stamped milestone framing on Decisions). Keep
1821
the non-obvious why, actionable guardrails ("don't switch to X, it breaks Y"), and historical pain that encodes a
1922
constraint the current code must defend. Litmus: if removing the history still leaves current state described AND enough

AGENTS.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,15 @@ Core structure:
9595
- `style-guide.md` - Writing, code, and design style rules
9696
- `security.md` - Security policies
9797
- `maintenance.md` - Recurring maintenance tasks (dep bumps, allowlist trims, doc sweeps) and a log of past runs
98-
- Feature-level docs live in **colocated `CLAUDE.md` files** next to the code (for example,
99-
`src/lib/settings/CLAUDE.md`). Claude Code auto-discovers these. See `docs/architecture.md` for the full map.
98+
- Feature-level docs live in **colocated `CLAUDE.md` + `DETAILS.md` files** next to the code (for example,
99+
`src/lib/settings/CLAUDE.md`). `CLAUDE.md` is the push tier: Claude Code auto-injects it whenever files in that
100+
directory are read, so every word costs tokens in every session that touches the area. `DETAILS.md` is the pull tier:
101+
the area's real docs, read on demand. The litmus: could an agent editing a random file here silently break something
102+
without this line? Then it's `CLAUDE.md`. Everything else is `DETAILS.md`. So `CLAUDE.md` = invariants, gotchas,
103+
don't-do-X-because-Y, a 2–3 line module map, and a pointer; target ~400–600 words. `DETAILS.md` = architecture
104+
narrative, data flows, decision rationale with depth, edge-case catalogs. Read it in whole before structural changes
105+
in an area. Never `@`-import `DETAILS.md` from a `CLAUDE.md` (that would rebuild the auto-load cost the split exists
106+
to remove). See `docs/architecture.md` for the full map.
100107

101108
## Testing and checking
102109

docs/architecture.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Architecture
22

3-
The orientation map: what each subsystem is and where it lives. Per-subsystem detail (invariants, gotchas, decisions)
4-
lives in each directory's colocated `CLAUDE.md`. Cross-cutting platform constraints that belong to no single subsystem
5-
are in the [Cross-cutting patterns](#cross-cutting-patterns) section below.
3+
The orientation map: what each subsystem is and where it lives. Per-subsystem must-knows (invariants, gotchas,
4+
guardrails) live in each directory's colocated `CLAUDE.md`; each area's full docs (architecture narrative, flows,
5+
decision detail) live in its colocated `DETAILS.md` (see `AGENTS.md` § File structure for the split contract).
6+
Cross-cutting platform constraints that belong to no single subsystem are in the
7+
[Cross-cutting patterns](#cross-cutting-patterns) section below.
68

79
## Frontend (Svelte 5 + TypeScript)
810

0 commit comments

Comments
 (0)