Communitygithub.com

架构决策记录

在Claude Code会话期间捕获架构决策,并将其转化为结构化的ADR文档。自动检测决策时刻,记录上下文、备选方案和理由,并维护ADR日志,帮助未来开发者理解代码库的演进逻辑。

架构决策记录 是什么?

这项技能让AI助手在编码过程中自动或按需捕获架构决策,生成遵循Michael Nygard轻量级ADR格式的结构化文档,并保存在`docs/adr/`目录下。它通过显式信号(如“ADR this”)和隐式信号(如在框架间权衡)自动检测决策时刻,引导用户完成上下文收集、备选方案分析、后果评估等完整流程。所有ADR文件在写入前需用户确认,避免了未经授权的文件创建。技能还支持读取现有ADR来回答“为什么选择X”这类问题,并维护一个索引文件以便快速检索。适用于Claude Code及其他AI辅助开发环境,特别适合需要长期维护和团队协作的项目,它能确保架构决策——包括被拒绝的备选方案——被持久化记录,防止知识丢失。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/architecture-decision-records

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

架构决策记录 (Architecture Decision Records)

在编码会话中实时捕获架构决策。这些决策不再仅存于Slack线程、PR评论或某人的记忆中,而是生成结构化的ADR文档,与代码共存。

何时激活

  • 用户明确说“让我们记录这个决定”或“ADR这个”
  • 用户在重大备选方案(框架、库、模式、数据库、API设计)之间做出选择
  • 用户说“我们决定……”或“我们选择X而不是Y的原因是……”
  • 用户问“我们为什么选择了X?”(读取现有ADR)
  • 在规划阶段讨论架构权衡时

ADR 格式

使用Michael Nygard提出的轻量级ADR格式,针对AI辅助开发进行了调整:

# ADR-NNNN:[决策标题]

**日期**:YYYY-MM-DD
**状态**:proposed | accepted | deprecated | superseded by ADR-NNNN
**决策者**:[参与决策的人员]

## 上下文

我们观察到什么问题,促使了本次决策或变更?

[2-5句话描述情况、约束条件和相关因素]

## 决策

我们提议和/或正在执行什么变更?

[1-3句话清晰陈述决策]

## 考虑的备选方案

### 备选方案 1:[名称]
- **优点**:[好处]
- **缺点**:[弊端]
- **为何不选**:[拒绝此方案的特定原因]

### 备选方案 2:[名称]
- **优点**:[好处]
- **缺点**:[弊端]
- **为何不选**:[拒绝此方案的特定原因]

## 后果

由于此变更,哪些事情变得更容易或更困难?

### 正面影响
- [好处 1]
- [好处 2]

### 负面影响
- [权衡 1]
- [权衡 2]

### 风险
- [风险及缓解措施]

工作流程

捕获新 ADR

当检测到决策时机时:

  1. 初始化(仅首次) — 如果 docs/adr/ 不存在,在获得用户确认前询问用户,然后创建目录、一个包含索引表头(见下方ADR索引格式)的 README.md,以及一个用于手动使用的空白 template.md。未经明确同意,不得创建文件。
  2. 识别决策 — 提取正在做出的核心架构选择
  3. 收集上下文 — 是什么问题引发了此决策?存在哪些约束?
  4. 记录备选方案 — 考虑了哪些其他选项?为什么被拒绝?
  5. 说明后果 — 有哪些权衡?哪些事情变得更容易或更困难?
  6. 分配编号 — 扫描 docs/adr/ 中现有的ADR并递增编号
  7. 确认并写入 — 向用户展示ADR草稿以供审阅。仅在获得明确批准后才写入 docs/adr/NNNN-decision-title.md。如果用户拒绝,则丢弃草稿,不写入任何文件。
  8. 更新索引 — 追加到 docs/adr/README.md

读取现有 ADR

当用户问“我们为什么选择了X?”时:

  1. 检查 docs/adr/ 是否存在 — 如果不存在,回复:“该项目中未找到ADR。您是否要开始记录架构决策?”
  2. 如果存在,扫描 docs/adr/README.md 索引以查找相关条目
  3. 读取匹配的ADR文件,并展示上下文和决策部分
  4. 如果未找到匹配项,回复:“未找到关于该决策的ADR。您是否要现在记录一个?”

ADR 目录结构

docs/
└── adr/
    ├── README.md              ← 所有ADR的索引
    ├── 0001-use-nextjs.md
    ├── 0002-postgres-over-mongo.md
    ├── 0003-rest-over-graphql.md
    └── template.md            ← 用于手动使用的空白模板

ADR 索引格式

# 架构决策记录

| ADR | 标题 | 状态 | 日期 |
|-----|------|------|------|
| [0001](0001-use-nextjs.md) | 使用Next.js作为前端框架 | accepted | 2026-01-15 |
| [0002](0002-postgres-over-mongo.md) | 使用PostgreSQL而非MongoDB作为主数据存储 | accepted | 2026-01-20 |
| [0003](0003-rest-over-graphql.md) | 使用REST API而非GraphQL | accepted | 2026-02-01 |

决策检测信号

关注对话中表示架构决策的模式:

显式信号

  • “我们选X”
  • “我们应该用X而不是Y”
  • “这种权衡是值得的,因为……”
  • “将此记录为ADR”

隐式信号(建议记录ADR——未经用户确认不要自动创建)

  • 比较两个框架或库并得出结论
  • 在给出明确理由的情况下做出数据库模式设计选择
  • 在架构模式之间选择(单体与微服务、REST与GraphQL)
  • 决定身份验证/授权策略
  • 在评估备选方案后选择部署基础设施

好的ADR应具备的特征

应该

  • 具体 — “使用Prisma ORM”,而不是“使用ORM”
  • 记录原因 — 理由比内容更重要
  • 包含被拒绝的备选方案 — 未来开发者需要知道考虑过什么
  • 诚实说明后果 — 每个决策都有权衡
  • 保持简短 — 一份ADR应在2分钟内读完
  • 使用一般现在时 — “我们使用X”,而不是“我们将使用X”

不应

  • 记录琐碎的决策 — 变量命名或格式选择不需要ADR
  • 写成长篇大论 — 如果上下文部分超过10行,那就太长了
  • 省略备选方案 — “我们就是选了它”不是一个有效的理由
  • 不加标记就回溯填充 — 如果记录过去的决策,请注明原始日期
  • 让ADR过时 — 被取代的决策应引用其替代方案

ADR 生命周期

proposed → accepted → [deprecated | superseded by ADR-NNNN]
  • proposed:决策正在讨论中,尚未确定
  • accepted:决策已生效并正在遵循
  • deprecated:决策不再相关(例如,功能已移除)
  • superseded:较新的ADR替代了此ADR(务必链接替代者)

值得记录的决策类别

类别示例
技术选择框架、语言、数据库、云服务商
架构模式单体与微服务、事件驱动、CQRS
API 设计REST vs GraphQL、版本控制策略、认证机制
数据建模模式设计、规范化决策、缓存策略
基础设施部署模型、CI/CD流水线、监控栈
安全认证策略、加密方法、密钥管理
测试测试框架、覆盖率目标、E2E与集成测试平衡
流程分支策略、审查流程、发布节奏

与其他技能的集成

  • 规划器代理:当规划器提议架构变更时,建议创建ADR
  • 代码审查代理:标记那些引入架构变更但没有相应ADR的PR

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能