← sources

What finally stopped Claude Code from undoing my old decisions: turning them into dumb tests

source: reddit (reddit:ClaudeAI)published 2026-10-28 11:08ingested 2026-10-29 02:37

retained text

I've been building a self-hosted flight and ship tracker with Claude Code since June, about 390 commits on one repo. The worst failure mode wasn't bad code. It was Claude confidently "cleaning up" something I had decided on purpose weeks earlier, in a session that didn't know the history.

Real examples from this repo:

- The ADS-B fetcher caps concurrent upstream calls at 8. Above that, one aggregator rate-limits you with HTTP 200 and a plain-text body, so it looks like success. To a fresh session that cap looks arbitrary and the non-JSON check looks redundant.
- The map deliberately never extrapolates aircraft between real fixes. Sessions kept wanting to "smooth" the motion, which makes stale positions look live.
- Internal code has to read the cached global snapshot, not call the route handler directly. Calling the handler in-process took the jamming layer down with 500s.

What didn't work: writing it all in CLAUDE.md. The file grew, the rules lost weight, and a fresh session would still undo one if the code looked wrong to it.

What works now:

1. Every decision I care about is a test. `tests/test_invariants.py` has 15 of them on the backend and there are 10 more on the frontend. Most are dumb on purpose, e.g. regex the source for `Semaphore(8)` and fail with a one-line reason.
2. The root CLAUDE.md is short and says: a guard failure means you're undoing an operator decision. Fix the code, or change BOTH the test and the doc on purpose.
3. A `docs/decisions.md` (39 entries now) holds the why and the post-mortem. Claude reads the entry before touching guarded code, but the test is what actually stops it.
4. Each directory has its own small CLAUDE.md, so the rules load only when Claude works there instead of all living in one giant file.
5. One `scripts/verify.sh` runs typecheck, lint and every guard. Nothing is "done" until it's green.

Since switching, regressions of old decisions basically stopped. When a guard trips, Claude usually reads the decision entry and backs off by itself.

The project itself: Velocity records every aircraft and ship position it sees from public feeds to your own disk, so you can rewind the map, set area alerts, and query it over MCP. Free and AGPL, `docker compose up`: https://github.com/AndrewCTF/velocity

Curious how others handle this. Do you keep decisions in prose, tests, hooks, something else?

document fetched 2026-10-29 00:23 · canonical https://reddit.com/r/ClaudeAI/comments/1xhl3zz/what_finally_stopped_claude_code_from_undoing_my