memory.md +120 −0
12| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------- |12| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------- |
13| **Enterprise policy** | • macOS: `/Library/Application Support/ClaudeCode/CLAUDE.md`<br />• Linux: `/etc/claude-code/CLAUDE.md`<br />• Windows: `C:\Program Files\ClaudeCode\CLAUDE.md` | Organization-wide instructions managed by IT/DevOps | Company coding standards, security policies, compliance requirements | All users in organization |13| **Enterprise policy** | • macOS: `/Library/Application Support/ClaudeCode/CLAUDE.md`<br />• Linux: `/etc/claude-code/CLAUDE.md`<br />• Windows: `C:\Program Files\ClaudeCode\CLAUDE.md` | Organization-wide instructions managed by IT/DevOps | Company coding standards, security policies, compliance requirements | All users in organization |
14| **Project memory** | `./CLAUDE.md` or `./.claude/CLAUDE.md` | Team-shared instructions for the project | Project architecture, coding standards, common workflows | Team members via source control |14| **Project memory** | `./CLAUDE.md` or `./.claude/CLAUDE.md` | Team-shared instructions for the project | Project architecture, coding standards, common workflows | Team members via source control |
15| **Project rules** | `./.claude/rules/*.md` | Modular, topic-specific project instructions | Language-specific guidelines, testing conventions, API standards | Team members via source control |
15| **User memory** | `~/.claude/CLAUDE.md` | Personal preferences for all projects | Code styling preferences, personal tooling shortcuts | Just you (all projects) |16| **User memory** | `~/.claude/CLAUDE.md` | Personal preferences for all projects | Code styling preferences, personal tooling shortcuts | Just you (all projects) |
16| **Project memory (local)** | `./CLAUDE.local.md` | Personal project-specific preferences | Your sandbox URLs, preferred test data | Just you (current project) |17| **Project memory (local)** | `./CLAUDE.local.md` | Personal project-specific preferences | Your sandbox URLs, preferred test data | Just you (current project) |
17 18
86 * CLAUDE.md memories can be used for both instructions shared with your team and for your individual preferences.87 * CLAUDE.md memories can be used for both instructions shared with your team and for your individual preferences.
87</Tip>88</Tip>
88 89
90## Modular rules with `.claude/rules/`
91
92For larger projects, you can organize instructions into multiple files using the `.claude/rules/` directory. This allows teams to maintain focused, well-organized rule files instead of one large CLAUDE.md.
93
94### Basic structure
95
96Place markdown files in your project's `.claude/rules/` directory:
97
98```
99your-project/
100├── .claude/
101│ ├── CLAUDE.md # Main project instructions
102│ └── rules/
103│ ├── code-style.md # Code style guidelines
104│ ├── testing.md # Testing conventions
105│ └── security.md # Security requirements
106```
107
108All `.md` files in `.claude/rules/` are automatically loaded as project memory, with the same priority as `.claude/CLAUDE.md`.
109
110### Path-specific rules
111
112Rules can be scoped to specific files using YAML frontmatter with the `paths` field. These conditional rules only apply when Claude is working with files matching the specified patterns.
113
114```markdown theme={null}
115---
116paths: src/api/**/*.ts
117---
118
119# API Development Rules
120
121- All API endpoints must include input validation
122- Use the standard error response format
123- Include OpenAPI documentation comments
124```
125
126Rules without a `paths` field are loaded unconditionally and apply to all files.
127
128### Glob patterns
129
130The `paths` field supports standard glob patterns:
131
132| Pattern | Matches |
133| ---------------------- | ---------------------------------------- |
134| `**/*.ts` | All TypeScript files in any directory |
135| `src/**/*` | All files under `src/` directory |
136| `*.md` | Markdown files in the project root |
137| `src/components/*.tsx` | React components in a specific directory |
138
139You can use braces to match multiple patterns efficiently:
140
141```markdown theme={null}
142---
143paths: src/**/*.{ts,tsx}
144---
145
146# TypeScript/React Rules
147```
148
149This expands to match both `src/**/*.ts` and `src/**/*.tsx`. You can also combine multiple patterns with commas:
150
151```markdown theme={null}
152---
153paths: {src,lib}/**/*.ts, tests/**/*.test.ts
154---
155```
156
157### Subdirectories
158
159Rules can be organized into subdirectories for better structure:
160
161```
162.claude/rules/
163├── frontend/
164│ ├── react.md
165│ └── styles.md
166├── backend/
167│ ├── api.md
168│ └── database.md
169└── general.md
170```
171
172All `.md` files are discovered recursively.
173
174### Symlinks
175
176The `.claude/rules/` directory supports symlinks, allowing you to share common rules across multiple projects:
177
178```bash theme={null}
179# Symlink a shared rules directory
180ln -s ~/shared-claude-rules .claude/rules/shared
181
182# Symlink individual rule files
183ln -s ~/company-standards/security.md .claude/rules/security.md
184```
185
186Symlinks are resolved and their contents are loaded normally. Circular symlinks are detected and handled gracefully.
187
188### User-level rules
189
190You can create personal rules that apply to all your projects in `~/.claude/rules/`:
191
192```
193~/.claude/rules/
194├── preferences.md # Your personal coding preferences
195└── workflows.md # Your preferred workflows
196```
197
198User-level rules are loaded before project rules, giving project rules higher priority.
199
200<Tip>
201 Best practices for `.claude/rules/`:
202
203 * **Keep rules focused**: Each file should cover one topic (e.g., `testing.md`, `api-design.md`)
204 * **Use descriptive filenames**: The filename should indicate what the rules cover
205 * **Use conditional rules sparingly**: Only add `paths` frontmatter when rules truly apply to specific file types
206 * **Organize with subdirectories**: Group related rules (e.g., `frontend/`, `backend/`)
207</Tip>
208
89## Organization-level memory management209## Organization-level memory management
90 210
91Enterprise organizations can deploy centrally managed CLAUDE.md files that apply to all users.211Enterprise organizations can deploy centrally managed CLAUDE.md files that apply to all users.