Docs / Explanation

Repository health

A repository is healthy when its next reader — a person with git log and an editor, Claude, or any other AI tool — can find what the code does, why it is that way, and what a change ships in, from the repository alone.

Most of what a team knows about its code never reaches the code. It sits in a chat, a ticket, a review thread, or a notes vault only some readers can open. A person who joins next month cannot ask that chat, and an AI tool reads only what is in front of it: the files, and the history git keeps. Whatever is not there, it guesses.

Otto runs many Claude sessions a day against its own repository, each starting from nothing but the checkout. Five practices came out of watching where those sessions, and the people reviewing them, went wrong. Each has a rule, a reason, and a failure it prevents. None of them needs Otto: they are plain files and plain git, and any tool that reads a repository benefits from them. Bring repository health to another repo shows how to adopt them.

1. The why lives in the repo

The rule. The commit that lands on the main branch carries a short body under its subject: Why: (the cause or the motivation, one to three lines), Proven: (what was actually run or checked) and, when the change added or changed a decision, a pointer to that decision's file. Commits made along the way on a branch can stay one line, because the landing squash replaces them.

Why. git log, git blame and git show are the one record every person and every tool already reads. A subject line says what changed; the diff says it again in detail. Neither says why, and the why is what the next person needs before they change the line again.

The failure it prevents. On 2026-10-29 the broker on Otto's server froze for two hours: a pass of the session pool woke a Keeper it had just paused, and the wake queued behind the very pass that was waiting for it. No session launched or resumed until a redeploy. The fix landed as one line, fix(host): a pool pass never waits on the launch chain for itself, and the story — the deadlock, the two hours, why a wake from inside a pass now answers held — is in the D059 addendum of the same day. Someone running git blame on broker-chain.ts a month later lands on that one line, with nothing that points to the addendum. A held answer looks like a simplification waiting to happen, until you know what it stopped. Since that day, the landing commit says why and names the decision it changed.

2. Decisions are records, one per file

The rule. Each architectural decision is its own file, docs/decisions/D###-<slug>.md, listed in an index. A later change to a decision is a dated addendum in its file. Once a decision has several addenda, it opens with a short Current state, so a reader gets today's truth without replaying its history.

Why. A reader has to be able to read a decision whole. A decision that cannot be read whole gets read in part, and the part read is usually the oldest.

The failure it prevents. Otto kept its decisions in one DECISIONS.md. By October 2026 it held 129 decisions and their addenda in 1.35 MB — far more than any AI tool can hold at once, and more than a person reads before making a change. A session paged through it or searched it, found the paragraph a rule started as, and missed the addendum two screens down that changed it. Split into 129 files of about 12 KB on average, each decision fits in a single read, links from a commit body, and shows up in a diff on its own.

3. Docs are an index, rules and co-located specs

The rule. Three kinds of doc, each with one job. The instruction file an AI tool loads by itself (CLAUDE.md, AGENTS.md and the like) is a thin index: what this directory is and where to read more. Imperatives that always apply — "never import Electron in the daemon" — live in a rules folder (.claude/rules/), scoped to the paths they govern. What a module guarantees lives in a SPEC.md beside its code. Each fact lives in one place; the others link to it.

Why. An instruction file is loaded into every session that works in its directory, so every line in it is paid for on every turn, whether that turn needs it or not. And a fact written in two places drifts: one copy gets the change, the other keeps the old truth, and a reader cannot tell which is right.

The failure it prevents. This is the one Otto still fails. Its root CLAUDE.md is an index, but src/host/CLAUDE.md has grown to 70 KB of per-file notes that restate decisions — the broker's description there repeats D059's Current state. Every session working on the host pays for all of it, and when D059 changes, the copy does not. /otto:analyze-specs writes the plan that splits it.

4. Files fit in one read

The rule. A source file is at most 500 lines. Tests, vendored and generated code don't count. Files already over the limit when the rule came in are recorded at their length and may only shrink, and a check in CI holds both.

Why. A file of thousands of lines costs a session most of its context window, or several paged reads that each forget the rest. A person reviewing a change to it has the same problem. A small file gets read whole, so it gets read right.

The failure it prevents. When Otto adopted the rule (D097), 73 files were over 500 lines, and App.tsx had grown past 2,000 — past the point where Claude's file reader stops by default, so a session that read it simply never saw its end. The ratchet only lets those files shrink; there are 63 now, and none over 2,000. A failing check says to split the file along a seam, and never to trim blank lines or comments to squeeze under.

5. Commit scopes say what ships

The rule. A commit subject is type(scope): subject, at most 100 characters, and its scope names the unit the change ships in — an app, a service, a package — from a fixed list mapped to paths, checked before the commit lands.

Why. The main branch's history should answer "what do we release or redeploy?" without anyone reading diffs. A scope derived from the paths a change touches makes that answer mechanical, for a person reading git log and for a release tool alike.

The failure it prevents. Otto ships as a Mac app and a dozen services on its server. Its scopes used to be feature names — leads, pool, sidebar — that said nothing about which of those units a change touched, and subjects ran to 300 characters. Now fix(host,vault-api): … says exactly which two to redeploy (D089).

Checking a repository

/otto:health-check audits a repository against these five principles. It reads the history and the tree, changes nothing, and writes one report: a verdict per principle with its evidence and one concrete step to start on. Run on Otto itself, it finds the decisions, file size and scopes healthy, the commit bodies half adopted, and the nested CLAUDE.md files the place to start.