Skip to content

Commit bb65595

Browse files
committed
Add review checks and a skill for fresh-context reviews
The review-changes skill runs when the owner says a change is ready. It briefs fresh subagents with the task in the owner's words, what done means, and the decisions made, never the author's opinion. A task review always runs; a blast-radius review runs for code or config others rely on; a code review runs per check. Each finding is fixed, dismissed with evidence, or left open for the owner. Reviewers work in their own git worktree with the change copied in. - .agents/checks/ has six checks, each saying what to report and what is fine: tests, the editor's design, the file format, the app boundary, privacy, and words. CLAUDE.md points to them. - scripts/rules.test.mjs checks one rule in code: format.ts uses only the Markdown parser. - The learn skill now knows review checks, after tests and script checks. - docs/agents.md says when to ask for a review or a release, what each check covers, and how to improve the system. - Reviewed with the skill itself: a task review and two check reviews. Their findings are fixed, including a worktree recipe that now runs pnpm verify, and a rule test that now also catches `export ... from` and `import()`.
1 parent f169006 commit bb65595

11 files changed

Lines changed: 266 additions & 9 deletions

File tree

‎.agents/checks/app-boundary.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Check: the line between the web view and the Mac
2+
3+
Applies to changes in `src-tauri/`, `src/lib/files.ts`, `src/lib/links.ts`, and `src/ai/client.ts`.
4+
The web view shows text from documents; the Rust side can touch files, the keychain, and other
5+
programs.
6+
7+
## Report
8+
9+
- A new `#[tauri::command]` that takes a path, URL, or program from the web view without checking
10+
it, the way `document_path` and `safe_url` do in `src-tauri/src/lib.rs`.
11+
- New permissions in `src-tauri/capabilities/default.json`, or a looser `csp` in
12+
`src-tauri/tauri.conf.json`.
13+
- The API key, or Claude account details such as the email, reaching the web view. They stay in
14+
`src-tauri/src/ai.rs` and `src-tauri/src/claude_code.rs`.
15+
- A save that can overwrite another app's change without asking: `write_text` must keep its
16+
`expected` check.
17+
- `claude` run with tools, MCP servers, settings, or saved sessions turned on. See the flags in
18+
`src-tauri/src/claude_code.rs`.
19+
20+
## Fine
21+
22+
- New commands that only read the app's own state.
23+
- Error messages that name the file the user picked.

‎.agents/checks/editor.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Check: how the editor is built
2+
3+
Applies to changes in `src/editor/` and the panels that read it. The design is in "How the
4+
editor works" in `CLAUDE.md`.
5+
6+
## Report
7+
8+
- Alternatives, ghosts, or versions changed other than through `setLayers`, in the same
9+
transaction as the text.
10+
- A layer command without a test that does, undoes, and redoes it, and checks the saved Markdown.
11+
- A command that dispatches on its own instead of returning a `TransactionSpec`, or null when it
12+
doesn't apply.
13+
- Undertext's own syntax (`{{ }}`, `{- -}`, `:::alt`) placed in the CodeMirror document. The
14+
document is the page as plain Markdown; the layers sit beside it.
15+
- React state that copies part of the editor state and isn't rebuilt from it on each update, so
16+
the two can disagree.
17+
18+
## Fine
19+
20+
- New helpers in their own module, with tests on `EditorState`.
21+
- Decorations computed from the editor state on each update.
22+
- `EditorInfo`, which `describe` in `src/editor/setup.ts` rebuilds from the editor state on each
23+
update for the React panels.
24+
- `src/editor/format.ts` using the Markdown parser from `@lezer/markdown`. It uses nothing else;
25+
`scripts/rules.test.mjs` checks that.

