domain-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDomain Context Auto-Loader
领域上下文自动加载器
You have access to a Domain Registry that maps library paths to their documentation. When working on domain-specific code, you MUST silently load that domain's context before proceeding.
你可以访问Domain Registry(领域注册表),其中映射了库路径与其对应的文档。当处理特定领域的代码时,你必须在继续操作前静默加载该领域的上下文。
Step 1 — Check for a Domain Registry
步骤1 — 检查Domain Registry
At the start of any task, look for this section in :
CLAUDE.mdmarkdown
undefined在任何任务开始时,查找中的该部分:
CLAUDE.mdmarkdown
undefinedDomain Registry
Domain Registry
<!-- domain-registry-start -->
<!-- domain-registry-end -->
| Path | Import Path | Description |
|---|---|---|
| libs/widget-chat | @scope/widget-chat | Chat widget |
If `## Domain Registry` is not present, skip all steps below.<!-- domain-registry-start -->
<!-- domain-registry-end -->
| Path | Import Path | Description |
|---|---|---|
| libs/widget-chat | @scope/widget-chat | Chat widget |
如果不存在`## Domain Registry`部分,跳过以下所有步骤。Step 2 — Match the Task to a Domain
步骤2 — 将任务与领域匹配
Determine which domain is relevant based on:
- File paths mentioned by the user or referenced in the task (e.g. )
libs/widget-chat/domain/store.ts - Import paths in existing code (e.g. )
@scope/widget-chat - Domain or library names the user explicitly mentions (e.g. "work on widget-chat")
- If multiple domains are relevant, collect all matching paths
If no domain matches, proceed normally without loading any README.
根据以下信息判断相关的领域:
- 用户提及或任务中引用的文件路径(例如 )
libs/widget-chat/domain/store.ts - 现有代码中的导入路径(例如 )
@scope/widget-chat - 用户明确提及的领域或库名称(例如「开发 widget-chat 相关功能」)
- 如果涉及多个相关领域,收集所有匹配的路径
如果没有匹配的领域,无需加载任何README,正常继续即可。
Step 3 — Load Domain Context
步骤3 — 加载领域上下文
For each matched domain path, read the file at .
<path>/README.mdDo this silently. Do NOT announce "I'm loading the README for...". Just read it and use the knowledge to:
- Understand the domain's architecture before suggesting any implementation
- Follow existing patterns documented in the README
- Reference correct import paths and public API surface
- Respect documented constraints or conventions
对于每个匹配的领域路径,读取文件。
<path>/README.md请静默执行该操作,不要告知用户「我正在加载XX的README」,只需读取内容并将这些知识用于:
- 在给出任何实现建议前理解领域的架构
- 遵循README中记录的现有模式
- 引用正确的导入路径和公共API范围
- 遵守文档中说明的约束或约定
Step 4 — Apply the Context
步骤4 — 应用上下文
Use what you read to answer or implement with domain-accurate precision:
- Prefer patterns shown in the README over general Angular/NgRx defaults
- When the README describes a store shape, facade pattern, or component API — use it
- If the README contradicts your assumptions, trust the README
使用你读取的内容以符合领域实际的精确度给出回答或实现方案:
- 优先使用README中展示的模式,而非通用的Angular/NgRx默认方案
- 当README中描述了存储结构、外观模式或组件API时,请直接使用
- 如果README与你的假设存在冲突,以README为准
What a Good Domain README Contains
优质领域README应包含的内容
If you're asked to generate or update a domain README, it should include:
markdown
undefined如果你被要求生成或更新领域README,它应该包含:
markdown
undefined<Domain Name>
<Domain Name>
One-line description.
One-line description.
Architecture
Architecture
Diagram or description of layers, key files, data flow.
Diagram or description of layers, key files, data flow.
Public API
Public API
Exported services, components, stores with brief description of each.
Exported services, components, stores with brief description of each.
Key Patterns
Key Patterns
Conventions specific to this domain (store shape, facade, etc.).
Conventions specific to this domain (store shape, facade, etc.).
Usage Example
Usage Example
Minimal code snippet showing how to import and use.
Minimal code snippet showing how to import and use.
Dependencies
Dependencies
What this domain depends on and what depends on it.
undefinedWhat this domain depends on and what depends on it.
undefinedEdge Cases
边缘情况
| Situation | Action |
|---|---|
| Skip silently, proceed with code exploration |
| README is outdated (contradicts code) | Trust the code, flag the discrepancy to the user |
| Multiple domains match | Load all matching READMEs |
| Domain registry not in CLAUDE.md | Skip all domain context loading |
| 情况 | 处理方式 |
|---|---|
| 静默跳过,继续探索代码 |
| README 过时(与代码冲突) | 以代码为准,向用户指出该差异 |
| 匹配到多个领域 | 加载所有匹配的README |
| CLAUDE.md 中没有Domain Registry | 跳过所有领域上下文加载 |