intermediate12 min read· Module 4, Lesson 6
📝CLAUDE.md and Memory System
Teach Claude about your project and let it remember across sessions
CLAUDE.md — Your Project's Instruction Manual
CLAUDE.md is a markdown file you add to your project root. Claude Code reads it at the start of every session. Think of it as a briefing document for your AI assistant.
Creating CLAUDE.md
The easiest way:
claude /initThis generates a starter CLAUDE.md based on your project. Or create it manually:
# Project: My Awesome App
## Overview
This is a Next.js e-commerce application with a Node.js backend.
## Tech Stack
- Frontend: Next.js 14, TypeScript, Tailwind CSS
- Backend: Express.js, PostgreSQL
- Testing: Jest, React Testing Library
## Code Style
- Use functional components with hooks
- Prefer const over let
- Use TypeScript strict mode
- File naming: kebab-case for files, PascalCase for components
## Architecture
- /src/app — Next.js app router pages
- /src/components — Reusable UI components
- /src/lib — Utility functions and API clients
- /src/types — TypeScript type definitions
## Commands
- npm run dev — Start development server
- npm test — Run tests
- npm run lint — Run ESLint
- npm run build — Production build
## Important Notes
- Never use any as a TypeScript type
- All API calls go through /src/lib/api-client.ts
- Database migrations are in /prisma/migrationsCLAUDE.md Best Practices
| Do | Don't |
|---|---|
| Include architecture decisions | Write a novel — keep it concise |
| List coding conventions | Repeat what's obvious from package.json |
| Note important patterns | Include secrets or API keys |
| Mention common gotchas | Duplicate your README |
| Specify preferred libraries | List every file in the project |
Where to Put CLAUDE.md
| Location | Scope |
|---|---|
| Project root | Applies to the whole project |
| Subdirectory | Applies when working in that folder |
| ~/.claude/CLAUDE.md | Applies to ALL your projects (personal preferences) |
Auto Memory
Claude Code also has an auto memory system. As it works with you, it automatically saves learnings like:
- Build commands that work
- Project-specific debugging insights
- Patterns it discovered in your codebase
You can view saved memories with:
claude /memoryMemory vs CLAUDE.md
| CLAUDE.md | Auto Memory |
|---|---|
| You write it | Claude writes it automatically |
| Static instructions | Dynamic learnings |
| Version controlled | Personal to your machine |
| Team-shareable | Only for you |
Next up: Learn about custom commands (skills) and hooks.