From 6f8a650ac0cb029da18a30c8d8d72b40bef33cc5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 13 Oct 2026 00:24:17 +0200 Subject: [PATCH] Make CLAUDE.md a short router, and move each topic's rules to a file under rules/ that loads when a session touches a matching file --- .gitignore | 2 + AGENTS.md | 2 +- CHANGELOG.md | 1 + CLAUDE.md | 100 ++++++---------------------- README.md | 2 +- agents/prose-reviewer.md | 4 +- agents/stability-reviewer.md | 4 +- bin/loop_claude/cycle/judge.py | 4 +- bin/loop_claude/cycle/prompts.py | 2 +- bin/loop_claude/loop/main.py | 6 +- bin/loop_claude/project/records.py | 10 +-- bin/loop_claude/test_loop_claude.py | 27 ++++++-- bin/repo_checks/test_citations.py | 23 ++++--- bin/rule_hook/override_log.py | 2 +- docs/decisions.md | 6 +- rules/api-specs.md | 10 +++ rules/comments.md | 36 ++++++++++ rules/decisions.md | 11 +++ rules/readme.md | 23 +++++++ rules/todo-items.md | 17 +++++ skills/larv-review/SKILL.md | 8 +-- todo.md | 13 +--- 22 files changed, 183 insertions(+), 130 deletions(-) create mode 100644 rules/api-specs.md create mode 100644 rules/comments.md create mode 100644 rules/decisions.md create mode 100644 rules/readme.md create mode 100644 rules/todo-items.md diff --git a/.gitignore b/.gitignore index b8232059..1fec2acb 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,8 @@ !docs/*.md !principles/ !principles/*.md +!rules/ +!rules/*.md !skills/ !skills/comprehension-panel/ !skills/comprehension-panel/*.md diff --git a/AGENTS.md b/AGENTS.md index 60d1c301..16c2a120 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ Decisions live in `docs/decisions.md`: - larv-review: a project under the comprehension floor is fixed at the lowest dimension -- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md` and `~/.claude/CLAUDE.md`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing +- loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md` and `~/.claude/rules/`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json` - bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e665343..5553d92a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `CLAUDE.md` keeps only the rules every session needs. The rules for `todo.md` items, comments, decisions, READMEs and public API specs moved to files under `rules/`. Claude Code loads each one when a session reads or writes a matching file. `loop-claude`'s judge reads them beside `CLAUDE.md`, and the prose and stability reviewers read them where they once read `CLAUDE.md`. - A hook blocks each Bash, Edit, MultiEdit and Write call that breaks a rule a program can check: a commit message that is not one line passed with `-m`, a Claude or Anthropic attribution, a container image short of a full patch version, an Action pinned to anything but a semver tag, an unsorted block in an ignore file, and a commit of a `todo.md` that `rank_todo.py --check` rejects. `CLAUDE.md` states those rules only where the hook cannot check them; `~/.claude/bin/rule-hook --help` states what it checks. A call overrides a rule with `# rule-override : `. larv-review's new overrides pass, run before stability, accepts or rejects each override the chunk logged, and the PR body lists each with its ruling; a rejected override means the chunk keeps the rule. An override that touches a credential, a security rule or a production system, or cannot be undone, is asked of you. - A project may opt out of larv-review's architect, product-owner pass or comprehension check in every chunk, through a `docs/decisions.md` entry titled `review opt-out: …` that names the goal that skipping them serves. A project without such an entry is reviewed as before. Opting out of the comprehension check also skips the scoring run due at a release's end, so the floor blocks nothing; the opt-out ends with a chunk that ships a plan item naming the floor, which removes the comprehension check from the entry. The principles audit always runs. - A README goal states the project's aim and intent, and no longer names a step of the work, such as "kill weak candidates early". Such steps go in a method section further down the README and name the goal they serve. diff --git a/CLAUDE.md b/CLAUDE.md index b2955490..f8c34d87 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,42 +4,32 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. Other words, such as *chunk*, are defined under "Vocabulary" at the end of this file. -- **Until `README.md` has a `## Goals` and an `## Audience` section, writing them is the only work.** Not even planning in `todo.md`. Both are public: an outside reader judges a project by where it is heading and who it is for. Goals or an audience written anywhere else, such as `AGENTS.md` or `docs/`, do not count. - - **Goals** state the project's aim and intent, not promises: one numbered line each, like slogans, in priority order; a sub-goal is indented under its goal — "1. Blazing fast performance. 2. Correctness is more important than many features." A goal names no step of the work, such as a check to run first, and rarely an implementation. How a goal is met goes in a method section further down the README and names the goal it serves. BANNED as a goal: `Kill weak candidates early, with the cheap checks first.` GOOD: the goal `Keep research on a budget, so it scales in both time and cost.`, with the cheap checks moved to the method section, naming that goal. - - **Audience** names who depends on the project and what they may rely on. -- **Plan `todo.md` as one scored table**, per "Todo items": every item names the release that ships it. If `todo.md` has another shape, reshaping it is the chunk, and the human approves it. +- **Until `README.md` has a `## Goals` and an `## Audience` section, writing them is the only work.** Not even planning in `todo.md`. Both are public: an outside reader judges a project by where it is heading and who it is for. Goals or an audience written anywhere else, such as `AGENTS.md` or `docs/`, do not count. How to write them: `~/.claude/rules/readme.md`. +- **Plan `todo.md` as one scored table**, per `~/.claude/rules/todo-items.md`: every item names the release that ships it. If `todo.md` has another shape, reshaping it is the chunk, and the human approves it. - **When the next release has no items and no work has landed towards it, plan it as this chunk.** Move the highest-scoring items of later releases into it, and get the human's approval of that set before writing any code. - **When the next release has no items left and work has landed towards it, it is finished: stop.** Report what it holds and that it is ready to cut. Under `/loop`, this ends the loop. Until the human cuts it, only a security fix lands, into that release; never start a later release's items or plan a new one. - **Open every chunk with one line:** the last version cut, what is unreleased (`CHANGELOG.md` → `## Unreleased`, or else the log since the last tag), and the release this chunk ships into. A repo that publishes nothing says so once. -- **Work one chunk at a time, and make it as large as one purpose allows.** Every review has a fixed cost, so a chunk takes the next plan item plus every other item for which three things hold: one PR title states what they achieve together, without listing them; they name one release; and they fire the same review passes (`larv-review` §3). Tiny items, a few lines of change each, need neither a shared purpose nor the same passes: bundle up to ten that name one release into one chunk. Split a milestone into items in `todo.md` before starting it. Fix a finding in the chunk's own change within the chunk. File a finding about anything else in `todo.md` per "Todo items". An item marked `question` waits for the human; take the next item. -- **Ask, don't guess.** First check whether the goals already answer the question. If they nearly do, propose a change to the goals and show how it answers this case: an answer settles one question, a goal settles every question like it. Write every answer once, where it belongs, never only in chat: a goal in `README.md`, a working rule in `AGENTS.md`, a standing choice in a comment at the one place it governs, or in `docs/decisions.md` once made in more than one place. If an answer is a goal and something else too, write the goal, and record a choice only for what the goal leaves open. +- **Work one chunk at a time, and make it as large as one purpose allows.** Every review has a fixed cost, so a chunk takes the next plan item plus every other item for which three things hold: one PR title states what they achieve together, without listing them; they name one release; and they fire the same review passes (`larv-review` §3). Tiny items, a few lines of change each, need neither a shared purpose nor the same passes: bundle up to ten that name one release into one chunk. Split a milestone into items in `todo.md` before starting it. Fix a finding in the chunk's own change within the chunk. File a finding about anything else in `todo.md`. An item marked `question` waits for the human; take the next item. +- **Ask, don't guess.** First check whether the goals already answer the question. If they nearly do, propose a change to the goals and show how it answers this case: an answer settles one question, a goal settles every question like it. Write every answer once, where it belongs, never only in chat: a goal in `README.md`, a working rule in `AGENTS.md`, a standing choice in a comment at the one place it governs, or in `docs/decisions.md` once made in more than one place. When an answer holds a goal and a choice, write the goal in the README, and record as a choice only what the goal leaves open. - **Bench a syntax with the people who write it.** Before a new or changed spelling of something users read or write ships — markdown, HTML, a config key, a CLI flag — a panel of fresh-context readers, seated as those users from the README's `## Audience`, picks it. - **Ship every chunk with `/larv-review`.** - **Remove a finished item's row and detail from `todo.md`, and revise any decision that cites it.** If the repo publishes something others consume — a package, an image, an API — reword the item for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete it; git history is the record. - **Releases are the human's.** The version bump and the publishing credentials are theirs, whatever another rule says. Prepare everything else, so cutting a release is one decision. - **Releases follow semver read strictly** (`~/.claude/principles/technical-principles.md`). - -### Todo items (`todo.md`, tickets, plans) -- **`todo.md` is mandatory in every project, in one shape**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. `## Scoring` holds the formula, the bar and the goal weights; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. Cite an item by its ID. The formula, bar and weights are the project's own to tune. -- **Score an item when it is filed or edited.** Each of R, S, A and G is a whole number from 1 to 10: - - **R** — the risk that the change creates serious bugs or issues. - - **S** — the size of the change. - - **A** — its value to the audience in `README.md` → `## Audience`. - - **G** — its value to the goals it cites in the Goals column; W is the weight of the heaviest of them. -- **An item scoring under the bar is deleted, with every item that needs it, and a finding under the bar is not filed.** The chunk's summary names each, with its score. -- **The Exempt cell keeps an item whatever its score:** `security` for a security finding, `defect` for a 🔴 finding, `question` for a question only the human can answer, `decision` for an item `docs/decisions.md` cites, and, where no other reason fits, `principle` for a 🟡 finding against a file under `~/.claude/principles/`, whose item's detail names that principle. Every item `docs/decisions.md` cites carries one of these reasons. -- Open each item with a bold one-sentence tagline, so the taglines alone say what a release holds. The tagline states the target state, checkable when done: an imperative verb plus what holds afterwards. A present-tense fact reads as the current state and says nothing about what to do. Add "today X" only where the direction is otherwise ambiguous. GOOD: `**Accept undefined in MetadataValue and drop such keys on output.**` BANNED: `MetadataValue accepts undefined; such keys are dropped on output`. -- A security finding — a leaked credential, secret or PII, an auth bypass, an injection — is filed the moment it is found, under the next release, marked `security`, naming the exposure and the path it reaches. `rank_todo.py` ranks it first in its release. Never among additive or nice-to-have items, never only in a chunk's summary, and never as a question about where it belongs: file it, say you did, and I will unmark it if I disagree. Fixing it inside an unrelated change is a separate call — say whether it is in the blast radius. -- **Unless the project has a reason to differ, weigh goals by position, the first heaviest.** When the weights stop listing the README's goals, `rank_todo.py` fails and prints those weights. +- **File a security finding the moment it is found.** A security finding — a leaked credential, secret or PII, an auth bypass, an injection — goes under the next release, marked `security`, naming the exposure and the path it reaches. `rank_todo.py` ranks it first in its release. Never among additive or nice-to-have items, never only in a chunk's summary, and never as a question about where it belongs: file it, say you did, and I will unmark it if I disagree. Fixing it inside an unrelated change is a separate call — say whether it is in the blast radius. ## Quality Quality is proven by review. Every change is reviewed as a diff. The whole project is measured when a change carries an architectural decision, and before each release, because a project can drift from the principles one clean diff at a time. `larv-review` §3 says which review runs when. Quality has three parts. When two pull against each other, the earlier one wins. 1. **Correct.** The work does what the goals and the plan say, and tests prove it. -2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). The `comprehension-panel` skill measures KISS in `larv-review`'s comprehension check (§3 → "Architecture"), which a project decision may suspend or opt out of. **Comprehension never falls:** when readers comparing the chunk with the last commit the panel scored or ruled better rule that it reads worse, improve what they named and rule again. After three such rounds, stop and ask the human. At a release's end, or for an item naming it, a score under the comprehension floor blocks a merge. +2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). `larv-review`'s comprehension check (§3 → "Architecture") measures KISS. 3. **Plainly written**, per "Prose". +### A false claim is a bug — fix it where you find it + +Docs, comments and what a program prints — `--help`, an error, a log line — assert checkable things: a command, a resolution rule, a path, a limit. Verify one before you repeat or build on it. When it is wrong, correct it in the same change: the claim — or the code, when consumers already rely on what the claim promises. Never work around it or record the discrepancy elsewhere. + ## Prose Everything written — chat, commit messages, comments, docs, code — is in **English**. Prose meets four priorities, in this order. When two pull against each other, the higher one wins. @@ -52,63 +42,15 @@ Everything written — chat, commit messages, comments, docs, code — is in **E - **Write the thing, not an introduction to it.** A sentence announcing what follows, or flagging that it deserves attention, carries nothing — if it matters, it is in what follows. A bare label is fine. BANNED: `Here's the new audience text, which is the part that needs your eye:`, `One thing I changed that deserves your attention.`, `One judgment call I'd flag rather than bury.`, `Three things came along that would otherwise have been left false.` GOOD: `New audience text:`, or the list alone. - **No contrastive tail.** `X rather than Y`, `not Y but X`, `instead of Y`: state X and stop. The rejected alternative is noise unless naming it stops a reader doing Y. BANNED: `verified in CI rather than asserted`. GOOD: `verified in CI`. -## Comments and documentation (`README.md`, `AGENTS.md`, `docs/`, API specs) +## Topic rules -### What earns a place +Each loads by itself when a session reads or writes a matching file; read it first when you need its rule before that. -The reader is a competent reader of THIS codebase. A comment or a paragraph earns its place by saying what that reader could not infer and the repo cannot say for itself: a surprising WHY, a footgun, an invariant, an external constraint. Fix a redundant one by deleting it, never by trimming it: two copies drift, and the doc copy is the one nobody updates. GOOD: `// Loud-fail: missing amount used to coerce to '0' = phantom "0 SEK reversal" in api-4.` — records a past prod bug the code can't show. - -### A false claim is a bug — fix it where you find it - -Docs, comments and what a program prints — `--help`, an error, a log line — assert checkable things: a command, a resolution rule, a path, a limit. Verify one before you repeat or build on it. When it is wrong, correct it in the same change: the claim — or the code, when consumers already rely on what the claim promises. Never work around it or record the discrepancy elsewhere. - -### Comments - -The rules below govern prose comments; doc comments a tool consumes — docstrings, godoc, JSDoc types — are outside them. - -Default to NO comment. Delete one that is any of: -1. A **restatement** of the adjacent code. BANNED: `// Sanitized + bounded to 1000 chars` above `mb_substr(json_encode(LogSanitizer::body($x)), 0, 1000)`. -2. A **cross-cutting convention** used elsewhere (sanitization, the 1000-char Loki cap, "log so the source is recoverable"). Project-wide facts live in ONE doc, never repeated at call sites. -3. A **justification of self-evident code** (a log line is self-evidently for observing its value). -4. A **file preamble or arrangement rationale**: what a file holds, why it exists, why two things share it, why a check sits beside what it judges, why an order was chosen. The file name and the declarations are the index; a choice with no effect on the running program belongs in the commit that made it. - -**What stays is one terse line, and only where the code cannot show it.** GOOD: `# Pinned to 7.x: hurl 8's jsonpath change breaks the nth-filter asserts.` A second line belongs in the commit message or the ticket. The one exception is a paragraph for an invariant a reader must hold before touching the code below; it stays with the code it guards. - -**Density is a review signal.** Prose comment lines much past ~10% of a file's non-blank lines mean something is wrong — narrating comments, or code that fails to carry its own meaning. A defect to investigate. - -### Negation, history and limitations: name the action, or say nothing - -Prose describing the code as it stands — a comment, a README, an `AGENTS.md`, an API spec — may narrate what is *not* done (a removed step, a call we don't make, a superseded version `we used to X, now Y`, a limitation) in one shape only: where a reader would otherwise **do** something harmful, and the sentence says what to do instead. GOOD: `wrap a direct ./tests/run.sh to put it under the same lock`. BANNED: `run.sh takes no host lock`. A limitation with nothing to do instead belongs in the PR or ticket, because **documenting a limitation is not fixing it**. - -### Links and pointers - -**Link, don't inline — and keep the link bare.** A mechanism identical across call sites or repos is documented once in the canonical source and pointed at with a one-line bare link. Don't summarize what's behind the link or restate the identifier's own name. - -**A pointer is not a definition.** A definition the reader needs to follow the code — what a unit counts, what a term means, what invariant a cache rests on — sits at the code in one line. A pointer to it (`see AGENTS.md §11`) cannot be checked against the code beside it, so it rots invisibly. A pointer carrying rationale — a rejected alternative, the premise behind a standing choice — is correct and stays. - -### Decisions: one home, each linked to a goal or a technical principle - -**A choice that shapes what the code does, made in one place, is a comment there, with its reason. Made in more than one place, it is a decision, and the decision log owns it.** A decision's rejected alternative, or what it deliberately does not cover, stays out of every call site. **The decision log has one home: `docs/decisions.md`**. A title states the whole decision in one line: what holds at the commit it ships in, in words a reader finds in the code or the plan. `AGENTS.md` lists every title, so a session works by the decisions without loading their background. A session reads the entry under a title only to question, revise or add a decision. The entry holds the background: its date, who made it, the reasoning, and the premise it rests on ("valid while X") so it can expire honestly when that premise dies. A choice found anywhere else — an `AGENTS.md` body, a comment, or a README section that is neither a goal nor how one is met — moves: to a comment at its one place, or, once made in more than one place, to the log, leaving its title in `AGENTS.md`'s list. A goal stays a goal in the README; the log records only what the goal leaves open. - -**Every decision links to a goal or a technical principle.** An entry names the goal it serves or the technical principle under `~/.claude/principles/` it applies; one that can do neither is a missing goal, and an entry already in the repo with neither behind it is a finding. Propose the goal, never a reason of your own — "Ask, don't guess" under "Working loop" says how. An entry working against a goal or a technical principle stands only while it names the `todo.md` item that ends it. - -### README - -**A README covers what a reader needs *before* opening the code**: how it meets its goals, how to build, test, run, and deploy it, and cross-cutting decisions no single file owns. It does **not** narrate an individual symbol, file, or test case — whoever wants to know what a test asserts opens the test, where the answer is exact and cannot drift. - -**"Refresh `README.md` to match" means keep it true, not longer.** A change that alters a build/test/run/deploy step, a required env var, or a prerequisite makes the README a false claim by omission, fixed per "A false claim is a bug". Otherwise most changes need no README edit at all. GOOD: `run-tests.sh` gained a required `--profile` flag → update the documented command. BANNED: the change added a test case → add a paragraph describing it. - -### Package README (what someone finds on npm or GitHub) -- The public API is the contract, so the README documents it: options, results, events, everything exported. The rule against narrating a file or test case still holds. -- Sections, in order: install, the main task, the next task, and so on. The reference half — options tables, in-depth behaviour, low-level API, development — goes below the quick starts. Each quick start opens with a line or two that links its in-depth section. -- Keep every documented behaviour, as facts, bullets and tables rather than paragraphs. Where the README is the only record of a behaviour, cutting it is a decision to ask about, not a tidy-up. -- Write for the app developer using the package. -- Top: badges (package version, CI), a one-line tagline that is also the package manifest's description, a feature list, a one-line table of contents. Near the bottom: a table of everything exported. -- A guide for migrating from an older major goes in `MIGRATION.md`, linked from one line in the README. - -### Public API specs -- Text in public API specs (OpenAPI `description`/`title` fields and the generated api-docs) is read by external consumers. Never leak internal references: no ticket IDs, internal URLs, repo/system code-names, "see ticket X". Describe behaviour in consumer terms. GOOD: `Deprecated alias for paymentAccountId`. BANNED: `…will be removed (ABC-123)`. -- The opposite of internal code comments, which *may* cite a ticket for a footgun/constraint. +- Public API specs: `~/.claude/rules/api-specs.md`. +- Comments, and what earns a place in a doc: `~/.claude/rules/comments.md`. +- Decisions and `docs/decisions.md`: `~/.claude/rules/decisions.md`. +- README goals and audience, and a README's contents, a package's included: `~/.claude/rules/readme.md`. +- `todo.md` items, their scores and Exempt reasons: `~/.claude/rules/todo-items.md`. ## Working with the codebase - Always start a new git worktree when doing something in a codebase, and clean it up when done. Unless told otherwise, branch it off a freshly-updated default branch (`git fetch origin`, then base on `origin/main`), not whatever happens to be checked out. @@ -116,7 +58,7 @@ Prose describing the code as it stands — a comment, a README, an `AGENTS.md`, - Run a project's language runtime, package manager, and task runner through its container/tooling setup, never directly on the host unless a decision puts them there. Example: `docker compose run --rm app …`. - Tear down test containers after a run. - Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. -- Check `README.md` first for build, test, install, and codegen commands; one that misbehaves is fixed per "A false claim is a bug". Refresh `README.md` whenever you change what it describes ("Refresh `README.md` to match"). +- Check `README.md` first for build, test, install, and codegen commands; one that misbehaves is fixed per "A false claim is a bug". Refresh `README.md` whenever you change what it describes (`~/.claude/rules/readme.md`). - Sort wherever order carries no meaning (`~/.claude/principles/technical-principles.md`) — attributes, array and object keys, enum members, imports, table rows and line-based file lists. Exception: `id` goes first. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. @@ -142,11 +84,11 @@ The rules every project follows, compose-not-entangle first: `~/.claude/principl ## Web research - **A list or threshold a consumer relies on is sourced.** Deny-lists, defaults, limits: follow a published standard or a widely deployed tool, and cite it in the decision recording the choice; where none exists, ask. Never assemble one from names that seem plausible. -- Default to `WebSearch`/`WebFetch`. When a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` — `./pw [options]` (see its README). Don't use claude-in-chrome for this. +- When a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` — `./pw [options]` (see its README). Don't use claude-in-chrome for this. ## Maintaining this file -- When you spot a pattern in how I work that isn't written here — a preference I've repeated, a correction I've given more than once, a convention you inferred from my code — tell me and ask me to write it up here. Don't add it silently, and don't just keep it in a memory file. -- After every change to this file, re-read the whole thing and restructure it: merge overlapping rules, cut prose that restates a rule, move rules to the section they belong in, drop what's now covered elsewhere. Same information, easier to read and shorter. +- When you spot a pattern in how I work that isn't written here or under `~/.claude/rules/` — a preference I've repeated, a correction I've given more than once, a convention you inferred from my code — tell me and ask me to write it up here. Don't add it silently, and don't just keep it in a memory file. +- After every change to this file or a file under `~/.claude/rules/`, re-read them all and restructure it: merge overlapping rules, cut prose that restates a rule, move rules to the section they belong in, drop what's now covered elsewhere. Same information, easier to read and shorter. ## Vocabulary diff --git a/README.md b/README.md index 5acaa0b1..c047e3c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Claude Code configuration -My personal `~/.claude`, version controlled: `CLAUDE.md` and `AGENTS.md` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold projects to; `docs/` for decisions and the comprehension history; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review. +My personal `~/.claude`, version controlled: `CLAUDE.md`, `AGENTS.md` and `rules/` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold projects to; `docs/` for decisions and the comprehension history; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review. ## Goals diff --git a/agents/prose-reviewer.md b/agents/prose-reviewer.md index 52248402..0f05247b 100644 --- a/agents/prose-reviewer.md +++ b/agents/prose-reviewer.md @@ -6,7 +6,7 @@ tools: Read, Grep, Glob You read the prose as someone who did not write it: you see only what it says, never what the author meant. -The bar: `~/.claude/CLAUDE.md` → "Prose" and "Comments and documentation". Read both each time — they change. Verdict, severities and rounds: ~/.claude/skills/larv-review/review-findings.md. +The bar: `~/.claude/CLAUDE.md` → "Prose", and every file under `~/.claude/rules/` that governs what the diff changes: `comments.md` always, `readme.md` for a README, `decisions.md` for a decision, `todo-items.md` for `todo.md`, `api-specs.md` for an API spec. Read them each time — they change. Verdict, severities and rounds: ~/.claude/skills/larv-review/review-findings.md. ## Checks, in priority order @@ -14,7 +14,7 @@ Run them in this order. A fix for a later check never breaks an earlier one. 1. **Easy to understand.** Read each sentence once, cold. A sentence you had to reread, a term used before it is explained, or an "it" or "them" that could point at two things is a finding. Fix: **Rewrite**, giving the plain sentence. 2. **Most important first.** Name the document's reader and what they want to know first. Check that the sections run in that order, then the paragraphs within each section, then the items within each list. If not, fix: **Reorder**, naming the new order. A section so long that a reader has to search it gets sub-headings or an index. Fix: **Split**. -3. **Default to delete.** A line the reader does not need fails. Fix: **Delete** what the code, a type, a test name, the README or another rule already says. Fix: **Move** a choice made in one place to a comment there, one made in more places to `docs/decisions.md` with its title in `AGENTS.md`, and a goal to the README. A pointer standing where a definition belongs ("A pointer is not a definition") gets the fix **Move back**: inline the definition, and leave the reasoning where it is. +3. **Default to delete.** A line the reader does not need fails. Fix: **Delete** what the code, a type, a test name, the README or another rule already says. Fix: **Move** a choice made in one place to a comment there, one made in more places to `docs/decisions.md` with its title in `AGENTS.md`, and a goal to the README. A pointer standing where a definition belongs (`~/.claude/rules/comments.md` → "Links and pointers", "A pointer is not a definition") gets the fix **Move back**: inline the definition, and leave the reasoning where it is. 4. **Short.** Words that do not clearly help 1–3 fail. Fix: **Cut**. Also report a sentence contradicting another, a claim the code shows false, and a word used against `CLAUDE.md` → "Vocabulary". diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 2e066910..2b5c8dbf 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -110,9 +110,9 @@ Every PR gets at least this sweep. - Is naming precise and unambiguous? - **Does every name in the diff still match its (possibly changed) contents?** When a change meaningfully shifts what a file/folder/package/service/variable does, its name must be updated in the same change — flag a stale name left behind by a content/purpose shift (e.g. a `webhook` test helper reworked into a JWT verifier but still called `webhook`/`WEBHOOK_URL`). The rename belongs in the PR, not "later." - Are magic numbers/strings replaced with named constants? -- **Judge every comment and prose line the diff adds against `~/.claude/CLAUDE.md` → "Comments and documentation"**; report a density breach with the ratio and the files driving it. +- **Judge every comment and prose line the diff adds against `~/.claude/rules/comments.md`**; report a density breach with the ratio and the files driving it. - **Flag a caveat the diff has outlived**, anywhere in the repo: report the sentence's `file:line` and the behaviour that replaced it. -- **Flag a pointer standing where a definition belongs** — `~/.claude/CLAUDE.md` → "Comments and documentation", "A pointer is not a definition". +- **Flag a pointer standing where a definition belongs** — `~/.claude/rules/comments.md` → "Links and pointers", "A pointer is not a definition". - **Never propose new documentation as a "nice to have".** Suggesting a doc paragraph is proposing bulk someone must maintain. Raise it as a 🟡 only when its absence would actively mislead someone, and say which mistake it prevents; otherwise don't raise it at all. Deleting redundant prose is always the cheaper fix. - **Never let documentation stand in for a fix.** A finding is not closed by describing the defect in a README, and neither is one of yours: if the only available remedy is telling the reader, say so and mark it a decision for the human, so it lands in the PR or ticket where a decision record belongs. Naming a residual risk is your job; choosing to publish it in the repo is not yours to hand out. diff --git a/bin/loop_claude/cycle/judge.py b/bin/loop_claude/cycle/judge.py index 814ba085..b6e3b69f 100644 --- a/bin/loop_claude/cycle/judge.py +++ b/bin/loop_claude/cycle/judge.py @@ -39,9 +39,9 @@ JUDGE_RULES = ( "The chunk is the piece of work the agent is on, shipped as one pull request. " "finished=true when the chunk is complete: merged, or nothing remains that the agent could do on " f"its own. Even then, it is finished only once {ANSWERS_RECORDED}. An answer counts as recorded " - f"where README.md or the records above hold it, {HUMAN_RULES} included. It also counts where " + f"where README.md or the records above hold it, {' and '.join(HUMAN_RULES)} included. It also counts where " f"the transcript shows the agent writing it into {ANSWER_DESTINATIONS}; writing it into " - f"{HUMAN_RULES} does not count. finished=false when work remains that a further run can " + f"{' or '.join(HUMAN_RULES)} does not count. finished=false when work remains that a further run can " "continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded." ) diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index a6462101..914b59fd 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -2,7 +2,7 @@ from loop_claude.project.records import HUMAN_RULES, RECORD_FILES from markdown_text import quoted # Where the judge may quote an answer from, named as the human and the worker see them; of README.md the judge sees only the premises. -QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES) + " or " + HUMAN_RULES +QUOTE_SOURCES = "README.md's Goals and Audience, " + ", ".join(RECORD_FILES + HUMAN_RULES[:1]) + " or " + HUMAN_RULES[1] # Where the worker may write an answer the human typed, so it counts as recorded. ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment" ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs" diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 1e1b7dce..ccdba7e1 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -5,7 +5,7 @@ usage: loop-claude Run it anywhere inside a project checkout whose README.md has ## Goals and ## Audience, the premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md -and the human's ~/.claude/CLAUDE.md, where they exist. It rules whether the chunk, the work of one +and the human's ~/.claude/CLAUDE.md and ~/.claude/rules/*.md, where they exist. It rules whether the chunk, the work of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a later chunk could need is recorded: the premises or the records hold it, or the transcript shows the worker writing it into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A choice the @@ -44,8 +44,8 @@ loop-claude --help succeeds: the loop reloads into the edited script. Exit 1, saying why, when: - no task is given - git cannot start or finds no checkout -- README.md, or AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md where they exist, cannot be - read or is not UTF-8 +- README.md, or AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/*.md where they + exist, cannot be read or is not UTF-8 - README.md holds no premises - the models file cannot be read or written - claude leaves no transcript diff --git a/bin/loop_claude/project/records.py b/bin/loop_claude/project/records.py index ad97e5f0..4d84a012 100644 --- a/bin/loop_claude/project/records.py +++ b/bin/loop_claude/project/records.py @@ -3,14 +3,16 @@ import pathlib from loop_claude.project.text_file import read_utf8 from loop_claude.stop import Stop -# The records: these project files and HUMAN_RULES; the judge reads them beside the README's premises. +# The records: these project files and the human's rules; the judge reads them beside the README's premises. RECORD_FILES = ("AGENTS.md", "docs/decisions.md") -HUMAN_RULES = "~/.claude/CLAUDE.md" +HUMAN_RULES = ("~/.claude/CLAUDE.md", "~/.claude/rules/") def read_records(root: str, claude_md: pathlib.Path) -> str | Stop: - """The project's record files, then the human's rules for every project, each headed by its name; a file that does not exist is left out.""" - sources = [(root, name, name) for name in RECORD_FILES] + [(str(claude_md.parent), claude_md.name, HUMAN_RULES)] + """The project's record files, then the human's rules for every project, CLAUDE.md first, each headed by its name; a file that does not exist is left out.""" + rules = claude_md.parent / "rules" + sources = [(root, name, name) for name in RECORD_FILES] + [(str(claude_md.parent), claude_md.name, HUMAN_RULES[0])] + sources += [(str(rules), rule.name, HUMAN_RULES[1] + rule.name) for rule in sorted(rules.glob("*.md"))] records = [] for folder, name, heading in sources: if not pathlib.Path(folder, name).exists(): diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index d9a3a7d4..096b9b8d 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -156,7 +156,7 @@ class Transitions(unittest.TestCase): class QuestionFor(unittest.TestCase): def test_puts_an_interrupts_question_as_asked_and_a_quoted_answer_past_the_cap_with_its_quote(self): self.assertEqual(run.question_for(Interrupt("e", "Which one?")), "Which one?") - self.assertEqual(run.question_for(QuotedAnswer("e", "Which one?", "A.")), "Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\nA.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.") + self.assertEqual(run.question_for(QuotedAnswer("e", "Which one?", "A.")), "Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ says:\nA.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.") class Cycles(unittest.TestCase): @@ -255,12 +255,12 @@ class Cycles(unittest.TestCase): with contextlib.redirect_stderr(io.StringIO()) as said, contextlib.redirect_stdout(io.StringIO()) as printed: self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed")) resumed = fake.made("stream_claude")[1] - self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md answers it:\n\nUse *A*.\n\nContinue the task.") + self.assertEqual(resumed[resumed.index("-p") + 1], "Your question: Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ answers it:\n\nUse *A*.\n\nContinue the task.") self.assertEqual(len(fake.made("stream_claude")), 4) - self.assertEqual(printed.getvalue().count("=== README.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md answered: Which one? ===\nUse *A*."), 3) - self.assertIn("Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\nUse *A*.\n\nThose files have answered 3 questions this cycle", said.getvalue()) - quoted = "2026-09-21T14:13:20Z Verdict: quoted answer\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\n> Use *A*.\n\nEvidence:\n> working\n" - self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md or ~/.claude/CLAUDE.md says:\nUse *A*.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.\n\nEvidence:\n> working\n\n2026-09-21T14:13:20Z Stopped: the human is needed to answer the question above, but the interrupt ended with nothing typed\n", *[f"Task: Do it.\n\n{quoted}"] * 3]) + self.assertEqual(printed.getvalue().count("=== README.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ answered: Which one? ===\nUse *A*."), 3) + self.assertIn("Which one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ says:\nUse *A*.\n\nThose files have answered 3 questions this cycle", said.getvalue()) + quoted = "2026-09-21T14:13:20Z Verdict: quoted answer\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ says:\n> Use *A*.\n\nEvidence:\n> working\n" + self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: interrupt\n\nWhich one?\n\nREADME.md's Goals and Audience, AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md or ~/.claude/rules/ says:\nUse *A*.\n\nThose files have answered 3 questions this cycle, the most allowed, so this one comes to you.\n\nEvidence:\n> working\n\n2026-09-21T14:13:20Z Stopped: the human is needed to answer the question above, but the interrupt ended with nothing typed\n", *[f"Task: Do it.\n\n{quoted}"] * 3]) def test_stops_when_a_quoted_answer_cannot_be_archived(self): self.archive.parent.mkdir(parents=True) @@ -405,6 +405,11 @@ class Records(unittest.TestCase): pathlib.Path(root, "docs", "decisions.md").write_text("# Decisions\n") pathlib.Path(root, "AGENTS.md").write_text("\n# Rules\n") self.assertEqual(records.read_records(root, claude_md), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global") + pathlib.Path(claude_md.parent, "rules").mkdir() + pathlib.Path(claude_md.parent, "rules", "todo.md").write_text("# Todo\n") + pathlib.Path(claude_md.parent, "rules", "readme.md").write_text("# Readme\n") + pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n") + self.assertTrue(records.read_records(root, claude_md).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/readme.md:\n# Readme\n\nFrom ~/.claude/rules/todo.md:\n# Todo")) def test_stops_on_a_record_it_cannot_read(self): with tempfile.TemporaryDirectory() as root: @@ -417,6 +422,14 @@ class Records(unittest.TestCase): self.assertEqual(records.read_records(root, claude_md), Stop(1, f"AGENTS.md in {root} is not UTF-8 on line 2 - the judge cannot read the records.")) + def test_stops_on_a_rule_it_cannot_read(self): + with tempfile.TemporaryDirectory() as root: + claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md") + rules = pathlib.Path(claude_md.parent, "rules") + rules.mkdir(parents=True) + pathlib.Path(rules, "todo.md").write_bytes(b"\xff\n") + self.assertEqual(records.read_records(root, claude_md), Stop(1, f"todo.md in {rules} is not UTF-8 on line 1 - the judge cannot read the records.")) + class JudgePrompt(unittest.TestCase): def test_shows_the_transcripts_tail_and_returns_what_it_showed(self): prompt, shown = judge.judge_prompt("Do it.", "## Goals", "", "old " + "x" * judge.JUDGE_PROMPT_CHARS + " new") @@ -500,7 +513,7 @@ class ExitContract(unittest.TestCase): def test_every_exit_1_stop_has_its_clause_in_help(self): read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "README.md holds no premises" models_ = "the models file cannot be read or written" - unreadable = f"README.md, or {', '.join(records.RECORD_FILES)} or {records.HUMAN_RULES} where they exist, cannot be read or is not UTF-8" + unreadable = f"README.md, or {', '.join(records.RECORD_FILES + records.HUMAN_RULES[:1])} or {records.HUMAN_RULES[1]}*.md where they exist, cannot be read or is not UTF-8" # Every Stop whose code is not a literal 0, 2 or 130, in source order: path, function, code, start of reason, its --help clause. clauses = [ ("cycle/interrupt.py", "interrupt", "1", "entries.reason", read), diff --git a/bin/repo_checks/test_citations.py b/bin/repo_checks/test_citations.py index 7df09d2e..ce94ab95 100644 --- a/bin/repo_checks/test_citations.py +++ b/bin/repo_checks/test_citations.py @@ -8,22 +8,27 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from repo_checks.test_python_floor import ROOT -CITATION = re.compile(r'`?CLAUDE\.md`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)') +CITATION = re.compile(r'`?(?:~/\.claude/)?(CLAUDE\.md|rules/[\w-]+\.md)`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)') HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE) LEAD = re.compile(r"^(?:- )?\*\*(.+?)(?:\*\*|[:.](?=\*\*| )| —)", re.MULTILINE) NAME = re.compile(r'"([^"]+)"') -STRAY = re.compile(r'CLAUDE\.md(?!`? → "|:\d)[^\n"]{1,5}"') +STRAY = re.compile(r'(?:CLAUDE|rules/[\w-]+)\.md(?!`? → "|:\d)[^\n"]{1,5}"') class Citations(unittest.TestCase): - def test_every_citation_names_a_heading_then_headings_or_bold_leads_of_claude_md(self): - text = (ROOT / "CLAUDE.md").read_text() - headings = set(HEADING.findall(text)) - leads = headings | set(LEAD.findall(text)) + def test_every_citation_names_a_heading_then_headings_or_bold_leads_of_the_file_it_cites(self): tracked = subprocess.run(["git", "ls-files", "-z"], capture_output=True, check=True, cwd=ROOT, text=True).stdout.split("\0") texts = [(path, (ROOT / path).read_text()) for path in filter(None, tracked)] self.assertEqual([f"{path}: {stray}" for path, text in texts for stray in STRAY.findall(text)], [], 'spell a citation `CLAUDE.md` → "Vocabulary"') - cited = [(path, NAME.findall(run)) for path, text in texts for run in CITATION.findall(text)] + cited = [(path, file, NAME.findall(run)) for path, text in texts for file, run in CITATION.findall(text)] self.assertTrue(cited) - unresolved = [(path, name) for path, names in cited for i, name in enumerate(names) if name not in (headings if i == 0 else leads)] - self.assertEqual([f"{path}: {name}" for path, name in unresolved], [], "the first name is a heading of CLAUDE.md, each later one a heading or a bold lead") + unresolved = [] + for path, file, names in cited: + if not (ROOT / file).exists(): + unresolved.append(f"{path}: {file}") + continue + text = (ROOT / file).read_text() + headings = set(HEADING.findall(text)) + leads = headings | set(LEAD.findall(text)) + unresolved += [f"{path}: {file} → {name}" for i, name in enumerate(names) if name not in (headings if i == 0 else leads)] + self.assertEqual(unresolved, [], "the first name is a heading of the cited file, each later one a heading or a bold lead") diff --git a/bin/rule_hook/override_log.py b/bin/rule_hook/override_log.py index 5017819f..36fde2c1 100644 --- a/bin/rule_hook/override_log.py +++ b/bin/rule_hook/override_log.py @@ -6,8 +6,8 @@ import sys import typing from rule_hook.rules import Breach -from failure import Failure from rule_hook.git import existing, git +from failure import Failure from utc_stamp import utc LOG = "rule-overrides.tsv" diff --git a/docs/decisions.md b/docs/decisions.md index 7e6596b1..1eb22bfa 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -4,7 +4,7 @@ 2026-09-20, lilleman. Serves goal 1. Across six projects scored with the four seats, Locality or Self-sufficiency was the lowest dimension at every seat and Navigation at none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats. -## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md` and `~/.claude/CLAUDE.md`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing +## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md` and `~/.claude/rules/`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing 2026-09-21, lilleman. Serves goal 1. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable. @@ -12,6 +12,8 @@ 2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 1.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day. +2026-10-13, lilleman, through todo item 95: `CLAUDE.md` keeps only the rules every session needs, and each topic's rules moved to a file under `~/.claude/rules/` that Claude Code loads when a session touches a matching file. The judge reads each of those files whole too, for the reason above, and a worker's write to one counts no more than a write to `CLAUDE.md`. + 2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 1.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` → "Maintaining this file" leaves new rules in it to the human. The judge cannot read a code comment or `todo.md`. Yet `CLAUDE.md` → "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there. And the human's approval of a release's items, which "Working loop" requires, is the set of rows `todo.md` names for that release. The judge also reads the records once a cycle from the main checkout. That checkout may not yet hold an answer the worker wrote and merged. A judge that refused any of these would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a worker whose chunk is held open knows it. ## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it @@ -117,7 +119,7 @@ lilleman decided to ship each of these under the floor on the day listed. Each l ## todo.md: one table of items scored by the formula and goal weights it states, held to its bar, ranked by `bin/rank_todo.py` -2026-10-02, lilleman. Serves goal 1: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `CLAUDE.md` → "Todo items" says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" → "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 1.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A 🟡 against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A 🟢 against a principle is scored like any other finding. 2026-10-08, lilleman: the goal weights in `todo.md` depart from an even spread by position, which would weigh goal 4, leaking nothing, at 0.11. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank. +2026-10-02, lilleman. Serves goal 1: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `~/.claude/rules/todo-items.md` says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" → "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 1.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A 🟡 against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A 🟢 against a principle is scored like any other finding. 2026-10-08, lilleman: the goal weights in `todo.md` depart from an even spread by position, which would weigh goal 4, leaking nothing, at 0.11. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank. ## settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped diff --git a/rules/api-specs.md b/rules/api-specs.md new file mode 100644 index 00000000..570d5c53 --- /dev/null +++ b/rules/api-specs.md @@ -0,0 +1,10 @@ +--- +paths: + - "**/*openapi*" + - "**/*swagger*" + - "**/api-docs/**" +--- + +# Public API specs +- Text in public API specs (OpenAPI `description`/`title` fields and the generated api-docs) is read by external consumers. Never leak internal references: no ticket IDs, internal URLs, repo/system code-names, "see ticket X". Describe behaviour in consumer terms. GOOD: `Deprecated alias for paymentAccountId`. BANNED: `…will be removed (ABC-123)`. +- The opposite of internal code comments, which *may* cite a ticket for a footgun/constraint. diff --git a/rules/comments.md b/rules/comments.md new file mode 100644 index 00000000..c85bebaa --- /dev/null +++ b/rules/comments.md @@ -0,0 +1,36 @@ +--- +paths: + - "**/*.{c,cpp,cs,go,h,java,js,jsx,kt,md,mjs,php,py,rb,rs,sh,sql,swift,toml,ts,tsx,yaml,yml}" + - "**/Dockerfile*" + - "**/bin/*" +--- + +# Comments and documentation + +## What earns a place + +The reader is a competent reader of THIS codebase. A comment or a paragraph earns its place by saying what that reader could not infer and the repo cannot say for itself: a surprising WHY, a footgun, an invariant, an external constraint. Fix a redundant one by deleting it, never by trimming it: two copies drift, and the doc copy is the one nobody updates. GOOD: `// Loud-fail: missing amount used to coerce to '0' = phantom "0 SEK reversal" in api-4.` — records a past prod bug the code can't show. + +## Comments + +The rules below govern prose comments; doc comments a tool consumes — docstrings, godoc, JSDoc types — are outside them. + +Default to NO comment. Delete one that is any of: +1. A **restatement** of the adjacent code. BANNED: `// Sanitized + bounded to 1000 chars` above `mb_substr(json_encode(LogSanitizer::body($x)), 0, 1000)`. +2. A **cross-cutting convention** used elsewhere (sanitization, the 1000-char Loki cap, "log so the source is recoverable"). Project-wide facts live in ONE doc, never repeated at call sites. +3. A **justification of self-evident code** (a log line is self-evidently for observing its value). +4. A **file preamble or arrangement rationale**: what a file holds, why it exists, why two things share it, why a check sits beside what it judges, why an order was chosen. The file name and the declarations are the index; a choice with no effect on the running program belongs in the commit that made it. + +**What stays is one terse line, and only where the code cannot show it.** GOOD: `# Pinned to 7.x: hurl 8's jsonpath change breaks the nth-filter asserts.` A second line belongs in the commit message or the ticket. The one exception is a paragraph for an invariant a reader must hold before touching the code below; it stays with the code it guards. + +**Density is a review signal.** Prose comment lines much past ~10% of a file's non-blank lines mean something is wrong — narrating comments, or code that fails to carry its own meaning. A defect to investigate. + +## Negation, history and limitations: name the action, or say nothing + +Prose describing the code as it stands — a comment, a README, an `AGENTS.md`, an API spec — may narrate what is *not* done (a removed step, a call we don't make, a superseded version `we used to X, now Y`, a limitation) in one shape only: where a reader would otherwise **do** something harmful, and the sentence says what to do instead. GOOD: `wrap a direct ./tests/run.sh to put it under the same lock`. BANNED: `run.sh takes no host lock`. A limitation with nothing to do instead belongs in the PR or ticket, because **documenting a limitation is not fixing it**. + +## Links and pointers + +**Link, don't inline — and keep the link bare.** A mechanism identical across call sites or repos is documented once in the canonical source and pointed at with a one-line bare link. Don't summarize what's behind the link or restate the identifier's own name. + +**A pointer is not a definition.** A definition the reader needs to follow the code — what a unit counts, what a term means, what invariant a cache rests on — sits at the code in one line. A pointer to it (`see AGENTS.md §11`) cannot be checked against the code beside it, so it rots invisibly. A pointer carrying rationale — a rejected alternative, the premise behind a standing choice — is correct and stays. diff --git a/rules/decisions.md b/rules/decisions.md new file mode 100644 index 00000000..14bcb32d --- /dev/null +++ b/rules/decisions.md @@ -0,0 +1,11 @@ +--- +paths: + - "**/AGENTS.md" + - "**/docs/decisions.md" +--- + +# Decisions: one home, each linked to a goal or a technical principle + +**A choice that shapes what the code does, made in one place, is a comment there, with its reason. Made in more than one place, it is a decision, and the decision log owns it.** A decision's rejected alternative, or what it deliberately does not cover, stays out of every call site. **The decision log has one home: `docs/decisions.md`**. A title states the whole decision in one line: what holds at the commit it ships in, in words a reader finds in the code or the plan. `AGENTS.md` lists every title, so a session works by the decisions without loading their background. A session reads the entry under a title only to question, revise or add a decision. The entry holds the background: its date, who made it, the reasoning, and the premise it rests on ("valid while X") so it can expire honestly when that premise dies. A choice found anywhere else — an `AGENTS.md` body, a comment away from the code it governs, or a README section that is neither a goal nor how one is met — moves: to a comment at its one place, or, once made in more than one place, to the log, leaving its title in `AGENTS.md`'s list. A goal stays a goal in the README; the log records only what the goal leaves open. + +**Every decision links to a goal or a technical principle.** An entry names the goal it serves or the technical principle under `~/.claude/principles/` it applies; one that can do neither is a missing goal, and an entry already in the repo with neither behind it is a finding. Propose the goal, never a reason of your own — `~/.claude/CLAUDE.md` → "Working loop", "Ask, don't guess" says how. An entry working against a goal or a technical principle stands only while it names the `todo.md` item that ends it. diff --git a/rules/readme.md b/rules/readme.md new file mode 100644 index 00000000..83a262a3 --- /dev/null +++ b/rules/readme.md @@ -0,0 +1,23 @@ +--- +paths: + - "**/README.md" +--- + +# Goals and Audience + +- **Goals** state the project's aim and intent, not promises: one numbered line each, like slogans, in priority order; a sub-goal is indented under its goal — "1. Blazing fast performance. 2. Correctness is more important than many features." A goal names no step of the work, such as a check to run first, and rarely an implementation. How a goal is met goes in a method section further down the README and names the goal it serves. BANNED as a goal: `Kill weak candidates early, with the cheap checks first.` GOOD: the goal `Keep research on a budget, so it scales in both time and cost.`, with the cheap checks moved to the method section, naming that goal. +- **Audience** names who depends on the project and what they may rely on. + +# README + +**A README covers what a reader needs *before* opening the code**: how it meets its goals, and how to build, test, run, and deploy it. It does **not** narrate an individual symbol, file, or test case — whoever wants to know what a test asserts opens the test, where the answer is exact and cannot drift. + +**"Refresh `README.md` to match" means keep it true, not longer.** A change that alters a build/test/run/deploy step, a required env var, or a prerequisite makes the README a false claim by omission, fixed per `~/.claude/CLAUDE.md` → "Quality", "A false claim is a bug". Otherwise most changes need no README edit at all. GOOD: `run-tests.sh` gained a required `--profile` flag → update the documented command. BANNED: the change added a test case → add a paragraph describing it. + +## Package README (what someone finds on npm or GitHub) +- The public API is the contract, so the README documents it: options, results, events, everything exported. The rule against narrating a file or test case still holds. +- Sections, in order: install, the main task, the next task, and so on. The reference half — options tables, in-depth behaviour, low-level API, development — goes below the quick starts. Each quick start opens with a line or two that links its in-depth section. +- Keep every documented behaviour, as facts, bullets and tables rather than paragraphs. Where the README is the only record of a behaviour, cutting it is a decision to ask about, not a tidy-up. +- Write for the app developer using the package. +- Top: badges (package version, CI), a one-line tagline that is also the package manifest's description, a feature list, a one-line table of contents. Near the bottom: a table of everything exported. +- A guide for migrating from an older major goes in `MIGRATION.md`, linked from one line in the README. diff --git a/rules/todo-items.md b/rules/todo-items.md new file mode 100644 index 00000000..5efcafd7 --- /dev/null +++ b/rules/todo-items.md @@ -0,0 +1,17 @@ +--- +paths: + - "**/todo.md" +--- + +# Todo items (`todo.md`, tickets, plans) + +- **`todo.md` is mandatory in every project, in one shape**, which `~/.claude/bin/rank_todo.py` checks and ranks; its `--help` shows a valid file. `## Scoring` holds the formula, the bar and the goal weights; `## Items` is one table of every item; `## Details` holds each item's detail under its ID. Cite an item by its ID. The formula, bar and weights are the project's own to tune. +- **Score an item when it is filed or edited.** Each of R, S, A and G is a whole number from 1 to 10: + - **R** — the risk that the change creates serious bugs or issues. + - **S** — the size of the change. + - **A** — its value to the audience in `README.md` → `## Audience`. + - **G** — its value to the goals it cites in the Goals column; W is the weight of the heaviest of them. +- **An item scoring under the bar is deleted, with every item that needs it, and a finding under the bar is not filed.** The chunk's summary names each, with its score. +- **The Exempt cell keeps an item whatever its score:** `security` for a security finding, `defect` for a 🔴 finding, `question` for a question only the human can answer, `decision` for an item `docs/decisions.md` cites, and, where no other reason fits, `principle` for a 🟡 finding against a file under `~/.claude/principles/`, whose item's detail names that principle. Every item `docs/decisions.md` cites carries one of these reasons. +- Open each item with a bold one-sentence tagline, so the taglines alone say what a release holds. The tagline states the target state, checkable when done: an imperative verb plus what holds afterwards. A present-tense fact reads as the current state and says nothing about what to do. Add "today X" only where the direction is otherwise ambiguous. GOOD: `**Accept undefined in MetadataValue and drop such keys on output.**` BANNED: `MetadataValue accepts undefined; such keys are dropped on output`. +- **Unless the project has a reason to differ, weigh goals by position, the first heaviest.** When the weights stop listing the README's goals, `rank_todo.py` fails and prints those weights. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 33c580c5..df3dbec3 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -24,7 +24,7 @@ Words: `~/.claude/CLAUDE.md` → "Vocabulary". What a reviewer reports: ~/.claud Follow `~/.claude/CLAUDE.md` → "Git, commits, and PRs". Never commit to the default branch. Commit, push with upstream set, and open a **draft** PR so CI cycles while the review runs. No remote → review locally and say so in the summary. -**Reading cost.** Run `~/.claude/bin/reading-cost` in the chunk's worktree and commit what it appends to `docs/reading-cost.md`; the commit re-enters no pass. Resolve a merge conflict in that file by putting the default branch's figures first and dropping a figure for a chunk the default branch already holds. On `Rising:`, file a plan item titled `**Lower the reading cost of the files a chunk reads most before its first commit.**`, scored per `~/.claude/CLAUDE.md` → "Todo items" with the tool's medians and files as its detail; where the plan already holds it, refresh its detail instead. The item names the next release, or the one after when this chunk ships the next release's last item. On exit 1, repair what its message names and run it again; when the message names no repair, file it as a `question` item, or refresh the question item an earlier run filed, and go on. Leave the plan as it is on any other output. The chunk that ships that item runs the tool with `--reset` instead, so the next rise is measured on chunks that finished after it. +**Reading cost.** Run `~/.claude/bin/reading-cost` in the chunk's worktree and commit what it appends to `docs/reading-cost.md`; the commit re-enters no pass. Resolve a merge conflict in that file by putting the default branch's figures first and dropping a figure for a chunk the default branch already holds. On `Rising:`, file a plan item titled `**Lower the reading cost of the files a chunk reads most before its first commit.**`, scored per `~/.claude/rules/todo-items.md` with the tool's medians and files as its detail; where the plan already holds it, refresh its detail instead. The item names the next release, or the one after when this chunk ships the next release's last item. On exit 1, repair what its message names and run it again; when the message names no repair, file it as a `question` item, or refresh the question item an earlier run filed, and go on. Leave the plan as it is on any other output. The chunk that ships that item runs the tool with `--reset` instead, so the next rise is measured on chunks that finished after it. ## 3. Passes @@ -80,9 +80,9 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its **Findings.** A reviewer rates each finding 🔴 must fix, 🟡 should fix, 🟢 nit, ❓ question, or 🔀 escalation naming the reviewer whose concern it is. -- **Outside the chunk.** A finding outside the chunk's change, whatever its pass or severity, is scored and filed in `todo.md` per `~/.claude/CLAUDE.md` → "Todo items". A 🔴 is marked `defect`. A 🟡 against a file under `~/.claude/principles/` is marked `principle`, its detail naming the principle, where no other reason fits. One under the bar and not exempt is named in the summary with its score. A verified security HIGH is handled per "Security". +- **Outside the chunk.** A finding outside the chunk's change, whatever its pass or severity, is scored and filed in `todo.md` per `~/.claude/rules/todo-items.md`. A 🔴 is marked `defect`. A 🟡 against a file under `~/.claude/principles/` is marked `principle`, its detail naming the principle, where no other reason fits. One under the bar and not exempt is named in the summary with its score. A verified security HIGH is handled per "Security". - **Goal or decision.** A fix that would change a goal, or a `docs/decisions.md` entry the repo held before the chunk began, is asked; no user reachable → filed, marked `question`, the goal or decision left as is. -- **🔴.** A 🔴 is fixed, or shown factually wrong, and what disproved it recorded per `~/.claude/CLAUDE.md` → "Decisions: one home, each linked to a goal or a technical principle": in a comment at the code the finding concerns, or in `docs/decisions.md` when it concerns more than one place. Never declined. +- **🔴.** A 🔴 is fixed, or shown factually wrong, and what disproved it recorded per `~/.claude/rules/decisions.md`: in a comment at the code the finding concerns, or in `docs/decisions.md` when it concerns more than one place. Never declined. - **🟡.** A 🟡 is fixed, shown factually wrong like a 🔴, or declined. Decline one only where the reason is sound, consistent with the goals and the technical principles, and confidence is very high; the decline and its reason are recorded the same way. A reason neither speaks to is a gap in the goals: fix the finding, or ask per `~/.claude/CLAUDE.md` → "Working loop", "Ask, don't guess"; no user reachable → fix. Never drop one silently, and never decline one for convenience or the size of the fix. - **🟢 and ❓.** A 🟢 or ❓ is fixed, answered, declined in the summary with its reason, or filed. Answer one where the code, a test, a goal or a decision the repo held before the chunk began settles it, and quote what in the summary. A ❓ only the user can answer is asked; no user reachable → filed, marked `question`. - **🔀.** A 🔀 runs the named reviewer's pass once the current pass is done. @@ -122,7 +122,7 @@ Two files of the project keep the records: - **History.** `docs/comprehension-history.md` keeps every paired ruling and scoring run, which `larv-review` appends; never edit one. Appending re-enters no pass. Resolve a merge conflict in the file by putting the default branch's entries first. - **Entry.** `docs/decisions.md` keeps one entry whose title opens `comprehension floor:`. It holds each decision to ship under the floor, with its scores. -Put each ruling with its base and votes, and each run's five scores, in the summary. List in the entry each decision to ship under the floor, and file its places in `todo.md` per `~/.claude/CLAUDE.md` → "Todo items". A project without the entry gets it at its first scoring run, titled `comprehension floor: every dimension and the overall at 7.0 or above` and applying KISS (`~/.claude/principles/technical-principles.md`). +Put each ruling with its base and votes, and each run's five scores, in the summary. List in the entry each decision to ship under the floor, and file its places in `todo.md` per `~/.claude/rules/todo-items.md`. A project without the entry gets it at its first scoring run, titled `comprehension floor: every dimension and the overall at 7.0 or above` and applying KISS (`~/.claude/principles/technical-principles.md`). **Fresh.** Where the chunk ran a comprehension check, the architecture pass is done only once its last paired ruling, and its last scoring run where one is due, read the commit to merge. They may predate commits that change only `docs/decisions.md`, `docs/comprehension-history.md`, `docs/reading-cost.md`, `todo.md` or `CHANGELOG.md`. Any other commit after them, a prose fix included, because the seats read the docs, calls for a rescore: the comprehension check again, once every other pass is done, the auto-reviewer included. A rescore reporting a 🔴 that no decision to ship answers is an architecture round. Any other rescore is not a round: append only its results to the history, in a commit titled `Rescore: …`. A `Rescore:` commit re-enters no pass: push it and wait for the forge's checks (§4 step 3), not for an auto-review. diff --git a/todo.md b/todo.md index 17e4d9a7..7cbbea39 100644 --- a/todo.md +++ b/todo.md @@ -24,7 +24,6 @@ | ID | Release | Exempt | Item | R | S | A | G | Goals | Score | |---|---|---|---|---|---|---|---|---|---| -| 95 | 0.1.0 | | **Make `CLAUDE.md` a short router: only the rules every session needs, and a pointer to where each topic's rules load.** | 6 | 6 | 8 | 8 | 1.1, 1.3, 1.4 | 24.3 | | 98 | 0.1.0 | | **Score R and S from a measurement wherever one exists, and calibrate each guessed score against the finished chunk's measured outcome.** | 2 | 5 | 6 | 7 | 1.1, 1.4 | 22.6 | | 99 | 0.1.0 | | **Drop the comprehension panel as a merge gate, and keep recording its scores and the places in the code its seats found hard, for later measurement and for other reviewers and agents to improve.** | 4 | 5 | 7 | 7 | 1.1, 1.4, 1.5 | 22.6 | | 87 | 0.1.0 | | **Score every `todo.md` item's complexity C from 1 to 10, and have `rank_todo.py` fail on an item without one.** | 3 | 4 | 6 | 7 | 1.1, 1.4 | 21.9 | @@ -63,16 +62,6 @@ ## Details -### 95. Make `CLAUDE.md` a short router: only the rules every session needs, and a pointer to where each topic's rules load. - -`CLAUDE.md` holds about 4,300 words and 150 or more rules, and every session loads it whole. Anthropic's memory docs (code.claude.com/docs/en/memory) say a longer file "reduce[s] adherence", and its best-practices page says to keep a line only if "removing this would cause Claude to make mistakes". IFScale (arxiv.org/abs/2507.11538) measures adherence falling as the instruction count grows, with earlier instructions followed more. Count instructions, not lines. - -Keep in it only what every session needs and no other file loads: the vocabulary, the working loop's order, and one line per topic naming the skill, agent or doc that holds its rules. Move each topic's rules to the place that loads it when the topic comes up, such as "Prose" and "Comments and documentation" to what a writer or prose-reviewer loads, "Todo items" to `rank_todo.py --help` and larv-review. Delete every rule Claude already follows unasked. When a rule moves, repoint each reference to it in `skills/`, `agents/` and `bin/`, and have loop-claude's judge, which answers the worker from this file, read the rule where it now lives. The PR states the instruction count before and after. The prose pass of PR #235 found these in the text as it stands; fix each where its text survives: - -- 🟡 "README" says a README covers "cross-cutting decisions no single file owns", while "Decisions: one home" makes `docs/decisions.md` the one home of a choice made in more than one place, and moves a README section that is neither a goal nor how one is met. Proposed: `**A README covers what a reader needs *before* opening the code**: how it meets its goals, and how to build, test, run, and deploy it.` -- 🟢 "Ask, don't guess": "If an answer is a goal and something else too, write the goal, and record a choice only for what the goal leaves open." Proposed: `When an answer holds a goal and a choice, write the goal in the README, and record as a choice only what the goal leaves open.` -- 🟢 "Decisions: one home" lists "a comment" as a wrong home, then names a comment as the destination. Proposed: `a comment away from the code it governs`. - ### 98. Score R and S from a measurement wherever one exists, and calibrate each guessed score against the finished chunk's measured outcome. A score that can be computed from the code it touches, such as the files an item names, comes from that computation. Otherwise size and risk are estimated from finished work, the way reference-class forecasting estimates a project from earlier projects like it. When a chunk merges, record its measured outcome beside the item's guessed R and S: lines and files changed, review rounds, 🔴 and 🟡 findings, and fixes the code needed later. Show the scorer, when it files an item, the finished items whose guessed scores sat nearest and what they measured. Once enough chunks are recorded, report how far each guess was from its outcome, so a scorer whose S runs high can be corrected. Item 87's C is scored and calibrated the same way. @@ -85,7 +74,7 @@ This revises the `comprehension floor:` decision and the `review:` decisions on ### 87. Score every `todo.md` item's complexity C from 1 to 10, and have `rank_todo.py` fail on an item without one. -C is how hard the change is to get right: novel design, subtle invariants, many interacting parts. It differs from R, the chance the change creates serious bugs, and from S, its size: a huge rename is low C, a ten-line lock fix can be high C. C routes work (items 88–92) and stays out of the Score formula. Add the column to `rank_todo.py`'s valid shape and its `--help`, backfill every item in this repo, and state in `CLAUDE.md` → "Todo items" that C is scored when an item is filed, like R, S, A and G, so no chunk starts on an unscored item. +C is how hard the change is to get right: novel design, subtle invariants, many interacting parts. It differs from R, the chance the change creates serious bugs, and from S, its size: a huge rename is low C, a ten-line lock fix can be high C. C routes work (items 88–92) and stays out of the Score formula. Add the column to `rank_todo.py`'s valid shape and its `--help`, backfill every item in this repo, and state in `~/.claude/rules/todo-items.md` that C is scored when an item is filed, like R, S, A and G, so no chunk starts on an unscored item. ### 97. Narrow each review pass to the findings worth a fix, so a pass converges in its second round.