Free rules / Claude Code
Free Claude Code rules
Claude Code loads CLAUDE.md into context at the start of every session. It's plain Markdown, so keep it short and specific: the commands to run, where things live, and the rules you'd otherwise repeat in every prompt.
How to install
- Save the file below as CLAUDE.md in your repo root (next to package.json).
- Fill in the [brackets]: what the project is, the real commands, the folder layout, generated files to leave alone.
- Commit it so everyone on the project shares it.
- Start a new Claude Code session; run /memory to check it was loaded or to edit it.
The rules file
# CLAUDE.md - project memory
> Claude Code loads this file at the start of every session. Fill in the [brackets], delete what doesn't apply, keep it short.
## Project
- What it is: [one sentence]
- Stack: [e.g. Next.js 15, TypeScript, Tailwind, Postgres via Drizzle]
## Commands
- Dev: `[npm run dev]`
- Test (single file): `[npm test -- path/to/file]`
- Typecheck: `[npx tsc --noEmit]`
- Lint: `[npm run lint]`
- Build: `[npm run build]`
## Layout
- `[app/]` routes and UI
- `[lib/]` shared logic, `[lib/server/]` server-only code
- `[tests/]` tests mirror source paths
- Generated, don't edit: [e.g. `*.gen.ts`, `migrations/`]
## How to work
- Read the files you will change and their neighbours before editing. Follow existing patterns.
- For anything bigger than a small fix, propose a short plan (files + approach) before writing code.
- Make the smallest change that fully solves the task. No unrelated refactors, renames or reformatting.
- Don't invent APIs or package names. Check the code, lockfile or docs.
- Ask before adding a dependency, and say why it's needed.
- If something is ambiguous, ask one focused question rather than guessing.
## Safety
- Never commit or print secrets. Read them from env vars; list every var in `.env.example` with a placeholder.
- Never put server secrets behind public prefixes (`NEXT_PUBLIC_`, `VITE_`); those ship to the browser.
- Ask before destructive commands: deleting data, dropping tables, `git push --force`, `rm -rf`, production migrations.
- Don't commit or push unless I ask.
## Definition of done
1. Typecheck, lint, tests and build pass. Fix failures; don't silence them with `any`, `@ts-ignore` or skipped tests.
2. New behaviour has a test, or a stated reason why not.
3. Finish with a summary: what changed, which files, how you verified it, anything left undone.
## Gotchas
- [Known footguns, flaky tests, odd config. Add them as you find them.]
Notes
- Rules you want in every project can go in ~/.claude/CLAUDE.md instead.
- Already have an AGENTS.md? Add a line @AGENTS.md to CLAUDE.md to import it instead of duplicating rules.
- Running /init in an existing repo drafts a CLAUDE.md from your code; merge the sections below into it.
Want a fuller CLAUDE.md plus stack rules for Next.js, FastAPI, Godot, Unity and discord.js? The Rules Mega Pack ($19) has them.