Aventuras/docs/development/README.md
Tony Frazier f6a096b48f
Move the docs to decision records and check them on every push (#807)
This swaps CLAUDE.md and the hand-written docs index for a small
decision-record setup, and adds a script that checks the docs so they
stop drifting from the code.

## What changes

CLAUDE.md is gone. AGENTS.md replaces it as the one instruction file for
people and coding agents alike. It has the commands, the rules for every
change, the area-doc table, and how to record a decision. (Claude Code
only reads AGENTS.md when there's no CLAUDE.md, so it's deleted rather
than kept around as an import.)

If you use Claude Code, check one thing. It only reads AGENTS.md on
version 2.1.277 or later, and only when there's no `CLAUDE.md`,
`.claude/CLAUDE.md` or `CLAUDE.local.md` in the repo or any directory
above it. If you keep one of those, set **Project instructions** to
`claude-md-and-agents-md` in `/config` to load both. Your
`~/.claude/CLAUDE.md` doesn't count, so it's fine.

Decisions now live in `docs/decisions/`, one file each, named
`YYYY-MM-DD-slug.md`. There's one so far, the record system itself. It
sets the bar for when a choice gets an ADR at all: intent the code can't
express that spans more than one site or won't fit in a short comment.
Anything smaller stays a comment, and refining a decision amends its ADR
instead of adding a new one.

Only tagged decisions are listed in `docs/README.md`, so the index grows
with the decisions that span areas, not with every local choice. The
code leads to the local ones, either through an `ADR(slug)` comment at a
single site or through `scope`, which lists the directories an ADR
governs. For each scoped directory, `npm run docs:gen` writes the ADRs'
summaries into a generated block in that directory's `AGENTS.md`, which
Claude Code loads when it reads a file there or below. Any hand-written
text in that file is left alone. `docs/README.md`, the cross-cutting
block in AGENTS.md and the scoped blocks are all generated, so don't
edit those by hand.

Once an ADR merges, its summary is the ruling and can't change. The rest
of the record can still be refined while the summary holds. Changing the
ruling means superseding the ADR.

Raw material (logs, benchmarks, probe output) goes in `docs/evidence/`,
and an ADR has to link it. A new `.ignore` lists the folder so a keyword
search over the whole repository skips it, while a search aimed at the
folder still finds it. Agents reach evidence through the ADR's link. Two
evidence docs record how that was tested: which tools load a nested
AGENTS.md (only the Read tool does), and why no hook or instruction file
guards the folder.

`npm run docs:check` (`scripts/docs-check.ts`) checks:

- the decision files and the generated output
- `ADR(slug)` comments and scopes
- `docs/` paths named in source
- relative links in Markdown
- that evidence files are linked from a decision

It also fails if a merged ADR's summary changed or its slug disappeared,
comparing against the merge-base with `origin/master`. `--base <ref>`
picks another ref, and a ref git can't resolve is an error. The default
`origin/master` only warns when it's missing, so a clone without that
remote can still run the check. (`master` has no decisions yet, so
there's nothing to compare until this merges.) An active ADR with no
tag, no scope and no anchor draws a warning, since nothing would lead a
reader to it. Cross-cutting ADRs are exempt because AGENTS.md lists
them.

`npm run docs:gen` writes nothing while an ADR or the tag list is
invalid. Otherwise a broken record would quietly drop out of the index
and the AGENTS.md blocks.

The check runs in pre-push on every push, and with `--strict` in a new
Docs check workflow on PRs to master. That workflow fetches the full
history so the merge-base exists.

The rules that were in CLAUDE.md now have their own files under
`docs/development/`, indexed by `docs/development/README.md`.
`release.md` and `platform-support.md` are each split into the rules and
a separate evidence file. `docs/ARCHITECTURE.md` is a starting map of
the code, and `docs/architecture/network-transport.md` is new.

Every doc under `docs/architecture/` and `docs/development/` was also
checked against the current code and corrected where it had drifted.

## Smaller changes

- Markdown under `docs/` is forced to LF (`.gitattributes` and
`docs/.editorconfig`).
- Git no longer ignores AGENTS.md or `docs/evidence/`, and the ignores
for the old root-level doc files now match only at the repo root.
- tsconfig and vitest now pick up TypeScript under `scripts/`.
- The README points contributors at AGENTS.md and drops the link to the
iOS build doc.

## Needs a follow-up

`.github/CODEOWNERS` puts `docs/decisions/` under a placeholder team
(`@AventurasTeam/TODO-owning-team`). GitHub ignores an owner it can't
resolve, so it does nothing until someone fills in the real team.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01EzTd9Y26s2eHcacyqFi1QK


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Added repository guidance for development rules, required checks, and
decision records; updated the README to direct contributors to the
relevant guides.
* Added checks and generated documentation for decision records, links,
evidence references, and summaries.
* Added ownership guidance for decision records and standardized
Markdown line endings in the documentation directory.
* Replaced the previous repository guide with the new contributor
guidance.

* **Chores**
* Documentation checks now run on pull requests and before pushing
changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 16:24:21 -05:00

5.1 KiB

Development rules

The rules for changing this codebase, one line each. Each links to the document that states the rule in full: where it applies, what to do, and the short reason. That document links the measurements and sources behind it.

AGENTS.md repeats the rules under Every change. The architecture of each area is in ARCHITECTURE.md. The decisions that span areas are indexed in docs/README.md; local ones are reached from the code they govern.

Every change

  • Run check, test and lint before calling a change done. None of them renders a component, so run the app for anything the UI shows. testing.md
  • Comment only what the code cannot say: an invariant, a non-obvious constraint, a reason. No history, measurements, self-referential prose or restatements. comments.md
  • Match the surrounding code, unless that means a dated idiom. code-style.md
  • Write new code, and code you are already changing, in the current idiom of the installed versions, keeping the modernizations out of the commit message. modern-code.md
  • Use no JS, CSS or Web API newer than Chrome 111 / Safari 16.4 unless MDN says it works there. platform-support.md
  • Read an area's decisions and architecture doc before changing it. Record a decision as an ADR in the PR that makes it, and update an area doc in the same commit when the behaviour it describes changes. ARCHITECTURE.md, docs/README.md

TypeScript and Svelte

  • Svelte 5 runes only, no legacy store syntax. code-style.md
  • Import src/lib as #lib/… with the file's real extension; there is no $lib. code-style.md
  • Import a service through its index.ts, not its internals. code-style.md
  • Never write ?? <default> for a value that has a default in ai/core/defaults.ts. code-style.md
  • Build a new UI primitive on bits-ui by hand; do not run the shadcn-svelte generator. ui-components.md
  • Build a modal, a confirmation or a control in a feature colour from the catalog's components. ui-components.md
  • Check the Tauri and AI SDK doc indexes before a general web search. external-docs.md

Prompt templates

  • A template change that an edited or custom pack will not pick up gets an ## Updating your prompt pack section in its PR. prompt-template-changes.md

Tests

  • Put logic that needs a test in a plain .ts module; a *.svelte.ts module cannot be imported by a test. testing.md
  • Opt a test into the DOM per file with // @vitest-environment jsdom; every other file stays on node. testing.md
  • Keep live provider tests out of required CI. testing.md

Network

Database

  • Never edit a migration that has shipped; add a new one, with LF line endings. persistence.md
  • Never BEGIN from the frontend; send statements that must land together through database.transaction(). persistence.md

Builds and releases

  • Read how a generation survives the background on iOS before changing the generation plugin; it needs iOS 26 and a real device. ios-background-generation.md
  • Never run tauri android init over the tracked src-tauri/gen/android/. Generate src-tauri/gen/apple/ only with the bootstrap workflow. release.md, release.md
  • Never hand-edit the generated RustWebView.kt; inject Kotlin through .cargo/config.toml. release.md
  • Write the release notes before publishing the draft; publishing is what ships the release. release.md
  • Keep RELEASE_REPO in updater.ts and updater.endpoints in tauri.conf.json in step. release.md
  • Bump the pinned Clippy toolchain in rust-lint.yml and package.json together. release.md
  • Move a release runner to a newer image only by a deliberate bump. release.md
  • Bump the android-v2 key suffix to change what Android's Rust cache stores. release.md
  • When upgrading Tailwind or Vite, check whether the platform floor moved, and keep the repository README's install table in step. platform-support.md