Project Rules and Memory Files
On a real project you do not want to re-explain your conventions every session. A memory file fixes this. Claude Code reads a CLAUDE.md at the project root automatically; Cursor reads files in a .cursor/rules folder. These are persistent instructions the agent loads every time, so your standards stick.
Step 1: Write a focused CLAUDE.md
Keep it short and specific. List the commands that matter, the conventions you care about, and the traps to avoid. A wall of text gets ignored; a tight checklist gets followed.
# Project: payments-service
## Commands
- Test: `npm test`
- Type check: `npm run typecheck`
- Lint: `npm run lint`
## Conventions
- TypeScript strict mode. No `any`.
- Use the existing `Money` type for all currency; never raw numbers.
- Write a test for every new endpoint before marking a task done.
## Do not
- Do not edit files in `/generated`.
- Do not add new dependencies without flagging them.Step 2: Let the agent draft it for you
You do not have to write the memory file from scratch. Run the init command and the agent will scan your repo and propose a draft you can trim.
Step 3: Keep it honest over time
When the agent repeatedly makes the same mistake, that is a signal to add a line to the memory file, not to keep correcting it by hand. The file is a living contract between you and the agent.