Cursor软件写代码交付AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险Web

ADR Skill:苏格拉底访谈后再写,给代理可执行实现计划

Scan→Capture Intent→Draft→Review;含 Implementation Plan 与可勾选验收。

经验丰富流程清单步骤
给谁
用编码代理做架构决策、要 ADR 能直接落地的团队
你会得到
含影响文件/模式/验证清单的 agent-ready ADR
你需要
npx skills add skillrecordings/adr-skill · Claude Code/Cursor/Codex

硬约束

安装 skill → Phase0 扫仓库 → 一次一问确认意图摘要 → 再起草含实现计划 → checklist 评审。

他们做了什么

仓库提供一套 ADR 技能,以扫描代码、逐项访谈、确认意图、起草和清单评审,把架构决策写成 Agent 可读取的实现规格。本页依据 README、完整 SKILL.md 和评审清单整理,不是团队实测报告。

效果如何

来源没有提供实现成功率或节省时间等实测数据;本站完成了来源和双语内容核对,未执行安装或代码实现。

值得知道

确认意图和人工批准缺口是流程要求,不是软件强制安全保证。简单模板与 MADR 按需求选择;脚本路径须替换为实际安装位置。

步骤

  1. 安装技能并准备目标仓库

    运行 npx skills add skillrecordings/adr-skill。记录实际安装路径,后文 /path/to/adr-skill 需要替换成该路径。让支持该技能格式的编码 Agent 在目标仓库工作;本站没有验证各客户端兼容性。完整原始技能指令保留在下方,安装后由技能加载,不要当作已执行结果。

  2. Phase 0:先扫描仓库

    查找 docs/decisions/、adr/、docs/adr/、decisions/ 下已有 ADR,读取目录、命名、模板习惯及相关决策;读取 package.json、go.mod、requirements.txt、Cargo.toml 等实际依赖文件;查找受影响代码路径、现有模式与 ADR-NNNN 引用,把发现带入访谈。

  3. Phase 1:一次问一个问题

    依次澄清决策标题、为何现在做、技术/时间/预算等约束、可衡量成功标准、至少两个真实选项及取舍、当前倾向、审批或知会人、实现涉及的路径/模式/测试。已明确的问题可跳过;仍需猜测的部分继续追问,不一次抛出整份问卷。

  4. 确认意图摘要后再写文件

    展示标题、触发原因、约束、选项、倾向、非目标、相关 ADR/代码、受影响路径和验证方法。等待人类确认或更正;未确认不能进入起草。遇到新依赖、新架构模式或与已有决策冲突时,先提议记录 ADR,得到同意再走完整流程。

  5. Phase 2:选择位置和模板

    沿用现有 ADR 目录;没有时选 docs/decisions/ 或 adr/。已有数字前缀就延续,否则用 slug 文件名。简单明确决策选 assets/templates/adr-simple.md;多选项与结构化利弊选 adr-madr.md。按确认摘要填所有必需部分,只可删除不适用的可选部分,不留占位符。

  6. 写具体实现计划和验收项

    明确文件/目录、依赖及版本约束、参考的已有代码模式、禁止的模式、环境变量/配置/开关和迁移步骤。验证用复选框,兼顾功能与架构,并给出可测条件。ADR 点名受影响文件,代码入口处用 ADR-NNNN 与路径回链,避免每行重复注释。

  7. 生成文件并更新索引

    在目标仓库根目录运行 node /path/to/adr-skill/scripts/new_adr.js --title "Choose database" --status proposed;需要 MADR 时追加 --template madr,更新索引追加 --update-index。脚本自动识别目录与命名;可用 --dir、--strategy 覆盖,--json 输出机器可读结果。无法运行脚本则复制所选模板并手填。新仓库可用 node /path/to/adr-skill/scripts/bootstrap_adr.js --dir docs/decisions 初始化目录、索引和第一条 ADR。

  8. Phase 3:对照完整清单评审

    检查上下文是否自包含,决策是否明确且有范围,后果是否有实际任务和风险处理,实现计划是否具体,验证是否可测,MADR 是否比较至少两个选项并说明拒绝原因,状态/日期/决策者/标题/文件名是否正确。下方保留完整原文清单。汇报通过项、具体缺口与建议;补齐缺口或由人类明确接受后才定稿。

    运行提示词 · 来源原文。Phase 3 review

    # ADR Review Checklist
    
    Use this checklist in Phase 3 to validate an ADR before finalizing. The goal: **could a coding agent read this ADR and start implementing the decision immediately, without asking any clarifying questions?**
    
    ## Agent-Readiness Checks
    
    ### Context & Problem
    - [ ] A reader with no prior context can understand why this decision exists
    - [ ] The trigger is clear (what changed, broke, or is about to break)
    - [ ] No tribal knowledge is assumed — acronyms are defined, systems are named explicitly
    - [ ] Links to relevant issues, PRs, or prior ADRs are included
    
    ### Decision
    - [ ] The decision is specific enough to act on (not "use a better approach" but "use X for Y")
    - [ ] Scope is bounded — what's in AND what's out (non-goals)
    - [ ] Constraints are explicit and measurable where possible (e.g., "< 200ms p95" not "fast enough")
    
    ### Consequences
    - [ ] Each consequence is concrete and actionable, not aspirational
    - [ ] Follow-up tasks are identified (migrations, config changes, documentation, new tests)
    - [ ] Risks are stated with mitigation strategies or acceptance rationale
    - [ ] No consequence is a disguised restatement of the decision
    
    ### Implementation Plan
    - [ ] Affected files/directories are named explicitly (not "the database code" but "src/db/client.ts")
    - [ ] Dependencies to add/remove are specified with version constraints
    - [ ] Patterns to follow reference existing code (not abstract descriptions)
    - [ ] Patterns to avoid are stated (what NOT to do)
    - [ ] Configuration changes are listed (env vars, config files, feature flags)
    - [ ] If replacing something, migration steps are described
    
    ### Verification
    - [ ] Criteria are checkboxes, not prose
    - [ ] Each criterion is testable — an agent could write a test or run a command to check it
    - [ ] Criteria cover both "it works" (functional) and "it's done right" (structural/architectural)
    - [ ] No criterion is vague ("it performs well" → "p95 latency < 200ms under 100 concurrent requests")
    
    ### Options (MADR template)
    - [ ] At least two options were genuinely considered (not just "do the thing" vs "do nothing")
    - [ ] Each option has real pros AND cons (not a straw-man comparison)
    - [ ] The justification for the chosen option references specific drivers or tradeoffs
    - [ ] Rejected options explain WHY they were rejected, not just what they are
    
    ### Meta
    - [ ] Status is set correctly (usually `proposed` for new ADRs)
    - [ ] Date is set
    - [ ] Decision-makers are listed
    - [ ] Title is a verb phrase describing the decision (not the problem)
    - [ ] Filename follows repo conventions
    
    ## Quick Scoring
    
    Count the checked items. This isn't a gate — it's a conversation tool.
    
    - **All checked**: Ship it.
    - **1–3 unchecked**: Discuss the gaps with the human. Most can be fixed in a minute.
    - **4+ unchecked**: The ADR needs more work. Go back to Phase 1 for the fuzzy areas.
    
    ## Common Failure Modes
    
    | Symptom | Root Cause | Fix |
    |---------|-----------|-----|
    | "Improve performance" as a consequence | Vague intent | Ask: "improve which metric, by how much, measured how?" |
    | Only one option listed | Decision already made, ADR is post-hoc | Ask: "what did you reject and why?" — capture the reasoning |
    | Context reads like a solution pitch | Skipped problem framing | Rewrite context as the problem, move solution to Decision |
    | Consequences are all positive | Cherry-picking | Ask: "what gets harder? what's the maintenance cost?" |
    | "We decided to use X" with no why | Missing justification | Ask: "why X over Y?" — the 'over Y' forces comparison |
    | Implementation Plan says "update the code" | Too abstract | Ask: "which files, which functions, what pattern?" |
    | Verification says "it works" | Not testable | Ask: "what command would you run to prove it works?" |
    | No affected paths listed | Implementation Plan is hand-wavy | Agent should scan the codebase and propose specific paths |
    
  9. 批准后跟踪实现与生命周期

    把实现计划和后续事项转成可跟踪任务,PR 链接 ADR,代码加入引用;执行验收并在 More Information 记录结果。状态变更用 scripts/set_adr_status.js;废弃说明替代路径,取代旧 ADR 时双向链接;新增经验加日期,不改写历史,并维护索引。已有 accepted ADR 应在实现前完整阅读,发现冲突告知人类。

