làm tíai?GitHub ↗
CHƯƠNG 13 / 16

Codebase lớn và tối ưu

Làm việc với monorepo, worktree, prompt caching, context và chi phí hiệu quả hơn.

18 phút đọc

Khi codebase phình to, các default tối ưu cho project nhỏ sẽ lấp đầy context window bằng instructions và file reads không liên quan đến task, tốn token và làm giảm hiệu suất của Claude. Chương này gom các kỹ thuật giữ Claude tập trung: scope một monorepo/codebase lớn, chạy song song bằng git worktrees, hiểu prompt caching, quản lý cost, và tối ưu context.

1. Làm việc với codebase lớn

Một codebase lớn có thể là một repo hàng triệu dòng hoặc một monorepo nhiều package. Nguyên tắc chung: scope Claude vào đúng phần code mà task đụng tới. Các setting dưới đây độc lập nhau và layer chồng lên nhau — áp dụng cái nào phù hợp.

Chọn nơi khởi động Claude

Nơi bạn chạy claude quyết định file nào Claude đọc/ghi được, CLAUDE.md nào load lúc startup, và project settings nào áp dụng.

Start từFile accessCLAUDE.md load lúc launchDùng khi
Repository rootMọi fileChỉ root; file subdir load on-demand khi Claude đọcTask trải nhiều package/subsystem
Một subdirectoryChỉ subtree đó, đến khi grant thêmFile của dir đó + mọi ancestorViệc gói gọn trong 1 package

Lưu ý: .claude/settings.json chỉ load từ starting directory, không kế thừa từ parent như CLAUDE.md. Root settings chỉ áp dụng khi bạn start từ root.

Layer CLAUDE.md theo directory

Thay vì một CLAUDE.md root khổng lồ phủ mọi subsystem, tách theo directory. Claude load mọi CLAUDE.md từ working dir và các parent lúc launch, rồi load file của mỗi subdir on-demand khi đọc file ở đó.

Split hai tầng phổ biến:

  • Root CLAUDE.md: quy tắc áp dụng khắp nơi (coding standards, commit conventions, layout repo).
  • Per-subdirectory CLAUDE.md: convention riêng cho stack của khu vực đó (một per package trong monorepo, hoặc một per subsystem như src/db/, src/api/).
This is a monorepo with three packages under packages/:

- packages/api: Node.js REST API with Express, TypeScript, and PostgreSQL
- packages/web: React frontend with Vite, TypeScript, and TailwindCSS
- packages/shared: shared TypeScript utilities used by both api and web

Run commands from the package directory, not the monorepo root.

Khi start từ packages/api/, Claude load cả packages/api/CLAUDE.md lẫn root, và không đưa instructions của packages/web/ vào context.

Giữ file cập nhật: review CLAUDE.md như mọi doc trong pull request; revisit sau các model release lớn (rule workaround cho model cũ có thể bỏ được); thêm một Stop hook đề xuất update dựa trên transcript.

CLAUDE.md per-directory vs path-scoped rules (.claude/rules/ với paths: glob): dùng per-directory khi owner tự bảo trì convention versioned cùng code; dùng path-scoped rule khi muốn gom mọi convention một chỗ hoặc cùng rule áp cho nhiều path rải rác.

Loại trừ CLAUDE.md không liên quan — claudeMdExcludes

Khi start từ root, mỗi subdir CLAUDE.md load ngay khi Claude đọc file ở đó. claudeMdExcludes skip hẳn theo path/glob — dùng cho khu vực bạn không bao giờ đụng (package của team khác, legacy, vendored). Đây là danh sách tĩnh, không phải switch per-task.

{
  "claudeMdExcludes": [
    "**/packages/admin-dashboard/**",
    "**/packages/legacy-*/**"
  ]
}
  • Pattern là glob khớp với absolute path, nên bắt đầu bằng **/ để khớp mọi nơi trong tree.
  • Managed policy CLAUDE.md không thể bị exclude — instructions cấp tổ chức luôn áp dụng.
  • Array merge across scopes (user/project/local/managed).
  • Để focus package khác nhau mỗi ngày, hãy start từ dir đó thay vì sửa exclusions.

Giảm những gì Claude đọc

File reads là chi phí context tăng theo kích thước codebase.

Block reads của generated/vendored code — content search tôn trọng .gitignore (nên node_modules/, dist/, build/ đã bị loại). Với path đã check-in (vendored SDK, generated code committed), thêm Read deny rules:

