← BLOG
Tips

CLAUDE.md Best Practices: Configure Claude Code for Any Project

CLAUDE.md is the single most impactful configuration for Claude Code. A well-written one turns generic AI assistance into project-specific expertise.

CLAUDE.md is a markdown file at the root of your project. Claude Code reads it at the start of every session before you type anything. A good CLAUDE.md transforms generic AI into a tool that understands your project's conventions, tech stack, and red lines.

What should you include in CLAUDE.md?

Focus on information that a smart developer joining your team would need on day one. Keep it practical: tech stack, commands, conventions, and things to avoid.

Minimal CLAUDE.md template

markdown
# Project Context

Next.js 14 app with TypeScript, Tailwind CSS, and Prisma.
Database: PostgreSQL. Auth: NextAuth.js.

## Commands
- `npm run dev` — start dev server (port 3000)
- `npm run test` — run Jest tests
- `npm run lint` — run ESLint
- `npm run db:migrate` — run Prisma migrations

## Architecture
- Server components by default, client components in /components/client/
- API routes in /app/api/ with Zod validation
- Database queries in /lib/db/ (never in components)

## Conventions
- TypeScript strict mode, never use `any`
- Tailwind for styling, no CSS modules
- Conventional commits: feat:, fix:, chore:

## Do NOT
- Modify files in /legacy/ or /vendor/
- Change auth configuration without explicit approval
- Add new dependencies without asking first

What are the most common CLAUDE.md mistakes?

MistakeWhy it hurtsFix
Too long (500+ lines)Wastes context window on every sessionKeep under 200 lines, link to docs for details
Too vague ("write clean code")Gives no actionable guidanceBe specific: "Use server components by default"
Missing commandsClaude guesses how to run/test/buildList every relevant npm script
No restrictionsClaude may modify sensitive filesAdd a clear "Do NOT" section
Duplicate of READMEREADME is for humans, CLAUDE.md is for AIFocus on conventions and rules, not project description

How do you structure CLAUDE.md for large projects?

For large codebases, use the @import syntax to split configuration across directories. Claude Code follows imports and builds a complete picture.

markdown
# Root CLAUDE.md

## Global conventions
- TypeScript strict, no `any`
- All API routes validate input with Zod

@import packages/api/CLAUDE.md
@import packages/web/CLAUDE.md
@import packages/shared/CLAUDE.md

Each sub-CLAUDE.md contains rules specific to that package. This keeps the root file short while giving Claude Code deep context about each area of the codebase.

How do you generate CLAUDE.md automatically?

Claude Code can generate a starting CLAUDE.md by analyzing your project:

bash
# Auto-generate CLAUDE.md
claude /init

# This creates a CLAUDE.md based on:
# - package.json scripts
# - Project structure
# - Existing config files
# - Git history patterns
TIP

Start with /init, then refine manually. The auto-generated file is a good starting point, but it won't know your team's unwritten conventions. Add those yourself.

What about CLAUDE.md memory hierarchy?

Claude Code reads CLAUDE.md files from multiple locations, in order of priority:

  • +Project root CLAUDE.md (everyone on the team shares this)
  • +Subdirectory CLAUDE.md files (via @import)
  • +~/.claude/CLAUDE.md (your personal global preferences)
  • +Auto Memory (MEMORY.md, managed by /memory command)

Project-level settings override personal ones. This means team conventions always win over individual preferences.

Frequently asked questions

Should I commit CLAUDE.md to git?+
Yes. CLAUDE.md is a team resource, like .editorconfig or .eslintrc. Committing it ensures every developer on the team gets the same AI behavior. If you have personal preferences, put them in ~/.claude/CLAUDE.md instead.
How often should I update CLAUDE.md?+
Update it whenever your project conventions change. Add new commands, update architecture notes, and refine restrictions as you learn what Claude Code needs guidance on. A quarterly review is a good minimum cadence.
Does CLAUDE.md work with other AI tools?+
CLAUDE.md is specific to Claude Code. Cursor uses .cursorrules for a similar purpose. The concepts are transferable, but the file format is not. Some teams maintain both files from a single source of truth.
What's the difference between CLAUDE.md and Skills?+
CLAUDE.md provides project context and rules that apply to every session. Skills are reusable command templates for specific tasks (e.g., "deploy to staging"). Think of CLAUDE.md as the briefing document and Skills as the action playbook.
ALL POSTSSTART FREE COURSE →