可复制提示词

搭建指导 · 来源原文。Installed ADR skill: SKILL.md

这一段是提示词,页面不会在这里插入广告。

---
name: adr-skill
description: Create and maintain Architecture Decision Records (ADRs) optimized for agentic coding workflows. Use when you need to propose, write, update, accept/reject, deprecate, or supersede an ADR; bootstrap an adr folder and index; consult existing ADRs before implementing changes; or enforce ADR conventions. This skill uses Socratic questioning to capture intent before drafting, and validates output against an agent-readiness checklist.
---

# ADR Skill

## Philosophy

ADRs created with this skill are **executable specifications for coding agents**. A human approves the decision; an agent implements it. The ADR must contain everything the agent needs to write correct code without asking follow-up questions.

This means:
- Constraints must be explicit and measurable, not vibes
- Decisions must be specific enough to act on ("use PostgreSQL 16 with pgvector" not "use a database")
- Consequences must map to concrete follow-up tasks
- Non-goals must be stated to prevent scope creep
- The ADR must be self-contained — no tribal knowledge assumptions
- **The ADR must include an implementation plan** — which files to touch, which patterns to follow, which tests to write, and how to verify the decision was implemented correctly

## When to Write an ADR

Write an ADR when a decision:
- **Changes how the system is built or operated** (new dependency, architecture pattern, infrastructure choice, API design)
- **Is hard to reverse** once code is written against it
- **Affects other people or agents** who will work in this codebase later
- **Has real alternatives** that were considered and rejected