‎.agents/checks/file-format.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Check: saved files keep the user's writing
2+
3+
Applies to changes in `src/editor/format.ts`, and to anything that changes what a save writes.
4+
Saved files are the user's data. A wrong change here loses writing, and no undo brings it back.
5+
6+
## Report
7+
8+
- A change to how files are read or written without a round-trip test in
9+
`src/editor/format.test.ts`.
10+
- A file the current version saved that the new version reads differently, or text lost on
11+
save. Run real older content through the new code to show it opens the same.
12+
- Plain text that reads as Undertext syntax after a save: `{{`, `{-`, a line reading `:::alt` or
13+
`<!-- overflow -->`. The save must escape it.
14+
- Undertext syntax read inside code spans or code blocks.
15+
- The File format section of `README.md` no longer matching the code.
16+
17+
## Fine
18+
19+
- New syntax that older files can't contain, with tests that it reads and writes back unchanged.
20+
- A known loss that is already listed under "Known limitations" in `README.md`, if the change
21+
doesn't make it worse.

‎.agents/checks/privacy.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Check: nothing private or secret
2+
3+
Applies to every change. The repository is public.
4+
5+
## Report
6+
7+
- Keys, tokens, passwords, or account emails in code, tests, fixtures, docs, or commit messages.
8+
- Someone's real writing or personal documents in tests, fixtures, or the welcome document.
9+
- Paths that name a person's machine, such as a home folder, in committed files.
10+
- An AI request that sends text before the user picks an AI feature, or sends more than the
11+
Privacy paragraph in `README.md` says.
12+
13+
## Fine
14+
15+
- `ANTHROPIC_API_KEY` read from the environment.
16+
- Sample text written for the repository.
17+
- Generic install paths such as `/opt/homebrew` or `/Applications`.

‎.agents/checks/tests.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Check: tests not weakened, new behavior tested
2+
3+
Applies to every change. The rules are in the "Tests" section of `CLAUDE.md`; this check follows
4+
them.
5+
6+
## Report
7+
8+
- A test deleted, skipped, or marked `.only`.
9+
- An assertion made looser: an exact value replaced by `toContain`, `toBeTruthy`, or
10+
`not.toBeNull()`; fewer cases in a list; a `toBe` on text turned into a length check.
11+
- An expected value changed to match new output, when the owner didn't ask for the new behavior.
12+
- In a refactor: any changed test input or expected value.
13+
- New behavior with no test, or a test that would still pass with the feature broken. For
14+
example, it asserts only that a command returned something, not what the text became.
15+
- A command that changes layers without a test that undoes and redoes it and checks the saved
16+
Markdown.
17+
- A multi-step test that checks only the end, where a step that does nothing would still pass.
18+
- An expected value taken from the code under test, such as an error code the TypeScript side
19+
matches.
20+
- A fake of code in `src/` that decides the result.
21+
- A new test the report doesn't show failing once.
22+
23+
## Fine
24+
25+
- A test moved, renamed, or reaching the code by a new path, with the same inputs and expected
26+
values.
27+
- A hash or id taken from the code, asserted equal or not equal, when another test pins that code.
28+
Example: the fingerprints in `scripts/verify.test.mjs`.
29+
- Stubs the test never calls, such as the app actions in the palette test in
30+
`src/editor/lab.test.ts`.
31+
- `not.toBeNull()` as a guard before using the value, as in the `apply` helper in
32+
`src/editor/layers.test.ts`, or when null is the failure ruled out and a nearby case pins the
33+
null, as for `matchScore`.
34+
- A skipped test that needs the network or an account, with a comment saying how to run it, like
35+
the `#[ignore]` test in `src-tauri/src/claude_code.rs`.
36+
- Tooling tests in `scripts/` that swap the real checks for a fake one in a throwaway repository.
37+
- An expected value that changed because the owner asked for the new behavior. Quote the request.

‎.agents/checks/words.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Check: UI text, docs, and instructions
2+
3+
Applies to every change that adds or edits words people or agents read.
4+
5+
## Report
6+
7+
- UI text or docs that aren't plain words, short sentences, and active voice.
8+
- A new shortcut missing from the Shortcuts table in `README.md` or from the command palette, or
9+
listed there with the wrong keys.
10+
- Instructions in `CLAUDE.md`, the skills, the checks, or `docs/agents.md` that contradict each
11+
other, or describe behavior the code doesn't have. `scripts/docs.test.mjs` checks paths and
12+
commands; this check covers what the words claim.
13+
14+
## Fine
15+
16+
- English only. The UI has no translations.
17+
- Technical terms the reader needs, such as `TransactionSpec` in a developer doc.

