domain-modeling

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Domain Modeling

领域建模

Actively build and sharpen the project's domain model as you design. This is the active discipline — challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely reading
CONTEXT.md
for vocabulary is not this skill — that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
在设计过程中主动构建并完善项目的领域模型。这是一项主动的实践——对术语提出质疑、设想边缘案例场景,并在概念明确的当下就将术语表和决策记录下来。(仅仅为了了解词汇而阅读
CONTEXT.md
不属于这项技能——那是任何技能都能做到的简单习惯。这项技能适用于你修改模型的场景,而非仅仅使用模型。)

File structure

文件结构

Most repos have a single context:
/
├── CONTEXT.md
├── docs/
│   └── adr/
│       ├── 0001-event-sourced-orders.md
│       └── 0002-postgres-for-write-model.md
└── src/
If a
CONTEXT-MAP.md
exists at the root, the repo has multiple contexts. The map points to where each one lives:
/
├── CONTEXT-MAP.md
├── docs/
│   └── adr/                          ← system-wide decisions
├── src/
│   ├── ordering/
│   │   ├── CONTEXT.md
│   │   └── docs/adr/                 ← context-specific decisions
│   └── billing/
│       ├── CONTEXT.md
│       └── docs/adr/
Create files lazily — only when you have something to write. If no
CONTEXT.md
exists, create one when the first term is resolved. If no
docs/adr/
exists, create it when the first ADR is needed.
大多数代码仓库只有一个上下文:
/
├── CONTEXT.md
├── docs/
│   └── adr/
│       ├── 0001-event-sourced-orders.md
│       └── 0002-postgres-for-write-model.md
└── src/
如果根目录下存在
CONTEXT-MAP.md
,则该代码仓库包含多个上下文。该映射文件会指向每个上下文的存放位置:
/
├── CONTEXT-MAP.md
├── docs/
│   └── adr/                          ← 系统级决策
├── src/
│   ├── ordering/
│   │   ├── CONTEXT.md
│   │   └── docs/adr/                 ← 上下文专属决策
│   └── billing/
│       ├── CONTEXT.md
│       └── docs/adr/
按需创建文件——仅当你有内容可写时再创建。如果不存在
CONTEXT.md
,则在第一个术语确定时创建它。如果不存在
docs/adr/
目录,则在首次需要ADR时创建它。

During the session

会话过程中

Challenge against the glossary

对照术语表提出质疑

When the user uses a term that conflicts with the existing language in
CONTEXT.md
, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
当用户使用的术语与
CONTEXT.md
中的现有表述冲突时,立即指出。例如:“你的术语表将‘cancellation’定义为X,但你此处的意思似乎是Y——到底是哪一个?”

Sharpen fuzzy language

明确模糊表述

When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
当用户使用模糊或多义术语时,提出精准的标准术语建议。例如:“你提到了‘account’——你指的是Customer还是User?这两者是不同的概念。”

Discuss concrete scenarios

讨论具体场景

When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
当讨论领域关系时,用特定场景进行压力测试。设想边缘案例场景,迫使用户明确概念之间的界限。

Cross-reference with code

与代码交叉验证

When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
当用户说明某功能的工作方式时,检查代码是否与之相符。如果发现矛盾,及时指出:“你的代码会取消整个Orders,但你刚才说支持部分取消——哪个是正确的?”

Update CONTEXT.md inline

即时更新CONTEXT.md

When a term is resolved, update
CONTEXT.md
right there. Don't batch these up — capture them as they happen. Use the format in CONTEXT-FORMAT.md.
CONTEXT.md
should be totally devoid of implementation details. Do not treat
CONTEXT.md
as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
当术语确定后,立即更新
CONTEXT.md
。不要批量处理——在概念明确的当下就记录下来。使用CONTEXT-FORMAT.md中的格式。
CONTEXT.md
应完全不包含实现细节。不要将
CONTEXT.md
当作规范、草稿本或实现决策的存储库。它仅仅是一个术语表。

Offer ADRs sparingly

谨慎提议创建ADR

Only offer to create an ADR when all three are true:
  1. Hard to reverse — the cost of changing your mind later is meaningful
  2. Surprising without context — a future reader will wonder "why did they do it this way?"
  3. The result of a real trade-off — there were genuine alternatives and you picked one for specific reasons
If any of the three is missing, skip the ADR. Use the format in ADR-FORMAT.md.
仅当以下三个条件全部满足时,才提议创建ADR:
  1. 难以逆转——后续改变决策的成本很高
  2. 缺乏上下文会令人困惑——未来的读者会疑惑“他们为什么要这么做?”
  3. 是权衡后的结果——存在真正的替代方案,且你因特定原因选择了其中一个
如果缺少任意一个条件,就不要创建ADR。使用ADR-FORMAT.md中的格式。