{
  "permissions": {
    "deny": [
      "Read(./**/dist/**)",
      "Read(./**/build/**)",
      "Read(./**/*.generated.*)",
      "Read(./vendor/**)"
    ]
  }
}

Deny rules phủ file tools built-in và các Bash file command nhận diện được (cat, head, grep, find) khi denied path là argument. Chúng không lọc path khỏi output của recursive search, và không phủ subprocess tùy ý tự mở file.

Code intelligence plugins — kết nối Claude với language server để jump-to-definition, find-references, surface type errors thay vì scan tree. Một "go to definition" thay cho grep + đọc nhiều candidate file.

/plugin install typescript-lsp@claude-plugins-official

Marketplace chính thức có plugin cho TypeScript, Python, Go, Rust... Yêu cầu language server binary trên máy mỗi dev. Kết hợp tốt với claudeMdExcludes và deny rules.

Grant access qua package/repository — additionalDirectories & --add-dir

Khi start từ packages/api/ nhưng task cần sửa file ở sibling package (ví dụ update shared type mà cả apiweb import):

{
  "permissions": {
    "additionalDirectories": ["../shared", "../web"]
  }
}

Hoặc grant runtime không sửa settings:

claude --add-dir ../shared

Khác biệt về việc load CLAUDE.md/rules/skills:

Thêm bằngLoad CLAUDE.md & rulesLoad skills
additionalDirectories settingKhông bao giờKhông
--add-dir / /add-dirChỉ khi set env var dưới
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared

Per-directory skills

Bất kỳ subdir nào cũng có thể định nghĩa skills scope theo stack riêng, đặt dưới .claude/skills/. Skill load on-demand khi Claude thấy liên quan, nên tooling của API package không tốn context lúc làm frontend.

mkdir -p packages/api/.claude/skills/api-testing

Giữ skills discoverable: mô tả ngắn, dẫn đầu bằng từ khóa mà request sẽ chứa ("writing or modifying tests in packages/api/") — vì descriptions bị cắt ngắn khi có quá nhiều skill, làm mất keyword Claude dùng để chọn. Skill dùng chung nhiều nơi (PR conventions, deploy checklist) đặt ở .claude/skills/ root; cần versioning riêng/across-repo thì đóng gói thành plugin (namespace plugin-name:skill-name).

Scope và plan cho thay đổi xuyên package

  • Đưa cả thay đổi trong một session: shared edit + mọi call site cùng lúc để quyết định nhất quán.
  • Lưu plan ra file trước khi edit: session dài xuyên package sẽ compact context dọc đường; plan đã lưu trong markdown sống sót nơi conversation history có thể mất.

2. Git worktrees — chạy song song nhiều task

Một git worktree là working directory riêng với file và branch riêng, chia sẻ chung history và remote với main checkout. Mỗi Claude session chạy trong worktree riêng nghĩa là edit ở session này không đụng file session kia — một session build feature trong khi session khác fix bug.

Worktree cần git repo; với VCS khác, cấu hình WorktreeCreate/WorktreeRemove hooks. Trong desktop app, mỗi session mới tự động có worktree riêng.

Start Claude trong worktree

claude --worktree feature-auth
  • Mặc định tạo worktree dưới .claude/worktrees/<name>/ tại repo root, trên branch mới worktree-<name>.
  • Chạy lại với tên khác ở terminal khác để có session isolated thứ hai.
  • Bỏ tên → Claude tự sinh (ví dụ bright-running-fox).
  • Interactive cần workspace trust; -p (non-interactive) skip trust check.

Thêm .claude/worktrees/ vào .gitignore. Worktree là fresh checkout — cần init dev env (cài dependencies, chạy setup). Để tự copy file gitignored (như .env) vào mỗi worktree mới, thêm .worktreeinclude.

Bạn cũng có thể bảo Claude "work in a worktree" giữa session — nó dùng tool EnterWorktree. Vào path ngoài .claude/worktrees/ thì Claude Code hỏi approval trước (chỉ bypassPermissions mới skip).

Copy file gitignored vào worktree — .worktreeinclude

Dùng cú pháp .gitignore. Chỉ file vừa khớp pattern vừa bị gitignore được copy (file tracked không bị duplicate):

.env
.env.local
config/secrets.json

Áp cho mọi worktree Claude Code tạo bằng git: --worktree, subagent worktrees, và parallel sessions desktop.

Sparse checkout — worktree.sparsePaths