‎.claude/skills/learn/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ description: Turns a correction or a repeated mistake into a check that catches
1010
1. a type, in TypeScript or Rust
1111
2. a test, in `src/`, `src-tauri/`, or `scripts/`
1212
3. a script check: a step in `scripts/verify-steps.mjs`, or the gate in `scripts/guard.mjs`
13-
4. a line in `CLAUDE.md` or a skill, only for what no code can check
13+
4. a review check in `.agents/checks/`, for what needs judgment
14+
5. a line in `CLAUDE.md` or a skill, only for what nothing else can hold
1415

1516
A rule that is already written down and still broken goes straight to code.
1617
3. **Prove it catches the mistake:** make the mistake on purpose and see the check fail.
17-
4. **Delete the instructions it replaces** in `CLAUDE.md`, the skills, and `docs/`.
18+
4. **Delete the instructions it replaces** in `CLAUDE.md`, the skills, the checks, and `docs/`.
1819
5. **Update the rules table** in `docs/agents.md`: the rule, what holds it, and how sure.
1920
6. Make it its own small change. Commit it when the owner asks.
2021

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: review-changes
3+
description: Reviews a change with fresh reviewers who see the task and the diff but none of the author's reasoning, then settles each finding with evidence. Use when the owner says "review this", "ready for a PR", "before I merge", or "before a release".
4+
---
5+
6+
# Review a change
7+
8+
A review costs several agent runs. Run it when the owner says the change is ready, or asks for a
9+
review. While you work, `pnpm verify` is the check.
10+
11+
1. **Run `pnpm verify`.** Review only a change that passes it.
12+
2. **Check what reviewers will see:** `git status --short`. Ask the owner about any untracked file
13+
that doesn't belong to the change. Never `git add -A`.
14+
3. **Write the brief.** Give the task in the owner's words, what done means, and the decisions
15+
made. Say where to read the change: `git diff <base>` for every commit and edit since the base
16+
branch, and the untracked files from `git status`. Never give your opinion of the change, or
17+
where you think the problems are. Add this rule, word for word, with the paths filled in:
18+
> The working tree is read-only for you. To run or break code, make your own worktree, copy
19+
> in the uncommitted and untracked files, and link the installed packages:
20+
> `git worktree add --detach <folder> HEAD`
21+
> `git ls-files -z -m -o --exclude-standard | xargs -0 -I{} rsync -R "{}" <folder>/`
22+
> `ln -s <checkout>/node_modules <folder>/node_modules`
23+
> Delete there any file the change deletes. Never run `pnpm install` in it: through the link,
24+
> that would empty the checkout's packages. For Rust, set
25+
> `CARGO_TARGET_DIR=<checkout>/src-tauri/target` to skip a cold build. When you are done,
26+
> run `git worktree remove --force <folder>`.
27+
4. **Start the reviewers in parallel,** each a fresh subagent with the brief:
28+
- **Task review, always:** missing pieces, changes nobody asked for, cases not handled, and
29+
tests that would pass with the feature broken. In a refactor, any changed test input or
30+
expected value. Read each new rule against every skill, check, and script, and report any
31+
that disagree.
32+
- **Blast-radius review,** when the change alters code or config others rely on:
33+
`src/editor/format.ts` (files already saved on disk), `src/editor/layers.ts`, the Rust
34+
commands in `src-tauri/src/`, `src-tauri/tauri.conf.json`,
35+
`src-tauri/capabilities/default.json`, `package.json`, `.claude/settings.json`, or
36+
`scripts/`. It names the one fact that makes the change safe, and proves it by running code.
37+
It also looks where a text search can't: files saved by older versions, library versions,
38+
timing.
39+
- **Code review:** one reviewer for each check in `.agents/checks/` that applies to the diff.
40+
5. **Reviewers rate each finding** on the ladder in the `verify` skill: said, cited, traced, ran,
41+
seen.
42+
6. **Settle each finding** at the rung its claim needs: the cited line for what the diff shows, a
43+
test or command that runs the code for behavior. Then fix it, dismiss it with that evidence
44+
(never with an argument), or leave it open for the owner. Look again when new evidence comes
45+
in.
46+
7. **Fix, run `pnpm verify`,** and give a large fix its own fresh review.
47+
8. **Report** each finding, what you did with it, and the evidence. Open findings go first.

