CLAUDE.md & Memory
Every Claude Code session starts without the conversation of earlier sessions. This page shows how to give Claude your test commands and conventions in CLAUDE.md, and how auto memory keeps what Claude learns while it works.
12 min read12 মিনিটে পড়া যায় · 9 sections9টি সেকশন · 5 sources5টি সোর্স · updated Nov 2026আপডেট: Nov 2026
Which CLAUDE.md files loadকোন CLAUDE.md ফাইল লোড হয়
Watch the files stack up from broad to specific, and see a subfolder file load only when Claude touches that folder.ফাইলগুলো বড় সীমা থেকে নির্দিষ্ট সীমার ক্রমে জমা হতে দেখুন, আর দেখুন সাবফোল্ডারের ফাইল শুধু তখনই লোড হয় যখন Claude সেই ফোল্ডারে হাত দেয়।
You’ll learnআপনি শিখবেন
- Files load from broad to specificফাইল বড় সীমা থেকে নির্দিষ্টের ক্রমে লোড হয়
- Files add up; none overridesফাইল জোড়া লাগে, কোনোটি override করে না
- A subfolder file loads only on touchসাবফোল্ডারের ফাইল শুধু ছুঁলে লোড হয়
- MEMORY.md loads up to 200 linesMEMORY.md সর্বোচ্চ 200 লাইন লোড হয়
- CLAUDE.md asks; a hook enforcesCLAUDE.md অনুরোধ করে, hook বাধ্য করে
Two ways Claude remembers
Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions: CLAUDE.md files, which you write, and auto memory, which Claude writes. Source 1সোর্স 1
CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You Source 1সোর্স 1 | Claude Source 1সোর্স 1 |
| Where it lives | Your project, your home folder, or a system folder (see below) Source 1সোর্স 1 | ~/.claude/projects/<project>/memory/ Source 1সোর্স 1 |
| What loads at session start | The full file, up to 4 MiB Source 1সোর্স 1 | The first 200 lines or the first 25KB of MEMORY.md Source 1সোর্স 1 |
| Shared with the team | The project file, through source control Source 1সোর্স 1 | No. It is machine-local. Source 1সোর্স 1 |
Claude treats both as context, not as enforced configuration. Source 1সোর্স 1 Claude Code delivers CLAUDE.md content as a user message after the system prompt, not as part of the system prompt. There is no guarantee of strict compliance. Source 1সোর্স 1
Common mistake: a hard rule only in CLAUDE.md
"Do not modify .env files" in CLAUDE.md is a request, not a block. To block an action regardless of what Claude decides, use a PreToolUse hook. Source 1সোর্স 1 The Settings page shows a deny rule that protects .env files.
সহজ English
Each Claude Code session starts with a fresh context window. Two things carry knowledge from one session to the next. You write the CLAUDE.md files. Claude writes the auto memory. Source 1সোর্স 1
- A
CLAUDE.mdfile lives in your project, your home folder, or a system folder. At session start, Claude Code loads the full file, up to 4 MiB. Your team can share the project file through source control. Source 1সোর্স 1 - Auto memory lives in
~/.claude/projects/<project>/memory/. At session start, Claude Code loads the first 200 lines or the first 25KB ofMEMORY.md. Auto memory stays on your machine. It is not shared with the team. Source 1সোর্স 1
Claude treats both as context, not as enforced configuration. Claude Code gives the CLAUDE.md content to Claude as a user message after the system prompt. Strict compliance is not guaranteed. Source 1সোর্স 1 So "Do not modify .env files" in CLAUDE.md is a request, not a block. To block an action every time, use a PreToolUse hook. Source 1সোর্স 1
বাংলা ব্যাখ্যা
প্রতিটি Claude Code session একটি নতুন context window দিয়ে শুরু হয়। এক session থেকে পরের session-এ জ্ঞান বয়ে নেওয়ার দুটি উপায় আছে: CLAUDE.md file, যা আপনি লেখেন, আর auto memory, যা Claude লেখে। Source 1সোর্স 1
CLAUDE.mdথাকে আপনার project-এ, home folder-এ অথবা একটি system folder-এ। Session শুরুতে পুরো file load হয়, 4 MiB পর্যন্ত। Project-এর file-টি source control-এর মাধ্যমে team-এর সাথে share হয়। Source 1সোর্স 1- Auto memory থাকে
~/.claude/projects/<project>/memory/-এ। Session শুরুতেMEMORY.md-এর প্রথম 200 line অথবা প্রথম 25KB load হয়। এটি machine-local, team-এর সাথে share হয় না। Source 1সোর্স 1
Claude দুটোকেই context হিসেবে দেখে, enforced configuration হিসেবে নয়। Claude Code CLAUDE.md-এর content system prompt-এর পরে একটি user message হিসেবে দেয়, system prompt-এর অংশ হিসেবে নয়। Claude যে কঠোরভাবে মানবে, তার কোনো guarantee নেই। Source 1সোর্স 1 তাই CLAUDE.md-এ "Do not modify .env files" লেখা একটি অনুরোধ, block নয়। Claude যা-ই ঠিক করুক, কোনো action block করতে একটি PreToolUse hook ব্যবহার করুন। Source 1সোর্স 1
Where CLAUDE.md files live
The table lists the locations in load order, from the broadest scope to the most specific. So a project instruction appears in context after a user instruction. Source 1সোর্স 1
| Scope | Location | Use it for |
|---|---|---|
| Managed policy | macOS: /Library/Application Support/ClaudeCode/CLAUDE.mdLinux and WSL: /etc/claude-code/CLAUDE.mdWindows: C:\Program Files\ClaudeCode\CLAUDE.md Source 1সোর্স 1 | Rules that an organization sets. Individual settings cannot exclude this file. Source 1সোর্স 1 |
| User | ~/.claude/CLAUDE.md Source 1সোর্স 1 | Your personal preferences for all projects Source 1সোর্স 1 |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md Source 1সোর্স 1 | Team instructions, shared through source control Source 1সোর্স 1 |
| Local | ./CLAUDE.local.md Source 1সোর্স 1 | Your personal preferences for this project. Add the file to .gitignore. Source 1সোর্স 1 |
An admin can also put managed CLAUDE.md content in managed-settings.json with the claudeMd key. The key has no effect in user, project, or local settings. Source 1সোর্স 1
How the files load
- Claude Code loads
CLAUDE.mdandCLAUDE.local.mdfrom the working directory and from every directory above it. Source 1সোর্স 1 - Claude Code concatenates all the files it finds. One file does not override another. Source 1সোর্স 1
- The order is from the filesystem root down to the working directory. In one directory,
CLAUDE.local.mdcomes afterCLAUDE.md. Source 1সোর্স 1 - A
CLAUDE.mdin a subdirectory below the working directory does not load at launch. It loads when Claude reads, writes, or edits a file in that subdirectory. Source 1সোর্স 1 - Claude Code does not load
CLAUDE.mdfrom directories that you add with--add-dir. To load them, setCLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1. Source 1সোর্স 1
Example: put the end-to-end test conventions in tests/e2e/CLAUDE.md. They load only when Claude works on a file in tests/e2e/, so a backend-only task does not pay for them.
Check what loaded
- Run
/context alland look at the list under Memory files. Source 1সোর্স 1 - Run
/memoryto see theCLAUDE.md,CLAUDE.local.md, and other memory files, turn auto memory on or off, and open the auto memory folder. Source 1সোর্স 1 Source 2সোর্স 2 - To log which
CLAUDE.mdand rules files load, and why, use theInstructionsLoadedhook. Source 1সোর্স 1
সহজ English
A CLAUDE.md file can be in four places. Claude Code loads them in this order, from the broadest scope to the most specific: Source 1সোর্স 1
- Managed policy: a system folder. An organization sets these rules. Individual settings cannot exclude this file.
- User:
~/.claude/CLAUDE.md, for your preferences in all projects. - Project:
./CLAUDE.mdor./.claude/CLAUDE.md, for team instructions in source control. - Local:
./CLAUDE.local.md, for your preferences in this project. Add this file to.gitignore.
Claude Code loads the CLAUDE.md and CLAUDE.local.md files from the working directory and from each directory above it. It joins all the files. One file does not override another. A CLAUDE.md in a subdirectory below the working directory does not load at launch. It loads when Claude reads, writes, or edits a file in that subdirectory. Source 1সোর্স 1
To see which files loaded, run /context all and look at the Memory files list. You can also run /memory to see the memory files. Source 1সোর্স 1 Source 2সোর্স 2
বাংলা ব্যাখ্যা
CLAUDE.md file চারটি জায়গায় থাকতে পারে। Claude Code এগুলো সবচেয়ে বড় scope থেকে সবচেয়ে নির্দিষ্ট scope-এর ক্রমে load করে: Source 1সোর্স 1
- Managed policy: একটি system folder। Organization এখানে নিয়ম ঠিক করে। Individual settings এই file-কে বাদ দিতে পারে না।
- User:
~/.claude/CLAUDE.md, সব project-এ আপনার নিজের পছন্দের জন্য। - Project:
./CLAUDE.mdঅথবা./.claude/CLAUDE.md, source control-এ share করা team instruction-এর জন্য। - Local:
./CLAUDE.local.md, এই project-এ আপনার নিজের পছন্দের জন্য। File-টি.gitignore-এ যোগ করুন।
Claude Code working directory এবং তার উপরের প্রতিটি directory থেকে CLAUDE.md ও CLAUDE.local.md file load করে। সব file একসাথে জোড়া লাগে, একটি আরেকটিকে override করে না। Working directory-র নিচের কোনো subdirectory-র CLAUDE.md launch-এর সময় load হয় না। Claude ওই subdirectory-র কোনো file read, write বা edit করলে তখন load হয়। Source 1সোর্স 1 যেমন, end-to-end test-এর convention tests/e2e/CLAUDE.md-এ রাখলে সেগুলো শুধু tests/e2e/-এর file-এ কাজ করার সময় load হয়।
কোন file load হলো দেখতে /context all চালান এবং Memory files list দেখুন। /memory চালিয়েও memory file-গুলো দেখা যায়। Source 1সোর্স 1 Source 2সোর্স 2
Generate a first file with /init
/init is a command inside a session, not a CLI flag. Source 2সোর্স 2 Start Claude Code in the project folder, then run it:
cd payment-service
claude/initClaude analyzes the codebase and writes a starting CLAUDE.md with build commands, test instructions, and conventions. If a CLAUDE.md already exists, /init suggests improvements and does not overwrite it. Source 1সোর্স 1 Source 2সোর্স 2
With CLAUDE_CODE_NEW_INIT=1, /init runs an interactive flow with several phases. It asks which artifacts to set up (CLAUDE.md files, skills, hooks), explores the codebase with a subagent, and shows a proposal that you review before it writes files. Source 1সোর্স 1 Source 2সোর্স 2
/init also reads rules that you wrote for other tools: Source 1সোর্স 1
- Cursor:
.cursor/rules/and.cursorrules - GitHub Copilot:
.github/copilot-instructions.md - With
CLAUDE_CODE_NEW_INIT=1also:AGENTS.md,.devin/rules/,.windsurf/rules/or.windsurfrules, and.clinerules
Edit what /init writes
Treat the generated file as a first draft. Add the test conventions that Claude cannot see in the code, then remove lines that do not help.
সহজ English
/init is a command that you run inside a session. It is not a CLI flag. Source 2সোর্স 2 Start Claude Code in the project folder, then run /init.
Claude studies the codebase and writes a first CLAUDE.md with build commands, test instructions, and conventions. If a CLAUDE.md already exists, /init does not overwrite it. It suggests improvements. Source 1সোর্স 1 Source 2সোর্স 2
If you set CLAUDE_CODE_NEW_INIT=1, /init runs an interactive flow with several phases. It asks which items to set up (CLAUDE.md files, skills, hooks). It shows you a proposal before it writes files. Source 1সোর্স 1 Source 2সোর্স 2
/init also reads rules that you wrote for other tools, for example .cursorrules for Cursor and .github/copilot-instructions.md for GitHub Copilot. Source 1সোর্স 1
Think of the new file as a first draft. Add the test conventions that Claude cannot see in the code. Remove the lines that do not help.
বাংলা ব্যাখ্যা
/init হলো session-এর ভিতরে চালানোর একটি command, CLI flag নয়। Source 2সোর্স 2 Project folder-এ Claude Code চালু করুন, তারপর /init চালান।
Claude codebase বিশ্লেষণ করে build command, test instruction আর convention দিয়ে একটি প্রাথমিক CLAUDE.md লেখে। আগে থেকেই CLAUDE.md থাকলে /init সেটি overwrite করে না, বরং উন্নতির পরামর্শ দেয়। Source 1সোর্স 1 Source 2সোর্স 2
CLAUDE_CODE_NEW_INIT=1 set করলে /init কয়েকটি phase-এর একটি interactive flow চালায়। এটি জিজ্ঞেস করে কোন artifact set up করবেন (CLAUDE.md file, skill, hook), একটি subagent দিয়ে codebase ঘুরে দেখে, আর file লেখার আগে আপনাকে review করার জন্য একটি proposal দেখায়। Source 1সোর্স 1 Source 2সোর্স 2
অন্য tool-এর জন্য লেখা rule-ও /init পড়ে, যেমন Cursor-এর .cursor/rules/ ও .cursorrules, আর GitHub Copilot-এর .github/copilot-instructions.md। Source 1সোর্স 1
তৈরি হওয়া file-টিকে প্রথম খসড়া হিসেবে দেখুন। Code-এ দেখা যায় না এমন test convention যোগ করুন, আর যে line কাজে আসে না তা মুছে ফেলুন।
What a test project's CLAUDE.md should contain
Write instructions that are concrete enough to verify, for example "Use 2-space indentation" or "Run npm test before committing". Source 1সোর্স 1 If two instructions contradict each other, Claude may pick one arbitrarily. Source 1সোর্স 1
Add a line to CLAUDE.md when one of these happens: Source 1সোর্স 1
- Claude makes the same mistake again.
- A code review catches something that Claude should know.
- You type the same correction again.
- A new teammate needs the same context.
Keep these out of CLAUDE.md:
- Procedures with many steps. Put them in a skill. Source 1সোর্স 1 See Skills & Commands.
- Rules for one part of the codebase. Put them in a path-scoped rule. Source 1সোর্স 1
- Hard rules that must always apply. Use a hook. Source 1সোর্স 1 See Hooks.
Target under 200 lines per CLAUDE.md file. Longer files use more context and reduce adherence. Source 1সোর্স 1
Example
A CLAUDE.md for a payment service with unit and end-to-end tests. The scripts, folders, and subagent names belong to this example project.
# Payment Service
## Commands
- Unit tests: `npm run test:unit`
- End-to-end tests: `npm run test:e2e`
- One end-to-end file: `npm run test:e2e -- tests/e2e/refund.spec.ts`
- Lint: `npm run lint`
## Test layout
- Unit tests sit next to the code: `src/**/*.test.ts`
- End-to-end tests live in `tests/e2e/`
- Test data seeds live in `tests/fixtures/`
## Conventions
- Mock external payment APIs. Never mock the database.
- Use the `user_id` values from `tests/fixtures/users.json`. Do not invent IDs.
- A task is done when `npm run lint` and `npm run test:unit` pass.
- If a test fails only sometimes, report it as flaky. Do not add retries.
## Help
- For requirement review and test design, use the qa-agent subagent.
- For root-cause analysis, use the sdet-agent subagent.Doকরুন: Concrete and verifiable
"Run npm test before committing." Claude can check that it did this. Source 1সোর্স 1
Don'tকরবেন না: Vague advice
"Write good tests." Claude cannot check this. Write a rule that you can verify instead. Source 1সোর্স 1
Doকরুন: Must-run steps in a hook
Hooks run as shell commands at fixed lifecycle events. Use a hook for a step that must run every time. Source 1সোর্স 1
Don'tকরবেন না: Security rules only in CLAUDE.md
Claude treats CLAUDE.md as context, not as enforced configuration. Source 1সোর্স 1
সহজ English
Write instructions that are concrete enough to check, for example "Run npm test before committing". Source 1সোর্স 1 Claude cannot check a vague line such as "Write good tests". Source 1সোর্স 1 If two instructions do not agree, Claude may pick either one. Source 1সোর্স 1
Add a line when Claude makes the same mistake again, when a code review finds something that Claude should know, when you type the same correction again, or when a new teammate needs the same context. Source 1সোর্স 1
Keep these items out of CLAUDE.md: Source 1সোর্স 1
- Put a procedure with many steps in a skill.
- Put a rule for one part of the codebase in a path-scoped rule.
- Use a hook for a hard rule that must always apply.
Try to keep each CLAUDE.md file under 200 lines. A longer file uses more context, and Claude follows it less well. Source 1সোর্স 1
The example shows a CLAUDE.md for a payment service. It lists the test commands, the test layout, the conventions, and the subagents to use.
বাংলা ব্যাখ্যা
এমন instruction লিখুন যা যাচাই করা যায়, যেমন "Use 2-space indentation" অথবা "Run npm test before committing"। Source 1সোর্স 1 "Write good tests"-এর মতো অস্পষ্ট পরামর্শ Claude যাচাই করতে পারে না। Source 1সোর্স 1 দুটি instruction পরস্পরবিরোধী হলে Claude যেকোনো একটি বেছে নিতে পারে। Source 1সোর্স 1
এই ক্ষেত্রগুলোতে CLAUDE.md-এ একটি line যোগ করুন: Claude একই ভুল আবার করলে, code review-তে এমন কিছু ধরা পড়লে যা Claude-এর জানা উচিত, একই correction আবার লিখতে হলে, অথবা নতুন teammate-এর একই context দরকার হলে। Source 1সোর্স 1
এগুলো CLAUDE.md-এর বাইরে রাখুন: Source 1সোর্স 1
- অনেক ধাপের procedure একটি skill-এ রাখুন।
- Codebase-এর একটি অংশের rule একটি path-scoped rule-এ রাখুন।
- যে hard rule সবসময় মানতে হবে, তার জন্য hook ব্যবহার করুন।
প্রতিটি CLAUDE.md file 200 line-এর নিচে রাখার চেষ্টা করুন। লম্বা file বেশি context খরচ করে এবং Claude সেটি কম মেনে চলে। Source 1সোর্স 1
Hook নির্দিষ্ট lifecycle event-এ shell command হিসেবে চলে। যে step প্রতিবার চালাতেই হবে, তার জন্য hook ব্যবহার করুন। Source 1সোর্স 1 উদাহরণে একটি payment service-এর CLAUDE.md আছে, যাতে test command, test layout, convention আর subagent-এর নাম দেওয়া।
Keep it small: imports, rules, and AGENTS.md
Import other files with @
To pull a file into context, write @path/to/import. Imported files load at launch with the CLAUDE.md that references them. A relative path resolves from the file that contains the import. Source 1সোর্স 1 Imported files can have imports too, to a maximum depth of four hops. Source 1সোর্স 1
Example:
Project overview: @README.md
Test conventions: @docs/testing-conventions.md- Imports organize a long file, but they do not reduce its context cost, because imported files also load at launch. Source 1সোর্স 1
- Claude Code does not parse imports in code spans or fenced code blocks. To mention a path without importing it, wrap it in backticks. Source 1সোর্স 1
- The first time a project has imports from outside the working directory, Claude Code shows an approval dialog. If you decline, the imports stay disabled. Source 1সোর্স 1
- Claude Code removes block-level HTML comments such as
<!-- maintainer notes -->before the content goes into context. Comments in code blocks stay. Source 1সোর্স 1
Path-scoped rules in .claude/rules/
Put topic files in .claude/rules/. Claude Code finds all .md files in it, also in subfolders. Source 1সোর্স 1 A rule without paths frontmatter loads at launch with the same priority as .claude/CLAUDE.md. Source 1সোর্স 1
A rule with paths frontmatter loads when Claude uses the Read, Write, or Edit tool on a matching file. Source 1সোর্স 1 paths is the only frontmatter field that Claude Code reads from a rule. It takes a YAML list or a comma-separated string. Source 1সোর্স 1
Example: a rule for Playwright specs, written for this guide. The docs show the paths format in the rules section. Source 1সোর্স 1
---
paths:
- "tests/**/*.spec.ts"
---
# Spec rules
- Use descriptive test names.
- Clean up side effects in afterEach.
- Use the fixtures in tests/fixtures/ for test data.Glob patterns such as **/*.ts, src/**/*, and *.md work, and so does brace expansion such as src/**/*.{ts,tsx}. Source 1সোর্স 1
User-level rules live in ~/.claude/rules/ and load before project rules. Neither set overrides the other. If a user rule and a project rule conflict, Claude may follow either one. Source 1সোর্স 1
সহজ English
Three tools help you keep CLAUDE.md small:
- Imports. Write
@path/to/importto pull another file into context. Imported files also load at launch, so they do not reduce the context cost. An imported file can import other files, to a maximum depth of four hops. Source 1সোর্স 1 - Rules. Put topic files in
.claude/rules/. A rule withoutpathsfrontmatter loads at launch. A rule withpathsfrontmatter loads when Claude uses the Read, Write, or Edit tool on a matching file. Source 1সোর্স 1
বাংলা ব্যাখ্যা
CLAUDE.md ছোট রাখার কয়েকটি উপায় আছে:
- Import: অন্য একটি file context-এ আনতে
@path/to/importলিখুন। Imported file-ও launch-এর সময় load হয়, তাই এতে context খরচ কমে না, শুধু লম্বা file গোছানো থাকে। Imported file নিজেও import করতে পারে, সর্বোচ্চ চার hop পর্যন্ত। Source 1সোর্স 1 - Rule: বিষয়ভিত্তিক file
.claude/rules/-এ রাখুন।pathsfrontmatter ছাড়া rule launch-এর সময় load হয়।pathsথাকলে rule তখনই load হয় যখন Claude Read, Write বা Edit tool দিয়ে মেলে এমন কোনো file-এ কাজ করে। Source 1সোর্স 1 User-level rule থাকে~/.claude/rules/-এ এবং project rule-এর আগে load হয়। Source 1সোর্স 1
File size
200 lines is a target for CLAUDE.md
Claude Code loads a CLAUDE.md file of up to 4 MiB in full and skips a larger file. Source 1সোর্স 1 The 200-line figure for CLAUDE.md is guidance. Source 1সোর্স 1 The hard cut-off of 200 lines or 25KB applies to the auto memory file MEMORY.md. Source 1সোর্স 1
If an instruction file is longer than the recommended length, Claude Code shows a warning at startup and when you run /status. Source 1সোর্স 1
AGENTS.md and other tools
If your repository has an AGENTS.md and no CLAUDE.md or CLAUDE.local.md in the working directory or above, Claude reads AGENTS.md. If a CLAUDE.md or CLAUDE.local.md exists, Claude reads only the CLAUDE.md files. Source 1সোর্স 1 Reading AGENTS.md directly needs Claude Code v2.1.277 or later. Source 1সোর্স 1
To share one file with other tools, put @AGENTS.md at the top of your CLAUDE.md and add text for Claude Code below it: Source 1সোর্স 1
@AGENTS.md
## Claude Code
- Run `npm run test:unit` before you report a task as done.Symlink. A symlink (ln -s AGENTS.md CLAUDE.md) also works. But the Edit and Write tools refuse to write through a symlink, and a symlink is not safe on Windows clones. Source 1সোর্স 1
The Project instructions setting in /config controls this. Its default is claude-md-or-agents-md. Other values are claude-md-and-agents-md, claude-md, and managed-only. Source 1সোর্স 1
Importing from other tools. To copy the configuration of another tool, use /import, with the argument codex, gemini, or cursor. It copies instruction files, MCP servers, commands, subagents, and skills. Source 1সোর্স 1 Source 2সোর্স 2 Importing from Cursor needs Claude Code v2.1.265 or later. /import is not available on Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, Claude Platform on AWS, or through a Claude apps gateway. Source 2সোর্স 2
Monorepos
In a monorepo, claudeMdExcludes skips CLAUDE.md files that you do not need. It takes a list of glob patterns for absolute paths. To keep the setting for yourself, put it in .claude/settings.local.json. Arrays merge across settings layers. Source 1সোর্স 1 A managed CLAUDE.md cannot be excluded. Source 1সোর্স 1
Example:
{
"claudeMdExcludes": ["/home/me/monorepo/mobile-app/**"]
}সহজ English
- AGENTS.md. If there is no
CLAUDE.mdorCLAUDE.local.mdin the working directory or above, Claude readsAGENTS.md. To share one file with other tools, put@AGENTS.mdat the top of yourCLAUDE.md. Source 1সোর্স 1
Claude Code loads a CLAUDE.md of up to 4 MiB in full and skips a larger file. The 200-line figure for CLAUDE.md is only guidance. The hard limit of 200 lines or 25KB is for the auto memory file MEMORY.md. Source 1সোর্স 1
In a monorepo, use claudeMdExcludes to skip the CLAUDE.md files that you do not need. Source 1সোর্স 1
বাংলা ব্যাখ্যা
- AGENTS.md: Working directory বা তার উপরে কোনো
CLAUDE.mdবাCLAUDE.local.mdনা থাকলে ClaudeAGENTS.mdপড়ে। এর জন্য Claude Code v2.1.277 বা তার পরের version লাগে। অন্য tool-এর সাথে একটি file share করতেCLAUDE.md-এর শুরুতে@AGENTS.mdলিখুন। Source 1সোর্স 1
Claude Code 4 MiB পর্যন্ত CLAUDE.md পুরোটা load করে, এর চেয়ে বড় file বাদ দেয়। CLAUDE.md-এর জন্য 200 line শুধু একটি নির্দেশিকা। 200 line বা 25KB-এর কঠোর সীমা auto memory-র MEMORY.md file-এর জন্য। Source 1সোর্স 1
Monorepo-তে যে CLAUDE.md file দরকার নেই, সেগুলো claudeMdExcludes দিয়ে বাদ দিন। তবে managed CLAUDE.md বাদ দেওয়া যায় না। Source 1সোর্স 1
Auto memory
Auto memory is on by default in local sessions. Source 1সোর্স 1 Source 4সোর্স 4 Claude writes the notes. Source 1সোর্স 1
- Each note has a frontmatter
type:user,feedback,project, orreference. Source 1সোর্স 1 - Claude skips what it can derive from the code and what
CLAUDE.mdalready says. It does not save something in every session. Source 1সোর্স 1 - The notes live in
~/.claude/projects/<project>/memory/. Claude Code takes<project>from the git repository, so all worktrees and subdirectories of one repository share one memory folder. Outside a git repository, Claude Code uses the project root. Source 1সোর্স 1 - When Claude writes or reads auto memory, you see a message such as "Saved 2 memories" or "Recalled 2 memories". Source 1সোর্স 1
The folder has an index file and one topic file for each memory: Source 1সোর্স 1 Source 3সোর্স 3
~/.claude/projects/<project>/memory/
├── MEMORY.md ← index, one line per memory
├── user_role.md
└── feedback_testing.md- The first 200 lines of
MEMORY.md, or the first 25KB, whichever comes first, load at the start of every conversation. Source 1সোর্স 1 Source 3সোর্স 3 - Topic files do not load at startup. Claude reads them with its file tools when it needs them. Source 1সোর্স 1
- Auto memory is machine-local. Claude Code does not share the files across machines or cloud environments. Source 1সোর্স 1
- The session cleanup (
cleanupPeriodDays, default 30) does not delete memory files. Source 1সোর্স 1 Source 3সোর্স 3
Control auto memory
To save a fact to auto memory, say so in the prompt. To put it in CLAUDE.md, say that instead: Source 1সোর্স 1
remember that the API tests require a local Redis instanceadd this to CLAUDE.mdTo turn auto memory off, use one of these: Source 1সোর্স 1 Source 4সোর্স 4
- The toggle in
/memory. It writesautoMemoryEnabledto~/.claude/settings.json. "autoMemoryEnabled": falsein the project settings.- The environment variable
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1.
The --bare flag also skips auto memory. Source 4সোর্স 4
To move the storage, set autoMemoryDirectory in settings. The value must be an absolute path or start with ~/. Source 1সোর্স 1
সহজ English
Auto memory is on by default in local sessions. Source 1সোর্স 1 Source 4সোর্স 4 Claude writes the notes. Claude skips what it can learn from the code and what CLAUDE.md already says. It does not save something in every session. Source 1সোর্স 1
The notes live in ~/.claude/projects/<project>/memory/. All worktrees and subdirectories of one git repository share one memory folder. The folder has an index file, MEMORY.md, and one topic file for each memory. Source 1সোর্স 1
At the start of each conversation, Claude Code loads the first 200 lines or the first 25KB of MEMORY.md, whichever comes first. Claude reads a topic file only when it needs it. The memory files stay on your machine, and the session cleanup does not delete them. Source 1সোর্স 1
To save a fact to auto memory, tell Claude to remember it. To put it in CLAUDE.md, say "add this to CLAUDE.md". Source 1সোর্স 1
To turn auto memory off, use the toggle in /memory, set "autoMemoryEnabled": false in the project settings, or set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. Source 1সোর্স 1 Source 4সোর্স 4
বাংলা ব্যাখ্যা
Local session-এ auto memory default-ভাবে চালু থাকে। Source 1সোর্স 1 Source 4সোর্স 4 Note-গুলো Claude নিজে লেখে। Code থেকে যা বোঝা যায় এবং CLAUDE.md-এ যা আগেই আছে, Claude তা বাদ দেয়। সব session-এ Claude কিছু save করবেই, এমন নয়। Source 1সোর্স 1
Note-গুলো থাকে ~/.claude/projects/<project>/memory/-এ। Claude Code <project> নেয় git repository থেকে, তাই একই repository-র সব worktree আর subdirectory একটি memory folder share করে। Claude memory লিখলে বা পড়লে আপনি "Saved 2 memories" বা "Recalled 2 memories"-এর মতো message দেখবেন। Source 1সোর্স 1
Folder-এ একটি index file MEMORY.md এবং প্রতিটি memory-র জন্য একটি topic file থাকে। প্রতিটি conversation-এর শুরুতে MEMORY.md-এর প্রথম 200 line অথবা প্রথম 25KB, যেটি আগে আসে, load হয়। Topic file startup-এ load হয় না, দরকার হলে Claude সেগুলো পড়ে। Source 1সোর্স 1 Auto memory machine-local। Session cleanup (cleanupPeriodDays, default 30) memory file মোছে না। Source 1সোর্স 1
কোনো তথ্য auto memory-তে save করতে prompt-এ সেটা বলুন। CLAUDE.md-এ রাখতে চাইলে "add this to CLAUDE.md" বলুন। Source 1সোর্স 1
Auto memory বন্ধ করতে /memory-এর toggle, project settings-এ "autoMemoryEnabled": false, অথবা CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 ব্যবহার করুন। Source 1সোর্স 1 Source 4সোর্স 4 --bare flag-ও auto memory বাদ দেয়। Source 4সোর্স 4
Subagent memory
CLAUDE.md files load into subagents too: all levels, rules, CLAUDE.local.md, managed files, and AGENTS.md. Source 5সোর্স 5 The built-in Explore, Plan, and web-fetch subagents skip them. A subagent whose frontmatter (or --agents JSON) sets omitClaudeMd: true skips the user, project, and local CLAUDE.md files. Managed policy files still load, except for subagents defined in managed settings. omitClaudeMd needs Claude Code v2.1.271 or later. Source 5সোর্স 5
The main conversation's auto memory does not load into subagents. A subagent gets its own memory only with the memory field. Source 5সোর্স 5
memory value | Folder |
|---|---|
user | ~/.claude/agent-memory/<name-of-agent>/ Source 5সোর্স 5 |
project | .claude/agent-memory/<name-of-agent>/ Source 5সোর্স 5 |
local | .claude/agent-memory-local/<name-of-agent>/ Source 5সোর্স 5 |
You can share project memory through version control. The docs recommend project as the default scope. Source 5সোর্স 5 When the memory field is set, the subagent gets: Source 5সোর্স 5
- Instructions to read and write its memory, in its system prompt
- The first 200 lines or the first 25KB of its own
MEMORY.md - The Read, Write, and Edit tools
If auto memory is off, the memory field has no effect. Source 5সোর্স 5
Example: add memory: project to the frontmatter of .claude/agents/qa-agent.md. The qa-agent then keeps notes on recurring defect patterns in .claude/agent-memory/qa-agent/. See Subagents for the other frontmatter fields.
সহজ English
CLAUDE.md files also load into subagents. Source 5সোর্স 5 The built-in Explore, Plan, and web-fetch subagents skip them. A subagent with omitClaudeMd: true skips the user, project, and local CLAUDE.md files. Managed policy files still load, except for subagents defined in managed settings. omitClaudeMd needs Claude Code v2.1.271 or later. Source 5সোর্স 5
A subagent does not get the auto memory of the main conversation. It gets its own memory only if you set the memory field to user, project, or local. Each value uses a different folder. You can share project memory through version control, and the docs recommend project as the default. Source 5সোর্স 5
With the memory field, the subagent gets instructions to read and write its memory, the first 200 lines or 25KB of its own MEMORY.md, and the Read, Write, and Edit tools. If auto memory is off, the memory field has no effect. Source 5সোর্স 5
For example, add memory: project to the frontmatter of .claude/agents/qa-agent.md. The qa-agent then keeps its notes in .claude/agent-memory/qa-agent/.
বাংলা ব্যাখ্যা
CLAUDE.md file subagent-এও load হয়: সব level, rule, CLAUDE.local.md, managed file এবং AGENTS.md। Source 5সোর্স 5 তবে built-in Explore ও Plan subagent এগুলো বাদ দেয়। কোনো subagent-এর frontmatter (বা --agents JSON)-এ omitClaudeMd: true থাকলে সেটি user, project ও local CLAUDE.md বাদ দেয়, কিন্তু managed policy file তখনও load হয়। Source 5সোর্স 5
Main conversation-এর auto memory subagent-এ load হয় না। Subagent নিজের memory পায় শুধু memory field set করলে। এর value হতে পারে user, project অথবা local, আর প্রতিটির folder আলাদা। project memory version control-এর মাধ্যমে share করা যায়, এবং docs project-কেই default scope হিসেবে recommend করে। Source 5সোর্স 5
memory field set থাকলে subagent পায়: system prompt-এ নিজের memory পড়া ও লেখার instruction, নিজের MEMORY.md-এর প্রথম 200 line বা প্রথম 25KB, এবং Read, Write ও Edit tool। Auto memory বন্ধ থাকলে memory field-এর কোনো প্রভাব নেই। Source 5সোর্স 5
উদাহরণ: .claude/agents/qa-agent.md-এর frontmatter-এ memory: project যোগ করুন। তখন qa-agent বারবার ঘটা defect pattern-এর note রাখে .claude/agent-memory/qa-agent/-এ।
When Claude ignores your instructions
- Run
/context alland check that the file is in the Memory files list. Source 1সোর্স 1 - Make the instruction concrete and verifiable. Source 1সোর্স 1
- Look for a contradicting instruction in another file. Claude may pick one arbitrarily. Source 1সোর্স 1
- If a step must always run, for example before every commit, write it as a hook. Source 1সোর্স 1
- Run
/doctor prompt-audit. It checksCLAUDE.md,CLAUDE.local.md,AGENTS.md, rules, skills, and other files for outdated or conflicting content, and changes nothing until you ask. It needs Claude Code v2.1.283 or later. Source 1সোর্স 1 Source 2সোর্স 2
Instructions in chat can be lost after /compact
The project-root CLAUDE.md survives /compact, because Claude re-reads it from disk. Nested CLAUDE.md files and path-scoped rules load again on demand. Instructions that you gave only in the chat can be lost. Source 1সোর্স 1 Put a lasting rule in CLAUDE.md.
সহজ English
If Claude does not follow your instructions, do these steps:
- Run
/context all. Make sure that the file is in the Memory files list. Source 1সোর্স 1 - Make the instruction concrete, so that it can be verified. Source 1সোর্স 1
- Look for an instruction in another file that says the opposite. Claude may pick either one. Source 1সোর্স 1
- If a step must always run, write it as a hook. Source 1সোর্স 1
- Run
/doctor prompt-audit. It looks for outdated or conflicting content in your instruction files. It changes nothing until you ask. It needs Claude Code v2.1.283 or later. Source 1সোর্স 1 Source 2সোর্স 2
After /compact, Claude reads the project-root CLAUDE.md again from disk. Instructions that you gave only in the chat can be lost. Source 1সোর্স 1 So put a lasting rule in CLAUDE.md.
বাংলা ব্যাখ্যা
Claude আপনার instruction না মানলে এই ধাপগুলো অনুসরণ করুন:
/context allচালান এবং দেখুন file-টি Memory files list-এ আছে কি না। Source 1সোর্স 1- Instruction-টি concrete এবং যাচাইযোগ্য করুন। Source 1সোর্স 1
- অন্য কোনো file-এ বিপরীত instruction আছে কি না খুঁজুন। এমন হলে Claude যেকোনো একটি বেছে নিতে পারে। Source 1সোর্স 1
- কোনো step সবসময় চালাতে হলে, যেমন প্রতিটি commit-এর আগে, সেটি hook হিসেবে লিখুন। Source 1সোর্স 1
/doctor prompt-auditচালান। এটিCLAUDE.md,CLAUDE.local.md,AGENTS.md, rule, skill ও অন্যান্য file-এ পুরোনো বা পরস্পরবিরোধী content খোঁজে, এবং আপনি না বলা পর্যন্ত কিছু বদলায় না। এর জন্য Claude Code v2.1.283 বা তার পরের version লাগে। Source 1সোর্স 1 Source 2সোর্স 2
Project-root-এর CLAUDE.md /compact-এর পরেও থাকে, কারণ Claude সেটি disk থেকে আবার পড়ে। Nested CLAUDE.md আর path-scoped rule দরকার হলে আবার load হয়। কিন্তু শুধু chat-এ দেওয়া instruction হারিয়ে যেতে পারে। Source 1সোর্স 1 তাই স্থায়ী rule CLAUDE.md-এ লিখুন।