Intermediate9 min

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.

CLAUDE.md
# 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.

claude - payments-service
$/init
Scanned 142 files. Drafted CLAUDE.md with commands and conventions.
Review and edit it down to what matters most.
$

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.

Memory is loaded every turn
Everything in CLAUDE.md costs context on every request. Keep it lean. Move rarely-needed detail into separate docs the agent can read on demand instead of bloating the always-on memory.
Editor - CLAUDE.md
Explorer
CLAUDE.md
src/
.cursor/rules/
package.json
CLAUDE.md
1## Commands
2- Test: npm test
3- Type check: npm run typecheck
4
5## Conventions
6- No `any`. Use the Money type for currency.
A tight memory file the agent loads automatically each session.

Hands-on tasks