Do NOT write an ADR for:
- Routine implementation choices within an established pattern
- Bug fixes or typo corrections
- Decisions already captured in an existing ADR (update it instead)
- Style preferences already covered by linters or formatters

When in doubt: if a future agent working in this codebase would benefit from knowing *why* this choice was made, write the ADR.

### Proactive ADR Triggers (For Agents)

If you are an agent coding in a repo and you encounter any of these situations, **stop and propose an ADR** before continuing:

- You are about to introduce a new dependency that doesn't already exist in the project
- You are about to create a new architectural pattern (new way of handling errors, new data access layer, new API convention) that other code will need to follow
- You are about to make a choice between two or more real alternatives and the tradeoffs are non-obvious
- You are about to change something that contradicts an existing accepted ADR
- You realize you're writing a long code comment explaining "why" — that reasoning belongs in an ADR

**How to propose**: Tell the human what decision you've hit, why it matters, and ask if they want to capture it as an ADR. If yes, run the full four-phase workflow. If no, note the decision in a code comment and move on.

## Creating an ADR: Four-Phase Workflow

Every ADR goes through four phases. Do not skip phases.

### Phase 0: Scan the Codebase

Before asking any questions, gather context from the repo:

1. **Find existing ADRs.** Check `docs/decisions/`, `adr/`, `docs/adr/`, `decisions/` for existing records. Read them. Note:
   - Existing conventions (directory, naming, template style)
   - Decisions that relate to or constrain the current one
   - Any ADRs this new decision might supersede

2. **Check the tech stack.** Read `package.json`, `go.mod`, `requirements.txt`, `Cargo.toml`, or equivalent. Note relevant dependencies and versions.

