Typical hand-written CLAUDE.md
## Commands
- npm run dev
- npm test # vitest
- npm run lint
## Stack
- React + TypeScript, Zustand for state
- API client in src/lib/http.ts
## Conventions
- Use the http client, don't call fetch directly
- Use the logger, not console.log
- Write tests for new features
- Keep components small
Reasonable rules, but they're advice. "Small" has no number, "write tests" has no bar, and nothing fails when a rule is broken or when http.ts moves. Lessons from past incidents usually aren't in it.
Written by gap-trap
- I2. Destructive operations need error handling
and a recovery path. Lost user data cannot be
patched later.
- P2. Test first: a failing test precedes every
feature and bugfix. Gate: proven-red CI job.
### HTTP
Owns: all network requests, auth headers
Path: src/lib/http.ts
Never: raw fetch or axios
Gate: instruction-gate test
### Logging
Owns: all log output, token redaction
Path: src/lib/logger.ts
Never: console.* outside the logger
Gate: instruction-gate test
Written from the code. Setup reads the codebase to find the real helpers and modules, and turns reverts in git history into "don't retry this" notes.
One fixed shape. Every rule has an ID, one statement, and a short reason. If a script can enforce it, the rule names that check. Docs and agent briefs cite "P2" instead of copying the text, so a rule changes in one place.
Small core, details on demand. The always-loaded files stay under a word cap. Topic playbooks load only for work in their area, which leaves more of the context for the task.
Existing rules kept. Rules from an existing CLAUDE.md or .cursorrules are migrated one at a time, and the setup plan shows each one. Other tools' files become pointers to the single rulebook.
The hand-written file is an illustrative example. The gap-trap rules are from its templates, with the wording lightly shortened.