Skip to Content
AdvancedCLAUDE.md Guide

CLAUDE.md Guide

Detailed guide to Claude Code’s core instruction file system.

One-line summary: CLAUDE.md is your project’s constitution. It determines how Claude Code understands your project, what rules it follows, and which agents it calls.

What is CLAUDE.md?

CLAUDE.md is the first instruction file Claude Code reads when starting a session. This file defines your project’s rules, agent structure, workflows, quality standards, and more.

Just as a person reads an employee handbook when joining a new company, Claude Code reads CLAUDE.md when starting a session to understand the project context.

File Structure

MoAI-ADK uses 2 instruction files and a rules directory.

File/DirectoryPurposeGit TrackedUpdate Behavior
CLAUDE.mdMoAI-ADK core instructionsYesOverwritten
CLAUDE.local.mdPersonal custom instructionsNoPreserved
.claude/rules/moai/Conditional detailed rulesYesOverwritten
.claude/rules/local/Personal custom rulesNoPreserved

MoAI CLAUDE.md Main Sections

1. Core Identity

Defines the role of the MoAI orchestrator and HARD rules.

## 1. Core Identity MoAI is the Strategic Orchestrator for Claude Code. ### HARD Rules (Required) - [HARD] Language-aware responses: Respond in user's conversation_language - [HARD] Parallel execution: Execute independent tool calls in parallel - [HARD] No XML tags: Don't display XML in user-facing responses - [HARD] Markdown output: Use Markdown for all communications

2. Request Processing Pipeline

4-stage pipeline for analyzing and routing user requests.

StageDescription
1. AnalyzeEvaluate request complexity, detect technical keywords
2. RouteSelect appropriate path based on command type
3. ExecuteDelegate to agents to perform tasks
4. ReportIntegrate results and report to user

3. Command Reference

Defines 3 command types in MoAI-ADK.

TypeCommandsPurpose
Type A (Workflow)/moai project, /moai plan, /moai run, /moai syncMajor development workflows
Type B (Utility)/moai, /moai fix, /moai loopQuick fixes, automation
Type C (Feedback)/moai feedbackImprovement reports

4. Agent Catalog

Defines roles and selection criteria for 20 agents.

TierAgentsCount
Managerspec, ddd, docs, quality, strategy, project, git7
Expertbackend, frontend, security, devops, performance, debug, testing, refactoring8
Builderagent, skill, command, plugin4

5. SPEC Workflow

Defines 3-stage SPEC-based development workflow.

# Plan: Create SPEC document (30K tokens) > /moai plan "feature description" # Run: DDD implementation (180K tokens) > /moai run SPEC-XXX # Sync: Documentation sync (40K tokens) > /moai sync SPEC-XXX

6. Quality Gates

Defines TRUST 5 framework and LSP quality gates.

Quality StandardRequirements
Tested85%+ coverage, 0 LSP type errors
ReadableClear names, 0 LSP lint errors
UnifiedConsistent style, ≤10 LSP warnings
SecuredOWASP compliance, 0 LSP security warnings
TrackableClear commits, LSP state tracking

7. User Interaction Architecture

Subagents cannot directly interact with users.

8. Configuration Reference

References language settings, user settings, and project rules.

language: conversation_language: ko # User response language agent_prompt_language: en # Agent internal language git_commit_messages: en # Git commit messages code_comments: en # Code comments documentation: en # Documentation files

Using CLAUDE.local.md

CLAUDE.local.md is for writing personal rules and notes. It’s preserved regardless of MoAI-ADK updates.

Writing Example

# Project Local Settings ## Documentation Writing Guidelines ### Prevent MDX Rendering Errors - Always add space between emphasis and parentheses ### Mermaid Diagram Direction - All diagrams in vertical orientation (flowchart TD) ## Personal Notes - Backup required before DB migration - API endpoint naming: use kebab-case

Usage Tips

PurposeExample Content
Coding rules”Variable names in camelCase, file names in kebab-case”
Project notes”Auth: JWT, expires 24h, refresh 7d”
Prohibitions”Don’t leave console.log in production code”
Preferred patterns”Use only function components for React”
MDX rules”Space required between emphasis and parentheses”

.claude/rules/ System

The .claude/rules/ directory stores conditionally loaded detailed rules.

Directory Structure

.claude/rules/moai/ ├── core/ # Core principles │ └── moai-constitution.md # TRUST 5, core rules ├── development/ # Development standards │ ├── skill-authoring.md # Skill writing guide │ └── coding-standards.md # Coding standards ├── workflow/ # Workflows │ ├── workflow-modes.md # Plan/Run/Sync definitions │ └── spec-workflow.md # SPEC workflow └── languages/ # Language-specific rules (16) ├── python.md ├── typescript.md ├── javascript.md └── ...

Conditional Loading (paths frontmatter)

Rule files are loaded only when working on specific files via paths frontmatter.

--- paths: - "**/*.py" - "**/pyproject.toml" --- # Python coding rules - Use ruff formatter - Type hints required - Docstrings in Google style

This rule is only loaded when modifying Python files, saving tokens.

Rule File Types

DirectoryFileLoad Condition
core/moai-constitution.mdAlways loaded
development/skill-authoring.mdDuring skill-related work
development/coding-standards.mdDuring code work
workflow/workflow-modes.mdDuring workflow commands
workflow/spec-workflow.mdDuring SPEC-related work
languages/python.md etc.When modifying that language’s files

Size Limits

CLAUDE.md should be kept at 40,000 characters or less.

Response to Size Exceeded

Response Strategy:

  1. Move detailed content: Separate long explanations into .claude/rules/ files
  2. Use references: Reference from CLAUDE.md using @filepath
  3. Keep only essentials: Maintain only identity, HARD rules, agent catalog
  4. Convert to skills: Convert long pattern explanations to skills

Practical Example: CLAUDE.local.md Custom Rules

Frontend Project

# Project Local Settings ## React Rules - Components must be written as function components - Props interfaces defined at top of component file - Use Zustand for state management - Use only Tailwind CSS for CSS ## Naming Rules - Components: PascalCase (UserProfile.tsx) - Utilities: camelCase (formatDate.ts) - Constants: UPPER_SNAKE_CASE (MAX_RETRY_COUNT) - API endpoints: kebab-case (/api/user-profiles) ## Prohibitions - No `any` type usage - No console.log in production code - No default exports (only named exports)

Backend Project

# Project Local Settings ## Python Rules - Use FastAPI - Prefer async functions (async/await) - Use Pydantic v2 models - SQLAlchemy 2.0 style ## Database Rules - Backup required before migration - Add indexes after query pattern analysis - Use soft delete pattern (is_deleted flag) ## API Rules - RESTful endpoint naming - Unified response format: {"data": ..., "message": ...} - Standardized error codes

Relationship Between CLAUDE.md, Rules, Skills, and Agents

LayerFileLoad TimeRole
1. CLAUDE.mdCLAUDE.mdAlwaysProject identity, core rules
2. Rules.claude/rules/*.mdFile pattern matchConditional detailed rules
3. Skills.claude/skills/*/skill.mdTrigger matchExpert knowledge, patterns
4. Agents.claude/agents/*.mdOn delegationExpert role definitions

Tip: Instead of directly modifying CLAUDE.md, it’s recommended to add personal rules in CLAUDE.local.md. Personal rules are safely preserved during MoAI-ADK updates.

Last updated on