Skip to content

Build your personal knowledge base with Trilium Notes

docs(claude): prefer a red spec to reverting the fix

Elian Doran6af7fdd2ed18
diff --git a/CLAUDE.md b/CLAUDE.md
index 98f2ec2cb5..6cf046ab8c 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -209,7 +209,7 @@ Use `note.getOwnedAttribute()` for direct, `note.getAttribute()` for inherited.
- **Build validation tests** check artifact integrity
- **Write concise tests**: Group related assertions together in a single test case rather than creating many one-shot tests
- **Extract and test business logic**: When adding pure business logic (e.g., data transformations, migrations, validations), extract it as a separate function and always write unit tests for it
-- **Confirm a new spec fails without the fix**: after adding a spec that covers a bug you just fixed, revert the fix, run the spec, confirm it fails, restore the fix, and report both results. A spec written against already-correct code can pass for the wrong reason — check every assertion in the reverted run, since one that still passes is either covering something else or is vacuous, and needs tightening (look the element up, assert it exists, *then* act on it)
+- **See the spec fail before it passes**: a spec written against already-correct code can pass for the wrong reason. Prefer writing the spec **before** the fix — run it red, then fix, then run it green; this needs no edit-revert-restore dance and leaves no window where the tree holds a hand-broken file. When the fix had to come first (the cause was only clear after reading the code, or the fix created the seam the spec attaches to), revert it with a targeted in-file edit — never `git stash` or `git checkout --` — run the spec, then restore. Either way, report both runs and **check every assertion in the red run**: one that still passes is covering something else or is vacuous, and needs tightening (look the element up, assert it exists, *then* act on it)
- **Don't drive the running app to verify a UI change** — the user exercises the UI and reports back, so a headless-browser walkthrough duplicates their work and adds no information. Ship once the relevant unit tests and `pnpm typecheck` are green, and state plainly what is and isn't verified. Booting an instance is for what the user cannot answer from the UI — which CSS rule actually won, a stacking or placement bug, a fixture-only repro: see `references/inspecting-the-running-app.md` in the `building-client-ui` skill
## Documentation