Back to Quick Reads
Cover: Your AI starts every session with a blank slate. Give it a project memory, and keep it fast with the prompt cache.
Illustrative comparison: without a memory file the AI may guess an Express handler; with CLAUDE.md it is more likely to write a NestJS controller method that calls a service.
Four memory file locations: ~/.claude/CLAUDE.md for you in every project, ./CLAUDE.md for the team, ./CLAUDE.local.md for you in this project, and .claude/rules for topic rules.
Example CLAUDE.md with the stack, an @import of an API style guide, conventions, and a "Do not touch" section listing migrations and generated files.
A path-scoped rule file in .claude/rules/api.md that loads only for files matching src/api/**/*.ts.
Comparison: CLAUDE.md is written by you, shared in git and loaded every session; auto memory is written by Claude, stays on your machine, and the first 200 lines or 25KB of MEMORY.md load each session.
Flow: each request is system prompt and tools, then project context (CLAUDE.md, auto memory), then the conversation. The cache matches the unchanged start.
Tips to keep the prompt cache warm: pick the model at the start, CLAUDE.md edits apply after /clear, /compact or restart, compact at natural breaks, clear between unrelated tasks.
Claude Code commands: /init, /memory, /context, /compact, /clear, /usage. Memory is guidance, not a lock; use a hook to block an action.
Follow Sharif on LinkedIn and sharifrahat.com

1 / 10

Quick Read · AI

Give your AI a project memory

· 10 slides

Your AI starts each new session from zero. So you explain your project again and again. The fix is simple: add a CLAUDE.md file to your project. Claude Code reads it at the start of every session. Write 4 things in it: 1. Your stack: NestJS, PostgreSQL, TypeScript 2. Your rules: thin controllers, logic in services 3. Your commands: build, test, lint 4. What not to touch: migrations, generated files Where to put it: → ./CLAUDE.md for your team (add it to git) → ~/.claude/CLAUDE.md for your own style → .claude/rules/ for rules that only some files need Save time and tokens: → Choose your model at the start. If you change it later, Claude reads everything again. → Use /compact between tasks. Use /clear for a new topic. Keep the file short. Anthropic suggests under 200 lines. What is the first rule you would add?
  • #claudecode
  • #ai
  • #softwareengineering
  • #developerproductivity
  • #webdevelopment
View on LinkedIn