document-decision
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocument a decision — write an ADR
记录决策——编写ADR
Create an ADR so future readers (including future you) understand why a technical choice was made. An ADR is immutable once accepted — it records the decision and its context at the moment of decision. New information gets a new ADR that references (and possibly supersedes) the old one.
This skill produces canonical MADR v4 (Markdown Architectural Decision Records, version 4.0.0, released 2024-09-17 — the current standard). Spec: https://adr.github.io/madr/ — template source: https://github.com/adr/madr/blob/develop/template/adr-template.md.
创建ADR是为了让未来的读者(包括未来的你)理解做出某项技术选择的原因。ADR一旦被接受便不可更改——它记录了决策做出时的内容和背景。新信息需要创建新的ADR,并引用(可能取代)旧的ADR。
此技能生成标准MADR v4(Markdown架构决策记录,4.0.0版本,发布于2024-09-17——当前标准)。规范地址:https://adr.github.io/madr/ —— 模板来源:https://github.com/adr/madr/blob/develop/template/adr-template.md。
Before You Start
开始之前
- The project's existing ADR directory — common locations: ,
docs/adr/,docs/decisions/,docs/arc42/decisions/, orarchitecture/decisions/. Find it withadr/.find . -type d -name 'adr*' -o -name 'decisions' - Any template file in that directory — often or
template.md. If a project template exists, follow it instead of the canonical MADR template — projects sometimes pin a specific subset of optional sections.0000-template.md - Existing ADRs — browse 2–3 well-written ones to match the project's voice and depth.
If the project has no ADR directory yet, ask the user where ADRs should live before creating the first one.
- 项目现有ADR目录——常见位置:、
docs/adr/、docs/decisions/、docs/arc42/decisions/或architecture/decisions/。可通过命令adr/查找。find . -type d -name 'adr*' -o -name 'decisions' - 该目录下的任何模板文件——通常为或
template.md。如果项目已有模板,请遵循项目模板而非标准MADR模板——项目有时会固定使用特定的可选章节子集。0000-template.md - 现有ADR——浏览2-3篇撰写良好的ADR,匹配项目的语气和深度。
如果项目还没有ADR目录,请先询问用户ADR应存放在何处,再创建第一篇ADR。
Step 1: analyze the change
步骤1:分析变更
bash
git diff main...HEAD
git diff --stat main...HEADIdentify:
- What was chosen?
- What were the alternatives considered?
- What forces (constraints, quality attributes, risks) pulled toward each alternative?
- What will change now, and what could change later as a result?
- How will compliance be confirmed? (MADR v4 elevated this — see in Step 4.)
### Confirmation
If you're writing the ADR before the code change, do the same analysis against the planned approach.
bash
git diff main...HEAD
git diff --stat main...HEAD确定:
- 选择了什么?
- 考虑过哪些替代方案?
- 哪些因素(约束、质量属性、风险)倾向于每个替代方案?
- 现在会发生什么变化,以及未来可能因此发生什么变化?
- 如何确认合规性?(MADR v4对此进行了强调——见步骤4中的。)
### Confirmation
如果在代码变更前编写ADR,请针对计划的方法进行同样的分析。
Step 2: check for existing ADRs on the topic
步骤2:检查是否存在相关主题的现有ADR
bash
undefinedbash
undefinedFind ADRs covering adjacent ground
查找涵盖相关领域的ADR
grep -rli "{topic-keyword}" <adr-dir>/ 2>/dev/null
If one exists:
- **Covers the same ground** — update it rather than creating a duplicate.
- **Covers related but different ground** — reference it in the new ADR's **Context and Problem Statement**.
- **Contradicts this decision** — mark the old one's frontmatter as `status: "superseded by ADR-NNNN"` and reference it in your new **Context and Problem Statement**.grep -rli "{topic-keyword}" <adr-dir>/ 2>/dev/null
如果存在:
- **涵盖相同内容**——更新该ADR,而非创建重复内容。
- **涵盖相关但不同的内容**——在新ADR的**背景与问题陈述**中引用它。
- **与本次决策矛盾**——将旧ADR的前置元数据标记为`status: "superseded by ADR-NNNN"`,并在新ADR的**背景与问题陈述**中引用它。Step 3: name the file
步骤3:命名文件
Two common conventions:
- Numbered: (e.g.,
NNNN-short-slug.md). Number is monotonic; pad to 4 digits. This is MADR's default.0042-adopt-postgres-rls.md - Dated: (e.g.,
YYYY_MM_DD_short_slug.md).2026_04_20_adopt_postgres_rls.md
Follow whatever the project already uses. Look at the filenames of existing ADRs to copy the pattern.
两种常见约定:
- 编号式: (例如:
NNNN-short-slug.md)。编号为递增序列;补零至4位。这是MADR的默认约定。0042-adopt-postgres-rls.md - 日期式: (例如:
YYYY_MM_DD_short_slug.md)。2026_04_20_adopt_postgres_rls.md
遵循项目已有的命名方式。查看现有ADR的文件名以复制其格式。
Step 4: write the ADR (canonical MADR v4)
步骤4:编写ADR(标准MADR v4)
Use the template below verbatim. Drop optional sections (marked with the HTML comment ) only when they genuinely add no value — in particular should almost always be kept (the MADR spec itself notes "although we classify this element as optional, it is included in many ADRs").
<!-- This is an optional element. Feel free to remove. -->### Confirmationmarkdown
---
status: "{proposed | rejected | accepted | deprecated | superseded by ADR-0123}"
date: {YYYY-MM-DD}
decision-makers: {list everyone involved in the decision}
consulted: {subject-matter experts with two-way communication}
informed: {kept up-to-date with one-way communication}
---严格使用以下模板。仅当确实没有价值时才删除可选章节(标记为HTML注释)——尤其应保留(MADR规范本身指出“尽管我们将此元素归类为可选,但许多ADR中都包含它”)。
<!-- This is an optional element. Feel free to remove. -->### Confirmationmarkdown
---
status: "{proposed | rejected | accepted | deprecated | superseded by ADR-0123}"
date: {YYYY-MM-DD}
decision-makers: {列出所有参与决策的人员}
consulted: {进行双向沟通的主题专家}
informed: {通过单向沟通保持知情的人员}
---{short title, representative of solved problem and found solution}
{简短标题,能代表所解决的问题和找到的解决方案}
Context and Problem Statement
背景与问题陈述
{Describe the context and problem in two to three sentences, or as an illustrative
story. You may articulate the problem as a question. Make the scope explicit by
naming the structural architecture elements affected (components, connectors,
modules). Link to issues, collaboration boards, prior ADRs.}
<!-- This is an optional element. Feel free to remove. -->{用两到三句话或一个说明性故事描述背景和问题。你可以将问题表述为一个问句。通过指明受影响的结构架构元素(组件、连接器、模块)明确范围。链接到问题、协作看板、先前的ADR。}
<!-- This is an optional element. Feel free to remove. -->Decision Drivers
决策驱动因素
- {decision driver 1 — a desired quality, faced concern, constraint, or force}
- {decision driver 2}
- …
- {决策驱动因素1——期望的质量、面临的问题、约束或因素}
- {决策驱动因素2}
- …
Considered Options
考虑的方案
- {title of option 1}
- {title of option 2}
- {title of option 3}
- …
- {方案1标题}
- {方案2标题}
- {方案3标题}
- …
Decision Outcome
决策结果
Chosen option: "{title of option 1}", because {justification — e.g., only option
that meets a k.o. criterion, resolves a specific force, comes out best in the
pros/cons analysis below}.
<!-- This is an optional element. Feel free to remove. -->选择的方案:"{方案1标题}",因为{理由——例如,唯一满足淘汰标准的方案,解决了特定因素,在下面的优缺点分析中表现最佳}。
<!-- This is an optional element. Feel free to remove. -->Consequences
影响
- Good, because {positive consequence — improvement of one or more desired qualities}
- Bad, because {negative consequence — compromising one or more desired qualities}
- …
- 有利,因为{积极影响——提升一个或多个期望的质量}
- 不利,因为{消极影响——损害一个或多个期望的质量}
- …
Confirmation
Confirmation(合规确认)
{How will compliance with this ADR be confirmed? Is there an automated or manual
fitness function? E.g., a code review, a test with ArchUnit, a CI check, a
periodic audit. Name the mechanism and where it lives.}
<!-- This is an optional element. Feel free to remove. -->{如何确认符合此ADR?是否有自动化或手动验证机制?例如,代码审查、使用ArchUnit的测试、CI检查、定期审计。指明机制及其所在位置。}
<!-- This is an optional element. Feel free to remove. -->Pros and Cons of the Options
各方案的优缺点
{title of option 1}
{方案1标题}
{example | description | pointer to more information}
- Good, because {argument a}
- Good, because {argument b}
- Neutral, because {argument c}
- Bad, because {argument d}
{示例 | 描述 | 指向更多信息的链接}
- 有利,因为{论点a}
- 有利,因为{论点b}
- 中性,因为{论点c}
- 不利,因为{论点d}
{title of option 2}
{方案2标题}
- Good, because {argument a}
- Neutral, because {argument b}
- Bad, because {argument c}
- 有利,因为{论点a}
- 中性,因为{论点b}
- 不利,因为{论点c}
More Information
更多信息
{Additional evidence/confidence for the outcome; team agreement; when/how the
decision should be realised; if/when it should be revisited; links to related
decisions and resources.}
undefined{决策结果的额外证据/信心;团队共识;决策应何时/如何实施;何时/应否重新审视;指向相关决策和资源的链接。}
undefinedWriting discipline
写作规范
- Heading names are exact. ,
Context and Problem Statement,Decision Drivers,Considered Options,Decision Outcome,Consequences,Confirmation,Pros and Cons of the Options. MADR-aware tooling parses on these names.More Information - Heading levels are exact. and
ConsequencesareConfirmationunder###, not top-level.## Decision Outcome - Frontmatter field names are exact. (hyphenated, plural), not
decision-makers.decidersvalue is a quoted string when it contains spaces (e.g.,status).status: "superseded by ADR-0123" - Bullet voice is "Good, because …" / "Bad, because …" / "Neutral, because …". Not "Pros:" / "Cons:".
- Context is specific. "We need to scale" → "Request latency at the 95th percentile has exceeded 500ms as traffic doubled; adding more replicas of the current stack costs $X/month."
- Drivers are verifiable. "Ease of use" is not a driver — "junior engineers onboard in under a week" is.
- Decision names the trade-off. If there's no trade-off, the decision isn't worth an ADR.
- Confirmation is concrete. Name the test file, the CI job, the review gate. "We will review this" is not confirmation.
- 标题名称必须准确。(背景与问题陈述)、
Context and Problem Statement(决策驱动因素)、Decision Drivers(考虑的方案)、Considered Options(决策结果)、Decision Outcome(影响)、Consequences(合规确认)、Confirmation(各方案的优缺点)、Pros and Cons of the Options(更多信息)。识别MADR的工具会根据这些名称进行解析。More Information - 标题层级必须准确。(影响)和
Consequences(合规确认)是Confirmation(决策结果)下的## Decision Outcome子标题,而非顶级标题。### - 前置元数据字段名称必须准确。(连字符连接,复数形式),而非
decision-makers。当deciders值包含空格时,需用引号括起(例如:status)。status: "superseded by ADR-0123" - 项目符号语气为“有利,因为……”/“不利,因为……”/“中性,因为……”。不能是“优点:”/“缺点:”。
- 背景需具体。“我们需要扩展” → “随着流量翻倍,95分位请求延迟已超过500ms;为当前栈添加更多副本每月需花费X美元。”
- 驱动因素可验证。“易用性”不是驱动因素——“初级工程师可在一周内完成入职”才是。
- 决策需说明权衡。如果没有权衡,该决策不值得记录为ADR。
- 合规确认需具体。指明测试文件、CI任务、审查关卡。“我们将对此进行审查”不属于合规确认。
Step 5: update the ADR index
步骤5:更新ADR索引
Most ADR directories have an or listing every ADR. Add an entry:
index.mdREADME.mdmarkdown
| {Number/Date} | [{Title}]({filename}) | {Status} |大多数ADR目录都有或列出所有ADR。添加一条记录:
index.mdREADME.mdmarkdown
| {编号/日期} | [{标题}]({文件名}) | {状态} |Verify
验证
bash
undefinedbash
undefinedThe file exists where expected
文件存在于预期位置
ls <adr-dir>/{NNNN-slug.md OR YYYY_MM_DD_slug.md}
ls <adr-dir>/{NNNN-slug.md 或 YYYY_MM_DD_slug.md}
Required MADR v4 sections are present (Context, Considered Options, Decision Outcome)
包含MADR v4必填章节(背景、考虑的方案、决策结果)
grep -E '^## (Context and Problem Statement|Considered Options|Decision Outcome)$' <adr-dir>/<filename> | wc -l
grep -E '^## (Context and Problem Statement|Considered Options|Decision Outcome)$' <adr-dir>/<filename> | wc -l
Expected: 3
预期结果:3
Confirmation sub-section is present (strongly recommended)
包含Confirmation子章节(强烈建议)
grep -q '^### Confirmation$' <adr-dir>/<filename> && echo "OK" || echo "MISSING — add unless intentionally omitted"
grep -q '^### Confirmation$' <adr-dir>/<filename> && echo "OK" || echo "缺失——除非有意省略否则请添加"
Frontmatter uses canonical field names
前置元数据使用标准字段名称
head -10 <adr-dir>/<filename> | grep -E '^(status|date|decision-makers|consulted|informed):'
head -10 <adr-dir>/<filename> | grep -E '^(status|date|decision-makers|consulted|informed):'
The index references it
索引中引用了该ADR
grep -q "{slug}" <adr-dir>/README.md <adr-dir>/index.md 2>/dev/null
undefinedgrep -q "{slug}" <adr-dir>/README.md <adr-dir>/index.md 2>/dev/null
undefinedCommon Mistakes
常见错误
| Mistake | Correction |
|---|---|
Using | Heading name is exact in MADR v4. |
Using | Same. |
Promoting | They are |
Frontmatter field | Renamed to |
Listing pros/cons as | Use |
Omitting | MADR v4 elevated this; almost every meaningful ADR has a confirmation mechanism. State it. |
| Writing an ADR for a decision with no real trade-off | Skip it. ADRs document choices with alternatives. |
| Context is the situation. If context and decision sound the same, the context isn't concrete enough. |
Consequences listed only as | Every decision has trade-offs. If you can't name a |
| Duplicating an existing ADR because you didn't search | Step 2 is mandatory. Duplicate ADRs fragment institutional memory. |
| 错误 | 修正方法 |
|---|---|
使用 | MADR v4中的标题名称必须准确。 |
使用 | 同上。 |
将 | 它们是 |
前置元数据字段使用 | MADR v4中已重命名为 |
用 | 使用 |
省略 | MADR v4对此进行了强调;几乎所有有意义的ADR都有合规确认机制。请明确说明。 |
| 为没有实际权衡的决策编写ADR | 跳过此类决策。ADR用于记录有替代方案的选择。 |
| 背景是所处的情境。如果背景和决策听起来相同,说明背景不够具体。 |
仅列出 | 每个决策都有权衡。如果无法列出 |
| 未搜索就创建重复的ADR | 步骤2是必填项。重复的ADR会分散组织记忆。 |