3. **Find related code patterns.** If the decision involves a specific area (e.g., "how we handle auth"), scan for existing implementations. Identify the specific files, directories, and patterns that will be affected by the decision.

4. **Check for ADR references in code.** Look for `ADR-NNNN` references in comments and docs (see "Code ↔ ADR Linking" below). This reveals which existing decisions govern which parts of the codebase.

5. **Note what you found.** Carry this context into Phase 1 — it will sharpen your questions and prevent the ADR from contradicting existing decisions.

### Phase 1: Capture Intent (Socratic)

Interview the human to understand the decision space. Ask questions **one at a time**, building on previous answers. Do not dump a list of questions.

**Core questions** (ask in roughly this order, skip what's already clear from context or Phase 0):

1. **What are you deciding?** — Get a short, specific title. Push for a verb phrase ("Choose X", "Adopt Y", "Replace Z with W").
2. **Why now?** — What broke, what's changing, or what will break if you do nothing? This is the trigger.
3. **What constraints exist?** — Tech stack, timeline, budget, team size, existing code, compliance. Be concrete. Reference what you found in Phase 0 ("I see you're already using X — does that constrain this?").
4. **What does success look like?** — Measurable outcomes. Push past "it works" to specifics (latency, throughput, DX, maintenance burden).
5. **What options have you considered?** — At least two. For each: what's the core tradeoff? If they only have one option, help them articulate why alternatives were rejected.
6. **What's your current lean?** — Capture gut intuition early. Often reveals unstated priorities.
7. **Who needs to know or approve?** — Decision-makers, consulted experts, informed stakeholders.
8. **What would an agent need to implement this?** — Which files/directories are affected? What existing patterns should it follow? What should it avoid? What tests would prove it's working? This directly feeds the Implementation Plan.

**Adaptive follow-ups**: Based on answers, probe deeper where the decision is fuzzy. Common follow-ups:
- "What's the worst-case outcome if this decision is wrong?"
- "What would make you revisit this in 6 months?"
- "Is there anything you're explicitly choosing NOT to do?"
- "What prior art or existing patterns in the codebase does this relate to?"
- "I found [existing ADR/pattern] — does this new decision interact with it?"

**When to stop**: You have enough when you can fill every section of the ADR — including the Implementation Plan — without making things up. If you're guessing at any section, ask another question.

**Intent Summary Gate**: Before moving to Phase 2, present a structured summary of what you captured and ask the human to confirm or correct it:

> **Here's what I'm capturing for the ADR:**
>
> - **Title**: {title}
> - **Trigger**: {why now}
> - **Constraints**: {list}
> - **Options**: {option 1} vs {option 2} [vs ...]
> - **Lean**: {which option and why}
> - **Non-goals**: {what's explicitly out of scope}
> - **Related ADRs/code**: {what exists that this interacts with}
> - **Affected files/areas**: {where in the codebase this lands}
> - **Verification**: {how we'll know it's implemented correctly}
>
> **Does this capture your intent? Anything to add or correct?**

Do NOT proceed to Phase 2 until the human confirms the summary.

### Phase 2: Draft the ADR

1. **Choose the ADR directory.**
   - If one exists (found in Phase 0), use it.
   - If none exists, create `docs/decisions/` (MADR default) or `adr/` (simpler repos).

2. **Choose a filename strategy.**
   - If existing ADRs use numeric prefixes (`0001-...`), continue that.
   - Otherwise use slug-only filenames (`choose-database.md`).

3. **Choose a template.**
   - Use `assets/templates/adr-simple.md` for straightforward decisions (one clear winner, minimal tradeoffs).
   - Use `assets/templates/adr-madr.md` when you need to document multiple options with structured pros/cons/drivers.
   - See `references/template-variants.md` for guidance.

4. **Fill every section from the confirmed intent summary.** Do not leave placeholder text. Every section should contain real content or be removed (optional sections only).

5. **Write the Implementation Plan.** This is the most important section for agent-first ADRs. It tells the next agent exactly what to do. See the template for structure.

6. **Write Verification criteria as checkboxes.** These must be specific enough that an agent can programmatically or manually check each one.

7. **Generate the file.**
   - Preferred: run `scripts/new_adr.js` (handles directory, naming, and optional index updates).
   - If you can't run scripts, copy a template from `assets/templates/` and fill it manually.

### Phase 3: Review Against Checklist

After drafting, review the ADR against the agent-readiness checklist in `references/review-checklist.md`.

**Present the review as a summary**, not a raw checklist dump. Format:

> **ADR Review**
>
> ✅ **Passes**: {list what's solid — e.g., "context is self-contained, implementation plan covers affected files, verification criteria are checkable"}
>
> ⚠️ **Gaps found**:
> - {specific gap 1 — e.g., "Implementation Plan doesn't mention test files — which test suite should cover this?"}
> - {specific gap 2}
>
> **Recommendation**: {Ship it / Fix the gaps first / Needs more Phase 1 work}

Only surface failures and notable strengths — do not recite every passing checkbox.

If there are gaps, propose specific fixes. Do not just flag problems — offer solutions and ask the human to approve.

Do not finalize until the ADR passes the checklist or the human explicitly accepts the gaps.

## Consulting ADRs (Read Workflow)

Agents should read existing ADRs **before implementing changes** in a codebase that has them. This is not part of the create-an-ADR workflow — it's a standalone operation any agent should do.

### When to Consult ADRs

- Before starting work on a feature that touches architecture (auth, data layer, API design, infrastructure)
- When you encounter a pattern in the code and wonder "why is it done this way?"
- Before proposing a change that might contradict an existing decision
- When a human says "check the ADRs" or "there's a decision about this"
- When you find an `ADR-NNNN` reference in a code comment

### How to Consult ADRs

1. **Find the ADR directory.** Check `docs/decisions/`, `adr/`, `docs/adr/`, `decisions/`. Also check for an index file (`README.md` or `index.md`).

2. **Scan titles and statuses.** Read the index or list filenames. Focus on `accepted` ADRs — these are active decisions.

3. **Read relevant ADRs fully.** Don't just read the title — read context, decision, consequences, non-goals, AND the Implementation Plan. The Implementation Plan tells you what patterns to follow and what files are governed by this decision.

4. **Respect the decisions.** If an accepted ADR says "use PostgreSQL," don't propose switching to MongoDB without creating a new ADR that supersedes it. If you find a conflict between what the code does and what the ADR says, flag it to the human.

5. **Follow the Implementation Plan.** When implementing code in an area governed by an ADR, follow the patterns specified in its Implementation Plan. If the plan says "all new queries go through the data-access layer in `src/db/`," do that.

6. **Reference ADRs in your work.** Add `ADR-NNNN` references in code comments and PR descriptions (see "Code ↔ ADR Linking" below).

## Code ↔ ADR Linking

ADRs should be bidirectionally linked to the code they govern.

### ADR → Code (in the Implementation Plan)

The Implementation Plan section names specific files, directories, and patterns:

```markdown
## Implementation Plan
- **Affected paths**: `src/db/`, `src/config/database.ts`, `tests/integration/`
- **Pattern**: all database queries go through `src/db/client.ts`
```

### Code → ADR (in comments)

When implementing code guided by an ADR, add a comment referencing it:

```typescript
// ADR-0004: Using better-sqlite3 for test database
// See: docs/decisions/0004-use-sqlite-for-test-database.md
import Database from 'better-sqlite3';
```

Keep these lightweight — one comment at the entry point, not on every line. The goal is discoverability: when a future agent reads this code, they can find the reasoning.

### Why This Matters

- An agent working in `src/db/` can find which ADRs govern that area
- An agent reading an ADR can find the code that implements it
- When an ADR is superseded, the code references make it easy to find everything that needs updating

## Other Operations

### Update an Existing ADR

1. Identify the intent:
   - **Accept / reject**: change status, add any final context.
   - **Deprecate**: status → `deprecated`, explain replacement path.
   - **Supersede**: create a new ADR, link both ways (old → new, new → old).
   - **Add learnings**: append to `## More Information` with a date stamp. Do not rewrite history.

2. Use `scripts/set_adr_status.js` for status changes (supports YAML front matter, bullet status, and section status).

### Post-Acceptance Lifecycle

After an ADR is accepted:

1. **Create implementation tasks.** Each item in the Implementation Plan and each follow-up in Consequences should become a trackable task (issue, ticket, or TODO).
2. **Reference the ADR in PRs.** Link to the ADR in PR descriptions: "Implements ADR-0004."
3. **Add code references.** Add `ADR-NNNN` comments at key implementation points.
4. **Check verification criteria.** Once implementation is complete, walk through the Verification checkboxes. Update the ADR with results in `## More Information`.
5. **Revisit when triggers fire.** If the ADR specified revisit conditions ("if X happens, reconsider"), monitor for those conditions.

### Index

If the repo has an ADR index/log file (often `README.md` or `index.md` in the ADR dir), keep it updated.

Preferred: let `scripts/new_adr.js --update-index` do it. Otherwise:
- Add a bullet entry for the new ADR.
- Keep ordering consistent (numeric if numbered; date or alpha if slugs).

### Bootstrap

When introducing ADRs to a repo that has none:

```bash
node /path/to/adr-skill/scripts/bootstrap_adr.js
```

This creates the directory, an index file, and a filled-out first ADR ("Adopt architecture decision records") with real content explaining why the team is using ADRs. Use `--json` for machine-readable output. Use `--dir` to override the directory name.

### Categories (Large Projects)

For repos with many ADRs, organize by subdirectory:

```
docs/decisions/
  backend/
    0001-use-postgres.md
  frontend/
    0001-use-react.md
  infrastructure/
    0001-use-terraform.md
```

Numbers are local to each category. Choose a categorization scheme early (by layer, by domain, by team) and document it in the index.

## Resources

### scripts/
- `scripts/new_adr.js` — create a new ADR file from a template, using repo conventions.
- `scripts/set_adr_status.js` — update an ADR status in-place (YAML front matter or inline). Use `--json` for machine output.
- `scripts/bootstrap_adr.js` — create ADR dir, `README.md`, and initial "Adopt ADRs" decision.

### references/
- `references/review-checklist.md` — agent-readiness checklist for Phase 3 review.
- `references/adr-conventions.md` — directory, filename, status, and lifecycle conventions.
- `references/template-variants.md` — when to use simple vs MADR-style templates.
- `references/examples.md` — filled-out short and long ADR examples with implementation plans.

### assets/
- `assets/templates/adr-simple.md` — lean template for straightforward decisions.
- `assets/templates/adr-madr.md` — MADR 4.0 template for decisions with multiple options and structured tradeoffs.
- `assets/templates/adr-readme.md` — default ADR index scaffold used by `scripts/bootstrap_adr.js`.

### Script Usage

From the target repo root:

```bash
# Simple ADR
node /path/to/adr-skill/scripts/new_adr.js --title "Choose database" --status proposed

# MADR-style with options
node /path/to/adr-skill/scripts/new_adr.js --title "Choose database" --template madr --status proposed

# With index update
node /path/to/adr-skill/scripts/new_adr.js --title "Choose database" --status proposed --update-index

# Bootstrap a new repo
node /path/to/adr-skill/scripts/bootstrap_adr.js --dir docs/decisions
```

Notes:
- Scripts auto-detect ADR directory and filename strategy.
- Use `--dir` and `--strategy` to override.
- Use `--json` to emit machine-readable output.

以下为完整原始技能文件,不是本站改写的启动词;安装后由 Agent 加载。

来源

ADR Skill — Architecture Decision Records as executable specs · skillrecordings · Web · 2026-10-01

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例