architecture-decision-records

在Claude Code会话期间,将做出的架构决策捕获为结构化的架构决策记录(ADR)。自动检测决策时刻,记录上下文、考虑的替代方案和理由。维护一个ADR日志,以便未来的开发人员理解代码库为何以当前方式构建。

144,923 stars
Complexity: easy

About this skill

This skill empowers an AI agent to proactively detect and formalize architectural decisions made during software development workflows. It automatically records key elements of each decision, including the underlying problem context, the specific choice implemented, alternative solutions that were considered, and the detailed justification for the selected path. By generating structured Architecture Decision Records (ADRs) and maintaining them as part of the codebase, this skill transforms transient discussions into permanent, searchable documentation. This ensures transparency, aids in developer onboarding, prevents knowledge decay, and allows future teams to understand the 'why' behind critical system design choices, significantly enhancing long-term code maintainability and project health. It adheres to a lightweight ADR format, optimized for integration within AI-driven development environments.

Best use case

Documenting significant architectural choices (e.g., framework selection, database decisions, API design patterns). Onboarding new developers by providing a historical context for the codebase's evolution. Preventing knowledge loss when team members change or project details are forgotten. Justifying technical debt or specific design compromises made under constraints. Facilitating architectural reviews and ensuring consistency across a project.

在Claude Code会话期间,将做出的架构决策捕获为结构化的架构决策记录(ADR)。自动检测决策时刻,记录上下文、考虑的替代方案和理由。维护一个ADR日志,以便未来的开发人员理解代码库为何以当前方式构建。

A newly generated Markdown file adhering to the specified lightweight ADR format, capturing the architectural decision, its context, considered alternatives, and the rationale. This ADR file will be logically integrated into the project's documentation structure, often alongside the relevant code. A persistent, traceable record of architectural choices that can be referenced by current and future development teams. Enhanced project transparency and a shared understanding of critical design decisions.

Practical example

Example input

For our new user authentication service, we need to choose between OAuth2 with JWTs and traditional session-based authentication. Given we're building a highly scalable, stateless microservice architecture, let's go with OAuth2 and JWTs as it better supports distributed systems and mobile clients, even though it adds a bit more complexity initially. Please capture this decision as an ADR.

Example output

{"status": "success", "message": "Architecture Decision Record successfully generated.", "file_path": "docs/adr/ADR-0005-OAuth2-JWT-for-Auth-Service.md", "adr_title": "Choose OAuth2 with JWTs for Authentication Service", "content_preview": "# ADR-0005: Choose OAuth2 with JWTs for Authentication Service\n\n**日期**: YYYY-MM-DD\n**状态**: 已接受\n**决策者**: Claude Code Assistant\n\n## 背景\n\nOur new user authentication service is designed for a highly scalable, stateless microservice architecture, supporting various client types including mobile. We need a robust and efficient authentication mechanism that aligns with these requirements.\n\n## 决策\n\nWe have decided to implement OAuth2 with JSON Web Tokens (JWTs) for user authentication in the new service.\n\n## 考虑的备选方案\n\n### 备选方案 1: 传统 Session-Based Authentication\n- **优点**: Simpler to implement for monolithic applications, well-understood security model.\n- **缺点**: Stateful (requires session management), less suitable for distributed microservices and cross-domain access, challenging with mobile clients.\n- **为何不选**: Does not align with the stateless nature and scalability requirements of our microservice architecture. Requires shared session storage or sticky sessions, complicating horizontal scaling.\n\n### 备选方案 2: OAuth2 with JWTs\n- **优点**: Stateless by design (tokens contain all necessary info), excellent for distributed systems and microservices, robust support for various client types (web, mobile, third-party apps), improved scalability.\n- **缺点**: Initial setup can be more complex, potential for token leakage if not handled carefully, requires robust token validation and revocation strategies.\n- **为何不选**: (This option was chosen, so this section would typically be empty or describe minor downsides accepted for the overall benefits.)\n"}

When to use this skill

  • When a user explicitly requests to record a decision (e.g., "Let's log this decision," "Create an ADR for this").
  • When the user is discussing or choosing between major architectural alternatives (e.g., different frameworks, libraries, design patterns, database technologies, API styles).
  • When the user states a decision and provides its rationale (e.g., "We've decided to use X instead of Y because...").
  • When a user asks about the reasoning behind an existing architectural choice ("Why did we choose X for this?").

