Generate a CLAUDE.md that gives Claude Code the project context it actually needs: your stack, conventions, build and test commands, and the boundaries it must not cross.
Generate a tuned CLAUDE.md for your repo. Stack-aware defaults, optional hook block, optional MCP block, optional budget guard. Copy and drop into the project root.
# my-app
Repo guidance for Claude Code. Read this before touching anything.
## Stack
- Primary stack: Next.js + TypeScript
- Package manager: npm
- Test runner: vitest
## Commands
Run these from the repo root.
- Dev: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- Typecheck: `npx tsc --noEmit`
- Lint: `npm run lint`
- Deploy: `vercel --prod` (manual gate, do not run unprompted)
## Agent posture
Balanced. Plan for changes touching more than 3 files. Confirm on production paths.
## Definition of done
Before claiming any task complete:
1. `npm test` passes
2. `npx tsc --noEmit` passes
3. `npm run lint` passes
4. `npm run build` succeeds
5. Manual sanity-check of the change in the dev environment.
## Production-sensitive paths
Any change touching these requires explicit human confirmation. Do not edit unprompted.
- `src/lib/db`
- `.github/workflows`
- `terraform/`
## House rules
- Plan before writing code on tasks larger than one file.
- TDD on every behavior change: red, green, refactor.
- One commit per logical change. No mega-commits.
- Match existing patterns in the file before introducing new ones.
- No new dependencies without explicit approval.
- Never silently catch errors. Either handle them or let them surface.
- Never bypass pre-commit hooks. If a hook fails, fix the underlying issue.
## Recommended hooks
Add to `.claude/settings.json`:
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": ".claude/hooks/block-destructive.sh" }
]
}
]
}
}
```
Where `block-destructive.sh` refuses `rm -rf` outside /tmp, `git push --force` on protected branches, and any `terraform destroy`.
## Token budget
Per-task soft cap: 200,000 tokens. Sessions that approach this should stop and ask the human to slice the task smaller, not keep iterating.
---
_Generated with the [CLAUDE.md Generator](https://hammadhaqqani.com/tools/claude-md-gen)._CLAUDE.md is loaded into context on every session, which makes it both the highest-leverage file in an agent-assisted repository and a recurring token cost. The instructions that pay for themselves are the ones the model cannot infer from the code: which of three plausible test commands is the real one, that the legacy directory is frozen, that migrations are never edited after merge.
What does not pay for itself is anything already visible in the code. Listing the directory structure, restating the framework, or describing what a file does is tokens spent on every session to tell the model something it can read directly. Bloat is the most common problem in these files: the AGENTS.md Converter and Bloat Linter exists specifically to measure it.