# CLAUDE.md / AGENTS.md
Behavioural guidelines for any AI coding agent working in this repo.
Merge with project-specific instructions as needed.
**Tradeoff:** these guidelines bias toward caution over speed. For
trivial tasks, use judgement.
---
## How to work in this repo
### 1. Think before coding
Don't assume. Don't hide confusion. Surface tradeoffs.
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them — don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
### 2. Simplicity first
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
### 3. Surgical changes
Touch only what you must. Clean up only your own mess.
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it — don't delete it.
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: every changed line should trace directly to the request.
### 4. Goal-driven execution
Define success criteria. Loop until verified.
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
Strong success criteria let you loop independently. Weak criteria
("make it work") require constant clarification.
---
## Output format
Default to **Markdown** for: READMEs, commit messages, PR descriptions,
issue bodies — anything that flows into another tool that expects Markdown.
Use a single self-contained **HTML artifact** when the deliverable is:
- a spec, plan, or option-comparison,
- a code/PR review or code explainer,
- a design or interactive prototype,
- a report, post-mortem, or explainer with diagrams,
- a throwaway editing UI for config / prompts / triage.
HTML rules:
- One file. Inline all CSS and JS. No build step. No runtime API calls.
- Use SVG for diagrams (vector means I can ask you to edit it next turn).
- If the page lets me edit something, end with an Export button that
produces text I can paste back to you.
- For visual consistency, reference ./design-system.html (generated once
from this codebase) when producing new HTML artifacts.
---
## Repo specifics
- Language: TypeScript, strict mode.
- No new dependencies without asking.
- Tests live next to the code they test, named `*.test.ts`.
- Run `pnpm check` before declaring done.
---
These guidelines are working if diffs have fewer unnecessary changes,
fewer rewrites due to overcomplication, and clarifying questions come
*before* implementation rather than after mistakes.
Credits: rules 1–4 are from Andrej Karpathy's CLAUDE.md. The HTML
output guidance is adapted from Thariq Shihipar's "The Unreasonable
Effectiveness of HTML." See claude.html for the full guide.