From 2fe396b461ed29ed3348917b8bb23580bc9f7316 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 1 Oct 2026 19:25:31 +0200 Subject: [PATCH 1/3] Order CLAUDE.md by what a session needs first, and say when order is worth a fix --- CLAUDE.md | 134 +++++++++++++++++++++++++++--------------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5d1f7b81..46807469 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,49 +1,8 @@ # Global instructions -## 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. The longer the document, the more this matters. -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 doing Y. BANNED: `verified in CI rather than asserted`. GOOD: `verified in CI`. - -## Vocabulary - -- **chunk** — the unit of work: the smallest PR-able change. -- **cycle** — one worker run and the judge's verdict on it, in `loop-claude`. -- **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. -- **pass** — one kind of review a chunk may take, run in rounds by its reviewers until clean; `larv-review` §3 lists them. -- **plan** — `todo.md`. -- **premises** — the goals and audience under `## Goals` and `## Audience` in the project's `README.md`. -- **release** — a semver version the human cuts. -- **reviewer** — a reporter of findings: an agent under `~/.claude/agents/`, `/security-review` or a forge's auto-reviewer. -- **round cap** — the rounds one pass may take per chunk; `larv-review` §3 → "Round cap". -- **session** — a Claude Code session: one id, what `claude --resume` continues. -- **trigger** — the condition under which a review pass runs on a change it has not seen; `larv-review` §3 lists them. -- **worker** — the headless claude that runs the task in a cycle, in the chunk's session. - -## 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. - -## Web research -- **A list or threshold a consumer relies on is sourced.** Deny-lists, defaults, limits: follow a published standard or a widely deployed tool, and cite it in the decision recording the choice; where none exists, ask. Never assemble one from names that seem plausible. -- Default to `WebSearch`/`WebFetch`. When a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` — `./pw [options]` (see its README). Don't use claude-in-chrome for this. - -## Technical principles - -The design rules every project follows, compose-not-entangle first: `~/.claude/principles/technical-principles.md`. Read it before designing or reviewing code. - ## Working loop -How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The *next release* is the earliest one not yet cut. +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** are the project's aims, not promises: one line each, in priority order, like slogans — "1. Blazing fast performance. 2. Correctness is more important than many features." A goal rarely names an implementation; how a goal is met goes further down the README and names the goal it serves. @@ -58,17 +17,44 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The - **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. - **Remove a finished item from `todo.md`; keep its release heading until the version is cut.** If the repo publishes something others consume — a package, an image, an API — reword the line for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete the line; git history is the record. +## 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. +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`. + ## 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. - Run a project's language runtime, package manager, and task runner through its container/tooling setup, never directly on the host. Example: `docker compose run --rm app …`. - 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"). -- 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. - Pin GitHub Actions to semver tags (`@v3`, `@v3.1.2`), not commit SHAs — including third-party actions. SHA-pin only in special pipelines that test our own specific builds. - Pin container images to the **full patch version** everywhere they're referenced — Dockerfile `FROM`, compose `image:`, base images in test fixtures: `node:24.18.1-bookworm-slim`, `mysql:8.4.7`, `alpine:3.23.3`. Never a floating major or minor (`node:24`, `node:24.18`, `:latest`, `:lts`): the same commit then builds a different image on different days, so a green pipeline says nothing about the next run, a base change lands with no diff to review, and any size or performance figure measured against it silently goes stale. Let a bot (Renovate/Dependabot) raise the bumps as reviewable PRs — that is where a base change belongs. (Actions are the exception above: a semver tag is fine there, because the action's own release is the reviewable unit.) -## Handoffs -- One document per project: `~/code/claude-handoffs/_.md`, with its supporting files (scripts, probes, saved sessions) under `~/code/claude-handoffs///`, dated the day they were written. -- Each document stands alone — projects move in parallel, so never reference another project's handoff. A fact two of them share (a test site, where credentials live) is stated in each, or kept in a memory file and named there. -- Content: only what the repo cannot hold — probe results, where credentials live. What is done and the next step live in the plan; goals, audience and decisions in `README.md`/`AGENTS.md`. A handoff never restates them: the repo's copy travels with the code and this one does not. +## Technical principles + +The design rules every project follows, compose-not-entangle first: `~/.claude/principles/technical-principles.md`. Read it before designing or reviewing code. + +## Code style +- Reuse before adding. Extend an existing test with an assertion rather than writing a new one. +- Signal failures with a result value carrying an optional error, not by throwing. A function that both returns a result and throws for some inputs has two error channels; collapse to one. Reserve exceptions for truly unrecoverable states at boundaries, never for control flow the caller is meant to handle. +- A cast (`x as Foo`) asserts what the compiler could not check and stops it checking — so when the type later changes, nothing tells you. Derive the real type instead: infer it, name the return type, or parse the input once into a typed shape. Where a value genuinely arrives untyped (HTTP body, `JSON.parse`, DB row), the boundary owes a **type guard validating the fields it claims**; past that boundary everything is typed. `as unknown as T` and non-null `!` are the same defect wearing a hat. BANNED: `const user = body as User` — one rename and it is a silent lie. GOOD: `function isUser(v: unknown): v is User` checking each field, then `if (!isUser(body)) return { error: … }`. +- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. Domain decisions and branching belong in the service layer — 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. +- DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks. +- Prefer explicit, descriptive names over generic ones (`invoiceRowsService`, not `service`). +- Prefer a standalone Python script with a `#!/usr/bin/env python3` shebang over a shell script — it runs identically across systems where shell dialects/builtins differ. Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. +- 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 such as `.gitignore`/`.dockerignore`. Exception: `id` goes first. +- Sort a compound line on the name it introduces, never on an incidental field: an import 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. +- Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation. + +## Naming files & folders +- Name by what's inside, not by catch-all. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. Use explicit names: `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/`. ## Tests - Write tests first for the behaviour we want, then implement until they pass. @@ -76,22 +62,6 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The - Use properly randomised UUID v7s — never `aaaa-0000`-style placeholders. - Tear down test containers after a run. -## Code style -- Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation. -- Reuse before adding. Extend an existing test with an assertion rather than writing a new one. -- 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 such as `.gitignore`/`.dockerignore`. Exception: `id` goes first. -- Sort a compound line on the name it introduces, never on an incidental field: an import 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. -- Prefer a standalone Python script with a `#!/usr/bin/env python3` shebang over a shell script — it runs identically across systems where shell dialects/builtins differ. Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. -- DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks. -- Prefer explicit, descriptive names over generic ones (`invoiceRowsService`, not `service`). -- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. Domain decisions and branching belong in the service layer — 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. -- Signal failures with a result value carrying an optional error, not by throwing. A function that both returns a result and throws for some inputs has two error channels; collapse to one. Reserve exceptions for truly unrecoverable states at boundaries, never for control flow the caller is meant to handle. -- A cast (`x as Foo`) asserts what the compiler could not check and stops it checking — so when the type later changes, nothing tells you. Derive the real type instead: infer it, name the return type, or parse the input once into a typed shape. Where a value genuinely arrives untyped (HTTP body, `JSON.parse`, DB row), the boundary owes a **type guard validating the fields it claims**; past that boundary everything is typed. `as unknown as T` and non-null `!` are the same defect wearing a hat. BANNED: `const user = body as User` — one rename and it is a silent lie. GOOD: `function isUser(v: unknown): v is User` checking each field, then `if (!isUser(body)) return { error: … }`. - -## Naming files & folders -- Name by what's inside, not by catch-all. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. Use explicit names: `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/`. - ## Comments and documentation (`README.md`, `AGENTS.md`, `docs/`, API specs) **One bar for all of it.** A comment or a paragraph earns its place by saying what a competent reader of THIS codebase could not infer and the repo cannot say for itself: a surprising WHY, a footgun, an invariant, an external constraint. The fix for a redundant one is deletion, not trimming — two copies drift, and the doc copy is the one nobody updates. Once it has earned its place, make it plain and short. 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. @@ -146,11 +116,41 @@ Default to NO comment. Delete one that is any of: - The opposite of internal code comments, which *may* cite a ticket for a footgun/constraint. ## Git, commits, and PRs -- 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 below applies to both. -- Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`. -- When the work has a ticket, read it before starting: verify the change matches it and pull useful context from it. +- Never add `Co-Authored-By: Claude ...`, `🤖 Generated with Claude Code`, or any Claude/Anthropic/Agent marker in commits, PR bodies, issue comments, or anywhere else. - 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. +- 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. - Keep the project's main checkout (e.g. `~/code/log`, never a worktree) current: when it is behind `origin` — a merge landed, or a fetch shows it — run `git pull --ff-only` there instead of reporting the lag, never with `--autostash`: a dirty checkout is a finding to report, not to carry along. - Releases follow semver read strictly (`~/.claude/principles/technical-principles.md`). -- Never add `Co-Authored-By: Claude ...`, `🤖 Generated with Claude Code`, or any Claude/Anthropic/Agent marker in commits, PR bodies, issue comments, or anywhere else. + +## Handoffs +- One document per project: `~/code/claude-handoffs/_.md`, with its supporting files (scripts, probes, saved sessions) under `~/code/claude-handoffs///`, dated the day they were written. +- Each document stands alone — projects move in parallel, so never reference another project's handoff. A fact two of them share (a test site, where credentials live) is stated in each, or kept in a memory file and named there. +- Content: only what the repo cannot hold — probe results, where credentials live. What is done and the next step live in the plan; goals, audience and decisions in `README.md`/`AGENTS.md`. A handoff never restates them: the repo's copy travels with the code and this one does not. + +## Web research +- **A list or threshold a consumer relies on is sourced.** Deny-lists, defaults, limits: follow a published standard or a widely deployed tool, and cite it in the decision recording the choice; where none exists, ask. Never assemble one from names that seem plausible. +- Default to `WebSearch`/`WebFetch`. When a page renders client-side and comes back empty/blocked, use the Playwright renderer at `~/code/playwright-for-agents/` — `./pw [options]` (see its README). Don't use claude-in-chrome for this. + +## 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. + +## Vocabulary + +- **chunk** — the unit of work: the smallest PR-able change. +- **cycle** — one worker run and the judge's verdict on it, in `loop-claude`. +- **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. +- **pass** — one kind of review a chunk may take, run in rounds by its reviewers until clean; `larv-review` §3 lists them. +- **plan** — `todo.md`. +- **premises** — the goals and audience under `## Goals` and `## Audience` in the project's `README.md`. +- **release** — a semver version the human cuts. +- **reviewer** — a reporter of findings: an agent under `~/.claude/agents/`, `/security-review` or a forge's auto-reviewer. +- **round cap** — the rounds one pass may take per chunk; `larv-review` §3 → "Round cap". +- **session** — a Claude Code session: one id, what `claude --resume` continues. +- **trigger** — the condition under which a review pass runs on a change it has not seen; `larv-review` §3 lists them. +- **worker** — the headless claude that runs the task in a cycle, in the chunk's session. -- 2.52.0 From c7738f8bcd2fd133cce2b87fd356f41d7005b4c7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 1 Oct 2026 19:27:04 +0200 Subject: [PATCH 2/3] Answer the order review's first round --- CLAUDE.md | 90 +++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 46807469..37d4a1c1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,20 +2,25 @@ ## Working loop -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. +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** are the project's aims, not promises: one line each, in priority order, like slogans — "1. Blazing fast performance. 2. Correctness is more important than many features." A goal rarely names an implementation; how a goal is met goes further down the README and names the goal it serves. - **Audience** names who depends on the project and what they may rely on. -- **Work one chunk at a time.** 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`, under a release. -- **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 `docs/decisions.md`. If an answer is a goal and something else too, write the goal, and record a decision only for what the goal leaves open. -- **Ship every chunk with `/larv-review`.** -- **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. - **Plan `todo.md` by semver release:** every item sits under 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.** Weigh the unscheduled items against the goals, put them in order, and get the human's approval 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. -- **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. +- **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.** 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`, under a release. +- **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 `docs/decisions.md`. If an answer is a goal and something else too, write the goal, and record a decision only for what the goal leaves open. +- **Ship every chunk with `/larv-review`.** - **Remove a finished item from `todo.md`; keep its release heading until the version is cut.** If the repo publishes something others consume — a package, an image, an API — reword the line for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete the line; 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) +- Open each item with a bold one-sentence tagline, so the taglines alone say what a release holds; detail follows it. 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, at the top of the list under its own `## Security` heading, naming the exposure and the path it reaches. 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 move it down if I disagree. Fixing it inside an unrelated change is a separate call — say whether it is in the blast radius. ## Prose @@ -29,39 +34,6 @@ Everything written — chat, commit messages, comments, docs, code — is in **E - **Write the thing, not an introduction to it.** A sentence announcing what follows, or flagging that it deserves attention, carries nothing — if it matters, it is in what follows. A bare label is fine. BANNED: `Here's the new audience text, which is the part that needs your eye:`, `One thing I changed that deserves your attention.`, `One judgment call I'd flag rather than bury.`, `Three things came along that would otherwise have been left false.` GOOD: `New audience text:`, or the list alone. - **No contrastive tail.** `X rather than Y`, `not Y but X`, `instead of Y`: state X and stop. The rejected alternative is noise unless naming it stops a reader doing Y. BANNED: `verified in CI rather than asserted`. GOOD: `verified in CI`. -## 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. -- Run a project's language runtime, package manager, and task runner through its container/tooling setup, never directly on the host. Example: `docker compose run --rm app …`. -- 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"). -- Pin GitHub Actions to semver tags (`@v3`, `@v3.1.2`), not commit SHAs — including third-party actions. SHA-pin only in special pipelines that test our own specific builds. -- Pin container images to the **full patch version** everywhere they're referenced — Dockerfile `FROM`, compose `image:`, base images in test fixtures: `node:24.18.1-bookworm-slim`, `mysql:8.4.7`, `alpine:3.23.3`. Never a floating major or minor (`node:24`, `node:24.18`, `:latest`, `:lts`): the same commit then builds a different image on different days, so a green pipeline says nothing about the next run, a base change lands with no diff to review, and any size or performance figure measured against it silently goes stale. Let a bot (Renovate/Dependabot) raise the bumps as reviewable PRs — that is where a base change belongs. (Actions are the exception above: a semver tag is fine there, because the action's own release is the reviewable unit.) - -## Technical principles - -The design rules every project follows, compose-not-entangle first: `~/.claude/principles/technical-principles.md`. Read it before designing or reviewing code. - -## Code style -- Reuse before adding. Extend an existing test with an assertion rather than writing a new one. -- Signal failures with a result value carrying an optional error, not by throwing. A function that both returns a result and throws for some inputs has two error channels; collapse to one. Reserve exceptions for truly unrecoverable states at boundaries, never for control flow the caller is meant to handle. -- A cast (`x as Foo`) asserts what the compiler could not check and stops it checking — so when the type later changes, nothing tells you. Derive the real type instead: infer it, name the return type, or parse the input once into a typed shape. Where a value genuinely arrives untyped (HTTP body, `JSON.parse`, DB row), the boundary owes a **type guard validating the fields it claims**; past that boundary everything is typed. `as unknown as T` and non-null `!` are the same defect wearing a hat. BANNED: `const user = body as User` — one rename and it is a silent lie. GOOD: `function isUser(v: unknown): v is User` checking each field, then `if (!isUser(body)) return { error: … }`. -- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. Domain decisions and branching belong in the service layer — 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. -- DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks. -- Prefer explicit, descriptive names over generic ones (`invoiceRowsService`, not `service`). -- Prefer a standalone Python script with a `#!/usr/bin/env python3` shebang over a shell script — it runs identically across systems where shell dialects/builtins differ. Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. -- 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 such as `.gitignore`/`.dockerignore`. Exception: `id` goes first. -- Sort a compound line on the name it introduces, never on an incidental field: an import 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. -- Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation. - -## Naming files & folders -- Name by what's inside, not by catch-all. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. Use explicit names: `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/`. - -## Tests -- Write tests first for the behaviour we want, then implement until they pass. -- Changing tests and changing other code are two separate processes — be very careful about doing both at once. -- Use properly randomised UUID v7s — never `aaaa-0000`-style placeholders. -- Tear down test containers after a run. - ## Comments and documentation (`README.md`, `AGENTS.md`, `docs/`, API specs) **One bar for all of it.** A comment or a paragraph earns its place by saying what a competent reader of THIS codebase could not infer and the repo cannot say for itself: a surprising WHY, a footgun, an invariant, an external constraint. The fix for a redundant one is deletion, not trimming — two copies drift, and the doc copy is the one nobody updates. Once it has earned its place, make it plain and short. 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. @@ -98,10 +70,6 @@ Default to NO comment. Delete one that is any of: **"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, and adding a section is a deliberate act you must justify. 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. -### Todo items (`todo.md`, tickets, plans) -- Open each item with a bold one-sentence tagline, so the taglines alone say what a release holds; detail follows it. 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, at the top of the list under its own `## Security` heading, naming the exposure and the path it reaches. 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 move it down if I disagree. Fixing it inside an unrelated change is a separate call — say whether it is in the blast radius. - ### 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. - Order sections by what a new developer wants first: 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. @@ -115,6 +83,40 @@ Default to NO comment. Delete one that is any of: - 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. +## 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. +- Keep the project's main checkout (e.g. `~/code/log`, never a worktree) current: when it is behind `origin` — a merge landed, or a fetch shows it — run `git pull --ff-only` there instead of reporting the lag, never with `--autostash`: a dirty checkout is a finding to report, not to carry along. +- Run a project's language runtime, package manager, and task runner through its container/tooling setup, never directly on the host. Example: `docker compose run --rm app …`. +- 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"). +- Pin GitHub Actions to semver tags (`@v3`, `@v3.1.2`), not commit SHAs — including third-party actions. SHA-pin only in special pipelines that test our own specific builds. +- Pin container images to the **full patch version** everywhere they're referenced — Dockerfile `FROM`, compose `image:`, base images in test fixtures: `node:24.18.1-bookworm-slim`, `mysql:8.4.7`, `alpine:3.23.3`. Never a floating major or minor (`node:24`, `node:24.18`, `:latest`, `:lts`): the same commit then builds a different image on different days, so a green pipeline says nothing about the next run, a base change lands with no diff to review, and any size or performance figure measured against it silently goes stale. Let a bot (Renovate/Dependabot) raise the bumps as reviewable PRs — that is where a base change belongs. (Actions are the exception above: a semver tag is fine there, because the action's own release is the reviewable unit.) + +## Technical principles + +The design rules every project follows, compose-not-entangle first: `~/.claude/principles/technical-principles.md`. Read it before designing or reviewing code. + +## Code style +- Reuse before adding. Extend an existing test with an assertion rather than writing a new one. +- Signal failures with a result value carrying an optional error, not by throwing. A function that both returns a result and throws for some inputs has two error channels; collapse to one. Reserve exceptions for truly unrecoverable states at boundaries, never for control flow the caller is meant to handle. +- A cast (`x as Foo`) asserts what the compiler could not check and stops it checking — so when the type later changes, nothing tells you. Derive the real type instead: infer it, name the return type, or parse the input once into a typed shape. Where a value genuinely arrives untyped (HTTP body, `JSON.parse`, DB row), the boundary owes a **type guard validating the fields it claims**; past that boundary everything is typed. `as unknown as T` and non-null `!` are the same defect wearing a hat. BANNED: `const user = body as User` — one rename and it is a silent lie. GOOD: `function isUser(v: unknown): v is User` checking each field, then `if (!isUser(body)) return { error: … }`. +- Keep delivery-layer entrypoints thin: inject services, validate + hand off the request data, map the service's return to a response. Domain decisions and branching belong in the service layer — 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. +- DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks. +- Prefer explicit, descriptive names over generic ones (`invoiceRowsService`, not `service`). +- Prefer a standalone Python script with a `#!/usr/bin/env python3` shebang over a shell script — it runs identically across systems where shell dialects/builtins differ. Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded. +- 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 such as `.gitignore`/`.dockerignore`. Exception: `id` goes first. +- Sort a compound line on the name it introduces, never on an incidental field: an import 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. +- Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation. + +## Tests +- Write tests first for the behaviour we want, then implement until they pass. +- Changing tests and changing other code are two separate processes — be very careful about doing both at once. +- Use properly randomised UUID v7s — never `aaaa-0000`-style placeholders. +- Tear down test containers after a run. + +## Naming files & folders +- Name by what's inside, not by catch-all. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. Use explicit names: `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/`. + ## Git, commits, and PRs - Never add `Co-Authored-By: Claude ...`, `🤖 Generated with Claude Code`, or any Claude/Anthropic/Agent marker in commits, PR bodies, issue comments, or anywhere else. - 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. @@ -122,8 +124,6 @@ Default to NO comment. Delete one that is any of: - When the work has a ticket, read it before starting: verify the change matches it and pull useful context from it. - 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. -- Keep the project's main checkout (e.g. `~/code/log`, never a worktree) current: when it is behind `origin` — a merge landed, or a fetch shows it — run `git pull --ff-only` there instead of reporting the lag, never with `--autostash`: a dirty checkout is a finding to report, not to carry along. -- Releases follow semver read strictly (`~/.claude/principles/technical-principles.md`). ## Handoffs - One document per project: `~/code/claude-handoffs/_.md`, with its supporting files (scripts, probes, saved sessions) under `~/code/claude-handoffs///`, dated the day they were written. -- 2.52.0 From fee0998fc1d883f1ac5e16acc03ba03510a98a99 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 1 Oct 2026 19:27:29 +0200 Subject: [PATCH 3/3] Bold the semver bullet's lead --- CLAUDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 37d4a1c1..23ba1b23 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,7 +16,7 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The - **Ship every chunk with `/larv-review`.** - **Remove a finished item from `todo.md`; keep its release heading until the version is cut.** If the repo publishes something others consume — a package, an image, an API — reword the line for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete the line; 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`). +- **Releases follow semver read strictly** (`~/.claude/principles/technical-principles.md`). ### Todo items (`todo.md`, tickets, plans) - Open each item with a bold one-sentence tagline, so the taglines alone say what a release holds; detail follows it. 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`. -- 2.52.0