adr-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADR Review
ADR审查
Review code changes against accepted Architecture Decision Records to detect violations, drift, and non-compliance.
对照已接受的架构决策记录(Architecture Decision Records)审查代码变更,检测违规、偏离和不合规情况。
When to use
使用场景
Before merging a PR, after significant code changes, or as part of a periodic compliance check. Use this to ensure code changes respect the architectural decisions the team has agreed upon.
在合并PR之前、完成重大代码变更后,或作为定期合规检查的一部分。使用此流程确保代码变更符合团队已达成一致的架构决策。
Steps
步骤
-
Get diff -- Run(or the specified branch) to list changed files. Then run
git diff main...HEAD --name-onlyto get the full diff content.git diff main...HEAD -
Find relevant ADRs -- For each changed file:
- the file for ADR references (
Grep)ADR-\d+ Grepfor ADRs that mention the changed file paths or modulesdocs/adr/- Call with the file path and change summary to find semantically related ADRs
mcp__claude-flow__memory_search
-
Load ADR content --each relevant ADR file. Focus on:
Read- The Decision section (what was decided)
- The Status (only enforce "accepted" ADRs)
- The Consequences (expected constraints)
-
Check for violations -- Analyze each changed file against its relevant ADRs:
- Does the code change contradict an accepted decision?
- Does it use a technology/pattern that an ADR explicitly rejected?
- Does it modify a module in a way the ADR's consequences warned against?
- Is the code referencing a deprecated or superseded ADR?
-
Query relationship graph -- Callto check if any referenced ADRs have been superseded. If so, flag that the code references an outdated decision.
mcp__claude-flow__agentdb_causal-query -
Report -- Present findings as a compliance report:
## ADR Compliance Report ### Violations - [ ] <file>:<line> — violates ADR-NNN: <reason> ### Warnings - [!] <file> references superseded ADR-NNN (replaced by ADR-MMM) ### Compliant - [x] <file> — consistent with ADR-NNN ### Unlinked Changes - [?] <file> — no ADR coverage (consider creating one) -
Suggest actions -- For each violation, suggest whether to update the code or propose a new ADR to supersede the violated one.
-
获取差异 —— 运行(或指定分支)列出变更文件。然后运行
git diff main...HEAD --name-only获取完整的差异内容。git diff main...HEAD -
查找相关ADR —— 针对每个变更文件:
- 使用在文件中查找ADR引用(
Grep)ADR-\d+ - 使用在
Grep目录中查找提及变更文件路径或模块的ADRdocs/adr/ - 调用,传入文件路径和变更摘要,查找语义相关的ADR
mcp__claude-flow__memory_search
- 使用
-
加载ADR内容 —— 读取每个相关的ADR文件。重点关注:
- 决策部分(已做出的决策内容)
- 状态(仅强制执行“已接受”状态的ADR)
- 影响(预期的约束条件)
-
检查违规情况 —— 针对每个变更文件及其相关ADR进行分析:
- 代码变更是否与已接受的决策相矛盾?
- 是否使用了ADR明确拒绝的技术/模式?
- 是否以ADR影响部分警告过的方式修改模块?
- 代码是否引用了已弃用或被取代的ADR?
-
查询关系图 —— 调用检查是否有任何引用的ADR已被取代。如果是,标记代码引用了过时的决策。
mcp__claude-flow__agentdb_causal-query -
生成报告 —— 将检查结果整理为合规报告:
## ADR合规报告 ### 违规情况 - [ ] <文件>:<行号> —— 违反ADR-NNN:<原因> ### 警告 - [!] <文件>引用了已被取代的ADR-NNN(已被ADR-MMM替代) ### 合规 - [x] <文件> —— 符合ADR-NNN ### 未关联变更 - [?] <文件> —— 无ADR覆盖(考虑创建新的ADR) -
建议行动 —— 针对每个违规情况,建议是更新代码还是提出新的ADR以取代被违反的ADR。