CLAUDE.md Guide

Write the Perfect CLAUDE.md

CLAUDE.md is the single file that shapes how Claude understands your project. A well-written one means fewer corrections, better code, and agents that actually know what they're working on.

This guide walks you through every section of a CLAUDE.md file, from tech stack declarations to agent-specific hints. Follow along and build yours step by step.

What Is CLAUDE.md?

CLAUDE.md is a markdown file you place at the root of your project. When Claude Code starts a session, it reads this file first. Everything inside it becomes part of Claude's context: your tech stack, your file structure, your team's conventions, and any specific instructions you want every agent to follow.

Think of it as a briefing document. Without it, Claude has to guess how your project is organized. With a good one, Claude already knows where things live, which patterns to follow, and what to avoid. The difference in output quality is significant.

A 10-minute investment in CLAUDE.md saves hours of correcting AI-generated code that doesn't match your project's patterns.

Observed across hundreds of Claude Code projects

Bad vs. Good CLAUDE.md

The structure and specificity of your CLAUDE.md directly impacts how well Claude performs in your codebase.

Weak CLAUDE.md

  • Vague instructions like "use best practices" with no specifics
  • No file structure map, so Claude guesses where to put new code
  • Missing coding conventions; output style varies between sessions
  • No build or test commands listed, leading to broken suggestions

Strong CLAUDE.md

  • Explicit tech stack with versions: React 19, Vite 6, Zustand 5, Tailwind 4
  • Clear file map showing key directories and their purpose
  • Documented naming patterns, error handling, and style preferences
  • Build, test, and dev commands ready to copy and run

6 Essential Sections

A well-structured CLAUDE.md covers these six areas. Each one gives Claude concrete information it can act on immediately.

Tech Stack Declaration

List your frameworks, libraries, and their versions explicitly. Include your package manager, Node version, and any runtime requirements. Claude uses this to generate compatible code without guessing.

File Structure Map

Describe your key directories and what lives in each one. Components, stores, services, API routes, types. A short tree diagram with one-line descriptions per folder works well.

Coding Conventions

Document your naming patterns (camelCase for files, PascalCase for components), error handling approach, import ordering, and any project-specific rules. This keeps Claude's output consistent with your existing code.

Build and Test Commands

Include your dev, build, test, and lint commands. When Claude needs to verify something works or suggest a script, it will use the exact commands your project expects.

Agent Role Hints

If you use multiple agents (QA, frontend, backend, DevOps), add a section describing what each role should focus on. This is especially useful with AgentsRoom's multi-agent setup.

Avoid Areas

Tell Claude what NOT to do. Don't modify config files, don't change the auth system, don't refactor the database layer. Explicit boundaries prevent agents from making unwanted changes.

Build Your CLAUDE.md in 4 Steps

You don't need to write everything at once. Start with the basics and expand as you discover what Claude needs to know.

1

Audit Your Project

Open your package.json and list every framework, library, and tool your project uses. Note the versions. Check your runtime requirements (Node version, Python version, database). This becomes your tech stack section.

package.json + runtime versions + database

2

Map Your File Tree

Run a quick tree of your src directory. Identify the top-level folders and write a one-line description of each. Focus on where components, stores, services, types, and API routes live.

src/ tree with purpose annotations

3

Document Your Conventions

Look at your existing code and note the patterns: how you name files, how you handle errors, how you structure imports, whether you use default or named exports. Write these down as short rules.

Naming, imports, error handling, exports

4

Add Agent-Specific Sections

If you work with specialized agents, add focus areas for each role. The frontend agent should know your component library. The DevOps agent should know your deployment pipeline. The QA agent should know your testing framework.

Per-role focus areas + avoid areas

Why AgentsRoom for CLAUDE.md?

AgentsRoom is built around CLAUDE.md as a first-class concept, not an afterthought.

Built-in CLAUDE.md Editor

Edit your CLAUDE.md directly inside AgentsRoom with syntax highlighting and live saving. No switching to your text editor or IDE.

Live Preview per Agent

See how each agent interprets your CLAUDE.md in real time. Watch terminal output to verify that agents follow your conventions and respect your avoid areas.

Per-Project Context

Each project in AgentsRoom has its own CLAUDE.md. Switch between projects and each agent automatically loads the right context file for that codebase.

Agent Role Integration

AgentsRoom's 14 agent roles pair directly with CLAUDE.md sections. Define focus areas and avoid areas per role, and each agent picks up exactly the instructions meant for it.

CLAUDE.md FAQ

Where should I place my CLAUDE.md file?+
Place it at the root of your project directory, next to your package.json or equivalent config file. Claude Code reads it automatically when starting a session in that directory. You can also have nested CLAUDE.md files in subdirectories for more specific context.
How long should a CLAUDE.md file be?+
There is no strict limit, but aim for 50 to 300 lines. Cover the essentials: tech stack, file structure, conventions, and commands. Too short and Claude lacks context. Too long and you risk diluting the important parts with noise.
Does CLAUDE.md work with all Claude models?+
Yes. CLAUDE.md is read by Claude Code regardless of which model you select (Opus, Sonnet, or Haiku). All models benefit from explicit project context, though larger models like Opus can absorb and apply more detailed instructions.
Should I commit CLAUDE.md to version control?+
Yes, for shared project instructions. Your team benefits from consistent AI behavior across all developers. For personal preferences, AgentsRoom supports personal agent configs that are gitignored automatically.
Can I use CLAUDE.md with multi-agent setups?+
Absolutely. In AgentsRoom, every agent in your project reads the same CLAUDE.md. You can add role-specific sections (e.g., notes for the QA agent vs. the frontend agent) so each specialist gets targeted instructions.
How often should I update my CLAUDE.md?+
Update it whenever your project's structure or conventions change. Added a new framework? Update the tech stack. Moved to a new directory layout? Update the file map. A stale CLAUDE.md leads to stale suggestions.

Start Writing Better CLAUDE.md Files

Download AgentsRoom and use the built-in CLAUDE.md editor to give your agents the context they need. Better instructions, better code.

Download AgentsRoom

Free forever · bring your own API key