All guides

AI Context

The definitive guide to CLAUDE.md

CLAUDE.md is how Claude Code learns your codebase's conventions, build commands, and house rules. Here is how to configure it, structure it, and keep it from drifting out of date.

Last reviewed: July 2026

What is CLAUDE.md?

CLAUDE.md is Claude Code's native memory and instruction file. At the start of every session, Claude Code reads this file to boot up its context—learning your project's commands, conventions, architecture patterns, and gotchas.

Unlike general readme files, CLAUDE.md is designed specifically for an AI coding agent. It holds standing instructions that tell Claude Code what style to write, what linters to run, and what commands to execute when building or testing.

Understanding the Scopes of CLAUDE.md

Claude Code checks for instructions at multiple levels, allowing you to separate personal, project, and team preferences:

1. Global/User Scope: Stored in your home directory (e.g., ~/.claude.json or ~/.claude.md). This holds your personal editor preferences and system-wide styles.

2. Project/Repo Scope: Stored at your repository root (e.g., repo/CLAUDE.md). This holds project-specific build/test commands and team coding guidelines. This file is committed to git.

3. Local Scope: Stored in the local workspace (.git/info/exclude or local-only configurations) for workspace-specific parameters you don't commit.

Wiring CLAUDE.md to AGENTS.md

If your team uses multiple AI coding agents (such as Cursor, Codex, and Claude Code), maintaining duplicate rules files like AGENTS.md and CLAUDE.md is a recipe for documentation drift.

The recommended pattern is to keep your core conventions and build commands in AGENTS.md (which is read by Cursor and other open tools), and make your CLAUDE.md import it using an @AGENTS.md directive or a symlink. You can then add Claude-specific command configurations below the import, maintaining a single source of truth for the core rules.

Keeping CLAUDE.md from Drifting

Like any documentation, CLAUDE.md can go stale. If a developer changes the test runner command or refactors the folder layout but forgets to update CLAUDE.md, Claude Code will confidently execute the wrong commands.

Tying CLAUDE.md updates to your CI/CD pipeline or pull request reviews is the best way to prevent drift. You can run automated checks that verify if the documented build and test commands still match what is defined in your package.json or config files.

Let Moxie Docs manage the drift

Moxie Docs connects to your repository, monitors code merges, and automatically updates your codebase guides. If your build commands or directory structures change, Moxie will automatically detect the drift and propose updates to your CLAUDE.md and AGENTS.md files via reviewable docs PRs—so you never have to worry about stale AI context.

FAQ

Frequently asked questions

Quick answers to the questions developers ask about CLAUDE.md guide.

Where should CLAUDE.md be located?+

At the root directory of your repository, so Claude Code can locate and read it immediately when you start a session in that folder.

Does Claude Code read AGENTS.md?+

No, Claude Code only reads CLAUDE.md natively. To share rules across tools, use a CLAUDE.md that imports or symlinks AGENTS.md.

Should I commit CLAUDE.md to Git?+

Yes. Committing CLAUDE.md ensures that everyone on your team—and any agent running on the repo—shares the same coding guidelines and build scripts.

Get started

Give your agents real codebase context.

Connect a repository and Moxie Docs generates living documentation and serves it to your agents over MCP. 14-day free trial, no charge today.