When not to use this skill

  • For trivial, non-architectural coding choices that don't impact system design or long-term maintainability.
  • In very early-stage prototyping where decisions are highly experimental, volatile, and not yet solidified.
  • When a decision is purely personal preference without significant architectural implications.
  • If the project intentionally avoids formal documentation processes for speed, although this may lead to future issues.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/architecture-decision-records/SKILL.md --create-dirs "https://raw.githubusercontent.com/affaan-m/everything-claude-code/main/docs/zh-CN/skills/architecture-decision-records/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/architecture-decision-records/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How architecture-decision-records Compares

Feature / Agentarchitecture-decision-recordsStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexityeasyN/A

Frequently Asked Questions

What does this skill do?

在Claude Code会话期间,将做出的架构决策捕获为结构化的架构决策记录(ADR)。自动检测决策时刻,记录上下文、考虑的替代方案和理由。维护一个ADR日志,以便未来的开发人员理解代码库为何以当前方式构建。

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as easy. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 架构决策记录

在编码会话期间捕捉架构决策。让决策不仅存在于 Slack 线程、PR 评论或某人的记忆中,此技能将生成结构化的 ADR 文档,并与代码并存。

## 何时激活

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

## ADR 格式

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

```markdown
# ADR-NNNN: [决策标题]

**日期**: YYYY-MM-DD
**状态**: 提议中 | 已接受 | 已弃用 | 被 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 索引格式

```markdown
# 架构决策记录

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

## 决策检测信号

留意对话中指示架构决策的以下模式:

**显式信号**

* "让我们选择 X"
* "我们应该使用 X 而不是 Y"
* "权衡是值得的,因为..."
* "将此记录为 ADR"

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

* 比较两个框架或库并得出结论
* 做出数据库模式设计选择并陈述理由
* 在架构模式之间选择(单体 vs 微服务,REST vs 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 取代了此决策(始终链接替代品)

## 值得记录的决策类别

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

## 与其他技能的集成

* **规划代理**:当规划者提出架构变更时,建议创建 ADR
* **代码审查代理**:标记引入架构变更但未附带相应 ADR 的 PR

Related Skills

android-clean-architecture

144923
from affaan-m/everything-claude-code

适用于Android和Kotlin多平台项目的Clean Architecture模式——模块结构、依赖规则、用例、仓库以及数据层模式。

DevelopmentClaude

workspace-surface-audit

144923
from affaan-m/everything-claude-code

Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.

DevelopmentClaude

safety-guard

144923
from affaan-m/everything-claude-code

Use this skill to prevent destructive operations when working on production systems or running agents autonomously.

DevelopmentClaude

repo-scan

144923
from affaan-m/everything-claude-code

Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.

DevelopmentClaude

project-flow-ops

144923
from affaan-m/everything-claude-code

Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.

DevelopmentClaude

manim-video

144923
from affaan-m/everything-claude-code

Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.

DevelopmentClaude

laravel-plugin-discovery

144923
from affaan-m/everything-claude-code

Discover and evaluate Laravel packages via LaraPlugins.io MCP. Use when the user wants to find plugins, check package health, or assess Laravel/PHP compatibility.

DevelopmentClaude

design-system

144923
from affaan-m/everything-claude-code

Use this skill to generate or audit design systems, check visual consistency, and review PRs that touch styling.

DevelopmentClaude

click-path-audit

144923
from affaan-m/everything-claude-code

Trace every user-facing button/touchpoint through its full state change sequence to find bugs where functions individually work but cancel each other out, produce wrong final state, or leave the UI in an inconsistent state. Use when: systematic debugging found no bugs but users report broken buttons, or after any major refactor touching shared state stores.

DevelopmentClaude

ck

144923
from affaan-m/everything-claude-code

Persistent per-project memory for Claude Code. Auto-loads project context on session start, tracks sessions with git activity, and writes to native memory. Commands run deterministic Node.js scripts — behavior is consistent across model versions.

DevelopmentClaude

canary-watch

144923
from affaan-m/everything-claude-code

Use this skill to monitor a deployed URL for regressions after deploys, merges, or dependency upgrades.

DevelopmentClaude

benchmark

144923
from affaan-m/everything-claude-code

Use this skill to measure performance baselines, detect regressions before/after PRs, and compare stack alternatives.

DevelopmentClaude