claude-code-project-memory
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude Code Project Memory (Jan 2026)
Claude Code项目内存(2026年1月)
Configure project memory so Claude Code gets stable, scoped instructions across sessions while keeping token cost low.
CLAUDE.md配置项目内存,让Claude Code在不同会话中获得稳定、限定范围的指令,同时降低Token消耗。
CLAUDE.mdQuick Reference
快速参考
| Memory Type | Typical Location | Purpose |
|---|---|---|
| Managed policy | OS-dependent (see official docs) | Organization-wide standards (security, compliance) |
| Project memory | | Shared project context and conventions |
| Project rules | | Modular, topic-focused rules (testing, security, style) |
| User memory | | Personal preferences across projects |
| Project memory (local) | | Local-only, project-specific preferences |
| 内存类型 | 典型存放位置 | 用途 |
|---|---|---|
| 托管策略 | 依赖操作系统(详见官方文档) | 全组织范围的标准(安全、合规) |
| 项目内存 | | 共享项目上下文与规范 |
| 项目规则 | | 模块化、主题化规则(测试、安全、风格) |
| 用户内存 | | 跨项目的个人偏好设置 |
| 本地项目内存 | | 仅本地生效的项目特定偏好 |
How Loading Works (High Level)
加载机制(概览)
- Recursive loading: from the current working directory up to (but not including) filesystem root ().
/ - On-demand loading: nested files under the cwd are loaded only when Claude reads files in those subtrees.
CLAUDE.md - Imports: pulls in additional context (max depth: 5;
@path/to/filesupported).~
- 递归加载:从当前工作目录向上加载,直至(但不包含)文件系统根目录()。
/ - 按需加载:当前工作目录下的嵌套文件仅在Claude读取对应子目录中的文件时才会加载。
CLAUDE.md - 导入:可引入额外上下文(最大深度:5;支持
@path/to/file路径)。~
Workflow (Best Practice)
最佳实践工作流
- Start with a minimal (50–120 lines): what the project is, how it’s shaped, and the “must not break” rules.
CLAUDE.md - Move long or fragile guidance into (one topic per file).
.claude/rules/ - Use as navigation for detailed docs instead of copying them into memory.
@imports - Treat memory like code: PR review, ownership, and periodic cleanup (remove dead rules).
- 从精简版开始(50–120行):说明项目内容、架构以及“绝对不能破坏”的规则。
CLAUDE.md - 将冗长或易变的指引迁移至目录(每个主题一个文件)。
.claude/rules/ - 使用作为详细文档的导航,而非将内容复制到内存文件中。
@imports - 将内存文件视为代码:进行PR评审、明确所有权并定期清理(移除失效规则)。
Rules With Optional Path Scope
带可选路径范围的规则
Create , , etc. If a rule only applies to a slice of the repo, scope it:
.claude/rules/testing.md.claude/rules/security.mdyaml
---
paths:
- "src/api/**/*.ts"
---创建、等文件。如果某条规则仅适用于仓库的部分内容,可设置范围:
.claude/rules/testing.md.claude/rules/security.mdyaml
---
paths:
- "src/api/**/*.ts"
---Commands (Claude Code)
Claude Code命令
- to view and directly edit memories.
> /memory - to bootstrap project memory (see official docs for current behavior).
> /init
- :查看并直接编辑内存文件。
> /memory - :引导生成项目内存(当前行为详见官方文档)。
> /init
Cross-Platform Strategy (AGENTS.md + CLAUDE.md)
跨平台策略(AGENTS.md + CLAUDE.md)
If you support multiple coding assistants, keep one canonical file and mirror it:
- macOS/Linux: symlink one to the other.
- Windows: prefer copying (or a small sync script) over symlinks unless Developer Mode is enabled.
Avoid tool-specific claims in the memory file; keep it portable and strictly project-focused.
如果您同时使用多个编码助手,请维护一个标准文件并进行镜像同步:
- macOS/Linux:将一个文件软链接到另一个。
- Windows:除非启用开发者模式,否则优先选择复制(或使用小型同步脚本)而非软链接。
避免在内存文件中加入工具专属内容;保持文件的可移植性,严格聚焦于项目本身。
Validation (Fast Checks)
验证(快速检查)
- Run the bundled linter:
bash frameworks/shared-skills/skills/claude-code-project-memory/scripts/lint_claude_memory.sh . - Manually scan for unresolved and secrets before merging memory changes.
@imports
- 运行内置的检查器:
bash frameworks/shared-skills/skills/claude-code-project-memory/scripts/lint_claude_memory.sh . - 在合并内存文件变更前,手动扫描未解析的和敏感信息。
@imports
Resources
资源
| Resource | Purpose |
|---|---|
| references/memory-patterns.md | Patterns and anti-patterns |
| references/memory-examples.md | Full examples by stack |
| references/large-codebase-strategy.md | 100K–1M LOC strategy |
| data/sources.json | Official links |
| 资源 | 用途 |
|---|---|
| references/memory-patterns.md | 内存模式与反模式 |
| references/memory-examples.md | 按技术栈分类的完整示例 |
| references/large-codebase-strategy.md | 10万–100万行代码库的策略 |
| data/sources.json | 官方链接 |
Related Skills
相关技能
| Skill | Purpose |
|---|---|
| claude-code-skills | Skill creation patterns |
| claude-code-agents | Claude Code agent setup |
| docs-codebase | Repo documentation patterns |
| 技能 | 用途 |
|---|---|
| claude-code-skills | 技能创建模式 |
| claude-code-agents | Claude Code Agent配置 |
| docs-codebase | 仓库文档模式 |