‎CLAUDE.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ Use these without being asked. They are in `.claude/skills/`.
4545
- `build-feature`: anything new.
4646
- `refactor`: structure only, always as its own change.
4747
- `learn`: after the owner corrects you, or when a mistake repeats.
48+
- `review-changes`: when the owner says a change is ready, or asks for a review.
49+
50+
Review checks are in `.agents/checks/`, one file per concern. Any review applies the ones that fit
51+
the change, whether an agent or a review tool runs it.
4852

4953
## How the editor works
5054

5155
- The CodeMirror document is the page as plain Markdown. Undertext's own syntax is not in it.
5256
- `src/editor/format.ts` reads and writes the file: `{{a|>b}}` alternatives, `{-x-}` ghosts,
53-
`:::alt` paragraph versions, `<!-- overflow -->`. It has no editor imports.
57+
`:::alt` paragraph versions, `<!-- overflow -->`. It uses only the Markdown parser, no editor
58+
code (`scripts/rules.test.mjs` checks).
5459
- `src/editor/layers.ts` keeps alternatives, ghosts, and versions as ranges beside the text, in a
5560
state field that maps through edits. Change them only with `setLayers`, in the same transaction
5661
as the text. Undo restores them from a snapshot when a change touches a layer.

‎docs/agents.md‎

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ is proof; "I read the code" is not.
1414
hasn't passed.
1515
3. **Ask first:** Claude Code asks you before it pushes or merges.
1616
4. **Skills** give each kind of work its first step and its proof: verify, fix a bug, build a
17-
feature, refactor, learn from a mistake.
18-
5. **CI** runs `pnpm verify` on GitHub for every push to `main` and every pull request.
19-
6. **`CLAUDE.md`** tells every agent session what done means, which skill to use, and how tests
17+
feature, refactor, learn from a mistake, review.
18+
5. **Review:** when you say a change is ready, fresh reviewers check it against the task and the
19+
checks in `.agents/checks/`.
20+
6. **CI** runs `pnpm verify` on GitHub for every push to `main` and every pull request.
21+
7. **`CLAUDE.md`** tells every agent session what done means, which skill to use, and how tests
2022
are written.
2123

2224
## Rules, and what holds them
@@ -29,6 +31,9 @@ is proof; "I read the code" is not.
2931
| Fix a bug with a failing test first; refactor without changing assertions | The `fix-bug` and `refactor` skills | Asked |
3032
| Expected values written by hand; each new test seen failing once | `CLAUDE.md` | Asked |
3133
| Instructions name only files and `pnpm` commands that exist, and each skill says when to use it | `scripts/docs.test.mjs`, in `pnpm verify` | Checked |
34+
| The file format code uses only the Markdown parser | `scripts/rules.test.mjs`, in `pnpm verify` | Checked |
35+
| Reviewers see the task and the diff, never the author's reasoning | The `review-changes` skill | Asked |
36+
| Tests not weakened, the editor's design, saved files, the app boundary, privacy, and plain words | The six checks in `.agents/checks/` | Reviewed, when a review runs |
3237
| Never weaken a check to pass it | `CLAUDE.md` | Asked |
3338
| Say what was not verified | `CLAUDE.md` | Asked |
3439

@@ -92,7 +97,8 @@ them without being asked.
9297
| `fix-bug` | Anything broken | A test that fails on the exact symptom | Undo the fix: the test fails. Restore it: it passes. |
9398
| `build-feature` | Anything new | Read the closest feature; settle your decisions in one round | One test per behavior, written first |
9499
| `refactor` | Structure only | Tests that pin today's behavior | The same tests pass, with their expected values untouched |
95-
| `learn` | A correction, or a mistake that repeats | Pick the strongest structure: type, test, script check, then a line of text | The check fails when the mistake is made on purpose |
100+
| `learn` | A correction, or a mistake that repeats | Pick the strongest structure: type, test, script check, review check, then a line of text | The check fails when the mistake is made on purpose |
101+
| `review-changes` | A change you call ready | Write a brief with your words, never the author's opinion | Each finding fixed, dismissed with evidence, or left open for you |
96102

