Three steps. Drop a markdown file into your project root, start Claude Code, watch it follow your rules. Then test v2.1.59+ auto-memory by asking the agent to remember a preference, restart the session, ask again. When this finishes you have procedural memory wired and persistence verified.
Create CLAUDE.md next to your package.json. Paste the block below and edit the project specifics. Claude Code reads it on every session start.
# Acme Dashboard | agent instructions Stack: Next.js 15 app router, TypeScript strict, Tailwind v4, pnpm. Tests: vitest + Playwright. Tests live next to the file as `*.test.ts`. Node: 22 LTS. Do not bump deps unless asked. ## Rules 1. Use pnpm. Never npm or yarn. Lockfile is the source of truth. 2. New routes go under `app/`. Server components by default; mark `"use client"` only when you actually need hooks. 3. Tailwind utilities first. Custom CSS goes in `globals.css` only. 4. Every new API route gets a vitest unit test in the same folder. 5. Commit messages: imperative present tense. No emoji. No "feat:" prefix. 6. Before writing code, look for an existing helper in `lib/`. Most things you need are already there. 7. When you read a file, prefer Edit over Write. Do not rewrite a whole file to change three lines. 8. Secrets live in `.env.local` (gitignored). Never log them. 9. If you are unsure which approach the team prefers, ask. 10. Style: short paragraphs, no jargon, no dashes-as-connectors.
Run the CLI from the directory that holds your new CLAUDE.md. The session boots with your rules already loaded.
cd ~/code/acme-dashboard claude
Then ask it something the rules cover. The agent will follow the file without you re-stating the rules in the prompt.
Add a `/api/health` route that returns `{"ok": true}` with a unit test.
Claude Code v2.1.59+ ships MEMORY.md auto-memory by default. The agent writes facts it decides are worth keeping. Tell it a preference, end the session, restart, ask.
Remember that I always prefer pnpm over npm.
Exit (Ctrl+D or /exit). Start a fresh session in the same folder. Ask:
What package manager do I prefer?
grep -rli pnpm ~/.claude/projects/*/memory/ 2>/dev/null
MEMORY.md is an index file in ~/.claude/projects/<encoded-path>/memory/. Each remembered fact lives in its own file with frontmatter (name, description, type) and gets indexed in MEMORY.md as a one-line pointer. The agent decides what type the memory is (user, feedback, project, reference) and writes it directly.
If you want to peek at the encoding: Claude Code replaces / in your project path with -, so ~/code/acme-dashboard becomes C--Users-you-code-acme-dashboard in the memory dir name.
Agent did not pick up the rules. CLAUDE.md must be at the directory you launched claude from, OR at a parent. Inner CLAUDE.md files merge with outer ones; project-level rules cascade.
Auto-memory did nothing. Check your version with claude --version. Need 2.1.59 or newer. If older, run npm i -g @anthropic-ai/claude-code (or pnpm dlx if you took your own advice).
Got two CLAUDE.md files. Global lives at ~/.claude/CLAUDE.md (cross-project rules); project lives at <project>/CLAUDE.md (this repo only). Both load. Keep cross-cutting rules global, project-specific ones local.