Mặc định worktree check out toàn bộ repo. Trong repo lớn, sparsePaths dùng git sparse-checkout chỉ ghi các directory liệt kê + root-level files ra đĩa → worktree khởi động nhanh hơn, tốn ít không gian.

{
  "worktree": {
    "sparsePaths": [".claude", "packages/api", "packages/shared"],
    "symlinkDirectories": ["node_modules"]
  }
}
  • Path tương đối so với repo root, bất kể start từ subdir nào.
  • Liệt kê directory, không phải file lẻ. Root-level files (package.json, lock files) luôn được check out. Root-level directories thì không — thêm .claude nếu muốn settings/rules/skills của root có trong worktree.
  • symlinkDirectories symlink node_modules/ về copy của main repo thay vì duplicate.
  • Đặc biệt hữu ích cho subagent worktree isolation; mọi worktree trong session chia sẻ cùng sparsePaths.
  • Sparse checkout bật extensions.worktreeConfig trong .git/config khi còn worktree sparse; Claude Code gỡ entry sau worktree cuối (chỉ nếu Claude Code tự thêm).

Chọn base branch — worktree.baseRef

Giá trịNghĩa
"fresh" (default)Branch từ default branch trên remote (thường main) → tree sạch khớp remote
"head"Branch từ local HEAD hiện tại → mang theo unpushed commits, feature-branch state
{ "worktree": { "baseRef": "head" } }

Không set được baseRef thành tên branch cụ thể; để làm vậy dùng git trực tiếp (xem dưới). Branch từ một pull request:

claude --worktree "#1234"    # fetch pull/1234/head, tạo tại .claude/worktrees/pr-1234

Isolate subagents với worktrees

Subagents chạy trong worktree riêng để parallel edits không conflict. Bảo Claude "use worktrees for your agents", hoặc làm vĩnh viễn cho custom subagent bằng frontmatter:

---
name: refactorer
description: Applies mechanical refactors across many files
isolation: worktree
---

Apply the requested refactor across every affected file, then run the tests
and report the results.

Mỗi subagent nhận worktree tạm; Claude Code gỡ tự động khi subagent xong mà không có thay đổi. Worktree còn work được giữ lại đến khi periodic sweep gỡ được mà không mất dữ liệu.

Cleanup

Khi thoát interactive worktree session, Claude kiểm tra work mà removal sẽ xóa (file thay đổi/untracked, commit mới):

  • Worktree sạch: session không tên → Claude gỡ worktree + branch tự động. Session có tên → hỏi trước để giữ lại.
  • Worktree có work: Claude hỏi giữ hay gỡ.

Non-interactive -p không có exit prompt → không cleanup; gỡ bằng git worktree remove.

Periodic sweep gỡ worktree của subagents và background sessions cũ hơn cleanupPeriodDays, bỏ qua cái còn work, và không bao giờ gỡ worktree bạn tạo bằng --worktree. Khi agent đang chạy, Claude git worktree lock worktree đó để cleanup đồng thời không gỡ nhầm.

Quản lý worktrees thủ công

Dùng git trực tiếp khi cần check out branch cụ thể hoặc đặt worktree ngoài repo:

git worktree add ../project-feature-a -b feature-a   # branch mới
git worktree add ../project-bugfix bugfix-123        # branch có sẵn
cd ../project-feature-a && claude
git worktree list
git worktree remove ../project-feature-a             # thêm --force nếu còn uncommitted