97103
## Asking for work
98104

@@ -101,6 +107,8 @@ them without being asked.
101107
| A bug fix | What you did, what happened, what should happen | Confirm Claude's restatement if the report was vague |
102108
| A feature | What it should do, and how you'd check it works | Answer the decisions Claude lists, all at once |
103109
| A refactor | What should get easier, and that behavior must not change | Read the list of tests whose expected values stayed the same |
110+
| A review | "Review this", or "it's ready for a PR" | Decide on the findings left open |
111+
| A release | "Ready to release: review it, then build and install the app" | Read the open findings first. After the install, open the app and try the change. |
104112

105113
Any request works better with:
106114

@@ -115,6 +123,46 @@ them. Start a new session for unrelated work, so it starts with a clean context.
115123

116124
Then read the report's "Not verified" part. Try in the app what Claude couldn't.
117125

126+
## Review
127+
128+
Run a review when a change is ready for a pull request or a release, or whenever you ask. It
129+
costs several agent runs, so it doesn't run on its own. During work, `pnpm verify` is the check.
130+
131+
The `review-changes` skill briefs fresh subagents with the task in your words, what done means,
132+
and the decisions made. They never see the author's opinion of the change.
133+
134+
- **A task review**, always: missing pieces, changes nobody asked for, and tests that would pass
135+
with the feature broken.
136+
- **A blast-radius review**, when the change touches code or config others rely on: the file
137+
format, the layers, the Rust commands, the app and permission config, or `scripts/`. It names
138+
the one fact that makes the change safe, and proves it by running code.
139+
- **A code review** for each check that fits the change:
140+
141+
| Check | Covers |
142+
| --- | --- |
143+
| `.agents/checks/tests.md` | Tests not weakened, new behavior tested |
144+
| `.agents/checks/editor.md` | How the editor is built: layers, commands, plain Markdown in the document |
145+
| `.agents/checks/file-format.md` | Saved files keep the user's writing, and old files still open |
146+
| `.agents/checks/app-boundary.md` | What the web view may ask the Mac to do: files, links, the keychain, `claude` |
147+
| `.agents/checks/privacy.md` | No keys, real personal writing, or machine paths in a public repository |
148+
| `.agents/checks/words.md` | Plain UI text and docs, and instructions that agree with each other and the code |
149+
150+
There are no translations to check: the UI is English only.
151+
152+
Reviewers work in their own git worktree, with the change copied in, never in the shared tree. Each finding is settled with
153+
evidence: the cited line for what the diff shows, a test or command for behavior. A finding is
154+
fixed, dismissed with that evidence, or left open for you.
155+
156+
## Improving the system
157+
158+
- When a mistake repeats, say so. The `learn` skill turns it into the strongest check that holds
159+
it, and updates the rules table above.
160+
- When a review keeps finding the same kind of problem, turn it into a test if code can catch it.
161+
If it needs judgment, add it to a check in `.agents/checks/`, with what to report and what is
162+
fine.
163+
- Prefer code to words: a test or a step in `pnpm verify` holds whether or not an agent
164+
remembers.
165+
118166
## `pnpm verify`
119167

120168
It runs, in order, and prints one line per check:
@@ -140,8 +188,8 @@ It runs, in order, and prints one line per check:
140188
checks anyway, for example after `rustup update`.
141189
- **Only docs changed** since the last pass: nothing to check. It records the new tree. Docs are
142190
`docs/`, `LICENSE`, and Markdown outside `src/` and `src-tauri/`, but not the instructions:
143-
`CLAUDE.md`, `README.md`, `docs/agents.md`, and everything in `.claude/`. The docs test reads
144-
those, so a change to them runs every check.
191+
`CLAUDE.md`, `README.md`, `docs/agents.md`, and everything in `.claude/` and `.agents/`. The docs
192+
test reads those, so a change to them runs every check.
145193
- **Only CI files changed** (`.github/`): local checks can't see them. It records nothing, even
146194
with `--force`. Push and read the CI run.
147195
- It finds `cargo` on `PATH`, in `~/.cargo/bin`, or in Homebrew's rustup folder. Without cargo it

0 commit comments

Comments
 (0)