Compare commits

...

47 Commits

Author SHA1 Message Date
lilleman 4061f19dff Answer prose round 1: test first wherever a test can check the change, and name larv-review's reviewers 2026-10-13 08:55:15 +02:00
lilleman 6c6d411f9d Write a failing test first whenever there is something to test 2026-10-13 08:54:35 +02:00
lilleman 21b060e7ad Merge pull request 'Have the worker write the simplest change, test first, reading a principle only where named, and move the rules only reviewers apply to larv-review's standards' (#245) from item-104 into main 2026-10-13 08:49:50 +02:00
lilleman e67a25bdbf Rescore: the paired ruling at a796bb3 is same 2026-10-13 08:49:43 +02:00
lilleman a796bb31ee Answer stability round 3: no findings 2026-10-13 07:58:26 +02:00
lilleman 109fb27e00 Answer architecture round 5: one shared git command parser for rule-hook and reading-cost, the reflog check unrolled, and rule-hook's Outcome and LogLine named apart from their namesakes 2026-10-13 07:56:59 +02:00
lilleman b0cfe20952 Record the paired ruling at f6d5ea7: worse, Shape under the floor 2026-10-13 07:52:40 +02:00
lilleman f6d5ea7b98 Merge main into item-104, keeping item 107 and dropping the finished item 104 2026-10-13 07:41:11 +02:00
lilleman 6b4b5d188b Answer stability round 2: no findings 2026-10-13 01:49:42 +02:00
lilleman f07303cd09 Answer architecture round 4: prose.md holds the full prose rules, the prose reviewer's bar is a list, CLAUDE.md names where the reviewers' standards live, and one helper words the judge's sources 2026-10-13 01:47:55 +02:00
lilleman 16076fa40f Record the paired ruling at b568522: worse, Locality under the floor 2026-10-13 01:45:33 +02:00
lilleman 4719c9289e Merge pull request 'File item 107: loop-claude puts the README's Goals and Audience into every fresh worker prompt, and the item sets the scope' (#246) from item-107 into main 2026-10-13 01:37:56 +02:00
lilleman a7dbaaabb2 File item 107: loop-claude puts the README's Goals and Audience into every fresh worker prompt, and the item sets the scope 2026-10-13 01:37:22 +02:00
lilleman b5685225e0 Answer prose round 1: a finding against a principle names it, a plainer changelog, and the contrastive-tail exception in prose.md 2026-10-13 01:35:19 +02:00
lilleman cfdc10d78c Answer product-owner round 1: test first only where the item changes code, and a changelog in the owner's terms 2026-10-13 01:31:59 +02:00
lilleman fc7f3e96e2 Drop an unchecked clause from the judge decision's reason 2026-10-13 01:30:30 +02:00
lilleman 4734167be6 Answer stability round 1: restate why a write to the human's rules records no answer, and name HUMAN_RULES_FILE for what it holds 2026-10-13 01:30:25 +02:00
lilleman 01e0a35372 Answer architecture round 2: the worker: decision's title states the test-first rule and when the worker reads a principle 2026-10-13 01:28:06 +02:00
lilleman 4ebe36edef Answer architecture round 1: the worker writes the test first and reads a principle a finding or its record names; findings name their principle; one regex for citable rule files 2026-10-13 01:27:05 +02:00
lilleman ed1c62ac8a Append the reading-cost figure 2026-10-13 01:16:15 +02:00
lilleman 854747f68d Have the worker implement the simplest change without loading the technical principles, and move the rules only reviewers apply to larv-review's standards 2026-10-13 01:15:59 +02:00
lilleman 8bbc07d9e9 Merge pull request 'File item 104: the worker implements the simplest change and loads no technical principle; the reviewers refactor it to the bar' (#244) from item-101 into main 2026-10-13 01:02:15 +02:00
lilleman d9ea961ca6 Merge main into item-101, and fold item 103 into item 104, which answers it 2026-10-13 01:00:58 +02:00
lilleman 2feda33ec6 Merge pull request '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' (#242) from claude-md-router into main 2026-10-13 00:56:29 +02:00
lilleman f1a84307be Rescore: the paired ruling at f351e14 against 4cc9953 is same 2026-10-13 00:56:19 +02:00
lilleman f351e14683 Answer stability round 4: no findings 2026-10-13 00:53:25 +02:00
lilleman b2bc0a966f File item 104: the worker implements the simplest change and loads no technical principle; the reviewers refactor it to the bar 2026-10-13 00:53:05 +02:00
lilleman 27ebf64eeb Answer product-owner round 4: no findings 2026-10-13 00:52:25 +02:00
lilleman 3b322596c2 Answer product-owner round 3: point the decision-log rule from Ask, don't guess, and file item 103, whether the saving must reach loop-claude workers, as a question 2026-10-13 00:49:22 +02:00
lilleman 2020a4f04f Answer architecture round 2: keep test data out of the rule-file check, and state the judge's reason for reading rule files in one entry 2026-10-13 00:49:22 +02:00
lilleman 950f06c0be Answer architecture round 1: give the rules/ design its own decision with its premise, move where a choice goes into the comment rules, let each rule file's paths frontmatter be the one map and check every rule file named exists, pass the judge its rules folder, and file two findings outside the chunk 2026-10-13 00:46:11 +02:00
lilleman 63b0759e2a Merge main into claude-md-router
# Conflicts:
#	CHANGELOG.md
#	todo.md
2026-10-13 00:39:38 +02:00
lilleman de0dad7d58 Answer prose round 1: list the judge's rule files in the vocabulary, widen the stability reviewer's prose bar, and reword the router, the maintenance rules and the decision 2026-10-13 00:38:48 +02:00
lilleman 5a1a615f87 Merge pull request 'Add deep modules as a technical principle, and put functional core, imperative shell second' (#243) from deep-modules into main 2026-10-13 00:36:02 +02:00
lilleman be21dbc400 File item 100: the unsorted imports in override_log.py fail the test suite on main 2026-10-13 00:36:01 +02:00
lilleman 415f7752c0 Answer stability round 3: no findings 2026-10-13 00:34:23 +02:00
lilleman cb15824487 Answer product-owner round 2: no findings 2026-10-13 00:33:53 +02:00
lilleman b93c318080 Answer stability round 2: put the public API spec rule back in the prose reviewer's bar 2026-10-13 00:33:53 +02:00
lilleman 9f9dfc7245 Answer prose round 1: functional core is a rule no other principle overrides, the banned call order is one only memory enforces, the changelog states the principle's exception as written, and one list of injected inputs 2026-10-13 00:33:07 +02:00
lilleman 326b239b24 Answer security round 1: no findings 2026-10-13 00:31:58 +02:00
lilleman fdb13957ab Answer product-owner round 1: answered in the stability round 1 commit, with each topic file's trigger in the router and a smoke test showing a user-level rule loads on Read and after Write 2026-10-13 00:31:58 +02:00
lilleman 3766e880ca Answer stability round 1: cite the shortened false-claim heading, keep the API-spec and tagline rules in CLAUDE.md, load the comment rules with any file, and name the judge's two rule sources apart 2026-10-13 00:31:58 +02:00
lilleman 42b6caf2dc Record the reading cost of the last finished chunk 2026-10-13 00:31:42 +02:00
lilleman 15d53b37b8 Add the deep-modules principle, move functional core, imperative shell to second place, and point the architect at the principle 2026-10-13 00:31:24 +02:00
lilleman a1adbbfd8b Record the reading cost of the chunk before this one 2026-10-13 00:24:31 +02:00
lilleman 6f8a650ac0 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 2026-10-13 00:24:17 +02:00
lilleman 72fd688d81 Merge pull request 'Enforce the checkable rules in a hook, with one override marker that larv-review's overrides pass rules on, and drop them from CLAUDE.md' (#241) from hook-rules into main 2026-10-13 00:11:18 +02:00
36 changed files with 718 additions and 255 deletions
+5
View File
@@ -22,6 +22,7 @@
!bin/comprehension_history.py
!bin/failure.py
!bin/file_writes.py
!bin/git_command.py
!bin/larv-review
!bin/larv_review/
!bin/larv_review/*.py
@@ -54,11 +55,15 @@
!docs/*.md
!principles/
!principles/*.md
!rules/
!rules/*.md
!skills/
!skills/comprehension-panel/
!skills/comprehension-panel/*.md
!skills/larv-review/
!skills/larv-review/*.md
!skills/larv-review/standards/
!skills/larv-review/standards/*.md
!workflow-bench/
!workflow-bench/bench.py
!workflow-bench/compare-prompt.md
+3 -1
View File
@@ -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`, `~/.claude/rules/` and larv-review's standards, 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
@@ -29,6 +29,8 @@ Decisions live in `docs/decisions.md`:
- reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR
- reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item
- rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override <rule>: <reason>` marker overrides one, and larv-review's overrides pass rules on each override before merge
- rules/: `CLAUDE.md` holds the worker's rules that no file path can scope, and each topic's rules for the worker live in a `rules/` file that Claude Code loads by its `paths:` frontmatter
- worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/`
## Working rules
+7
View File
@@ -2,6 +2,13 @@
## Unreleased
- A session no longer reads the technical principles before writing code. It writes the simplest change that solves its item, test first wherever a test can check the change, and reads a principle only when the item changes it, a finding names it, or a decision or `todo.md` item it writes cites it. larv-review's reviewers hold the change to the principles, and a finding against one names it. Expect more findings from the prose and stability reviewers, since sessions no longer load the rules for comments and READMEs.
- The rules for comments and READMEs, "Quality" and the examples behind "Prose" moved to `skills/larv-review/standards/`, which the prose and stability reviewers and `loop-claude`'s judge read. `CLAUDE.md` keeps a short core of "Prose"; sorting where order carries no meaning lives only in the technical principles.
- A session no longer points out a preference you have repeated or asks you to write it up, and no longer restructures `CLAUDE.md` and `rules/` after changing them.
- A `todo.md` item names a release whose version bump fits the item under strict semver: a major for a change to what exists (a minor before 1.0.0), a minor for an addition, a patch for a fix.
- `CLAUDE.md` keeps only the rules no file path can scope. The rules for `todo.md` items, decisions and a README's Goals and Audience 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`.
- A README no longer holds cross-cutting decisions; `docs/decisions.md` does.
- A technical principle, "Prefer deep modules": a module puts a small, intuitive interface in front of a lot of hidden work, and hides how it works but never what it depends on. It wins over "Explicit over implicit" unless hiding the work makes it harder for someone new to the project to tell what a call does. "Functional core, imperative shell" moves up to second place, a core rule beside "Compose, do not entangle" that no other principle overrides. The systems architect holds every module to it.
- 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 <rule>: <reason>`. 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.
+24 -98
View File
@@ -5,110 +5,45 @@
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.
- **Plan `todo.md` as one scored table**: 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`.**
- **Implement the simplest change that solves the item, and ship it with `/larv-review`.** Whenever a test can check the change, write that test first and see it fail. larv-review's reviewers hold the change to the technical principles, and a finding against one names it. Read a file under `~/.claude/principles/` only when the item changes it, a finding or a record you write names it, or you decline a finding.
- **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.
## 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.
3. **Plainly written**, per "Prose".
- **Open each `todo.md` item or ticket 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`.
- **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. `~/.claude/bin/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.
## 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.
1. **Easy to understand.** A reader with little time gets it on one read. Keep each sentence to one idea. Explain a term before using it, or use a plainer word. Never fold a clause into a noun phrase to save words. BANNED: `An empty earliest unreleased release with nothing shipped toward it is planned as this chunk`. GOOD: `When the next release has no items and no work has landed towards it, plan it.`
2. **Most important first**, judged by what this document's reader wants to know first. Put the most important section first. Within each section, put the most important paragraph first, and within each list the most important item. Order matters most in long documents; in a short one, don't spend a fix on it.
3. **Default to delete.** Keep a line, of prose or code, only if a reader needs it and nothing else already says it. Adding words is a deliberate act: name what a reader could not understand without them.
1. **Easy to understand.** A reader with little time gets it on one read: one idea per sentence, and each term explained before it is used.
2. **Most important first**, judged by what the reader wants to know first.
3. **Default to delete.** Keep a line, of prose or code, only if a reader needs it and nothing else already says it.
4. **Short.** Cut whatever does not clearly help 1–3.
- **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`.
Write the thing, not an introduction to it. State what holds and stop; name a rejected alternative only where that stops a reader choosing it.
## Comments and documentation (`README.md`, `AGENTS.md`, `docs/`, API specs)
Reviewers hold prose to the full rules, with examples: `~/.claude/skills/larv-review/standards/prose.md`.
### What earns a place
## Public API specs
- Text in public API specs (OpenAPI `description`/`title` fields, in a spec file or in code, 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)`.
- Internal code comments, by contrast, *may* cite a ticket for a footgun or constraint.
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.
## Topic rules
### A false claim is a bug — fix it where you find it
Claude Code loads a rule file when a session reads or writes a file its `paths:` frontmatter matches, and after a write only once the write is done. Read a rule file before you create a file it covers.
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.
- The decision log: `~/.claude/rules/decisions.md`.
- README goals and audience: `~/.claude/rules/goals-and-audience.md`.
- `todo.md` items, their scores and Exempt reasons: `~/.claude/rules/todo-items.md`.
### 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.
The rules only reviewers apply, for quality, comments, READMEs and prose, live in `~/.claude/skills/larv-review/standards/`.
## 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,23 +51,18 @@ 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 <tool> …`.
- 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").
- 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.
- Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer.
- 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.
## Naming files & folders
- Name by what's inside. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. GOOD: `e2e-tests/`, `db-migrations/`, `release-tooling/`.
- Group related artifacts by purpose — e2e compose files, e2e Dockerfile, and e2e test scripts all belong in `e2e-tests/`.
## Technical principles
The rules every project follows, compose-not-entangle first: `~/.claude/principles/technical-principles.md`. Read it before writing, designing or reviewing code.
## Git, commits, and PRs
- Mark no commit, PR, issue comment or file as the work of Claude, Anthropic or an agent.
- Commit message and PR title: **one line**, prefixed with the ticket ID when the work has one. Example: `ABC-123 - Regression tests for GET /v4/clients`. Never include the repo/project name (like "twu-4") — we're already in that context.
- PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title).
- When the work has a ticket, read it before starting: verify the change matches it and pull useful context from it.
- PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title).
- Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`.
- Use `gh` on GitHub remotes and `tea` on Gitea remotes (e.g. `gitea.larvit.se`) — same command shape: `tea pr list|create`, `tea issue`, `tea release`, `tea api`. Everything in this section applies to both.
@@ -142,16 +72,12 @@ 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 <url> [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 a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` — `./pw <url> [options]` (see its README). Don't use claude-in-chrome for this.
## Vocabulary
- **chunk** — the unit of work, shipped as one PR; "Working loop" says what it holds.
- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md`.
- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md`, `~/.claude/rules/` or `~/.claude/skills/larv-review/standards/`.
- **gate** — the merge gate: the checks a PR passes before it merges.
- **interrupt** — `loop-claude` handing the terminal to the human, `claude --resume`, for a decision that is theirs.
- **judge** — the headless claude that reads a worker's transcript each cycle and decides whether to interrupt and whether the chunk is finished.
+1 -1
View File
@@ -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/` and `skills/larv-review/standards/` 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
+9 -3
View File
@@ -6,7 +6,13 @@ 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, read each time, since it changes:
- every file under `~/.claude/skills/larv-review/standards/`, of `quality.md` only "A false claim is a bug";
- `~/.claude/CLAUDE.md` → "Public API specs";
- each file under `~/.claude/rules/` whose `paths:` frontmatter matches a file the diff changes.
Verdict, severities and rounds: ~/.claude/skills/larv-review/review-findings.md.
## Checks, in priority order
@@ -14,10 +20,10 @@ 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/skills/larv-review/standards/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".
Also report a list whose order carries no meaning and is not sorted (`~/.claude/principles/technical-principles.md` → "Deterministic order"), a sentence contradicting another, a claim the code shows false, and a word used against `CLAUDE.md` → "Vocabulary".
## Growth
+3 -3
View File
@@ -10,7 +10,7 @@ You are an elite stability-focused code reviewer with deep expertise in defensiv
## First Steps
1. **Scope the change.** You review every PR; a fresh invocation has no prior context, so determine the diff yourself. Diff the PR branch against its base (`gh pr diff`, or `git merge-base <base> HEAD` then `git diff`), and review the changed lines **plus enough surrounding code and callers** to judge correctness — read the whole changed file when practical; a diff alone hides whether a caller breaks. Read the PR description and, when the project uses an issue tracker (project-specific — check its docs) and the change references a ticket, that ticket: the diff is judged against its stated intent, and a scope mismatch in either direction is a finding — claimed-but-unimplemented, and implemented-but-unasked (#2).
2. **Read every file in the shared principles** at `~/.claude/principles/`. These are mandatory org guidelines; all code MUST comply with each that applies. A file's `Applies to` line says what it covers; one without the line covers every change. Re-read each time — they change. Flag violations prominently.
2. **Read every file under `~/.claude/principles/`**, the shared principles, and `~/.claude/skills/larv-review/standards/quality.md`. These are mandatory org guidelines; all code MUST comply with each that applies. A file's `Applies to` line says what it covers; one without the line covers every change. Re-read each time — they change. Flag violations prominently.
3. **Read README.md, AGENTS.md and `docs/decisions.md`** in the current project for project-specific conventions, build instructions, tooling, and the accepted trade-offs a reviewer should honor rather than re-flag. Note the documented test, lint, and static-analysis commands — you will run them.
4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it — a scratch script, a targeted test run — before reporting it. Put scratch work in a directory you create for this run, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped.
5. **Two passes minimum, then hunt absences.**
@@ -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/skills/larv-review/standards/comments.md`, against `readme.md` beside it for a README, and against every file under `~/.claude/rules/` whose `paths:` frontmatter matches its file**; 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/skills/larv-review/standards/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.
+1 -1
View File
@@ -17,7 +17,7 @@ You are an elite Systems Architect with decades of experience designing software
**Question the requirement, not just the structure.** Complexity with a reason is not automatically worth its cost. For every complexity hotspot — reasoned or not — name the requirement that forces it and sketch the simpler design that drops or relaxes it. When a near-equivalent solution achieves almost the same result far more simply, propose the trade and name the delta precisely ("drop per-source ordering → the entire reorder buffer disappears") so the owner can accept or reject it. A small, named loss of functionality bought with a large complexity reduction is one of the best wins available — surfacing that option is your job; deciding it is the owner's.
**Simple to reason about, not merely simple to call.** A clean external API over a core you cannot follow to the bottom is a shallow win. Trace the key data structures and core abstractions down to their foundation and confirm the core is genuinely simple to *understand*, not just convenient to *implement against*. In Ousterhout's terms: prefer deep modules (simple interface, real work hidden) over shallow ones; complexity is dependencies + obscurity, and it surfaces as change amplification (one change touches many places) and cognitive load (a reader must hold too much in their head). Hunt both, all the way down.
**Simple to reason about, not merely simple to call.** A clean external API over a core you cannot follow to the bottom is a hollow win. Trace the key data structures and core abstractions down to their foundation and confirm the core is genuinely simple to *understand*, not just convenient to *implement against*. Hold every module to "Prefer deep modules" in `~/.claude/principles/technical-principles.md`. Complexity is dependencies + obscurity, and it surfaces as change amplification (one change touches many places) and cognitive load (a reader must hold too much in their head). Hunt both, all the way down.
**Be non-pragmatic about fundamentals.** You are deliberately uncompromising on architectural choices that shape the system for years. Do not bend on:
- Functional core, imperative shell separation
+58
View File
@@ -0,0 +1,58 @@
import dataclasses
from shell_command import resolved, Simple
# git's global options that take a value as the next word.
GIT_VALUED = {"-C", "-c", "--exec-path", "--git-dir", "--namespace", "--work-tree"}
@dataclasses.dataclass(frozen=True)
class Commit:
directory: str
messages: list[str]
from_file: bool
def commits(simples: list[Simple], home: str) -> list[Commit]:
found = []
for simple in simples:
invoked = git_subcommand(simple.words, simple.directory, home)
if invoked and invoked[0] == "commit":
found.append(Commit(invoked[2], *commit_message(invoked[1])))
return found
def git_subcommand(words: list[str], directory: str, home: str) -> tuple[str, list[str], str] | None:
"""A git command's subcommand, its arguments and the directory it runs in, after git's own options such as -C."""
if words[:1] != ["git"]:
return None
args = iter(words[1:])
for word in args:
if word in GIT_VALUED:
value = next(args, "")
directory = resolved(directory, value, home) if word == "-C" else directory
elif not word.startswith("-"):
return word, list(args), directory
return None
def commit_message(args: list[str]) -> tuple[list[str], bool]:
"""git commit's messages, and whether it reads one from a file."""
messages = []
from_file = False
words = iter(args)
for word in words:
if word == "--":
break
name, equals, value = word.partition("=")
if name in ("--message", "--file"):
given = value if equals else next(words, "")
elif word.startswith("-") and not word.startswith("--") and (flags := [flag for flag in word[1:] if flag in "mF"]):
# A cluster such as -am: the valued flag takes the rest of the word, or else the next word.
name = "--message" if flags[0] == "m" else "--file"
given = word[word.index(flags[0]) + 1:] or next(words, "")
else:
continue
messages += [given] if name == "--message" else []
from_file = from_file or name == "--file"
return messages, from_file
+4 -4
View File
@@ -3,11 +3,11 @@ import json
import re
import typing
from loop_claude.cycle.prompts import ANSWER_DESTINATIONS, ANSWERS_RECORDED
from loop_claude.cycle.prompts import ANSWER_DESTINATIONS, ANSWERS_RECORDED, either
from loop_claude.effects import Effects
from failure import Failure
from claude_code.entries import hit_limit, limit_said, parse_entry, structured_output
from loop_claude.project.records import HUMAN_RULES
from loop_claude.project.records import HUMAN_RULE_NAMES
from loop_claude.cycle.retry import Limited, retried
from loop_claude.stop import Stop
@@ -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, {', '.join(HUMAN_RULE_NAMES)} 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"{either(HUMAN_RULE_NAMES)} 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."
)
+7 -2
View File
@@ -1,8 +1,13 @@
from loop_claude.project.records import HUMAN_RULES, RECORD_FILES
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from markdown_text import quoted
def either(names: tuple[str, ...]) -> str:
"""The names as `a, b or c`."""
return f"{', '.join(names[:-1])} or {names[-1]}"
# 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 = either(("README.md's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES))
# 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"
+8 -7
View File
@@ -4,10 +4,11 @@ usage: loop-claude <task>
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
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
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, ~/.claude/rules/*.md and
~/.claude/skills/larv-review/standards/*.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
worker made that the premises or the records settle is not asked about. When the worker asks a
question they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes
@@ -44,8 +45,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, ~/.claude/rules/*.md or
~/.claude/skills/larv-review/standards/*.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
@@ -118,7 +119,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
premises = read_premises(loop_run.root)
if isinstance(premises, Stop):
return premises
records = read_records(loop_run.root, paths.claude_md)
records = read_records(loop_run.root, paths.claude_dir)
if isinstance(records, Stop):
return records
models = get_or_ask_models(key, paths, env, effects)
+2 -2
View File
@@ -5,8 +5,8 @@ import pathlib
@dataclasses.dataclass(frozen=True)
class Paths:
claude_code_transcripts: pathlib.Path
claude_dir: pathlib.Path
claude_json: pathlib.Path
claude_md: pathlib.Path
home: pathlib.Path
model_catalog: pathlib.Path
models_file: pathlib.Path
@@ -16,8 +16,8 @@ def paths_from(home: pathlib.Path) -> Paths:
claude = home / ".claude"
return Paths(
claude_code_transcripts=claude / "projects",
claude_dir=claude,
claude_json=home / ".claude.json",
claude_md=claude / "CLAUDE.md",
home=home,
model_catalog=claude / "cache" / "model-catalog",
models_file=claude / "loop-claude-models.json",
+10 -5
View File
@@ -3,14 +3,19 @@ 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 the judge reads beside the README's premises: these project files, then the human's rules below.
RECORD_FILES = ("AGENTS.md", "docs/decisions.md")
HUMAN_RULES = "~/.claude/CLAUDE.md"
# The human's rules for every project, under ~/.claude: CLAUDE.md, then each .md file in these folders, which a repo check keeps present.
HUMAN_RULES_FILE = "CLAUDE.md"
HUMAN_RULE_DIRS = ("rules", "skills/larv-review/standards")
HUMAN_RULE_NAMES = (f"~/.claude/{HUMAN_RULES_FILE}", *(f"~/.claude/{folder}/" for folder in HUMAN_RULE_DIRS))
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)]
def read_records(root: str, claude_dir: pathlib.Path) -> str | Stop:
"""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_dir / HUMAN_RULES_FILE] + [rule for folder in HUMAN_RULE_DIRS for rule in sorted((claude_dir / folder).glob("*.md"))]
sources = [(root, name, name) for name in RECORD_FILES]
sources += [(str(rule.parent), rule.name, f"~/.claude/{rule.relative_to(claude_dir)}") for rule in rules]
records = []
for folder, name, heading in sources:
if not pathlib.Path(folder, name).exists():
+29 -13
View File
@@ -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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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, ~/.claude/rules/ or ~/.claude/skills/larv-review/standards/ 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)
@@ -397,26 +397,41 @@ class Records(unittest.TestCase):
def test_heads_each_record_by_its_name_the_humans_rules_last(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
self.assertEqual(records.read_records(root, claude_md), "")
self.assertEqual(records.read_records(root, claude_md.parent), "")
claude_md.parent.mkdir(parents=True)
claude_md.write_text("# Global\n")
self.assertEqual(records.read_records(root, claude_md), "From ~/.claude/CLAUDE.md:\n# Global")
self.assertEqual(records.read_records(root, claude_md.parent), "From ~/.claude/CLAUDE.md:\n# Global")
pathlib.Path(root, "docs").mkdir()
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")
self.assertEqual(records.read_records(root, claude_md.parent), "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-items.md").write_text("# Todo\n")
pathlib.Path(claude_md.parent, "rules", "goals-and-audience.md").write_text("# Goals\n")
pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n")
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True)
pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n")
self.assertTrue(records.read_records(root, claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/goals-and-audience.md:\n# Goals\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments"))
def test_stops_on_a_record_it_cannot_read(self):
with tempfile.TemporaryDirectory() as root:
claude_md = pathlib.Path(root, "home", ".claude", "CLAUDE.md")
claude_md.mkdir(parents=True)
self.assertEqual(records.read_records(root, claude_md), Stop(1, f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
self.assertEqual(records.read_records(root, claude_md.parent), Stop(1, f"CLAUDE.md in {claude_md.parent}: Is a directory - the judge cannot read the records."))
pathlib.Path(root, "docs", "decisions.md").mkdir(parents=True)
self.assertEqual(records.read_records(root, claude_md), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the records."))
self.assertEqual(records.read_records(root, claude_md.parent), Stop(1, f"docs/decisions.md in {root}: Is a directory - the judge cannot read the records."))
pathlib.Path(root, "AGENTS.md").write_bytes(b"# Rules\n\xff\n")
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."))
self.assertEqual(records.read_records(root, claude_md.parent), 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-items.md").write_bytes(b"\xff\n")
self.assertEqual(records.read_records(root, claude_md.parent), Stop(1, f"todo-items.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 +515,8 @@ 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"
names = (*records.RECORD_FILES, records.HUMAN_RULE_NAMES[0], *(f"{folder}*.md" for folder in records.HUMAN_RULE_NAMES[1:]))
unreadable = f"README.md, or {', '.join(names[:-1])} or {names[-1]} 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),
+5 -6
View File
@@ -1,12 +1,11 @@
import collections
import dataclasses
import re
from claude_code.entries import assistant_parts, parse_entry, tool_call
from git_command import commits
from reading_cost.shell_reads import Reads, shell_reads
from shell_command import resolved
from shell_command import resolved, simple_commands
COMMIT = re.compile(r"(^|[\s;&|(])git\s+(-C\s+\S+\s+)?commit\b")
@@ -27,7 +26,7 @@ class Checkout:
def measure(threads: list[bytes], checkout: Checkout, home: str) -> Reading | None:
worker, *subagents = [entries_of(thread) for thread in threads]
commit = commit_time(worker)
commit = commit_time(worker, home)
if commit is None:
return None
before = [[entry for entry in thread if entry.get("type") == "assistant" and str(entry.get("timestamp", "")) < commit] for thread in (worker, *subagents)]
@@ -41,11 +40,11 @@ def entries_of(raw: bytes) -> list[dict]:
return [entry for line in raw.splitlines() if (entry := parse_entry(line))]
def commit_time(worker: list[dict]) -> str | None:
def commit_time(worker: list[dict], home: str) -> str | None:
for entry in worker:
for part in assistant_parts(entry):
name, arguments = call_of(part)
if name == "Bash" and COMMIT.search(str(arguments.get("command", ""))):
if name == "Bash" and commits(simple_commands(str(arguments.get("command", "")), str(entry.get("cwd") or "/"), home), home):
return str(entry.get("timestamp", ""))
return None
+4
View File
@@ -66,6 +66,10 @@ class Measure(unittest.TestCase):
def test_measures_nothing_for_a_worker_that_never_committed(self):
self.assertIsNone(measure.measure([jsonl([said("1", "m1", command="git log --grep commit")])], Checkout("/c/p", "/c/p", frozenset()), "/h"))
self.assertIsNone(measure.measure([jsonl([said("1", "m1", command="echo git commit")])], Checkout("/c/p", "/c/p", frozenset()), "/h"))
def test_finds_a_commit_behind_git_options(self):
self.assertIsNotNone(measure.measure([jsonl([said("1", "m1", command="git -c user.name=t commit -m x")])], Checkout("/c/p", "/c/p", frozenset()), "/h"))
def test_skips_a_usage_that_is_not_a_count(self):
self.assertEqual(measure.tokens_in([{"message": {"id": "m", "usage": {"input_tokens": "7", "cache_creation_input_tokens": 2}}}]), 2)
+28 -9
View File
@@ -6,24 +6,43 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from loop_claude.project.records import HUMAN_RULE_DIRS
from repo_checks.test_python_floor import ROOT
CITATION = re.compile(r'`?CLAUDE\.md`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)')
RULE_PATH = rf"(?:{'|'.join(map(re.escape, HUMAN_RULE_DIRS))})/[\w-]+\.md"
CITATION = re.compile(rf'`?(?:~/\.claude/)?(CLAUDE\.md|{RULE_PATH})`? → ("[^"]+"(?:,? (?: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}"')
RULE_FILE = re.compile(rf"(?<![\w/.-])(?:~/\.claude/)?({RULE_PATH})")
STRAY = re.compile(rf'(?:CLAUDE\.md|{RULE_PATH})(?!`? → "|:\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")
def test_every_rule_file_named_exists_and_topic_rules_lists_each(self):
tracked = subprocess.run(["git", "ls-files", "-z"], capture_output=True, check=True, cwd=ROOT, text=True).stdout.split("\0")
named = {(path, rule) for path in filter(None, tracked) if not pathlib.Path(path).name.startswith("test_") for rule in RULE_FILE.findall((ROOT / path).read_text())}
self.assertTrue(named)
self.assertEqual(sorted(f"{path}: {rule}" for path, rule in named if not (ROOT / rule).exists()), [])
topic_rules = (ROOT / "CLAUDE.md").read_text().split("## Topic rules\n")[1].split("\n## ")[0]
self.assertEqual(sorted(set(RULE_FILE.findall(topic_rules))), sorted(f"rules/{rule.name}" for rule in (ROOT / "rules").glob("*.md")))
def test_every_folder_the_judge_reads_rules_from_exists(self):
self.assertEqual([folder for folder in HUMAN_RULE_DIRS if not (ROOT / folder).is_dir()], [])
+3 -2
View File
@@ -36,7 +36,8 @@ import sys
import time
from rule_hook.call import applied, Call, FILE_TOOLS, parsed_call, text
from rule_hook.rules import Breach, command_breaches, commits, file_breaches, rules_help, verdict, Verdict
from rule_hook.rules import Breach, command_breaches, file_breaches, Outcome, rules_help, verdict
from git_command import commits
from failure import Failure
from rule_hook.override_log import Log, log_path, logged, print_overrides, write_override
from shell_command import simple_commands
@@ -79,7 +80,7 @@ def breaches_of(call: Call, home: str) -> tuple[str, str, list[Breach]] | None:
return added, path, file_breaches(path, before, added, after)
def answer(judged: Verdict, what: str, now: float) -> int:
def answer(judged: Outcome, what: str, now: float) -> int:
for message in judged.messages:
print(message, file=sys.stderr)
if judged.blocked:
+18 -10
View File
@@ -6,15 +6,15 @@ 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"
@dataclasses.dataclass(frozen=True)
class Entry:
class LogLine:
"""One line of the log, its fields tab-separated in this order."""
at: str
branch: str
@@ -28,12 +28,12 @@ class Entry:
return "\t".join(" ".join(field.split()) for field in dataclasses.astuple(self)) + "\n"
def parsed_entry(line: str) -> Entry | None:
def parsed_entry(line: str) -> LogLine | None:
fields = line.rstrip("\n").split("\t")
return Entry(*fields) if len(fields) == len(dataclasses.fields(Entry)) else None
return LogLine(*fields) if len(fields) == len(dataclasses.fields(LogLine)) else None
def this_chunks(entry: Entry, reflog: set[str], branch: str, on_default: typing.Callable[[str], bool]) -> bool:
def this_chunks(entry: LogLine, reflog: set[str], branch: str, on_default: typing.Callable[[str], bool]) -> bool:
"""Whether the override is the current branch's: its commit is in the branch's reflog, which keeps a commit an amend or a rebase replaced, follows `git branch -m`, and holds no other branch's commit."""
if entry.commit == "":
return True
@@ -62,7 +62,7 @@ def log_path(directory: str) -> Log | Failure | None:
return Log(pathlib.Path(str(common)) / LOG, str(branch) or "HEAD", "" if isinstance(head, Failure) else head)
def write_override(log: Log, entry: Entry) -> Failure | None:
def write_override(log: Log, entry: LogLine) -> Failure | None:
try:
# No symlink, and no FIFO to hang on: the checkout, and so its git directory, may come from anyone.
descriptor = os.open(log.path, os.O_WRONLY | os.O_APPEND | os.O_CREAT | os.O_NOFOLLOW | os.O_NONBLOCK, 0o600)
@@ -79,8 +79,8 @@ def write_override(log: Log, entry: Entry) -> Failure | None:
return None
def logged(log: Log, breach: Breach, reason: str, what: str, now: float) -> Entry:
return Entry(utc(now), log.branch, log.head, breach.rule, reason, what)
def logged(log: Log, breach: Breach, reason: str, what: str, now: float) -> LogLine:
return LogLine(utc(now), log.branch, log.head, breach.rule, reason, what)
def print_overrides(directory: str) -> int:
@@ -92,8 +92,7 @@ def print_overrides(directory: str) -> int:
branch = found if isinstance(found, str) and found else "HEAD"
reflog = git(directory, "reflog", "show", "--format=%H", branch)
head = git(directory, "rev-parse", "HEAD")
# A reflog missing HEAD is off or expired, and would hide this chunk's overrides.
unread = reflog if isinstance(reflog, Failure) else head if isinstance(head, Failure) else None if head in reflog.split() else Failure("it does not hold HEAD")
unread = unread_reflog(reflog, head)
if unread:
print(f"rule-hook overrides cannot read the branch's reflog, so it cannot tell which overrides are this chunk's: {unread.reason}", file=sys.stderr)
return 1
@@ -107,6 +106,15 @@ def print_overrides(directory: str) -> int:
return 0
def unread_reflog(reflog: str | Failure, head: str | Failure) -> Failure | None:
if isinstance(reflog, Failure):
return reflog
if isinstance(head, Failure):
return head
# A reflog missing HEAD is off or expired, and would hide this chunk's overrides.
return None if head in reflog.split() else Failure("it does not hold HEAD")
def default_branch(directory: str) -> str | None:
return next((name for name in ("origin/HEAD", "main", "master") if not isinstance(git(directory, "rev-parse", "--verify", "--quiet", name), Failure)), None)
+5 -58
View File
@@ -3,7 +3,8 @@ import posixpath
import re
import typing
from shell_command import resolved, Simple
from git_command import commits
from shell_command import Simple
RuleName = typing.Literal["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "todo-rank-check"]
@@ -50,8 +51,6 @@ FROM = re.compile(r"^[ \t]*FROM[ \t]+(?:--\S+[ \t]+)*(\S+)(?:[ \t]+AS[ \t]+(\S+)
COPIED = re.compile(r"^[ \t]*COPY[ \t].*?--from=(\S+)", re.IGNORECASE | re.MULTILINE)
IMAGE = re.compile(r"^[ \t]*(?:-[ \t]+)?(?:image|container):[ \t]*[\"']?([^\s\"'#{]+)", re.MULTILINE)
USES = re.compile(r"^[ \t]*(?:-[ \t]+)?uses:[ \t]*[\"']?([^\s\"'#]+)", re.MULTILINE)
# git's global options that take a value as the next word.
GIT_VALUED = {"-C", "-c", "--exec-path", "--git-dir", "--namespace", "--work-tree"}
@dataclasses.dataclass(frozen=True)
@@ -63,14 +62,7 @@ class Breach:
@dataclasses.dataclass(frozen=True)
class Commit:
directory: str
messages: list[str]
from_file: bool
@dataclasses.dataclass(frozen=True)
class Verdict:
class Outcome:
messages: list[str]
blocked: bool
# Each breach an override let through, with its reason; logged only when the call goes through.
@@ -84,7 +76,7 @@ def overrides(written: str) -> tuple[dict[str, str], list[str]]:
return granted, [f"rule-override {rule}: {reason}" for rule, reason in given if rule not in granted]
def verdict(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> Verdict:
def verdict(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> Outcome:
granted, malformed = overrides(written)
blocking = [breach for breach in breaches if breach.rule not in granted]
messages = [f"`{marker}` names no rule below, or gives no reason." for marker in malformed] if blocking else []
@@ -93,52 +85,7 @@ def verdict(breaches: list[Breach], written: str, markdown: bool, bash: bool) ->
details = "; ".join(breach.detail for breach in blocking if breach.rule == rule)
marker = f"<!-- rule-override {rule}: <reason> -->" if markdown else f"# rule-override {rule}: <reason>"
messages.append(f"Blocked by rule {rule}: {details}. The rule: {RULES[rule].holds}. Where it does not fit this case, add `{marker}` to {where}; larv-review rules on the reason.")
return Verdict(messages, bool(blocking), [(breach, granted[breach.rule]) for breach in breaches if breach.rule in granted])
def commits(simples: list[Simple], home: str) -> list[Commit]:
found = []
for simple in simples:
invoked = git_subcommand(simple.words, simple.directory, home)
if invoked and invoked[0] == "commit":
found.append(Commit(invoked[2], *commit_message(invoked[1])))
return found
def git_subcommand(words: list[str], directory: str, home: str) -> tuple[str, list[str], str] | None:
"""A git command's subcommand, its arguments and the directory it runs in, after git's own options such as -C."""
if words[:1] != ["git"]:
return None
args = iter(words[1:])
for word in args:
if word in GIT_VALUED:
value = next(args, "")
directory = resolved(directory, value, home) if word == "-C" else directory
elif not word.startswith("-"):
return word, list(args), directory
return None
def commit_message(args: list[str]) -> tuple[list[str], bool]:
"""git commit's messages, and whether it reads one from a file."""
messages = []
from_file = False
words = iter(args)
for word in words:
if word == "--":
break
name, equals, value = word.partition("=")
if name in ("--message", "--file"):
given = value if equals else next(words, "")
elif word.startswith("-") and not word.startswith("--") and (flags := [flag for flag in word[1:] if flag in "mF"]):
# A cluster such as -am: the valued flag takes the rest of the word, or else the next word.
name = "--message" if flags[0] == "m" else "--file"
given = word[word.index(flags[0]) + 1:] or next(words, "")
else:
continue
messages += [given] if name == "--message" else []
from_file = from_file or name == "--file"
return messages, from_file
return Outcome(messages, bool(blocking), [(breach, granted[breach.rule]) for breach in breaches if breach.rule in granted])
def command_breaches(command: str, simples: list[Simple], home: str) -> list[Breach]:
+6 -5
View File
@@ -8,10 +8,11 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from rule_hook.rules import blocks, Breach, command_breaches, Commit, commit_message, commits, file_breaches, overrides, verdict
from rule_hook.rules import blocks, Breach, command_breaches, file_breaches, overrides, verdict
from git_command import Commit, commit_message, commits
from test_rank_todo import DECISIONS, README, TODO
from rule_hook.override_log import Entry, parsed_entry, this_chunks
from test_env import isolated_env
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
from shell_command import simple_commands
HOOK = pathlib.Path(__file__).resolve().parents[1] / "rule-hook"
@@ -139,8 +140,8 @@ class Overrides(unittest.TestCase):
class OverrideLog(unittest.TestCase):
def test_an_entry_reads_back_as_written(self):
entry = Entry("2026-10-13T00:00:00Z", "chunk", "c1", "image-pin", "the vendor\ttags no patch", "Dockerfile")
self.assertEqual(parsed_entry(entry.line()), Entry("2026-10-13T00:00:00Z", "chunk", "c1", "image-pin", "the vendor tags no patch", "Dockerfile"))
entry = LogLine("2026-10-13T00:00:00Z", "chunk", "c1", "image-pin", "the vendor\ttags no patch", "Dockerfile")
self.assertEqual(parsed_entry(entry.line()), LogLine("2026-10-13T00:00:00Z", "chunk", "c1", "image-pin", "the vendor tags no patch", "Dockerfile"))
self.assertIsNone(parsed_entry("a\tb"))
def test_an_override_is_the_chunk_s_by_its_reflog_and_name(self):
@@ -148,7 +149,7 @@ class OverrideLog(unittest.TestCase):
cases = [("chunk", "c1", True), ("other", "c1", True), ("other", "c9", False), ("chunk", "base", True), ("other", "base", False), ("other", "", True)]
for branch, commit, expected in cases:
with self.subTest(branch=branch, commit=commit):
self.assertEqual(this_chunks(Entry("t", branch, commit, "image-pin", "r", "w"), {"base", "c1"}, "chunk", on_default), expected)
self.assertEqual(this_chunks(LogLine("t", branch, commit, "image-pin", "r", "w"), {"base", "c1"}, "chunk", on_default), expected)
class Hook(unittest.TestCase):
+261
View File
@@ -1175,3 +1175,264 @@ Inherited architect, decided by:
- Locality: `bin/rule_hook/main.py:82` `answer`: resolve-then-write order carried by one comment, and `Breach.directory` set deep in rules.py decides which log gets a line
- Locality: `bin/rule_hook/rules.py:108` `git_subcommand`: a second answer to "is this a git commit" beside `measure.py`'s `COMMIT` regex
- Locality: `bin/rule_hook/todo_check.py:7` `import rank_todo`: a change to rank_todo's check changes what the hook blocks
## 2026-10-12T22:43:27Z, PR #242 at 63b0759, against 4cc9953
Ruling: better
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | better | same | better | better | better |
| Inherited architect | better | same | same | same | better |
Mid A, decided by:
- Shape, Navigation: `bin/shell_command.py:20` `simple_commands`: splitting a shell command and tracking each `cd` is one module named for what it holds, where `shell_reads.py` spread it over three helpers
- Shape: `bin/reading_cost/measure.py:7` `measure` imports: `resolved` comes from `shell_command`, no longer from a module named for shell reads
- Self-sufficiency, Navigation: `bin/rule_hook/main.py:1` module docstring: each rule's `holds` and `checked` build `--help`, so a blocked commit leads to one authority
- Navigation: `CLAUDE.md:50` "Topic rules": each topic's rules have their own file and the section says which loads with what, where the old charter was one 167-line wall
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: git argument parsing sits in `rules`, while `git.py` only runs git
- Locality: `bin/loop_claude/project/records.py:14` `read_records`: the rules folder is spelled twice, as `HUMAN_RULES_DIR` and as `claude_md.parent / "rules"`
- Shape: `bin/rule_hook/todo_check.py:7` `import rank_todo`: one tool imports another tool's script, though the README states it
Inherited architect, decided by:
- Navigation, Overall: `CLAUDE.md:50` "Topic rules": each topic has a file named for it and scoped by `paths:`, indexed in four lines, so a rule is one step from its question
- Navigation: `bin/shell_command.py:20` `simple_commands`: command splitting has one obvious home, used by the hook and by reading-cost
- Locality: `bin/shell_command.py:31` `segments`: the shared parser means a change for the hook moves reading-cost's figures, and nothing at `reading_cost/` says so
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: a module named `rules` parses git's command line, and `Breach.directory` carries the override log's concern
- Shape, Locality: `bin/rule_hook/override_log.py:96` `print_overrides`: a chained ternary of four outcomes beside `this_chunks`, whose reflog rule needs both comments held at once
- Locality: `bin/rule_hook/main.py:82` `answer`: resolve-before-write holds only by the loops' arrangement, stated in one comment
- Self-sufficiency: `bin/rule_hook/main.py:1` module docstring: the rules print from `RULES`, while `CLAUDE.md:67` now sends a charter reader to `rules.py` for the pinning rule
- Locality: `bin/rule_hook/todo_check.py:10` `todo_breaches`: a change to `rank_todo`'s output reaches a hook that can block every commit
## 2026-10-12T22:56:19Z, PR #242 at f351e14, against 4cc9953
Ruling: same
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | same | same | worse | same | same |
| Inherited architect | same | same | same | same | same |
Mid A, decided by:
- Shape: `bin/rule_hook/rules.py:99` `commits`: a file named for the rule table parses git's command line, while `git.py` only runs git
- Shape: `bin/rule_hook/override_log.py:82` `logged`: builds an Entry and logs nothing; `holds` is an is-ancestor test and `this_chunks` needs two comments
- Shape: `bin/shell_command.py:20` `simple_commands`: shell lexing moved out of `shell_reads.py`, which now holds only what counts as a read
Inherited architect, decided by:
- Locality, Shape: `bin/shell_command.py:20` `simple_commands`: one shared lexer, though a fix for the hook shifts reading-cost's figures unseen
- Locality, Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: a second definition of a commit beside `measure.py`'s `COMMIT` regex, in a module that also holds the rule table and verdict
- Locality: `bin/rule_hook/override_log.py:86` `print_overrides`: a four-way chained conditional beside `this_chunks`' reflog rule
- Locality: `skills/larv-review/SKILL.md:56` "Opt-out": a third skip mechanism to cross-check beside "Precedent, then ask" and "Suspended"
- Navigation, Self-sufficiency: `bin/rule_hook/main.py:46` `main`: a blocked call leads cold to the rule, its text and the override syntax
- Self-sufficiency, Navigation: `CLAUDE.md:50` "Topic rules": each topic's rules are found by file name, while `CLAUDE.md:67` sends a reader to `rules.py` for the pinning rule's full text
## 2026-10-12T23:45:13Z, PR #245 at b568522, against 4cc9953
Ruling: worse
Fell: Navigation, Locality. Under the floor of 7.0: Locality 6.88, so the same ruling counts as worse.
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | same | worse | same | same | same |
| Inherited architect | worse | worse | same | same | worse |
| Maintainability senior | worse | worse | same | same | worse |
| Junior A | worse | same | same | same | same |
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Junior A | 7 | 6.5 | 6.5 | 6.5 | 6.5 |
| Mid A | 7.5 | 7 | 7 | 6.5 | 7 |
| Maintainability senior | 7.5 | 7 | 7 | 7 | 7 |
| Inherited architect | 7.5 | 7 | 6.5 | 7 | 7 |
| Mean | 7.38 | 6.88 | 6.75 | 6.75 | 6.88 |
Mid A, decided by:
- Locality: `agents/prose-reviewer.md:9` "The bar": the prose bar now combines CLAUDE.md → "Prose", the standards files and path-matched rules/ files, and `prose.md` splits one concept across two files
- Locality: `bin/loop_claude/project/records.py:11` `HUMAN_RULE_NAMES`: what the judge reads depends on the files in two folders, and `QUOTE_SOURCES` slices the tuple to word it
- Overall, Shape: `bin/shell_command.py:20` `simple_commands`: `shell_reads` drops its own lexer for a shared module, at the cost of denser regexes
- Shape: `bin/rule_hook/rules.py:99` `commits`: git argument parsing sits in a module named for the rule registry
- Self-sufficiency: `bin/rule_hook/main.py:1` module docstring: each rule carries its own text and --help is generated from it
- Navigation: `CLAUDE.md:36` "Topic rules": a router to rules/, and the standards are a third home for instructions, balanced by README's rule-hook entry
Inherited architect, decided by:
- Navigation, Locality: `CLAUDE.md:21` "Prose": each priority is split between CLAUDE.md and `skills/larv-review/standards/prose.md`, and nothing in CLAUDE.md points to the second
- Navigation: `agents/prose-reviewer.md:9` "The bar": the bar is a three-way split, the worst place to go from a flag to the rule that fired
- Locality: `bin/loop_claude/project/records.py:10` `HUMAN_RULE_DIRS`: the judge globs one skill's internal folder, and moving it silently empties the records
- Locality: `bin/loop_claude/cycle/prompts.py:5` `QUOTE_SOURCES`: a tuple sliced with [:-1] and [-1] to place an "or", worked out across two modules
- Locality, Shape: `bin/shell_command.py:20` `simple_commands`: lexing moved out of `shell_reads` into a shared module, the change's clearest gain
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: git command parsing sits in rules.py while git.py only runs git
- Navigation: `README.md:75` "Tools": the new tool is easy to find cold, and --help renders each rule
- Locality: `bin/rule_hook/override_log.py:96` `print_overrides`: a three-level conditional expression, and "this chunk" needs reflog semantics
Maintainability senior, decided by:
- Navigation, Locality: `skills/larv-review/standards/prose.md:3` "Prose, in detail": it expands CLAUDE.md's priorities by number, so it reads only with CLAUDE.md open, and a change to a priority edits two files
- Navigation: `CLAUDE.md:36` "Topic rules": the router lists only rules/, so finding where comments or "A false claim is a bug" live needs README line 3 or the Vocabulary
- Locality: `skills/larv-review/standards/quality.md:7` "Quality": each standard points at two or three other files, and CLAUDE.md:50 paraphrases the README rule without pointing to it
- Locality: `bin/loop_claude/project/records.py:9` `HUMAN_RULE_NAMES`: a derived tuple sliced by position feeds three prompts, and the folder list must match hand-kept copies in CLAUDE.md and AGENTS.md
- Locality: `bin/shell_command.py:31` `segments`: reading-cost and rule-hook share one parser, so a fix for the hook moves the reading-cost figures
- Navigation: `bin/rule_hook/main.py:1` module docstring: from a blocked commit to the rule is easy through --help and `RULES`
Junior A, decided by:
- Navigation: `CLAUDE.md:36` "Topic rules": the moved rules are not routed from here, and nothing in CLAUDE.md points to `standards/quality.md`
- Navigation: `skills/larv-review/standards/prose.md:3` "Prose, in detail": one rule lives in two files, and a reader must know the second exists
- Navigation: `agents/prose-reviewer.md:9` "The bar": working out which documents bind a review takes a small search
Junior A, hardest first:
- `skills/larv-review/SKILL.md:64` "Round cap": with "Re-entry" and "Fresh", four sections held at once to count a round
- `bin/larv_review/record.py:14` `record_ruling`: four exits, its terms defined in three other files
- `bin/rule_hook/override_log.py:36` `this_chunks`: reflog semantics, and a three-way conditional at :96
- `bin/shell_command.py:31` `segments`: dense regexes and a redirect flag, output unpredictable by reading
- `bin/loop_claude/cycle/judge.py:16` `JUDGE_RULES`: the judge's prompt assembled from three files
- `bin/larv_review/plan.py:8` `scoring_run_due`: set arithmetic over four inputs
Mid A, hardest first:
- `bin/larv_review/record.py:14` `record_ruling`: four outcomes, the counting rule only in the help
- `skills/larv-review/SKILL.md:64` "Round cap": interlocking with "Re-entry" and "Fresh"
- `bin/loop_claude/cycle/judge.py:127` `run_judge`: two mismatches handled two ways; `QUOTE_SOURCES` slices a tuple
- `bin/loop_claude/cycle/states.py:69` `transition`: a counter threaded through three states
- `bin/rule_hook/override_log.py:86` `print_overrides`: three chained conditionals
- `bin/larv_review/ruling_base.py:4` `measured_commit`: rests on the docstring and the help
Maintainability senior, hardest first:
- `skills/larv-review/SKILL.md:91` "Architecture": six conditions held at once, and the no-rescore file list only in prose
- `bin/larv_review/record.py:14` `record_ruling`: five modules open at once
- `bin/larv_review/ruling_base.py:4` `measured_commit`: why same does not move the base, on a second read
- `bin/loop_claude/cycle/judge.py:16` `JUDGE_RULES`: what the judge accepts spans three files nothing checks agree
- `bin/rule_hook/override_log.py:36` `this_chunks`: reflog membership; two `default_branch` functions differ
- `bin/rank_todo.py:374` `rank_details`: regex surgery on markdown
Inherited architect, would restructure first:
- `bin/loop_claude/project/records.py:16` `read_records`: a missing rule folder is skipped silently
- `bin/rule_hook/override_log.py:110` `default_branch`: a second default-branch rule, unlike larv-review's
- `bin/loop_claude/loop/main.py:16` module docstring: --help restates the retry constants as prose
- `bin/larv_review/rounds.py:4` `PASSES`: the round cap and rescores live in the skill's prose
- `bin/comprehension_history.py:42` `Entry`: one name over five concepts across the repo
## 2026-10-13T05:52:26Z, PR #245 at f6d5ea7, against 4cc9953
Ruling: worse
Fell: Shape. Under the floor of 7.0: Shape 6.75, so the same ruling counts as worse.
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | same | same | worse | same | same |
| Inherited architect | same | worse | worse | same | worse |
| Maintainability senior | same | worse | same | same | same |
| Junior A | better | same | worse | same | same |
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Junior A | 7 | 6.5 | 7 | 6 | 6.5 |
| Mid A | 7.5 | 6.5 | 7 | 6.5 | 7 |
| Maintainability senior | 7.5 | 7 | 6.5 | 6.5 | 7 |
| Inherited architect | 7 | 6.5 | 6.5 | 7.5 | 7 |
| Mean | 7.25 | 6.63 | 6.75 | 6.63 | 6.88 |
Mid A, decided by:
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: a module named for the rule catalogue also parses git arguments, override markers and verdicts
- Shape: `bin/rule_hook/override_log.py:96` `print_overrides`: three chained conditional expressions decide whether the reflog is readable
- Shape: `bin/rule_hook/rules.py:73` `Verdict`: two unrelated `Verdict` types, and `logged`, `existing` and `holds` do not say what they compute
- Shape: `bin/loop_claude/project/records.py:11` `HUMAN_RULE_NAMES`: a nested comprehension where one constant stood, though `either` keeps the prompt readable
- Shape: `bin/shell_command.py:20` `simple_commands`: a flat `shell_reads` over a denser shared lexer, a small net change
Inherited architect, decided by:
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: rules.py mixes six jobs while git.py only runs git, and `reading_cost/measure.py:9` `COMMIT` is a second commit check
- Locality: `CLAUDE.md:21` "Prose": the worker's core and `skills/larv-review/standards/prose.md` are two copies that word the contrastive tail differently
- Locality: `bin/loop_claude/project/records.py:10` `HUMAN_RULE_DIRS`: the judge hard-codes larv-review's folder, and a test imports the constant back out
- Locality, Shape: `bin/rule_hook/override_log.py:86` `print_overrides`: a three-deep conditional, reflog semantics in a docstring, and the git-dir lookup done again
- Shape: `bin/rule_hook/main.py:82` `answer`: a two-phase pass and an unnamed 3-tuple from `breaches_of`
- Locality, Shape: `skills/larv-review/SKILL.md:56` "Opt-out": a third skip mechanism, three sections held at once
Maintainability senior, decided by:
- Locality: `CLAUDE.md:21` "Prose": the prose rules exist twice, and `CLAUDE.md:30` words the contrastive tail differently from `skills/larv-review/standards/prose.md:13`
- Locality: `rules/decisions.md:9` "Decisions": the decision rule is split between a worker file and `skills/larv-review/standards/comments.md:9` "Where a choice goes"
- Locality: `bin/rule_hook/override_log.py:110` `default_branch`: a second default-branch rule and git runner, unlike larv-review's
- Locality: `bin/loop_claude/project/records.py:10` `HUMAN_RULE_DIRS`: one folder list feeds the judge, the quote sources and a test, and `loop/main.py` spells it out by hand
- Locality: `bin/rank_todo.py:114` `check_failures`: copies the read, rank and compare flow `main` still runs
- Locality: `bin/rule_hook/rules.py:99` `commits`: computed on two paths for one command
Junior A, decided by:
- Navigation: `CLAUDE.md:38` "Topic rules": a short router to one small file per topic
- Navigation: `README.md:75` "Tools": names rule-hook and what runs it
- Shape: `bin/rule_hook/rules.py:108` `git_subcommand`: the rule table's file also parses git arguments, Dockerfiles and ignore files
- Shape: `bin/rule_hook/override_log.py:96` `print_overrides`: three failure cases in one chained conditional
- Shape: `bin/rule_hook/main.py:38` imports: the entry point pulls from six modules
- Navigation: `bin/shell_command.py:20` `simple_commands`: shell tokenizing has one home
Junior A, hardest first:
- `bin/larv_review/record.py:14` `record_ruling`: five files held at once, four outcomes
- `bin/rule_hook/override_log.py:36` `this_chunks`: reflog semantics and a three-level conditional at :96
- `skills/larv-review/SKILL.md:64` "Round cap": rules pointing at each other, exceptions on exceptions
- `bin/loop_claude/cycle/judge.py:127` `run_judge`: two quote checks with different tolerance
- `bin/shell_command.py:31` `segments`: heredoc and comment regexes and a redirect flag at once
- `bin/larv_review/plan.py:8` `scoring_run_due`: plan before and after, shipped IDs and tag state
Mid A, hardest first:
- `skills/larv-review/SKILL.md:64` "Round cap": a dozen interlocking conditions simulated in the head
- `bin/larv_review/record.py:14` `record_ruling`: branch order carries meaning, terms defined only in the skills
- `bin/loop_claude/cycle/judge.py:16` `JUDGE_RULES`: the prompt assembled from three files
- `bin/comprehension_history.py:110` `seat_places`: a parser with a flag reset by any unindented line
- `bin/rule_hook/override_log.py:86` `print_overrides`: reflog semantics and a chained conditional
- `bin/shell_command.py:31` `segments`: regex-heavy, no inline samples
Maintainability senior, hardest first:
- `skills/larv-review/SKILL.md:29` "Passes": a rule engine in prose, its mechanised half unmarked
- `bin/larv_review/record.py:14` `record_ruling`: four exits over two parallel vote maps
- `bin/loop_claude/cycle/judge.py:16` `JUDGE_RULES`: the judge's contract built across three files
- `bin/rule_hook/override_log.py:86` `print_overrides`: reflog membership and a three-level conditional
- `bin/shell_command.py:31` `segments`: five concerns in one pass, two tools depend on it
- `bin/transcript_archive/write.py:13` `archive`: one invariant held across three files
Inherited architect, would restructure first:
- `bin/larv_review/rounds.py:8` `round_counts`: the round cap is enforced only by prose across five places
- `bin/larv_review/git.py:21` `default_branch`: one of two default-branch rules and five git runners
- `bin/loop_claude/loop/main.py:8` module docstring: the rule-folder list hand-written in four places
- `bin/rule_hook/rules.py:73` `Verdict`: one name over three concepts, like `Entry` and `ruling`
- `bin/rule_hook/rules.py:108` `git_subcommand`: a second commit detector beside `reading_cost/measure.py:9` `COMMIT`
## 2026-10-13T06:49:43Z, PR #245 at a796bb3, against 4cc9953
Ruling: same
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | same | same | same | same | same |
| Inherited architect | same | worse | better | same | same |
Mid A, decided by:
- Locality: `bin/git_command.py:16` `commits`: one shared parser replaces reading-cost's lexer and regex, at the cost of a parser shared with rule-hook
- Locality, Self-sufficiency: `skills/larv-review/standards/prose.md:3` "Prose": a full copy beside CLAUDE.md's core, against small single-topic files
- Navigation: `CLAUDE.md:38` "Topic rules": three homes for a rule, all listed in the README map
- Shape: `bin/rule_hook/git.py:11` `git`: a bounded package, but `rule_hook/git.py` beside `git_command.py` and some vague names
Inherited architect, decided by:
- Locality: `CLAUDE.md:21` "Prose": two spellings of the prose rules, already worded differently
- Locality: `agents/prose-reviewer.md:9` "The bar": the bar is assembled from three sources and path globs
- Locality: `bin/loop_claude/project/records.py:16` `read_records`: any file added to the rule folders lengthens the judge's records
- Locality: `bin/rule_hook/override_log.py:36` `this_chunks`: reflog, default branch and logged branch held at once
- Shape: `bin/reading_cost/measure.py:43` `commit_time`: reading-cost and rule-hook share one parser, one concept with one implementation
- Shape: `bin/rank_todo.py:114` `check_failures`: --check pulled out so rule-hook reuses it
+29 -3
View File
@@ -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`, `~/.claude/rules/` and larv-review's standards, 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,7 +12,11 @@
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-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.
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: the judge reads the live `~/.claude`, which holds the write only once it merges and the checkout is pulled. 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.
2026-10-13, implementing todo item 95: the judge reads each file under `~/.claude/rules/` whole too, as the `rules/:` decision moved topic rules there, for the reason it reads `CLAUDE.md` whole, and a worker's write to one does not count as recording an answer, as a write to `CLAUDE.md` does not.
2026-10-13, implementing todo item 104: the judge reads each file under `~/.claude/skills/larv-review/standards/` whole too, for the same reason, as the `worker:` decision moved rules there.
## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
@@ -117,7 +121,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
@@ -138,3 +142,25 @@ lilleman decided to ship each of these under the floor on the day listed. Each l
## rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override <rule>: <reason>` marker overrides one, and larv-review's overrides pass rules on each override before merge
2026-10-12, lilleman. Serves goals 1.2 and 1.3. Anthropic's best-practices page calls `CLAUDE.md` advisory and hooks deterministic, so a rule that must hold every time moves into `bin/rule-hook`, and `CLAUDE.md` keeps it only where the hook cannot check it. A Claude Code hook ties the check to one vendor ("Prefer the vendor-neutral option", `principles/technical-principles.md`), which is the target itself here: this repo configures Claude Code. What the tie buys: the hook blocks before a write lands, Edit and Write calls included, in every project with no per-repo install; a git `commit-msg` hook sees only commits, and CI sees them only after the push. The hook checks each write, so the agent fixes the line it just wrote; checking the staged diff at commit time would also cover files a Bash command writes, at the cost of later feedback. The marker's spelling was picked by a panel of three fresh readers, two to one. Each override is logged in the checkout's git directory, which is never pushed (goal 4). The plan had loop-claude's judge to rule on overrides inside a loop; lilleman approved larv-review's overrides pass in every run, because it rules before merge and an outrageous override still reaches the human through its ask. Valid while a PreToolUse hook that exits 2 blocks the call and hands its stderr to the model, and while an agent commits through Claude Code's Bash tool.
## rules/: `CLAUDE.md` holds the worker's rules that no file path can scope, and each topic's rules for the worker live in a `rules/` file that Claude Code loads by its `paths:` frontmatter
2026-10-13, lilleman through todo item 95, implemented by claude. Serves goals 1.3 and 1.4. Every session loaded `CLAUDE.md` whole, about 4,200 words. Anthropic's memory docs (code.claude.com/docs/en/memory) say a longer file "reduce[s] adherence", and IFScale (arxiv.org/abs/2507.11538) measures adherence falling as the instruction count grows. A rule goes in `CLAUDE.md` when no file path marks the moment it is needed: the working loop, prose that chat follows, commits, and API spec text, which may sit in code. Every other topic gets a file under `rules/` whose `paths:` name the files that topic is about.
A session that writes a file has read one first, since Edit needs a Read, except for a new file written before any read; the "Topic rules" line says to read the rule file first there. 2026-10-13, todo item 104: the rules a reviewer applies and the worker need not load, those for comments and READMEs among them, moved out of `rules/`, per the `worker:` decision.
Claude Code's user-level rules tie this repo to Claude Code, which "Prefer the vendor-neutral option" (`principles/technical-principles.md`) allows here because this repo configures Claude Code itself. The tie buys topic rules that load without a pointer the session must follow.
Valid while Claude Code loads `~/.claude/rules/*.md` in every project, a path-scoped one when a session reads, writes or edits a matching file, or reads one with a single-file Bash command such as `cat`, and after a write only once the write is done. On 2026-10-13 a smoke test confirmed both triggers: a rule in `~/.claude/rules/` with `paths: ["**/smoke-target.txt"]` held a secret word. `claude -p` in a project under `/tmp` printed the word after reading the target with the Read tool, and after creating it with the Write tool. A control run that opened no file printed none. Per the docs, a path-scoped rule leaves the context at compaction and returns at the next matching read.
## worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/`
2026-10-13, lilleman through todo item 104, implemented by claude. Serves goals 1.4 and 1.5. Like red, green, refactor: the worker makes the item work, and the review passes raise it to the bar. A loop-claude worker loaded `CLAUDE.md` and every file under `rules/`, 4,247 words, and `CLAUDE.md` told it to read `technical-principles.md` too, 2,426 words more. The reviewers read the principles anyway, and a finding against one names it.
The worker keeps what it needs to write its own work. Each project's decision titles stay in its `AGENTS.md`, since a worker that misses a decision builds the wrong behaviour. A core of "Prose" stays in `CLAUDE.md`, since no reviewer reads the worker's chat. lilleman chose both on 2026-10-13. The rules for writing Goals and Audience, `todo.md` items and decisions stay in `rules/`, since writing those is the worker's job. `bin/rule-hook` stays: it blocks what a program can check, at no context cost. "Quality", the rules for comments and READMEs, and the examples behind "Prose" moved to `skills/larv-review/standards/`, which no path loads. The prose and stability reviewers read them, and so does loop-claude's judge. They sit beside larv-review, whose passes apply them; `principles/` stays where it is, since the principles auditor reads it per file.
A finding against a principle names it, so the worker reads only that one when it fixes or declines the finding. The worker still writes a failing test first wherever a test can check the change, since no reviewer can make a test come first; lilleman widened it from changes to code on 2026-10-13. A chunk that changes no code, config or test, such as one that only plans, meets no principles review; the chunk that implements its items does. The prose reviewer checks that a doc sorts a list whose order carries no meaning.
The item also cut the rule that a session proposes new rules for `CLAUDE.md` and `rules/` and restructures them after each change: changes to these rules go through this repo's chunks and their reviews, like any other change.
Valid while review rounds per pass do not rise. A principle found late, such as functional core, can cost a rewrite within a pass's three rounds. `todo.md` item 105 compares rounds per pass and reading cost in loop-claude's archive for the five chunks before and after this one.
+34
View File
@@ -111,3 +111,37 @@ Read most (opens and searches):
- `skills/larv-review/SKILL.md` 1
- `skills/larv-review/review-findings.md` 1
- `todo.md` 1
## Reading cost, chunk 00ad6c532a93, finished 2026-10-12T22:15:42Z
172162 new input tokens before the first commit.
Read most (opens and searches):
- `.gitignore` 2
- `bin/loop_claude/cycle/prompts.py` 2
- `bin/rank_todo.py` 2
- `skills/larv-review/SKILL.md` 2
- `.claude/settings.json` 1
- `AGENTS.md` 1
- `CHANGELOG.md` 1
- `CLAUDE.md` 1
- `README.md` 1
- `bin/failure.py` 1
## Reading cost, chunk 8c8ffb885ec4, finished 2026-10-12T23:06:46Z
106562 new input tokens before the first commit.
Read most (opens and searches):
- `CLAUDE.md` 11
- `todo.md` 7
- `skills/larv-review/SKILL.md` 5
- `bin/loop_claude/loop/main.py` 4
- `bin/loop_claude/test_loop_claude.py` 4
- `README.md` 3
- `bin/loop_claude/project/records.py` 3
- `docs/decisions.md` 3
- `CHANGELOG.md` 2
- `bin/loop_claude/cycle/judge.py` 2
+11 -6
View File
@@ -12,6 +12,16 @@
- Functions: a function takes what it needs as arguments and returns what it produces. One that works only after another has set up shared state, or leaves state for the next to find, is entangled with it. BANNED: `validate(conf)` that fills defaults `send(conf)` relies on. GOOD: `send(withDefaults(conf))`.
- Tests and tooling: a test, script or pipeline stage that passes only because another ran first is entangled; it states what it needs and gets it.
- Proximity is not a reason. Reusing a listener, config file, table, module or service because it is already there, when the new thing has no relationship to it, is how entanglement gets in. If you cannot name the seam, there is none.
* Functional core, imperative shell — a core rule beside "Compose, do not entangle": no other principle overrides it.
- Decisions live in pure functions, data in and data out; the shell around them performs the effects and holds no branching of its own.
- Every side effect comes from outside: output, time, randomness, network and storage are injectable, so a test runs exactly the code production runs.
- BANNED: `new Date(entry.msTimestamp ?? Date.now())` in a formatter; a test swapping `globalThis.fetch`. GOOD: the clock is a parameter, defaulted to the system clock only where the program is wired together.
- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. An entrypoint reaching into a payload to decide *what to do* is the smell. BANNED: `if (body.tx.source === 'notification') { /* drop, skip enqueue */ }` in a route handler. GOOD: the entrypoint forwards `source` on the event → the service decides drop-vs-process and returns a result → the entrypoint maps that result to a status code.
* Prefer deep modules: a small, intuitive interface in front of a lot of hidden work.
- A caller should know what a call does and what it returns, without knowing how it does it. `fs.writeFile("notes.txt", data)` hides opening the file, encoding, buffering, permissions and the disk itself. Yet anyone reading that line knows the outcome: the data is written, or the call fails and says why.
- A module hides how it works, never what it depends on: what "Functional core, imperative shell" injects stays injected.
- A shallow module costs more to learn than it saves. BANNED: a wrapper that only renames the function it calls; a module whose callers must make three calls in an order nothing but their memory enforces. GOOD: one call that does the whole job and handles the order itself.
- When this pulls against "Explicit over implicit", the deep module wins, unless hiding the work makes it harder for someone new to the project to tell what the call does.
* Make invalid states unrepresentable.
- Example: using a time-only type in the database when we actually want to store a time of day introduces risk for errors.
* Always store timestamps as full ISO datetime in UTC.
@@ -51,13 +61,8 @@
- A default earns its place where most callers want the same value, a wrong guess does no harm, and the caller can see and change it through a `--help` line or a documented option. Anything else is asked for.
- Defaults live at the program's edge: a CLI, a config file, a library's public API. A library still asks for every input that can change between runs, such as data, the clock and randomness; only the code that wires a program together, such as its CLI, defaults those, as "Functional core, imperative shell" asks.
- BANNED: a CLI that refuses to run until given `--data-path` and `--seed`, when nearly every run wants the shipped data and fresh randomness. GOOD: it uses the shipped data and fresh randomness unless a flag overrides them, and `--help` names those flags.
* Functional core, imperative shell.
- Decisions live in pure functions, data in and data out; the shell around them performs the effects and holds no branching of its own.
- Every side effect comes from outside: output, time, randomness, network and storage are injectable, so a test runs exactly the code production runs.
- BANNED: `new Date(entry.msTimestamp ?? Date.now())` in a formatter; a test swapping `globalThis.fetch`. GOOD: the clock is a parameter, defaulted to the system clock only where the program is wired together.
- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. An entrypoint reaching into a payload to decide *what to do* is the smell. BANNED: `if (body.tx.source === 'notification') { /* drop, skip enqueue */ }` in a route handler. GOOD: the entrypoint forwards `source` on the event → the service decides drop-vs-process and returns a result → the entrypoint maps that result to a status code.
* Deterministic order wherever order carries no meaning.
- Sort it, on a key that does not move: the name a line introduces, never where it came from. A sorted list is searchable, its diff shows only what changed, and two edits to it conflict only where they mean to.
- Sort such a list, on a key that does not move: the name a line introduces, never where it came from. Exception: `id` goes first. A sorted list is searchable, its diff shows only what changed, and two edits to it conflict only where they mean to.
- An import sorts on its first binding, not its path, so moving or renaming a module reorders nothing. Where lines already group by kind — type imports, host packages — the key sorts within each group.
* Keep It Simple, Stupid (KISS): keep solutions simple, so a reader new to the project understands each part on one read.
- Keep a size or complexity limit only while the comprehension panel's readers (`~/.claude/skills/comprehension-panel/`) find the code it flags hard.
+11
View File
@@ -0,0 +1,11 @@
---
paths:
- "**/AGENTS.md"
- "**/docs/decisions.md"
---
# Decisions: one home, each linked to a goal or a technical principle
**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.
**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.
+9
View File
@@ -0,0 +1,9 @@
---
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.
+17
View File
@@ -0,0 +1,17 @@
---
paths:
- "**/todo.md"
---
# Todo items (`todo.md`)
- **`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.
- **An item's release allows the bump that semver read strictly asks for.** An item that changes what exists needs a major, or before 1.0.0 a minor. One that only adds needs a minor, and a fix a patch.
- **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.
- **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.
+5 -5
View File
@@ -9,7 +9,7 @@ You orchestrate, fix, and ship; reviewers only report. Run every reviewer synchr
**Forge-neutral.** Five PR operations recur below: read a PR's diff, open a draft PR, read check status, mark ready, merge. Resolve the tooling from the remote per `~/.claude/CLAUDE.md` → "Git, commits, and PRs"; on any other forge, achieve the same intents through its CLI or API — discover how rather than assuming. A forge without a native draft state gets the closest equivalent (a `WIP:`/`Draft:` title prefix); note any approximation in the summary.
Words: `~/.claude/CLAUDE.md` → "Vocabulary". What a reviewer reports: ~/.claude/skills/larv-review/review-findings.md; how you resolve it: §3 → "Findings".
The bar a chunk is reviewed to: ~/.claude/skills/larv-review/standards/quality.md. Words: `~/.claude/CLAUDE.md` → "Vocabulary". What a reviewer reports: ~/.claude/skills/larv-review/review-findings.md; how you resolve it: §3 → "Findings".
**An ask** holds only what it asks about; the rest runs on while it waits. No user reachable (a headless run) → finish the rest, then leave the PR unmerged with the question and your recommendation in the summary, unless the ask's rule names another branch.
@@ -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/skills/larv-review/standards/comments.md` → "Where a choice goes": 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.
+2
View File
@@ -12,6 +12,8 @@ A reviewer reads and reports; it edits nothing. Read `docs/decisions.md` and `to
- ❓ **question** for the author: a finding you could not confirm goes here, not above.
- 🔀 **escalation** — names the reviewer whose concern it is (`product-owner-reviewer`, `systems-architect` or `/security-review`) and why, in one line.
A finding against a technical principle names it and the file under `~/.claude/principles/` it lives in.
## Verdict
A review's first line, derived from the findings:
+33
View File
@@ -0,0 +1,33 @@
# 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.
## Where a choice goes
**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. 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 `docs/decisions.md`, leaving its title in `AGENTS.md`'s list.
## 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.
+13
View File
@@ -0,0 +1,13 @@
# Prose
The full rules; `~/.claude/CLAUDE.md` → "Prose" keeps a core of them for the worker.
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.
1. **Easy to understand.** A reader with little time gets it on one read. Keep each sentence to one idea. Explain a term before using it, or use a plainer word. Never fold a clause into a noun phrase to save words. BANNED: `An empty earliest unreleased release with nothing shipped toward it is planned as this chunk`. GOOD: `When the next release has no items and no work has landed towards it, plan it.`
2. **Most important first**, judged by what this document's reader wants to know first. Put the most important section first. Within each section, put the most important paragraph first, and within each list the most important item. Order matters most in long documents; in a short one, don't spend a fix on it.
3. **Default to delete.** Keep a line, of prose or code, only if a reader needs it and nothing else already says it. Adding words is a deliberate act: name what a reader could not understand without them.
4. **Short.** Cut whatever does not clearly help 1–3.
- **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 choosing Y. BANNED: `verified in CI rather than asserted`. GOOD: `verified in CI`.
+11
View File
@@ -0,0 +1,11 @@
# 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. `SKILL.md` §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 check (`SKILL.md` §3 → "Architecture") measures KISS.
3. **Plainly written**, per `prose.md`.
## A false claim is a bug
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.
+13
View File
@@ -0,0 +1,13 @@
# 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` only to keep it true.** 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/skills/larv-review/standards/quality.md` → "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.
+29 -11
View File
@@ -6,7 +6,7 @@
`Bar = 9`
`Next ID = 100`
`Next ID = 108`
| Goal | W |
|---|---|
@@ -24,7 +24,7 @@
| 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 |
| 107 | 0.1.0 | | **Have loop-claude put the README's Goals and Audience into every fresh worker prompt, under a line that the item sets the scope and the goals choose within it.** | 3 | 3 | 8 | 8 | 1.1, 1.2 | 28.1 |
| 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 |
@@ -34,6 +34,7 @@
| 88 | 0.2.0 | | **Define one routing ladder of (model, effort) rungs ordered by a published ranking of their competence, and map a task's R + C to a rung relative to the project's model.** | 3 | 4 | 6 | 7 | 1.4 | 21.4 |
| 90 | 0.2.0 | | **Route each reviewer by the chunk's R + C, once a replay of past chunks shows the routed reviewer finds the 🔴 and 🟡 findings on record.** | 4 | 5 | 6 | 7 | 1.4 | 20.2 |
| 91 | 0.2.0 | | **Start each chunk's worker on the rung its item's R + C picks, never below the project's model, and step it one rung up after two unfinished verdicts on one chunk.** | 4 | 5 | 6 | 7 | 1.4 | 20.2 |
| 105 | 0.2.0 | decision | **Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose.** | 1 | 2 | 5 | 6 | 1.4 | 20.0 |
| 92 | 0.2.0 | | **Have the worker route each subagent by its task's R + C, and delegate a task only when the worker needs just its conclusion.** | 2 | 2 | 5 | 6 | 1.4 | 19.0 |
| 89 | 0.2.0 | | **Run the judge on the rung its chunk's R + C picks, once a replay of archived transcripts shows it returns the verdicts on record.** | 3 | 4 | 5 | 6 | 1.4 | 17.5 |
| 1 | 0.3.0 | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 3, 4 | 27.0 |
@@ -46,7 +47,9 @@
| 5 | 0.3.0 | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 5 | 5 | 5 | 6 | 1.1 | 15.6 |
| 84 | 0.3.0 | | **Check, at each release's scoring run, that seats in a paired ruling agree more often than two scoring runs on near-identical code do, as the paired-ruling decision assumes.** | 2 | 2 | 4 | 5 | 1.4 | 15.1 |
| 67 | 0.3.0 | principle | **Point stability-reviewer at the technical principles in place of its own restatement of them.** | 2 | 3 | 4 | 5 | 1.3 | 14.9 |
| 106 | 0.3.0 | | **Make larv-review's "Do not over-read a clean result" cite a rule that says Renovate or Dependabot owns dependency CVEs, or drop the citation.** | 1 | 1 | 3 | 5 | 1.1 | 14.7 |
| 66 | 0.3.0 | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 3 | 3 | 4 | 5 | 1.1 | 14.2 |
| 101 | 0.3.0 | principle | **Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 3 | 3 | 4 | 5 | 1.1 | 14.2 |
| 69 | 0.3.0 | principle | **Measure test coverage, so a chunk that lowers it is seen.** | 3 | 4 | 4 | 5 | 1.1 | 13.9 |
| 29 | 0.3.0 | | **Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.** | 2 | 2 | 3 | 5 | 1.1, 1.4 | 13.4 |
| 68 | 0.3.0 | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 4 | 3 | 5 | 1.1 | 12.9 |
@@ -55,6 +58,7 @@
| 73 | 0.3.0 | | **Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.** | 3 | 4 | 4 | 4 | 1.4 | 11.7 |
| 6 | 0.3.0 | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 5 | 5 | 4 | 5 | 1.1 | 11.7 |
| 51 | 0.3.0 | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 3 | 5 | 3 | 5 | 1.1 | 11.7 |
| 102 | 0.3.0 | | **Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`.** | 2 | 2 | 3 | 4 | 1.1 | 11.4 |
| 50 | 0.3.0 | principle | **Grant the bench's runs only the tools a review needs, in place of skipping every permission.** | 2 | 2 | 3 | 4 | 4 | 9.9 |
| 81 | 0.3.0 | principle | **Have `workflow-bench/bench.py` return each run's failure as a value, so one failed clone does not hide the later runs' results.** | 2 | 2 | 3 | 4 | 4 | 9.9 |
| 4 | 0.3.0 | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 4 | 3 | 3 | 9.6 |
@@ -63,15 +67,13 @@
## Details
### 95. Make `CLAUDE.md` a short router: only the rules every session needs, and a pointer to where each topic's rules load.
### 107. Have loop-claude put the README's Goals and Audience into every fresh worker prompt, under a line that the item sets the scope and the goals choose within it.
`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.
Today loop-claude hands the premises only to the judge (`bin/loop_claude/cycle/judge.py`), and a worker reads them only when the typed task says to read `README.md`. A worker that implements the simplest change (`docs/decisions.md` → the `worker:` decision) needs the goals to know what it must not give up, and "Ask, don't guess" checks the goals first. The premises are short: 113 words on this repo. The human chose this on 2026-10-13.
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`.
- Add the premises loop-claude already reads to `prompts.fresh`, with a test.
- Above them, one line: the item sets the scope, and the goals choose between ways to meet it. A worker then extends no item towards a goal.
- For a session outside the loop, add one line to `CLAUDE.md`'s working loop: read the README's Goals and Audience before starting a chunk.
### 98. Score R and S from a measurement wherever one exists, and calibrate each guessed score against the finished chunk's measured outcome.
@@ -85,7 +87,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.
@@ -125,6 +127,10 @@ loop-claude reads the top item of the next release with `rank_todo.py` before st
Needs 88.
### 105. Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose.
The `worker:` decision is valid while review rounds per pass do not rise. Count the rounds from each PR's `Answer <pass> round <n>:` commits, and take reading cost from `docs/reading-cost.md`. Run it once five chunks have merged after the one that recorded the decision.
### 92. Have the worker route each subagent by its task's R + C, and delegate a task only when the worker needs just its conclusion.
State in `CLAUDE.md` when the worker delegates: a search or read that spans many files whose conclusion is all it needs, and work independent enough to run in parallel. Edits and anything the worker must verify line by line stay in the main thread, since a delegated diff is read again to check it. The worker scores R and C for each delegated task as it would for an item, and passes the rung's model and effort. In item 73's measurement, reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegating searches saves the most context. The Agent tool sets a subagent's effort only when instructions ask, so the rule names both model and effort.
@@ -189,17 +195,25 @@ Raised by the principles audit of PR #228: the `review: a paired ruling …` ent
DRY, in `principles/technical-principles.md`: `agents/stability-reviewer.md` restates principles in its own words, and the copy has drifted: it asks for "properly randomised UUIDs" where the principle requires UUID v7.
### 106. Make larv-review's "Do not over-read a clean result" cite a rule that says Renovate or Dependabot owns dependency CVEs, or drop the citation.
Found by the goals audit of PR #245. `skills/larv-review/SKILL.md` §3 → "Security" says Renovate or Dependabot owns dependency CVEs per `CLAUDE.md` → "Working with the codebase", which says nothing about either.
### 66. Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.
KISS, in `principles/technical-principles.md`, which keeps a limit only while readers find the flagged code hard. `agents/systems-architect.md` makes cyclomatic 7 and 24 lines gate rules from the first commit, a 🔴 unless a reason is stated.
### 101. Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.
Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/record.py:94` reads `time.time()`, then checks git (`:97`, `commit_exists`) and the history file (`:100`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout.
### 69. Measure test coverage, so a chunk that lowers it is seen.
"Test coverage should not decline", in `principles/technical-principles.md`: nothing reports coverage, so a chunk that deletes a test or adds untested code passes unseen.
### 29. Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.
State that in `CLAUDE.md`'s goals-and-audience rule, and have larv-review's comprehension floor name the contributor as the reader it serves. The floor's block then applies to a project whose audience includes the contributor, and a project that drops them skips it.
State that in `~/.claude/rules/goals-and-audience.md` → "Goals and Audience", and have larv-review's comprehension floor name the contributor as the reader it serves. The floor's block then applies to a project whose audience includes the contributor, and a project that drops them skips it.
### 68. Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.
@@ -234,6 +248,10 @@ Claude Code owns that file and writes it. `trust` reads it, changes it and write
"Functional core, imperative shell", in `principles/technical-principles.md`: `archive`, `trust`, `retried`, the worker, `interrupt` and `model_choice` print to stderr themselves, and the tests swap the global stream.
### 102. Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`.
Found by the principles audit of PR #242. `bin/loop_claude/test_black_box.py:113-114` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans. An override of the delay lets the test run the code as production runs it.
### 50. Grant the bench's runs only the tools a review needs, in place of skipping every permission.
"Always grant explicit access to data", in `principles/technical-principles.md`: `workflow-bench/bench.py` starts claude with `--dangerously-skip-permissions`, and no rule confines it to a sandbox, so a run on the host reaches the host's credentials and other checkouts.