Files
Luong NGUYEN ac9ee17169 docs: make version stamps and Compatible Models footers true (#259)
Type: docs

Makes the version stamps, Compatible Models footers and locale README badges say only what has been checked. Every claim below was checked against `https://code.claude.com/docs/en/<page>.md` or the raw changelog (2.1.303–2.1.322), not written from memory.

## Part A: English footers at 2.1.310 / 2.1.302

Each file's behavioural claims were checked against every changelog entry after its stamp, up to 2.1.322, and against the current docs. A stamp moves only when every claim checks out.

| File | Claims checked | Fixes | Sources | New stamp |
|---|---|---|---|---|
| `INDEX.md` | ~75: AGENTS.md rule (v2.1.277); skill/agent/MCP install paths; `/mcp__github__list_prs`; 5 hook types, 33 events, task-tool model note; `--plugin-dir`; checkpoint menu (6 options); `/workflows`, ultracode (v2.1.284), size guideline; 6 permission modes; `/loop` and the cron tools; Chrome; Remote Control; `SendMessage`/`ListAgents`/`notify_when_idle`; CLI flags | 1. Workflow size: medium aims for fewer than 10 agents only since v2.1.271 (15 before), and the default is small on a Pro plan. 2. dontAsk: file reads inside the working directories also run, as do *most* calls a `permissions.allow` rule or a `PreToolUse` hook approves (neither can approve critical-path `rm`/`rmdir` or network-path reads), and an installed mod can approve some calls. No version is given: the changelog doesn't say when a mod's `tool.check` allow arrived (it is already referenced in 2.1.290, 2.1.292 and 2.1.299). 3. `SendMessage` also reaches sessions on other machines and in the cloud, from a session connected to Remote Control with a claude.ai sign-in; a cloud session can't answer with `SendMessage`. The L383 use-case column now says the same. 4. The `--model` list adds the Fable models. 5. Plan mode: "Read-only analysis" → researches and proposes, runs shell commands to explore, edits blocked until the plan is approved. | [workflows#set-a-size-guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline) ("The default is `medium`, or `small` when you're signed in on a Pro plan with Claude Code v2.1.271 or later"); CL 2.1.219 ("aim for fewer than 15 agents"), CL 2.1.271 ("lowered the medium size guideline from 15 to 10 agents"); [permission-modes](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode) ("a mod you installed can still approve some of those calls"; "Claude still runs … file reads inside your working directories and read-only Bash commands"; "It also denies the built-in `AskUserQuestion` tool even if your allow rules match it"; "An allow rule or `PreToolUse` hook can't approve these: Recognized `rm` and `rmdir` critical-path removals … Reads from a network path"); CL 2.1.292 ("Fixed a plugin's `tool.check` hook answering allow running a tool…"), CL 2.1.299 ("…that a `PreToolUse` hook or a mod's `tool.check` hook allowed"); [permission-modes#analyze-before-you-edit-with-plan-mode](https://code.claude.com/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) ("Claude reads files, runs shell commands to explore, and writes a plan, but does not edit your source. Except in interactive terminal sessions with bypass permissions available, edits stay blocked until you approve the plan."); [cross-session-messaging](https://code.claude.com/docs/en/cross-session-messaging) ("reach your sessions on other machines or in the cloud"; "from a session that is connected to Remote Control, which needs a claude.ai sign-in"; "A cloud session … can't use `SendMessage` to answer a message from another machine"); model-config. The "device card" line checked out against [whats-new/2026-w34](https://code.claude.com/docs/en/whats-new/2026-w34). | **2.1.322** |
| `LEARNING-ROADMAP.md` | 33 hook events / 5 types; 6 built-in subagents (Explore, Plan, General-purpose, claude, statusline-setup, claude-code-guide); 60+ commands (commands page has 121 rows); `/design` (v2.1.265); `/plan`, `/rewind`, `/loop 5m`, `/schedule`; 6 permission modes (Manual since v2.1.200); Alt+T; skill `effort`/`shell`; plugin `workflows`/`channels`/`dependencies`; agent-teams env var; `claude mcp add --transport http`; `-r`, `--max-turns`, `--output-format json`; all 17 source links resolve | 1. Remote Control: "generally available" → "out of research preview", the docs' own wording. 2. Extended thinking (L368, Exercise 3, checklist): Opus 5.5, Sonnet 5.5, Haiku 5.5 and the Fable models always use extended thinking, so the exercise uses `/effort` and scopes Alt+T / Option+T to models that allow turning thinking off. 3. Exercise 4: checkpoints are automatic and unnamed, so step 1 no longer creates a named "Clean state" checkpoint and step 5 says which one to `/rewind` to. | [whats-new/2026-w34](https://code.claude.com/docs/en/whats-new/2026-w34): "Any machine running `claude remote-control` now shows up as a device card at the top of the Code tab in the Claude app. Remote Control is also out of research preview."; [interactive-mode](https://code.claude.com/docs/en/interactive-mode): Alt+T "Has no effect on Opus 5.5, Sonnet 5.5, Haiku 5.5, or the Fable models, which always use extended thinking."; [model-config](https://code.claude.com/docs/en/model-config): "the effort level is the primary control for how much thinking happens"; [checkpointing](https://code.claude.com/docs/en/checkpointing): "Every prompt you send that starts a turn creates a new checkpoint" | **2.1.322** |
| `resources.md` | Adaptive reasoning on Opus 4.7+, Sonnet 5+, Haiku 5.5 and the Fable models; permission modes; 33 hook events; `/loop` and cron; 7 memory tiers; Chrome; keybinding chords; Code Review; Monitor (2.1.98); `/goal` and `claude agents` (2.1.139); `--json` (2.1.145); all links | none needed | model-config, hooks, memory, agent-view, changelog | **stays 2.1.310**: L253 gives `/run`, `/verify`, `/run-skill-generator` as "(v2.1.145+)". Neither the changelog, the v2.1.145 release notes, the skills/commands docs nor the what's-new pages for weeks 19–22 give a version. |
| `03-skills/claude-md/SKILL.md` | `name`/`description` frontmatter, `$ARGUMENTS`; CLAUDE.md locations and loading; "under 200 lines"; AGENTS.md gates (v2.1.277, v2.1.281), blocking files, `/config` Project instructions values and default; `@AGENTS.md`/symlink fallback; `.claude/agents/` | L196: the list of cases where AGENTS.md isn't read now includes a disabled built-in plugin, and limits the upgrade case to "in some cases" after upgrading from v2.1.276 or earlier | [memory#when-agents-md-support-is-unavailable](https://code.claude.com/docs/en/memory#when-agents-md-support-is-unavailable): "You used `/plugin` to disable the built-in plugin that reads `AGENTS.md`"; "In some cases, it's your first session after you upgrade from v2.1.276 or earlier" | **stays 2.1.302**: no primary source states L24 ("~150-200 instructions", "system prompt already uses ~50") or L214 (the system reminder says CLAUDE.md "may or may not be relevant") |
| `07-plugins/devops-automation/README.md` | `--plugin-dir` install; commands; agents; hooks; MCP; workflow; source URLs (all 200) | none: the stale claims need a design decision (below) | [plugins/components](https://code.claude.com/docs/en/plugins/components): "Save a command at `commands/<file>.md` and it becomes `/<plugin>:<file>`"; [plugins-reference](https://code.claude.com/docs/en/plugins-reference) standard layout: "Hooks \| `hooks/hooks.json`", "MCP servers \| `.mcp.json`" | **stays 2.1.302**: bare `/deploy`, `/rollback`, `/status` (`/status` is also a built-in), `/incident`; `hooks/*.js` are never registered (no `hooks/hooks.json`); `mcp/kubernetes-config.json` never loads (no `.mcp.json` or `mcpServers`) |
| `07-plugins/documentation/README.md` | same | none | same | **stays 2.1.302**: bare command names; `mcp/github-docs-config.json` never loads, so the `GITHUB_TOKEN` setup has no effect |
| `07-plugins/pr-review/README.md` | same | none | same | **stays 2.1.302**: bare command names; `hooks/pre-review.js` is not registered; `mcp/github-config.json` never loads |

No changelog entry from 2.1.303 to 2.1.322 touched the plugin READMEs or SKILL.md. Their problems predate the stamps, and #209 already listed the hook/MCP files that never load.

**Locale copies:** the same factual fixes went into every locale with the same sentence. That's dontAsk and plan mode in all six INDEX files; workflow size in fa and ko; `SendMessage` and the use-case column in fa and ko; the `--model` list in fa and ko; "generally available" in fa and ko LEARNING-ROADMAP; the extended-thinking exercise/checklist and the checkpoint exercise in all six LEARNING-ROADMAP copies; the AGENTS.md cases in all six SKILL.md copies. Locale stamps were not bumped. INDEX and LEARNING-ROADMAP stay at 2.1.310 in every locale, and the SKILL.md copies keep their footers.

## Part B: Compatible Models footers

The new list is **Claude Fable 5.2, Claude Fable 5.1, Claude Fable 5, Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5.5, Claude Sonnet 5, Claude Sonnet 4.6, Claude Opus 4.8, Claude Haiku 5.5, Claude Haiku 4.5**. It is used on root docs and module pages alike, and it's the README FAQ's list, so the footers and the FAQ no longer disagree.

Why one list for both file types: STYLE_GUIDE's footer rule ("List all compatible models") applies to both. A shorter "current models only" list on module pages would break that rule. Justification from [model-config](https://code.claude.com/docs/en/model-config):

- **Current models:** "| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |"; "the `fable` alias resolves to Fable 5 in Claude apps gateway sessions and to Fable 5.2 everywhere else"; "Fable 5.2 requires Claude Code v2.1.321 or later".
- **Older models still in use:**
  - "**Fable 5.1 or Fable 5**: select it by model ID."
  - "| Claude Platform on AWS | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |".
  - "biology-flagged requests re-run on Opus 5, and cybersecurity-flagged requests re-run on Opus 4.8".
  - "**Sonnet 5.5**: cybersecurity-flagged requests re-run on Sonnet 5."
- **None are retired.** The [models overview](https://platform.claude.com/docs/en/about-claude/models/overview) that model-config links marks only Opus 4.1, Opus 4 and Sonnet 4 as "retired". All eleven listed models appear there without that mark.

Scope: 336 lines in 331 files. The changed lines are the `**Compatible Models**` lines (92, some of them in locale files) and every localized label (`호환 모델`, `مدل‌های سازگار`, `Các Mô Hình Tương Thích`, `Сумісні моделі`, `対応モデル`, `互換モデル`, `兼容模型`), plus the italic `*対応:…*` / `*Для …*` / `*适用于 …*` lines in the ja/uk/zh concepts guides. Labels, separators (`, ` `、` `، `) and locale stamps are unchanged. The README FAQ lines and the 05-mcp `tool_reference` note are not footers and were left alone. The footer lines of `CHANGELOG.md`, `fa/CHANGELOG.md` and `ko/CHANGELOG.md` also carry the new list; only the footer line changed, not the entries.

## Part C: locale README badges

Real state: the newest version that most (more than half) of the locale's ten module READMEs carry or exceed, backed by the sync commit that brought them there.

A badge is marked **(partial)** when one or more of the locale's module READMEs has no version footer (never synced since its first translation), or when the locale is a condensed translation. A module synced to an older version than the badge doesn't make it partial on its own; the majority rule above already covers that. Only zh meets the rule (02-memory and 05-mcp have no footer, and #247 calls zh condensed).

| Locale | Old badge / "latest" | Evidence | New |
|---|---|---|---|
| ja | 2.1.119 (badge, "latest", FAQ) | module footers: 3×2.1.322, 5×2.1.316, 1×2.1.310, 1×2.1.302; 8/10 ≥ 2.1.316 (#230); #247 carried only the sections ja has | **2.1.316** (Oct 2026) |
| uk | 2.1.112 (FAQ line; no badge) | 3×2.1.322, 4×2.1.316, 1×2.1.310, 2×2.1.302; 7/10 ≥ 2.1.316 (#230) | **2.1.316** (Oct 2026) |
| zh | 2.1.112 (badge, "latest", FAQ) | 2.1.316, 2.1.310 ×2, 2.1.302 ×2, 2.1.300 ×2, 2.1.278; 02 and 05 have no footer (untouched since the first translation); 7/10 ≥ 2.1.300 (#193); #247 was "condensed", model lists only | **2.1.300 (partial)** (Oct 2026): the badge, "latest" and FAQ lines say zh is condensed and that 02-memory and 05-mcp haven't been synced since the April 2026 translation |
| ko | 2.1.310 | 5×2.1.322, 5×2.1.310; #228 synced ko to 2.1.310, and #247 says 2.1.316 "was not backfilled" | **2.1.310** (unchanged) |
| fa | 2.1.310 | 5×2.1.322, 5×2.1.316; #241 "syncs the translation from v2.1.310 to v2.1.316"; #247 carried only the 2.1.322 P1 changes | **2.1.316** (Oct 2026) |
| vi | none (README has no badge or version line) | 4×2.1.322, 6×2.1.316 | no change |

Months come from the docs changelog: 2.1.300 was released October 14, 2026 and 2.1.316 October 31, 2026. The README *footers* in fa/ja/ko/uk/zh stay at 2.1.322: #247 checked those files themselves, while the badge describes the whole locale.

## Deliberately left

- **Stamps not bumped:** `resources.md` (2.1.310), `03-skills/claude-md/SKILL.md` and the three plugin READMEs (2.1.302), for the reasons in the Part A table.
- **Example plugins:** the fix is a design choice between wiring up `hooks/hooks.json` / `.mcp.json` and rewording the READMEs, and renaming commands to `/<plugin>:<name>` touches seven languages plus `07-plugins/README.md` (bare `/review-pr`). It needs a follow-up issue.
- **Same unverifiable version elsewhere:** `03-skills/README.md` also said `/run-skill-generator` is v2.1.145+. Handled by #262, now merged into this branch from `main`.
- **Older `--model` lists:** ja/uk/vi/zh INDEX have pre-5.x lists (e.g. "Sonnet 4.6, Opus 4.7, Haiku 4.5"). That isn't the English sentence, so it belongs to a locale sync.

## Follow-ups
- **LEARNING-ROADMAP `/effort` line (review r3 N13):** line 368 can read as if `/effort` applies only to the models that always use extended thinking; per model-config's effort table it also works on Opus 5, Sonnet 5 and Opus 4.8. Not wrong; clarify in the next pass.

- **Compatible Models scope (review S3):** Opus 4.6 is Microsoft Foundry's current `opus`, and Sonnet 4.5 is the current `sonnet` on Bedrock, Google Cloud's Agent Platform and Foundry (deprecated, retiring Nov 30, 2026), per model-config's alias table. Both are still in use, so either add them to the FAQ and every footer (Sonnet 4.5 marked deprecated), or define the list's scope in STYLE_GUIDE (e.g. the models the aliases resolve to on the Anthropic API plus older models in active use) and cite the deprecations table.
- **Model order (review N8):** the list puts Opus 4.8 after Sonnet 4.6. Grouping by family (Fable, Opus 5.5/5/4.8, Sonnet, Haiku) would read better; the order is shared by STYLE_GUIDE, the FAQ and every footer, so change it everywhere at once.
- **Example plugins:** the follow-up issue proposed above.

## Validation

- `SKIP=mermaid,vietnamese-mermaid,japanese-mermaid,korean-mermaid,persian-mermaid pre-commit run --files <338 changed files>`: every hook passes, including link-check (246 URLs per language). The Mermaid hooks can't install here (`language: node must have package.json or additional_dependencies`, the same failure #247 reported). `python scripts/check_mermaid.py --strict` was run directly instead: Pele 1.6.0 rendered all 416 blocks.
- `python scripts/check_cross_references.py`: all valid (674 files).
- Review fix round 1 (18 files): the same `pre-commit run --files` passes every hook (Mermaid hooks skipped as above; no Mermaid block was touched), and the cross-reference check is still valid after merging `main`.
- Review fix round 2 (14 files: the extended-thinking wording in all 7 LEARNING-ROADMAP files, the dontAsk line in all 7 INDEX files): `pre-commit run --files` passes every hook (Mermaid hooks skipped; no Mermaid block touched), and the cross-reference check is valid (674 files) after merging `main` again (#257).
- Pre-push secret scan: it flagged `06-hooks/README.md:1683` (en, fa, vi), a false positive. The `sk-…{20,}` pattern matches the docs anchor `hooks#pretooluse-ask-decisions-in-auto-mode`, which has been on `main` since 11b2ae3 (en), c2f92c8 (fa) and 8de1820 (vi), and is not on a line this PR changes. The PR's added lines have no secret-pattern matches.

Closes #256
2026-11-12 14:29:18 +01:00
..

Claude How To

Hướng Dẫn Bộ Nhớ

Bộ nhớ cho phép Claude lưu giữ bối cảnh xuyên suốt các phiên và cuộc hội thoại. Nó tồn tại dưới hai dạng: tổng hợp tự động trong claude.ai, và CLAUDE.md dựa trên filesystem trong Claude Code.

Tổng Quan

Bộ nhớ trong Claude Code cung cấp bối cảnh liên tục mà hoạt động qua nhiều phiên và cuộc hội thoại. Không giống như các cửa sổ bối cảnh tạm thời, files bộ nhớ cho phép bạn:

  • Chia sẻ tiêu chuẩn dự án cho toàn bộ đội của bạn
  • Lưu trữ tùy thích phát triển cá nhân
  • Duy trì các quy tắc và cấu hình cụ thể theo thư mục
  • Nhập tài liệu bên ngoài
  • Kiểm soát phiên bản bộ nhớ như một phần của dự án của bạn

Hệ thống bộ nhớ hoạt động ở nhiều cấp độ, từ tùy thích cá nhân toàn cầu xuống đến các thư mục con cụ thể, cho phép kiểm soát chi tiết những gì Claude nhớ và cách nó áp dụng kiến thức đó.

Tham Khảo Nhanh Các Lệnh Bộ Nhớ

Lệnh Mục Đích Cách Sử Dụng Khi Nào Sử Dụng
/init Khởi tạo bộ nhớ dự án /init Bắt đầu dự án mới, thiết lập CLAUDE.md lần đầu
/memory Chỉnh sửa files bộ nhớ trong editor /memory Các cập nhật mở rộng, tái tổ chức, xem lại nội dung
# prefix Thêm bộ nhớ một dòng nhanh # Quy tắc của bạn ở đây Thêm quy tắc nhanh trong cuộc hội thoại
# new rule into memory Thêm bộ nhớ rõ ràng # new rule into memory<br/>Quy tắc chi tiết của bạn Thêm các quy tắc đa dòng phức tạp
# remember this Bộ nhớ ngôn ngữ tự nhiên # remember this<br/>Hướng dẫn của bạn Cập nhật bộ nhớ theo hội thoại
@path/to/file Nhập nội dung bên ngoài @README.md hoặc @docs/api.md Tham khảo tài liệu hiện có trong CLAUDE.md

Bắt Đầu Nhanh: Khởi Tạo Bộ Nhớ

Lệnh /init

Lệnh /init là cách nhanh nhất để thiết lập bộ nhớ dự án trong Claude Code. Nó khởi tạo một file CLAUDE.md với tài liệu nền tảng của dự án.

Cách sử dụng:

/init

Những gì nó làm:

  • Tạo một file CLAUDE.md mới trong dự án của bạn (thường tại ./CLAUDE.md hoặc ./.claude/CLAUDE.md)
  • Thiết lập các quy ước và hướng dẫn dự án
  • Thiết lập nền tảng cho tính liên tục của bối cảnh qua các phiên
  • Cung cấp cấu trúc mẫu để ghi tiêu chuẩn dự án của bạn

Chế độ tương tác nâng cao: Đặt CLAUDE_CODE_NEW_INIT=1 để bật quy trình tương tác đa giai đoạn hướng dẫn bạn qua việc thiết lập dự án từng bước:

CLAUDE_CODE_NEW_INIT=1 claude
/init

Khi nào sử dụng /init:

  • Bắt đầu một dự án mới với Claude Code
  • Thiết lập tiêu chuẩn code và quy ước cho đội
  • Tạo tài liệu về cấu trúc codebase của bạn
  • Thiết lập hệ phân cấp bộ nhớ cho phát triển hợp tác

Ví dụ workflow:

# Trong thư mục dự án của bạn
/init

# Claude tạo CLAUDE.md với cấu trúc như:
# Project Configuration
## Project Overview
- Name: Your Project
- Tech Stack: [Your technologies]
- Team Size: [Number of developers]

## Development Standards
- Code style preferences
- Testing requirements
- Git workflow conventions

Cập Nhật Bộ Nhớ Nhanh Với #

Bạn có thể thêm thông tin vào bộ nhớ nhanh chóng trong bất kỳ cuộc hội thoại nào bằng cách bắt đầu thông điệp của bạn với #:

Cú pháp:

# Quy tắc hoặc hướng dẫn bộ nhớ của bạn ở đây

Ví dụ:

# Luôn sử dụng chế độ TypeScript strict mode trong dự án này

# Ưu tiên async/await hơn promise chains

# Chạy npm test trước mỗi commit

# Sử dụng kebab-case cho tên file

Cách nó hoạt động:

  1. Bắt đầu thông điệp của bạn với # theo sau là quy tắc của bạn
  2. Claude nhận ra đây là một yêu cầu cập nhật bộ nhớ
  3. Claude hỏi file bộ nhớ nào để cập nhật (dự án hoặc cá nhân)
  4. Quy tắc được thêm vào file CLAUDE.md phù hợp
  5. Các phiên tương lai tự động tải bối cảnh này

Các mẫu thay thế:

# new rule into memory
Luôn xác thực input người dùng với Zod schemas

# remember this
Sử dụng semantic versioning cho tất cả các releases

# add to memory
Database migrations phải có thể đảo ngược

Lệnh /memory

Lệnh /memory cung cấp truy cập trực tiếp để chỉnh sửa các file bộ nhớ CLAUDE.md của bạn trong các phiên Claude Code. Nó mở các file bộ nhớ của bạn trong editor hệ thống để chỉnh sửa toàn diện.

Cách sử dụng:

/memory

Những gì nó làm:

  • Mở các file bộ nhớ của bạn trong editor mặc định của hệ thống
  • Cho phép bạn thực hiện các thêm, sửa đổi, và tái tổ chức mở rộng
  • Cung cấp truy cập trực tiếp đến tất cả các file trong hệ phân cấp
  • Cho phép bạn quản lý bối cảnh liên tục qua các phiên

Khi nào sử dụng /memory:

  • Xem lại nội dung bộ nhớ hiện có
  • Thực hiện các cập nhật mở rộng cho tiêu chuẩn dự án
  • Tái tổ chức cấu trúc bộ nhớ
  • Thêm tài liệu hoặc hướng dẫn chi tiết
  • Duy trì và cập nhật bộ nhớ khi dự án của bạn phát triển

So sánh: /memory vs /init

Khía cạnh /memory /init
Mục đích Chỉnh sửa các file bộ nhớ hiện có Khởi tạo CLAUDE.md mới
Khi nào sử dụng Cập nhật/sửa đổi bối cảnh dự án Bắt đầu dự án mới
Hành động Mở editor để thay đổi Tạo mẫu khởi đầu
Workflow Duy trì liên tục Thiết lập một lần

Ví dụ workflow:

# Mở bộ nhớ để chỉnh sửa
/memory

# Claude trình bày các tùy chọn:
# 1. Managed Policy Memory
# 2. Project Memory (./CLAUDE.md)
# 3. User Memory (~/.claude/CLAUDE.md)
# 4. Local Project Memory

# Chọn tùy chọn 2 (Project Memory)
# Editor mặc định của bạn mở với nội dung ./CLAUDE.md

# Thực hiện thay đổi, lưu, và đóng editor
# Claude tự động tải lại bộ nhớ đã cập nhật

Sử Dụng Bộ Nhớ Nhập:

Các file CLAUDE.md hỗ trợ cú pháp @path/to/file để bao gồm nội dung bên ngoài:

# Project Documentation
Xem @README.md để có tổng quan dự án
Xem @package.json để có các lệnh npm có sẵn
Xem @docs/architecture.md để có thiết kế hệ thống

# Import từ thư mục home sử dụng đường dẫn tuyệt đối
@~/.claude/my-project-instructions.md

Tính năng import:

  • Cả đường dẫn tương đối và tuyệt đối đều được hỗ trợ (ví dụ: @docs/api.md hoặc @~/.claude/my-project-instructions.md)
  • Các import đệ quy được hỗ trợ với độ sâu tối đa 5
  • Lần đầu tiên import từ các vị trí bên ngoài sẽ kích hoạt hộp thoại phê duyệt để bảo mật
  • Các chỉ thị import không được đánh giá bên trong các khoảng mã markdown hoặc khối code (vì vậy tài liệu hóa chúng trong ví dụ là an toàn)
  • Giúp tránh trùng lặp bằng cách tham khảo tài liệu hiện có
  • Tự động bao gồm nội dung được tham chiếu trong bối cảnh của Claude

Kiến Trúc Bộ Nhớ

Bộ nhớ trong Claude Code theo một hệ thống phân cấp trong đó các phạm vi khác nhau phục vụ các mục đích khác nhau:

graph TB
    A["Claude Session"]
    B["User Input"]
    C["Memory System"]
    D["Memory Storage"]

    B -->|User provides info| C
    C -->|Synthesizes every 24h| D
    D -->|Loads automatically| A
    A -->|Uses context| C

Hệ Phân Cấp Bộ Nhớ trong Claude Code

Claude Code sử dụng một hệ thống bộ nhớ phân cấp đa tầng. Các file bộ nhớ được tự động tải khi Claude Code khởi động, với các file cấp cao hơn được ưu tiên.

Hệ Phân Cấp Bộ Nhớ Hoàn Chỉnh (theo thứ tự ưu tiên):

  1. Managed Policy - Hướng dẫn toàn tổ chức

    • macOS: /Library/Application Support/ClaudeCode/CLAUDE.md
    • Linux/WSL: /etc/claude-code/CLAUDE.md
    • Windows: C:\Program Files\ClaudeCode\CLAUDE.md
  2. Managed Drop-ins - Các file chính sách được hợp nhất theo bảng chữ cái (v2.1.83+)

    • Thư mục managed-settings.d/ bên cạnh file chính sách được quản lý CLAUDE.md
    • Các file được hợp nhất theo thứ tự bảng chữ cái để quản lý chính sách mô-đun
  3. Project Memory - Bối cảnh được chia sẻ cho đội (được kiểm soát phiên bản)

    • ./.claude/CLAUDE.md hoặc ./CLAUDE.md (trong root repository)
    • Từ v2.1.277, ./AGENTS.md được tải ở chính tầng này thay thế, khi không có CLAUDE.md hay CLAUDE.local.md ở thư mục làm việc hoặc phía trên nó — điều khiển bằng Project instructions trong /config
  4. Project Rules - Hướng dẫn dự án mô-đun, cụ thể theo chủ đề

    • ./.claude/rules/*.md
  5. User Memory - Tùy thích cá nhân (tất cả dự án)

    • ~/.claude/CLAUDE.md
  6. User-Level Rules - Quy tắc cá nhân (tất cả dự án)

    • ~/.claude/rules/*.md
  7. Local Project Memory - Tùy thích cụ thể dự án cá nhân

    • ./CLAUDE.local.md

Lưu ý: CLAUDE.local.md được hỗ trợ đầy đủ và có trong tài liệu chính thức. Đặt ở thư mục gốc dự án, file này được tải cùng với CLAUDE.md và chứa các tùy thích cá nhân theo dự án không được commit vào version control. Hãy thêm CLAUDE.local.md vào .gitignore.

  1. Auto Memory - Các ghi chú và bài học tự động của Claude
    • ~/.claude/projects/<project>/memory/

Hành Vi Khám Phá Bộ Nhớ:

Claude tìm kiếm các file bộ nhớ theo thứ tự này, với các vị trí trước đó được ưu tiên:

graph TD
    A["Managed Policy<br/>/Library/.../ClaudeCode/CLAUDE.md"] -->|highest priority| A2["Managed Drop-ins<br/>managed-settings.d/"]
    A2 --> B["Project Memory<br/>./CLAUDE.md"]
    B --> C["Project Rules<br/>./.claude/rules/*.md"]
    C --> D["User Memory<br/>~/.claude/CLAUDE.md"]
    D --> E["User Rules<br/>~/.claude/rules/*.md"]
    E --> F["Local Project Memory<br/>./CLAUDE.local.md"]
    F --> G["Auto Memory<br/>~/.claude/projects/.../memory/"]

    B -->|imports| H["@docs/architecture.md"]
    H -->|imports| I["@docs/api-standards.md"]

    style A fill:#fce4ec,stroke:#333,color:#333
    style A2 fill:#fce4ec,stroke:#333,color:#333
    style B fill:#e1f5fe,stroke:#333,color:#333
    style C fill:#e1f5fe,stroke:#333,color:#333
    style D fill:#f3e5f5,stroke:#333,color:#333
    style E fill:#f3e5f5,stroke:#333,color:#333
    style F fill:#e8f5e9,stroke:#333,color:#333
    style G fill:#fff3e0,stroke:#333,color:#333
    style H fill:#e1f5fe,stroke:#333,color:#333
    style I fill:#e1f5fe,stroke:#333,color:#333

Loại Trừ Các File CLAUDE.md Với claudeMdExcludes

Trong các monorepos lớn, một số file CLAUDE.md có thể không liên quan đến công việc hiện tại của bạn. Cài đặt claudeMdExcludes cho phép bạn bỏ qua các file CLAUDE.md cụ thể để chúng không được tải vào bối cảnh:

// In ~/.claude/settings.json hoặc .claude/settings.json
{
  "claudeMdExcludes": [
    "**/packages/legacy-app/CLAUDE.md",
    "**/vendors/**/CLAUDE.md"
  ]
}

Các mẫu được so khớp với đường dẫn file tuyệt đối theo cú pháp glob, vì vậy hãy bắt đầu các mẫu trong repo bằng **/. Điều này đặc biệt hữu ích cho:

  • Monorepos với nhiều dự án con, trong đó chỉ một số có liên quan
  • Các kho chứa chứa các file CLAUDE.md của bên thứ ba hoặc được bán
  • Giảm tiếng ồn trong cửa sổ bối cảnh của Claude bằng cách loại trừ các hướng dẫn cũ hoặc không liên quan

Hệ Phân Cấp File Settings

Các cài đặt Claude Code (bao gồm autoMemoryDirectory, claudeMdExcludes, và các cấu hình khác) được giải quyết từ một hệ phân cấp năm cấp, với các cấp cao hơn được ưu tiên:

Cấp Vị Trí Phạm Vi
1 (Cao nhất) Managed policy (cấp hệ thống) Thực thi toàn tổ chức
2 managed-settings.d/ (v2.1.83+) Các drop-in chính sách mô-đun, được hợp nhất theo bảng chữ cái
3 .claude/settings.local.json Ghi đè cục bộ (bị git bỏ qua)
4 .claude/settings.json Cấp dự án (được commit vào git)
5 (Thấp nhất) ~/.claude/settings.json Tùy thích người dùng

Cấu hình cụ thể theo nền tảng (v2.1.51+):

Các cài đặt cũng có thể được cấu hình qua:

  • macOS: Các file property list (plist)
  • Windows: Windows Registry

Các cơ chế gốc theo nền tảng này được đọc cùng với các file settings JSON và theo cùng các quy tắc ưu tiên.

Hệ Thống Quy Tắc Mô-Đun

Tạo các quy tắc có tổ chức, cụ thể theo đường dẫn sử dụng cấu trúc thư mục .claude/rules/. Các quy tắc có thể được định nghĩa ở cả cấp dự án và cấp người dùng:

your-project/
├── .claude/
│   ├── CLAUDE.md
│   └── rules/
│       ├── code-style.md
│       ├── testing.md
│       ├── security.md
│       └── api/                  # Subdirectories được hỗ trợ
│           ├── conventions.md
│           └── validation.md

~/.claude/
├── CLAUDE.md
└── rules/                        # User-level rules (tất cả dự án)
    ├── personal-style.md
    └── preferred-patterns.md

Các quy tắc được khám phá đệ quy trong thư mục rules/, bao gồm bất kỳ thư mục con nào. Các quy tắc cấp người dùng tại ~/.claude/rules/ được tải trước các quy tắc cấp dự án, cho phép các mặc định cá nhân mà các dự án có thể ghi đè.

Quy Tắc Cụ Thể Theo Đường Dẫn Với YAML Frontmatter

Định nghĩa các quy tắc chỉ áp dụng cho các đường dẫn file cụ thể:

---
paths: src/api/**/*.ts
---

# API Development Rules

- All API endpoints must include input validation
- Use Zod for schema validation
- Document all parameters and response types
- Include error handling for all operations

Ví dụ Mẫu Glob:

  • **/*.ts - Tất cả files TypeScript
  • src/**/* - Tất cả files dưới src/
  • src/**/*.{ts,tsx} - Nhiều phần mở rộng
  • {src,lib}/**/*.ts, tests/**/*.test.ts - Nhiều mẫu

Các quy tắc trong .claude/rules/ hỗ trợ hai tính năng tổ chức:

  • Thư mục con: Các quy tắc được khám phá đệ quy, vì vậy bạn có thể tổ chức chúng thành các thư mục theo chủ đề (ví dụ: rules/api/, rules/testing/, rules/security/)
  • Symlinks: Symlinks được hỗ trợ để chia sẻ các quy tắc qua nhiều dự án. Ví dụ: bạn có thể symlink một file quy tắc được chia sẻ từ một vị trí trung tâm vào thư mục .claude/rules/ của mỗi dự án

Bảng Vị Trí Bộ Nhớ

Vị Trí Phạm Vi Ưu Tiên Được Chia Sẻ Truy Cập Tốt Nhất Cho
/Library/Application Support/ClaudeCode/CLAUDE.md (macOS) Managed Policy 1 (Cao nhất) Tổ chức Hệ thống Chính sách toàn công ty
/etc/claude-code/CLAUDE.md (Linux/WSL) Managed Policy 1 (Cao nhất) Tổ chức Hệ thống Tiêu chuẩn tổ chức
C:\Program Files\ClaudeCode\CLAUDE.md (Windows) Managed Policy 1 (Cao nhất) Tổ chức Hệ thống Hướng dẫn công ty
managed-settings.d/*.md (bên cạnh chính sách) Managed Drop-ins 1.5 Tổ chức Hệ thống Các file chính sách mô-đun (v2.1.83+)
./CLAUDE.md hoặc ./.claude/CLAUDE.md Project Memory 2 Đội Git Tiêu chuẩn đội, kiến trúc được chia sẻ
./.claude/rules/*.md Project Rules 3 Đội Git Các quy tắc mô-đun, cụ thể theo đường dẫn
~/.claude/CLAUDE.md User Memory 4 Cá nhân Filesystem Tùy thích cá nhân (tất cả dự án)
~/.claude/rules/*.md User Rules 5 Cá nhân Filesystem Quy tắc cá nhân (tất cả dự án)
./CLAUDE.local.md Project Local 6 Cá nhân Git (bị bỏ qua) Tùy thích cụ thể dự án cá nhân
~/.claude/projects/<project>/memory/ Auto Memory 7 (Thấp nhất) Cá nhân Filesystem Các ghi chú và bài học tự động của Claude

Vòng Đời Cập Nhật Bộ Nhớ

Đây là cách các cập nhật bộ nhớ luân chuyển qua các phiên Claude Code của bạn:

sequenceDiagram
    participant User
    participant Claude as Claude Code
    participant Editor as File System
    participant Memory as CLAUDE.md

    User->>Claude: "Add async/await rule to CLAUDE.md"
    Claude->>User: "Which memory file?"
    User->>Claude: "Project memory"
    Claude->>Editor: Open ./CLAUDE.md
    Claude->>Memory: Write to ./CLAUDE.md
    Memory-->>Claude: File saved
    Claude->>Claude: Load updated memory
    Claude-->>User: "Memory saved!"

Auto Memory

Auto memory là một thư mục liên tục nơi Claude tự động lưu các ghi chú có phân loại (user, feedback, project, reference) khi nó làm việc với dự án của bạn. Claude bỏ qua những gì có thể suy ra từ codebase, như kiến trúc, đường dẫn file, hoặc các bản sửa lỗi debug. Không giống như các file CLAUDE.md mà bạn viết và duy trì thủ công, auto memory được viết bởi Claude bản thân trong các phiên.

Cách Auto Memory Hoạt Động

  • Vị trí: ~/.claude/projects/<project>/memory/
  • Điểm vào: MEMORY.md phục vụ như file chính trong thư mục auto memory
  • Files chủ đề: Các file bổ sung tùy chọn, mỗi file một mục nhớ (ví dụ: prefers-pnpm.md, release-checklist.md)
  • Hành vi tải: 200 dòng đầu tiên của MEMORY.md được tải vào system prompt khi bắt đầu phiên. Các file chủ đề được tải theo yêu cầu, không phải khi khởi động.
  • Đọc/ghi: Claude đọc và ghi các file bộ nhớ trong các phiên khi nó học được sở thích, phản hồi của bạn và bối cảnh dự án

Kiến Trúc Auto Memory

graph TD
    A["Claude Session Starts"] --> B["Load MEMORY.md<br/>(first 200 lines)"]
    B --> C["Session Active"]
    C --> D["Claude learns<br/>preferences & feedback"]
    D --> E{"Write to<br/>auto memory"}
    E -->|General notes| F["MEMORY.md"]
    E -->|Topic-specific| G["prefers-pnpm.md"]
    E -->|Topic-specific| H["release-checklist.md"]
    C --> I["On-demand load<br/>topic files"]
    I --> C

    style A fill:#e1f5fe,stroke:#333,color:#333
    style B fill:#e1f5fe,stroke:#333,color:#333
    style C fill:#e8f5e9,stroke:#333,color:#333
    style D fill:#f3e5f5,stroke:#333,color:#333
    style E fill:#fff3e0,stroke:#333,color:#333
    style F fill:#fce4ec,stroke:#333,color:#333
    style G fill:#fce4ec,stroke:#333,color:#333
    style H fill:#fce4ec,stroke:#333,color:#333
    style I fill:#f3e5f5,stroke:#333,color:#333

Cấu Trúc Thư Mục Auto Memory

~/.claude/projects/<project>/memory/
├── MEMORY.md              # Entrypoint (200 dòng đầu tiên được tải khi khởi động)
├── prefers-pnpm.md        # Topic file (được tải theo yêu cầu)
├── release-checklist.md   # Topic file (được tải theo yêu cầu)
└── team-contacts.md       # Topic file (được tải theo yêu cầu)

Yêu Cầu Phiên Bản

Auto memory yêu cầu Claude Code v2.1.59 hoặc mới hơn. Nếu bạn đang sử dụng phiên bản cũ hơn, hãy nâng cấp trước:

npm install -g @anthropic-ai/claude-code@latest

Lưu ý: Trên npm 12, vốn mặc định bỏ qua bước postinstall của Claude Code, lệnh này kết thúc với lỗi Error: claude native binary not installed. Hãy chuyển sang trình cài đặt native hoặc làm theo Fix an npm 12 install.

Thư Mục Auto Memory Tùy Chỉnh

Theo mặc định, auto memory được lưu trữ trong ~/.claude/projects/<project>/memory/. Bạn có thể thay đổi vị trí này sử dụng cài đặt autoMemoryDirectory (có sẵn kể từ v2.1.74):

// Trong bất kỳ file cài đặt nào: người dùng, dự án, cục bộ hoặc chính sách được quản lý
{
  "autoMemoryDirectory": "/path/to/custom/memory/directory"
}

Lưu ý: autoMemoryDirectory được đọc từ mọi phạm vi cài đặt: người dùng, dự án, cục bộ, chính sách được quản lý, hoặc --settings. Giá trị phải là đường dẫn tuyệt đối hoặc bắt đầu bằng ~/.

Điều này hữu ích khi bạn muốn:

  • Lưu trữ auto memory ở một vị trí được chia sẻ hoặc đồng bộ
  • Tách biệt auto memory khỏi thư mục cấu hình Claude mặc định
  • Sử dụng một đường dẫn cụ thể theo dự án bên ngoài hệ phân cấp mặc định

Worktree và Chia Sẻ Repository

Tất cả các worktrees và thư mục con trong cùng một git repository chia sẻ một thư mục auto memory duy nhất. Điều này có nghĩa là chuyển đổi giữa các worktree hoặc làm việc trong các thư mục con khác nhau của cùng một repo sẽ đọc và ghi vào cùng các file bộ nhớ.

Bộ Nhớ Subagent

Các subagent (được tạo ra qua công cụ Agent) có thể giữ bộ nhớ lâu dài riêng của chúng. Trường frontmatter memory trong định nghĩa subagent chọn nơi đặt thư mục bộ nhớ đó:

memory: user      # ~/.claude/agent-memory/<agent-name>/
memory: project   # .claude/agent-memory/<agent-name>/ (có thể chia sẻ qua git)
memory: local     # .claude/agent-memory-local/<agent-name>/ (không commit)

Subagent đọc 200 dòng đầu / 25KB đầu của MEMORY.md trong thư mục đó khi khởi động và được cấp Read/Write/Edit để duy trì nó. Trường này không có tác dụng khi auto memory bị tắt.

Kiểm Soát Auto Memory

Auto memory có thể được kiểm soát qua biến môi trường CLAUDE_CODE_DISABLE_AUTO_MEMORY:

Giá Trị Hành Vi
0 Buộc auto memory bật
1 Buộc auto memory tắt
(chưa đặt) Hành vi mặc định (auto memory được bật)
# Tắt auto memory cho một phiên
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 claude

# Buộc auto memory bật rõ ràng
CLAUDE_CODE_DISABLE_AUTO_MEMORY=0 claude

Các Thư Mục Bổ Sung Với --add-dir

Cờ --add-dir cho phép Claude Code tải các file CLAUDE.md từ các thư mục bổ sung ngoài thư mục làm việc hiện tại. Điều này hữu ích cho các monorepos hoặc thiết lập đa dự án mà bối cảnh từ các thư mục khác có liên quan.

Để bật tính năng này, đặt biến môi trường:

CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1

Sau đó khởi động Claude Code với cờ:

claude --add-dir /path/to/other/project

Claude sẽ tải CLAUDE.md từ thư mục bổ sung được chỉ định cùng với các file bộ nhớ từ thư mục làm việc hiện tại của bạn.

Các Ví Dụ Thực Tiễn

Ví Dụ 1: Cấu Trúc Bộ Nhớ Dự Án

File: ./CLAUDE.md

# Project Configuration

## Project Overview
- **Name**: E-commerce Platform
- **Tech Stack**: Node.js, PostgreSQL, React 18, Docker
- **Team Size**: 5 developers
- **Deadline**: Q4 2025

## Architecture
@docs/architecture.md
@docs/api-standards.md
@docs/database-schema.md

## Development Standards

### Code Style
- Use Prettier for formatting
- Use ESLint with airbnb config
- Maximum line length: 100 characters
- Use 2-space indentation

### Naming Conventions
- **Files**: kebab-case (user-controller.js)
- **Classes**: PascalCase (UserService)
- **Functions/Variables**: camelCase (getUserById)
- **Constants**: UPPER_SNAKE_CASE (API_BASE_URL)
- **Database Tables**: snake_case (user_accounts)

### Git Workflow
- Branch names: `feature/description` hoặc `fix/description`
- Commit messages: Follow conventional commits
- PR required before merge
- All CI/CD checks must pass
- Minimum 1 approval required

### Testing Requirements
- Minimum 80% code coverage
- All critical paths must have tests
- Use Jest for unit tests
- Use Cypress for E2E tests
- Test filenames: `*.test.ts` hoặc `*.spec.ts`

### API Standards
- RESTful endpoints only
- JSON request/response
- Use HTTP status codes correctly
- Version API endpoints: `/api/v1/`
- Document all endpoints with examples

### Database
- Use migrations for schema changes
- Never hardcode credentials
- Use connection pooling
- Enable query logging in development
- Regular backups required

### Deployment
- Docker-based deployment
- Kubernetes orchestration
- Blue-green deployment strategy
- Automatic rollback on failure
- Database migrations run before deploy

## Common Commands

| Command | Purpose |
|---------|---------|
| `npm run dev` | Start development server |
| `npm test` | Run test suite |
| `npm run lint` | Check code style |
| `npm run build` | Build for production |
| `npm run migrate` | Run database migrations |

## Team Contacts
- Tech Lead: Sarah Chen (@sarah.chen)
- Product Manager: Mike Johnson (@mike.j)
- DevOps: Alex Kim (@alex.k)

## Known Issues & Workarounds
- PostgreSQL connection pooling limited to 20 during peak hours
- Workaround: Implement query queuing
- Safari 14 compatibility issues with async generators
- Workaround: Use Babel transpiler

## Related Projects
- Analytics Dashboard: `/projects/analytics`
- Mobile App: `/projects/mobile`
- Admin Panel: `/projects/admin`

Ví Dụ 2: Bộ Nhớ Cụ Thể Theo Thư Mục

File: ./src/api/CLAUDE.md

# API Module Standards

This file supplements root CLAUDE.md for everything in /src/api/. Memory files are
concatenated, not overridden — the root CLAUDE.md still applies, and Claude Code
loads this file on demand when it reads, writes, or edits files in this subtree.

## API-Specific Standards

### Request Validation
- Use Zod for schema validation
- Always validate input
- Return 400 with validation errors
- Include field-level error details

### Authentication
- All endpoints require JWT token
- Token in Authorization header
- Token expires after 24 hours
- Implement refresh token mechanism

### Response Format

All responses must follow this structure:

```json
{
  "success": true,
  "data": { /* actual data */ },
  "timestamp": "2025-11-06T10:30:00Z",
  "version": "1.0"
}

Error responses:

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "User message",
    "details": { /* field errors */ }
  },
  "timestamp": "2025-11-06T10:30:00Z"
}

Pagination

  • Use cursor-based pagination (not offset)
  • Include hasMore boolean
  • Limit max page size to 100
  • Default page size: 20

Rate Limiting

  • 1000 requests per hour for authenticated users
  • 100 requests per hour for public endpoints
  • Return 429 when exceeded
  • Include retry-after header

Caching

  • Use Redis for session caching
  • Cache duration: 5 minutes default
  • Invalidate on write operations
  • Tag cache keys with resource type

### Ví Dụ 3: Bộ Nhớ Cá Nhân

**File:** `~/.claude/CLAUDE.md`

```markdown
# My Development Preferences

## About Me
- **Experience Level**: 8 years full-stack development
- **Preferred Languages**: TypeScript, Python
- **Communication Style**: Direct, with examples
- **Learning Style**: Visual diagrams with code

## Code Preferences

### Error Handling
I prefer explicit error handling with try-catch blocks and meaningful error messages.
Avoid generic errors. Always log errors for debugging.

### Comments
Use comments for WHY, not WHAT. Code should be self-documenting.
Comments should explain business logic or non-obvious decisions.

### Testing
I prefer TDD (test-driven development).
Write tests first, then implementation.
Focus on behavior, not implementation details.

### Architecture
I prefer modular, loosely-coupled design.
Use dependency injection for testability.
Separate concerns (Controllers, Services, Repositories).

## Debugging Preferences
- Use console.log with prefix: `[DEBUG]`
- Include context: function name, relevant variables
- Use stack traces when available
- Always include timestamps in logs

## Communication
- Explain complex concepts with diagrams
- Show concrete examples before explaining theory
- Include before/after code snippets
- Summarize key points at the end

## Project Organization
I organize my projects as:

   project/
   ├── src/
   │   ├── api/
   │   ├── services/
   │   ├── models/
   │   └── utils/
   ├── tests/
   ├── docs/
   └── docker/

## Tooling
- **IDE**: VS Code with vim keybindings
- **Terminal**: Zsh with Oh-My-Zsh
- **Format**: Prettier (100 char line length)
- **Linter**: ESLint with airbnb config
- **Test Framework**: Jest with React Testing Library

Ví Dụ 4: Cập Nhật Bộ Nhớ Trong Phiên

Bạn có thể thêm các quy tắc mới vào CLAUDE.md trong một phiên Claude Code đang hoạt động (yêu cầu Claude ghi nhớ điều gì đó sẽ lưu vào auto memory thay vì CLAUDE.md). Có hai cách để làm điều này:

Phương Pháp 1: Yêu Cầu Trực Tiếp

User: Add this to CLAUDE.md: I prefer using React hooks instead of class components
     for all new components.

Claude: I'm adding that to your memory. Which memory file should this go in?
        1. Project memory (./CLAUDE.md)
        2. Personal memory (~/.claude/CLAUDE.md)

User: Project memory

Claude: ✅ Memory saved!

Added to ./CLAUDE.md:
---

### Component Development
- Use functional components with React Hooks
- Prefer hooks over class components
- Custom hooks for reusable logic
- Use useCallback for event handlers
- Use useMemo for expensive computations

Phương Pháp 2: Sử Dụng Mẫu "# new rule into memory"

Bạn cũng có thể sử dụng mẫu rõ ràng "# new rule into memory" để kích hoạt cập nhật bộ nhớ:

User: # new rule into memory
      Always validate user input with Zod schemas before processing.

Claude: I'm saving this rule to memory. Which memory file should I use?
        1. Project memory (./CLAUDE.md)
        2. Personal memory (~/.claude/CLAUDE.md)

User: Project memory

Claude: ✅ Memory saved!

Added to ./CLAUDE.md:
---

### Input Validation
- Always validate user input with Zod schemas before processing
- Define schemas at the top of each API handler file
- Return 400 status with validation errors

Mẹo Để Thêm Bộ Nhớ

  • Hãy cụ thể và có thể thực hiện trong các quy tắc của bạn
  • Nhóm các quy tắc liên quan lại với nhau dưới một tiêu đề phần
  • Cập nhật các phần hiện có thay vì nhân đôi nội dung
  • Chọn phạm vi bộ nhớ phù hợp (dự án vs cá nhân)

So Sánh Tính Năng Bộ Nhớ

Tính Năng Claude Web/Desktop Claude Code (CLAUDE.md)
Auto-synthesis ✅ Every 24h ❌ Manual
Cross-project ✅ Shared ❌ Project-specific
Team access ✅ Shared projects ✅ Git-tracked
Searchable ✅ Built-in ✅ Through /memory
Editable ✅ In-chat ✅ Direct file edit
Import/Export ✅ Yes ✅ Copy/paste
Persistent ✅ 24h+ ✅ Indefinite

Bộ Nhớ Trong Claude Web/Desktop

Dòng Thời Gian Tổng Hợp Bộ Nhớ

graph LR
    A["Day 1: User<br/>Conversations"] -->|24 hours| B["Day 2: Memory<br/>Synthesis"]
    B -->|Automatic| C["Memory Updated<br/>Summarized"]
    C -->|Loaded in| D["Day 2-N:<br/>New Conversations"]
    D -->|Add to| E["Memory"]
    E -->|24 hours later| F["Memory Refreshed"]

Ví Dụ Tóm Tắt Bộ Nhớ:

## Claude's Memory of User

### Professional Background
- Senior full-stack developer with 8 years experience
- Focus on TypeScript/Node.js backends and React frontends
- Active open source contributor
- Interested in AI and machine learning

### Project Context
- Currently building e-commerce platform
- Tech stack: Node.js, PostgreSQL, React 18, Docker
- Working with team of 5 developers
- Using CI/CD and blue-green deployments

### Communication Preferences
- Prefers direct, concise explanations
- Likes visual diagrams and examples
- Appreciates code snippets
- Explains business logic in comments

### Current Goals
- Improve API performance
- Increase test coverage to 90%
- Implement caching strategy
- Document architecture

Thực Hành Tốt Nhất

Nên Làm - Những Gì Để Bao Gồm

  • Hãy cụ thể và chi tiết: Sử dụng các hướng dẫn rõ ràng, chi tiết thay vì hướng dẫn mơ hồ

    • ✅ Tốt: "Use 2-space indentation for all JavaScript files"
    • ❌ Tránh: "Follow best practices"
  • Giữ tổ chức: Cấu trúc các file bộ nhớ với các phần và tiêu đề markdown rõ ràng

  • Sử dụng các cấp hệ phân cấp phù hợp:

    • Managed policy: Các chính sách toàn công ty, tiêu chuẩn bảo mật, yêu cầu tuân thủ
    • Project memory: Tiêu chuẩn đội, kiến trúc, quy ước code (commit vào git)
    • User memory: Tùy thích cá nhân, phong cách giao tiếp, lựa chọn công cụ
    • Directory memory: Các quy tắc và ghi đè cụ thể theo module
  • Tận dụng imports: Sử dụng cú pháp @path/to/file để tham khảo tài liệu hiện có

    • Hỗ trợ tối đa 4 chặng đệ quy (recursive hops)
    • Tránh nhân đôi qua các file bộ nhớ
    • Ví dụ: See @README.md for project overview
  • Tài liệu hóa các lệnh thường dùng: Bao gồm các lệnh bạn sử dụng lặp lại để tiết kiệm thời gian

  • Kiểm soát phiên bản bộ nhớ dự án: Commit các file CLAUDE.md cấp dự án vào git để lợi ích cho đội

  • Xem lại định kỳ: Cập nhật bộ nhớ thường xuyên khi các dự án phát triển và yêu cầu thay đổi

  • Cung cấp các ví dụ cụ thể: Bao gồm các đoạn code và các kịch bản cụ thể

Không Nên Làm - Những Gì Cần Tránh

  • Đừng lưu trữ bí mật: Không bao giờ bao gồm API keys, mật khẩu, tokens, hoặc credentials

  • Đừng bao gồm dữ liệu nhạy cảm: Không PII, thông tin riêng tư, hoặc bí mật độc quyền

  • Đừng nhân đôi nội dung: Sử dụng imports (@path) để tham khảo tài liệu hiện có thay thế

  • Đừng mơ hồ: Tránh các câu chung chung như "follow best practices" hoặc "write good code"

  • Đừng làm nó quá dài: Giữ các file bộ nhớ cá thể tập trung và dưới 500 dòng

  • Đừng tổ chức quá mức: Sử dụng hệ phân cấp một cách chiến lược; đừng tạo quá nhiều ghi đè thư mục con

  • Đừng quên cập nhật: Bộ nhớ cũ có thể gây nhầm lẫn và thực hành lỗi thời

  • Đừng vượt quá giới hạn lồng: Bộ nhớ import hỗ trợ tối đa 4 chặng đệ quy

Mẹo Quản Lý Bộ Nhớ

Chọn cấp bộ nhớ đúng:

Use Case Cấp Bộ Nhớ Lý Do
Company security policy Managed Policy Áp dụng cho tất cả dự án toàn tổ chức
Team code style guide Project Được chia sẻ với đội qua git
Your preferred editor shortcuts User Tùy thích cá nhân, không được chia sẻ
API module standards Directory Cụ thể cho module đó thôi

Workflow cập nhật nhanh:

  1. Đối với các quy tắc đơn: Sử dụng tiền tố # trong cuộc hội thoại
  2. Đối với nhiều thay đổi: Sử dụng /memory để mở editor
  3. Đối với thiết lập ban đầu: Sử dụng /init để tạo mẫu

Thực hành import tốt nhất:

# Tốt: Tham khảo tài liệu hiện có
@README.md
@docs/architecture.md
@package.json

# Tránh: Sao chép nội dung tồn tại ở nơi khác
# Thay vì sao chép nội dung README vào CLAUDE.md, chỉ cần import nó

Hướng Dẫn Cài Đặt

Thiết Lập Bộ Nhớ Dự Án

Phương Pháp 1: Sử Dụng Lệnh /init (Khuyến Nghị)

Cách nhanh nhất để thiết lập bộ nhớ dự án:

  1. Điều hướng đến thư mục dự án của bạn:

    cd /path/to/your/project
    
  2. Chạy lệnh init trong Claude Code:

    /init
    
  3. Claude sẽ tạo và điền CLAUDE.md với một cấu trúc mẫu

  4. Tùy chỉnh file được tạo để phù hợp với nhu cầu dự án của bạn

  5. Commit vào git:

    git add CLAUDE.md
    git commit -m "Initialize project memory with /init"
    

Phương Pháp 2: Tạo Thủ Công

Nếu bạn thích thiết lập thủ công:

  1. Tạo một CLAUDE.md trong root dự án của bạn:

    cd /path/to/your/project
    touch CLAUDE.md
    
  2. Thêm tiêu chuẩn dự án:

    cat > CLAUDE.md << 'EOF'
    # Project Configuration
    
    ## Project Overview
    - **Name**: Your Project Name
    - **Tech Stack**: List your technologies
    - **Team Size**: Number of developers
    
    ## Development Standards
    - Your coding standards
    - Naming conventions
    - Testing requirements
    EOF
    
  3. Commit vào git:

    git add CLAUDE.md
    git commit -m "Add project memory configuration"
    

Phương Pháp 3: Cập Nhật Nhanh Với #

Khi CLAUDE.md tồn tại, thêm các quy tắc nhanh trong các cuộc hội thoại:

# Use semantic versioning for all releases

# Always run tests before committing

# Prefer composition over inheritance

Claude sẽ nhắc bạn chọn file bộ nhớ nào để cập nhật.

Thiết Lập Bộ Nhớ Cá Nhân

  1. Tạo thư mục ~/.claude:

    mkdir -p ~/.claude
    
  2. Tạo CLAUDE.md cá nhân:

    touch ~/.claude/CLAUDE.md
    
  3. Thêm tùy thích của bạn:

    cat > ~/.claude/CLAUDE.md << 'EOF'
    # My Development Preferences
    
    ## About Me
    - Experience Level: [Your level]
    - Preferred Languages: [Your languages]
    - Communication Style: [Your style]
    
    ## Code Preferences
    - [Your preferences]
    EOF
    

Thiết Lập Bộ Nhớ Cụ Thể Theo Thư Mục

  1. Tạo bộ nhớ cho các thư mục cụ thể:

    mkdir -p /path/to/directory/.claude
    touch /path/to/directory/CLAUDE.md
    
  2. Thêm các quy tắc cụ thể theo thư mục:

    cat > /path/to/directory/CLAUDE.md << 'EOF'
    # [Directory Name] Standards
    
    This file supplements root CLAUDE.md for this directory. Memory files are
    concatenated, not overridden — Claude Code loads this file on demand when it
    reads, writes, or edits files in this directory.
    
    ## [Specific Standards]
    EOF
    
  3. Commit vào kiểm soát phiên bản:

    git add /path/to/directory/CLAUDE.md
    git commit -m "Add [directory] memory configuration"
    

Xác Minh Thiết Lập

  1. Kiểm tra các vị trí bộ nhớ:

    # Project root memory
    ls -la ./CLAUDE.md
    
    # Personal memory
    ls -la ~/.claude/CLAUDE.md
    
  2. Claude Code sẽ tự động tải các file này khi bắt đầu một phiên

  3. Kiểm tra với Claude Code bằng cách bắt đầu một phiên mới trong dự án của bạn

Tài Liệu Chính Thức

Để có thông tin cập nhật nhất, hãy tham khảo tài liệu Claude Code chính thức:

Chi Tiết Kỹ Thuật Chính Từ Tài Liệu Chính Thức

Tải Bộ Nhớ:

  • Các file CLAUDE.md tại thư mục làm việc và các thư mục cấp trên, các quy tắc không có phạm vi đường dẫn, và phần đầu của MEMORY.md được tự động tải khi Claude Code khởi động
  • Claude duyệt lên từ thư mục làm việc hiện tại để khám phá các file CLAUDE.md
  • Các file subtree được khám phá và tải theo bối cảnh khi truy cập các thư mục đó

Cú Pháp Import:

  • Sử dụng @path/to/file để bao gồm nội dung bên ngoài (ví dụ: @~/.claude/my-project-instructions.md)
  • Hỗ trợ cả đường dẫn tương đối và tuyệt đối
  • Các import đệ quy được hỗ trợ với độ sâu tối đa 5
  • Lần đầu tiên import bên ngoài sẽ kích hoạt hộp thoại phê duyệt
  • Không được đánh giá bên trong các khoảng mã markdown hoặc khối code
  • Tự động bao gồm nội dung được tham chiếu trong bối cảnh của Claude

Ưu Tiên Hệ Phân Cấp Bộ Nhớ:

  1. Managed Policy (ưu tiên cao nhất)
  2. Managed Drop-ins (managed-settings.d/, v2.1.83+)
  3. Project Memory
  4. Project Rules (.claude/rules/)
  5. User Memory
  6. User-Level Rules (~/.claude/rules/)
  7. Local Project Memory
  8. Auto Memory (ưu tiên thấp nhất)

Các Liên Kết Khái Niệm Liên Quan

Các Điểm Tích Hợp

  • Giao Thức MCP - Truy cập dữ liệu trực tiếp cùng với bộ nhớ
  • Lệnh Slash - Các lối tắt cụ thể theo phiên
  • Skills - Các workflow tự động với bối cảnh bộ nhớ

Các Tính Năng Claude Liên Quan


Cập Nhật Lần Cuối: Ngày 1 tháng 11 năm 2026 Phiên Bản Claude Code: 2.1.316 Nguồn: