adr-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ADR 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

步骤

  1. Get diff -- Run
    git diff main...HEAD --name-only
    (or the specified branch) to list changed files. Then run
    git diff main...HEAD
    to get the full diff content.
  2. Find relevant ADRs -- For each changed file:
    • Grep
      the file for ADR references (
      ADR-\d+
      )
    • Grep
      docs/adr/
      for ADRs that mention the changed file paths or modules
    • Call
      mcp__claude-flow__memory_search
      with the file path and change summary to find semantically related ADRs
  3. Load ADR content --
    Read
    each relevant ADR file. Focus on:
    • The Decision section (what was decided)
    • The Status (only enforce "accepted" ADRs)
    • The Consequences (expected constraints)
  4. 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?
  5. Query relationship graph -- Call
    mcp__claude-flow__agentdb_causal-query
    to check if any referenced ADRs have been superseded. If so, flag that the code references an outdated decision.
  6. 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)
  7. Suggest actions -- For each violation, suggest whether to update the code or propose a new ADR to supersede the violated one.
  1. 获取差异 —— 运行
    git diff main...HEAD --name-only
    (或指定分支)列出变更文件。然后运行
    git diff main...HEAD
    获取完整的差异内容。
  2. 查找相关ADR —— 针对每个变更文件:
    • 使用
      Grep
      在文件中查找ADR引用(
      ADR-\d+
    • 使用
      Grep
      docs/adr/
      目录中查找提及变更文件路径或模块的ADR
    • 调用
      mcp__claude-flow__memory_search
      ,传入文件路径和变更摘要,查找语义相关的ADR
  3. 加载ADR内容 —— 读取每个相关的ADR文件。重点关注:
    • 决策部分(已做出的决策内容)
    • 状态(仅强制执行“已接受”状态的ADR)
    • 影响(预期的约束条件)
  4. 检查违规情况 —— 针对每个变更文件及其相关ADR进行分析:
    • 代码变更是否与已接受的决策相矛盾?
    • 是否使用了ADR明确拒绝的技术/模式?
    • 是否以ADR影响部分警告过的方式修改模块?
    • 代码是否引用了已弃用或被取代的ADR?
  5. 查询关系图 —— 调用
    mcp__claude-flow__agentdb_causal-query
    检查是否有任何引用的ADR已被取代。如果是,标记代码引用了过时的决策。
  6. 生成报告 —— 将检查结果整理为合规报告:
    ## ADR合规报告
    
    ### 违规情况
    - [ ] <文件>:<行号> —— 违反ADR-NNN:<原因>
    
    ### 警告
    - [!] <文件>引用了已被取代的ADR-NNN(已被ADR-MMM替代)
    
    ### 合规
    - [x] <文件> —— 符合ADR-NNN
    
    ### 未关联变更
    - [?] <文件> —— 无ADR覆盖(考虑创建新的ADR)
  7. 建议行动 —— 针对每个违规情况,建议是更新代码还是提出新的ADR以取代被违反的ADR。