Worktree chia sẻ với main checkout: .git directory (nên git commit chạy được từ trong worktree, kể cả sandbox bật), project-scope plugins, và permission approvals ("Yes, don't ask again" lưu về main checkout's .claude/settings.local.json, áp cho mọi worktree).

Worktrees vs subagents vs agent teams

Worktrees isolate file edits. Subagents và agent teams coordinate công việc. Dùng chung được: subagent chạy trong worktree để vừa isolate edits vừa delegate work.


3. Prompt caching

Prompt caching làm Claude Code nhanh và rẻ hơn: thay vì reprocess toàn bộ history mỗi turn, API tái dùng phần đã xử lý và chỉ làm việc mới với phần thay đổi. Claude Code tự quản lý caching (trừ khi bạn disable). Biết cách nó hoạt động giúp tránh làm invalidate cache giữa task.

Cache được tổ chức thế nào

API cache bằng cách khớp prefix — phần đầu của mỗi request — với content vừa xử lý gần đây. Khớp là exact: thay đổi ở bất kỳ đâu trong prefix sẽ recompute mọi thứ sau đó. Không có per-file hay per-segment caching. Claude Code sắp xếp request để content ít thay đổi nằm trước:

LayerContentThay đổi khi
System promptCore instructions, tool definitions, output styleSet tool definitions đổi, hoặc Claude Code upgrade
Project contextCLAUDE.md, auto memory, unscoped rulesSession start, hoặc sau /clear / /compact
ConversationMessages của bạn, responses, tool resultsMỗi turn

Thay đổi conversation layer → system prompt và project context vẫn cached. Thay đổi system prompt → invalidate mọi thứ. Ngoài ra hai thứ không phải text nhưng là phần của cache key: model (mỗi model có cache riêng) và effort level (mỗi level có cache riêng).

Chọn model và effort ở đầu session, để dành /compact cho các break tự nhiên giữa task. Càng ít thay đổi giữa task, cache hit rate càng cao.

Actions làm INVALIDATE cache

Mỗi cái gây một turn chậm hơn/đắt hơn một lần, sau đó prefix mới được cached:

  • Switching models (/model) — mỗi model có cache riêng. opusplan resolve Opus khi plan mode và Sonnet khi execute, nên mỗi toggle plan-mode là một model switch.
  • Changing effort level (/effort) — Claude Code hỏi confirm trước khi áp thay đổi làm mất cache.
  • Turning on fast mode — thêm request header thuộc cache key; chi phí áp một lần per conversation (nên bật đầu session rẻ hơn bật sâu trong session dài).
  • Connect/disconnect MCP server — chỉ khi tool loaded vào prefix. Deferred tools (mặc định) chỉ append, không đụng cache.
  • Enable/disable plugin cung cấp MCP server — theo cùng rule MCP. Skills/commands/agents/hooks/LSP/themes không invalidate.
  • Deny cả một tool (thêm Bash hoặc WebFetch bare vào deny) — gỡ tool khỏi context, thuộc system prompt layer. Scoped deny như Bash(rm *) thì không.
  • Compacting (/compact) — thay history bằng summary → invalidate conversation layer (cố ý).
  • Upgrading Claude Code — version mới thường đổi system prompt/tool definitions. Auto-update áp lúc launch kế, không giữa session.

Resume một session sau khi upgrade reprocess toàn bộ history không cache hit — turn đầu vào session dài có thể là request đắt nhất bạn gửi.

Actions GIỮ cache

Các action này append vào cuối conversation hoặc không đụng request:

  • Edit file trong repo — content vào context khi Claude đọc; edit sau đó chỉ thêm <system-reminder> báo file đổi.
  • Edit CLAUDE.md giữa session — không invalidate, nhưng cũng không apply. Root/user CLAUDE.md đọc một lần lúc start; content mới load ở /clear, /compact, hoặc restart tiếp theo.
  • Đổi output style — tương tự CLAUDE.md, giữ cache nhưng không apply đến khi restart.
  • Đổi permission mode — cache-safe (ngoại lệ: plan mode với opusplan = model switch).
  • Invoke skills/commands — inject instructions dạng user message tại điểm invoke.
  • /recap — append summary dạng command output, khác /compact.
  • /rewind — truncate về turn cũ; prefix đó đã cached nên hit cache cũ. Rẻ hơn /compact khi muốn bỏ hẳn một hướng đi.
  • Spawn subagent — subagent có conversation/cache riêng; parent's prefix nguyên vẹn.

Cache lifetime & scope

Cached prefix hết hạn sau thời gian không hoạt động; mỗi cache hit reset timer. Có hai TTL: 5 phút (mặc định) và 1 giờ (giữ ấm qua break dài, bill cache write cao hơn).

  • Claude subscription: tự request TTL 1 giờ (usage nằm trong plan → không tốn thêm). Vượt limit dùng usage credits → tự hạ về 5 phút.
  • API key / cloud provider: mặc định 5 phút; opt-in 1 giờ bằng ENABLE_PROMPT_CACHING_1H=1.
  • Ép 5 phút: FORCE_PROMPT_CACHING_5M=1.

Scope: cache hiệu quả gắn với một máy + một directory (system prompt nhúng working dir, platform, shell, OS, git status). Hai session khác directory (kể cả worktrees cùng repo) build prefix khác → miss cache của nhau. Session parallel cùng directory đọc cache của nhau.

Check cache performance

Hai token count API report mỗi response (đọc được qua statusline script từ object current_usage):

FieldNghĩa
cache_creation_input_tokensToken ghi vào cache turn này, bill theo cache write rate
cache_read_input_tokensToken phục vụ từ cache, bill ~10% standard input rate

Read-to-creation ratio cao = caching hoạt động tốt. Creation cao liên tục = có gì đó đang đổi trong prefix.

Disable prompt caching

Chỉ hữu ích khi debug. Set 1:

VariableEffect
DISABLE_PROMPT_CACHINGDisable mọi model
DISABLE_PROMPT_CACHING_HAIKUChỉ Haiku
DISABLE_PROMPT_CACHING_SONNETChỉ Sonnet
DISABLE_PROMPT_CACHING_OPUSChỉ Opus
DISABLE_PROMPT_CACHING_FABLEChỉ Fable

4. Quản lý cost

Claude Code charge theo API token consumption. Trung bình enterprise ~$13/dev/active day và $150–250/dev/tháng, với 90% users dưới $30/active day. Bắt đầu bằng pilot nhỏ và dùng tracking tools để lập baseline trước khi rollout rộng.

Track cost

  • /usage — Session block hiển thị token stats (input/output/cache read/cache write) và dollar figure ước tính cục bộ (có thể khác bill thật; billing chính thức xem Console). Totals reset khi /clear. Trên plan Pro/Max/Team/Enterprise, /usage còn breakdown usage theo skills/subagents/plugins/MCP servers; d/w chuyển 24h/7 ngày.
  • /usage-credits (Pro/Max) — bật usage credits, mua thêm, set/đổi/xóa monthly spend limit, cấu hình auto-reload. Cần đăng nhập claude.ai qua /login.

Manage cho tổ chức

SetupSee spendCap spendPer-user reporting
Claude for Teams/EnterpriseSpend report org analyticsSpend limits admin settingsSpend report CSV; Enterprise Analytics API
Claude Console (API)Console usage pageWorkspace spend limitsConsole dashboard; Claude Code Analytics API
Bedrock / Google Agent Platform / FoundryCloud billing consoleCloud budget controlsOpenTelemetry hoặc LLM gateway

OpenTelemetry export chạy trên mọi setup và là lựa chọn duy nhất stream per-user token/cost metrics near real-time vào observability stack của bạn.

Khi dev hỏi về limit, phân biệt: "hit your session/weekly limit" là seat-based window (đổi model không khôi phục vì window chia sẻ mọi model); context/auto-compact warning không phải usage limit; spend cao bất ngờ trên API/cloud thường do session dài không clear hoặc để Opus làm default.

Reduce token usage

Token cost scale theo context size. Các chiến lược:

  • Clear giữa task/clear khi chuyển việc không liên quan. /rename trước khi clear để tìm lại, /resume để quay lại.
  • Chọn đúng model — Sonnet xử lý phần lớn coding task tốt và rẻ hơn Opus; để dành Opus cho architectural/multi-step reasoning. Subagent đơn giản: model: haiku.
  • Giảm MCP overhead — MCP tool definitions deferred by default; prefer CLI tools (gh, aws, gcloud) vì không thêm per-tool listing; /mcp disable server không dùng. /context xem gì đang chiếm chỗ.
  • Code intelligence plugins cho typed languages — symbol navigation chính xác thay text search, giảm file reads.
  • Offload sang hooks/skills — hook có thể grep ERROR trả về vài trăm token thay vì Claude đọc log 10.000 dòng; skill cho domain knowledge để Claude khỏi explore.
{
  "hooks": {
    "PreToolUse": [
      { "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "~/.claude/hooks/filter-test-output.sh" }] }
    ]
  }
}
  • Chuyển instructions từ CLAUDE.md sang skills — CLAUDE.md load lúc start (luôn có mặt kể cả khi làm việc khác); skills load on-demand. Giữ CLAUDE.md dưới ~200 dòng.
  • Adjust extended thinking — thinking tokens bill như output. Task đơn giản: hạ effort (/effort), disable thinking trong /config, hoặc set MAX_THINKING_TOKENS=8000 (model fixed budget). Adaptive-reasoning model bỏ qua nonzero budget → dùng effort level. Fable 5 luôn dùng extended thinking.
  • Delegate verbose ops sang subagents — chạy test, fetch docs, xử lý log ở subagent; chỉ summary về main conversation.
  • Write specific prompts — "add input validation to the login function in auth.ts" thay vì "improve this codebase".
  • Plan mode cho task phức tạp (Shift+Tab) — explore và propose approach trước, tránh re-work đắt. Course-correct sớm bằng Escape; /rewind để restore checkpoint.

Agent team costs

Agent teams spawn nhiều Claude instance, mỗi cái context window riêng — dùng ~7x token so với standard session khi teammate chạy plan mode. Giữ team nhỏ; dùng Sonnet cho teammates; spawn prompt gọn; shut down teammate khi xong; disabled by default (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 để bật).


5. Tối ưu context

Context window giữ mọi thứ Claude biết về session: instructions, files nó đọc, responses của nó, và content không bao giờ hiện trong terminal.

Cái gì load vào context

  • Trước khi bạn gõ: system prompt, auto memory (MEMORY.md), environment info, MCP tool names (deferred), skill descriptions, ~/.claude/CLAUDE.md, project CLAUDE.md — tất cả đã ở trong context trước prompt đầu tiên. Prompt của bạn nhỏ xíu so với đó.
  • Khi Claude làm việc: mỗi file read tăng context (file reads chiếm phần lớn context usage); path-scoped rules load tự động cạnh matching files; PostToolUse hooks fire sau mỗi edit (output vào context qua additionalContext JSON).
  • Subagent: chạy trong context window riêng, tách biệt. File reads của nó không đụng context của bạn — chỉ final summary + metadata trailer nhỏ quay về. Đó là khoản tiết kiệm context lớn nhất.

What survives compaction

Khi session dài compact, Claude Code summarize history để vừa context window:

MechanismSau compaction
System prompt và output styleKhông đổi; không thuộc message history
Project-root CLAUDE.md và unscoped rulesRe-inject từ disk
Auto memoryRe-inject từ disk
Rules với paths: frontmatterMất đến khi đọc lại matching file
Nested CLAUDE.md trong subdirectoryMất đến khi đọc lại file trong subdir đó
Invoked skill bodiesRe-inject, cap 5.000 token/skill và 25.000 token tổng; drop oldest trước
HooksKhông áp dụng; hook chạy như code, không phải context

Skill body bị truncate giữ phần đầu file → đặt instructions quan trọng nhất gần đầu SKILL.md. Nếu một rule phải sống sót qua compaction, bỏ paths: frontmatter hoặc chuyển vào project-root CLAUDE.md.

Hành động trước khi context đầy

Claude Code auto-compact khi gần limit (session không kết thúc). Bạn cũng chủ động được:

  • /compact với focus: /compact focus on the auth bug fix — summary giữ thứ bạn chọn thay vì đoán tự động. Chạy ở break tự nhiên giữa task.
  • /clear giữa task không liên quan — context cũ chèn chỗ file cần tiếp theo và tốn token mỗi message.
  • Delegate large reads sang subagent — content file ở lại context của nó.

Context window lớn hơn (1M token)

Fable 5, Sonnet 5, Opus 4.6+, và Sonnet 4.6 hỗ trợ context window 1 triệu token. Chọn model variant [1m] (xem Extended context để biết availability theo plan). Sonnet 5 chạy 1M mà không cần variant [1m]. Compaction hoạt động y hệt ở limit lớn hơn.

Check session của bạn

  • /context — breakdown context usage live theo category kèm optimization suggestions (gồm CLAUDE.md và auto memory files nào đã load).
  • /memory — mở và sửa các file đó.
  • statusline — hiển thị context window usage liên tục.

Xem thêm

  • content/en/docs/claude-code/large-codebases.md — Setup cho monorepo/codebase lớn (CLAUDE.md layering, claudeMdExcludes, deny rules, code intelligence, sparsePaths).
  • content/en/docs/claude-code/worktrees.md — Parallel sessions với git worktrees, subagent isolation, .worktreeinclude, non-git VCS hooks.
  • content/en/docs/claude-code/prompt-caching.md — Cách Claude Code dùng prompt caching, actions invalidate/keep cache, TTL, scope.
  • content/en/docs/claude-code/costs.md — Track/manage/reduce cost, org controls, rate limit recommendations, agent team costs.
  • content/en/docs/claude-code/context-window.md — Cái gì load vào context, what survives compaction, 1M token window.
  • Chương liên quan trong sách: Subagents, Skills, Memory & CLAUDE.md, Hooks, Plugins.
Nguồn của chương

Tài liệu chính thức duy nhất từ Anthropic.

Claude Code docs
Trở về mục lục