Lesson 16Memory
Memory & CLAUDE.md
Project context
Memory Hierarchy
Claude Code loads instructions from multiple levels. All levels are combined:
Managed (Organization)Priority 1
Managed by organizationOrganization rules applied to all employee projects
UserPriority 2
~/.claude/CLAUDE.mdYour personal preferences for all projects
ProjectPriority 3
.claude/CLAUDE.md или CLAUDE.mdInstructions for the whole team, committed to git
LocalPriority 4
CLAUDE.local.mdLocal settings, not committed to git
Example CLAUDE.md
# CLAUDE.md ## Project Overview This is a Next.js 14 e-commerce application with TypeScript. ## Tech Stack - Next.js 14 with App Router - TypeScript 5.3 - Prisma ORM with PostgreSQL - Tailwind CSS + shadcn/ui ## Development Commands ```bash npm run dev # Start development server npm run test # Run Jest tests npm run lint # ESLint check npm run db:push # Push Prisma schema ``` ## Code Conventions - Use functional components with hooks - Prefer server components where possible - Use Zod for validation - All API routes should have error handling ## Directory Structure ``` src/ ├── app/ # Next.js app router ├── components/ # React components ├── lib/ # Utilities and helpers ├── prisma/ # Database schema └── types/ # TypeScript types ``` ## Important Files - src/lib/auth.ts — Authentication logic - src/lib/db.ts — Database client - prisma/schema.prisma — Data model
File Imports
CLAUDE.md can import other files for modularity:
# CLAUDE.md ## Imports @docs/api-conventions.md @docs/testing-guide.md @.claude/rules/security.md ## Project specific rules ...
💡 Use @path/to/file to include file contents in context
/memory Command
Use /memory to quickly add information to memory:
> /memory
What to add to project memory?
Always use pnpm instead of npm
✓ Added to .claude/CLAUDE.md
What to Include in CLAUDE.md
✓ Recommended
- • Project description
- • Development commands
- • Directory structure
- • Code style and conventions
- • Important files and modules
- • Dependencies and versions
✗ Avoid
- • Secrets and API keys
- • Personal data
- • Huge code blocks
- • Outdated documentation
- • Information not for Claude
Memory Organization Tips
- 1.Keep CLAUDE.md up to date — outdated info is harmful
- 2.Split into modules for large projects
- 3.Use CLAUDE.local.md for personal settings
- 4.Commit .claude/CLAUDE.md to git for team
This lesson is part of a structured LLM course.
My Learning Path