agf-writing-adr

$npx mdskill add pcliangx/AppGenesisForge/agf-writing-adr

Writes an ADR following a structured format and guidelines

  • Identifies when to write an ADR for significant architectural decisions.
  • Deploys version-audit appendix format and 'what NOT to ADR' guidance.
  • Ensures ADR follows the correct file path and status lifecycle.
  • Delivers a well-structured ADR document that replaces ad-hoc copy from ADR-000.

SKILL.md

.github/skills/agf-writing-adrView on GitHub ↗
---
name: agf-writing-adr
description: Use when tech-lead is about to record an architecture decision (new tech stack member, deviation from baseline, deployment / observability / auth scheme choice). Provides ADR structure, version-audit appendix format, and "what NOT to ADR" guidance. Replaces ad-hoc copy from ADR-000.
---

# Writing an ADR (Architecture Decision Record)

Use this skill when:

- A new technology / framework / vendor is being added to the stack (not already covered by ADR-000)
- An existing baseline is being **deviated from** (e.g. swapping Postgres → SQLite for a specific service)
- A cross-cutting decision needs explicit record (auth scheme, deployment shape, observability stack, LLM caching policy)
- code-reviewer escalates a "this needs ADR" finding

**Do NOT write an ADR for**:
- Routine library version bumps (lockfile is enough)
- Internal refactors that don't change external contract or stack
- Bug fixes
- Anything one team would forget within a month

If unsure → write it. ADR cost is low; the "why" memory is what disappears.

## File path & numbering

`docs/adr/NNN-[slug-kebab-case].md` — sequential, zero-padded 3 digits. Examples:
- `001-jwt-vs-session-auth.md`
- `002-llm-caching-policy.md`
- `003-deploy-target-fly-io.md`

ADR-000 is reserved for the system architecture baseline. Never reuse a number; if abandoned, mark `Status: Superseded by ADR-NNN`.

## Status lifecycle

`Proposed` → `Accepted` → (later) `Superseded by ADR-NNN` / `Deprecated`. Once `Accepted`, **do not edit decisions**; supersede with a new ADR.

Allowed in-place edits on Accepted ADRs:
- Backfill `## 版本与查证` rows when a deferred row resolves
- Typos and broken links

Anything else → new ADR.

## Required sections

```markdown
# ADR-NNN: [Title]

- 状态:Proposed / Accepted / Superseded by ADR-NNN / Deprecated
- 日期:YYYY-MM-DD
- 决策者:tech-lead [+ co-decider role if any]
- 影响范围:[模块/全栈/单服务]

## 上下文

为什么现在需要这个决策?1–3 段:业务驱动、技术约束、当前痛点、不做这个决策会出什么问题。

## 决策

| 维度 | 选型 | 理由 |
|---|---|---|
| ... | ... | 为什么是它,而不是 [备选] |

或者用文字描述(如果不是结构化对比)。**关键:必须列出至少一个备选方案 + 为什么否决它。**

## 备选方案

- **A. [备选 1]** — pros / cons / 否决理由
- **B. [备选 2]** — pros / cons / 否决理由

如果没列备选 = 你没真正决策,只是默认接受。回去补。

## 影响

- 对现有代码:哪些模块会变 / 不变
- 对团队:谁需要学新东西
- 对成本:每月预估增量(CNY 或 token)
- 对运维:新增监控点 / 告警 / 备份策略

## 本 ADR 不覆盖的决策

明确列出"相关但留给未来 ADR"的内容,避免读者期待落空。

## 后续工作

- [ ] 谁 / 什么时间 / 做什么(具体到角色 + 触发条件)

## 版本与查证

> tech-lead 行事原则 #3「先查最新版再决策」的回填段。新增技术或大版本升级时必填。

**查证基线日期**:YYYY-MM-DD

| 选型 | 选定版本 | 最新稳定版 | 与最新版差距 | 维护状态 | 信息来源(含原文摘录) |
|---|---|---|---|---|---|
| ... | x.y.z | a.b.c | 1 个 minor 落后 | Active | [官方 changelog URL] — "原文..." |

**回填规则**:执行层在落地时(write lockfile / pyproject.toml)回填本表对应行,commit message 加 `docs(adr): backfill ADR-NNN verification for [pkg]`。
```

## "查证 → 决策 → 写 ADR" 三步骤

ADR 不是事后总结,是决策**前**的工具:

1. **查证**:每个候选选型先用 Context7(`resolve-library-id` → `query-docs`)拉当前版本官方文档;未收录或版本信息不足再 WebFetch 官方 changelog / release notes。记录"今天最新稳定版 + 维护状态 + 已知 breaking change"
2. **决策**:在多个候选间挑选,列至少 1 个备选 + 否决理由
3. **写 ADR**:把上述过程落地,commit + announce

做完 1 + 2 但跳过 3,未来一定会被问"当时为啥选这个"——答不了就是组织记忆缺失。

## 完成前的验证

- [ ] 至少 1 个备选方案被列出并解释为何否决?
- [ ] 「影响」节包含成本估算?
- [ ] 「版本与查证」表至少 1 行(如果是新技术决策)?
- [ ] 引用的官方 URL 都能打开?
- [ ] CLAUDE.md 的 Tech Stack 表已同步更新(如果决策影响该表)?
- [ ] 已通过 `TaskCreate` 跟踪「后续工作」中的事项(如有)?

## 反模式

- ❌ 「因为大家都用」/「业界标准」 — 不是理由,写出**你具体的约束**
- ❌ 没有备选 — 表示你只是默认采纳,不是决策
- ❌ ADR 改 Accepted 状态后的「决策」段 — 必须 supersede
- ❌ 写完 ADR 不更新 CLAUDE.md Tech Stack 表 — 单一来源原则破裂
- ❌ ADR 标题用「升级 X 到 Y 版本」 — 那不是决策,是事实记录;除非升级跨大版本且有 breaking change,否则进 commit message 即可

## Hand-off

ADR 落盘后:

1. **同步 CLAUDE.md** Tech Stack 表(如果选型清单变了)
2. **同步 ADR-000** 的「本 ADR 不覆盖的决策」节(如果新 ADR 覆盖了某项)
3. SendMessage product-lead:"ADR-NNN 已 accepted, 后续工作清单 [link]"
4. 如果 ADR 引入新依赖 → SendMessage 对应执行层落地(且引用 cost-budget.md 评估增量)

More from pcliangx/AppGenesisForge

SkillDescription
agf-code-mapDeeply Understand (codemap) — 持久化代码图谱 + 变更影响分析 + 理解地图。接手遗留项目 Day-1 / PR 影响分析 / 解释陌生代码 / PRD·ADR 前现状理解时用。编排 tools/codemap/ 的 codemap CLI
agf-deploying-uatUse when deploy-engineer is about to deploy the merged-to-main code to the isolated local UAT stack (after code review + SIT Audit pass and merge, before qa-engineer runs E2E/UAT). Provides the applicability gate, pre-flight checks, isolated compose bring-up (independent project name + port offset +900), in-container migration, real-output smoke test, hand-off, and the deploy-report skeleton. Pairs with deployment.md "UAT 环境部署" contract and slash /agf-deploy-uat.
agf-design-disciplineUse when uiux-designer is about to produce a design spec (spec.md) or static HTML prototype, or frontend-dev is about to build UI from a design. Provides the anti-AI-slop design discipline layer — Brief Inference (Design Read), three aesthetic dials tuned for product UI, AI Tells blacklist with overrides, mechanically-checkable Pre-Flight. Sits above the token layer (DESIGN.md) and mechanical review (code-reviewer); does not redeclare tokens or guide non-shadcn design systems. Inspired by taste-skill, cropped for AGF product UI per ADR-013.
agf-releasing-appleUse when apple-release-engineer is about to build the signed distributable (TestFlight build / notarized DMG / internal package) from merged-to-main code (after apple code review + SIT Audit pass and merge, before apple-qa-engineer runs E2E/UAT). Provides the applicability gate, pre-flight checks, lane execution per channel, notarization, real-output smoke test, hand-off, and the release-report skeleton. Pairs with deployment.md §7 "Apple 发布" contract and slash /agf-apple-release.
agf-running-apple-sitUse when apple-dev has finished feature code + Unit tests (Swift Testing) and is about to enter code-review. Provides the Apple SIT scope (xcodebuild test + simulator per declared target), the AC-driven integration walk, APIProtocol-mock discipline, and evidence sink (progress/apple-dev.md). SIT is dev-owned; apple-code-reviewer audits the evidence.
agf-running-release-retroUse when product-lead is about to run a release retrospective after a successful MAJOR or MINOR release push (PATCH skipped). Provides applicability gate, pre-conditions, 7-step execution sequence, anti-patterns, and the verification gate before commit. Pairs with template docs/reviews/retro-_TEMPLATE.md and slash /agf-release-retro.
agf-running-sit-testsUse when an execution-layer dev (frontend-dev / backend-dev / ai-agent-dev / ml-engineer / miniapp-dev) has finished feature code + Unit tests and is about to enter code-review. Provides the SIT scope, environment, AC-driven integration walk, and evidence sink (progress/<role>.md). SIT is now a dev-owned step, not a separate QA stage.
agf-skill-stocktakeUse when PL / tech-lead audits the content quality of AGF's own skills (`.claude/skills/agf-*/SKILL.md`). Provides the 5-dimension checklist (Actionability / Scope fit / Uniqueness vs CLAUDE.md+standards / Currency of pointers / Gate-binding validity), 5-verdict rubric (Keep/Improve/Update/Retire/Merge), reason-quality bar (反敷衍), and output skeleton. Triggered each MINOR release retro or manually.
agf-wiring-apple-llmUse when wiring LLM features into the Apple client (macOS / iOS) — streaming chat via the FastAPI multi-LLM gateway, or on-device inference (Apple Foundation Models / Core ML). Provides the route decision (gateway vs on-device), streaming transport pattern, env/config contract, offline & cost guardrails, and minimum verifications before declaring the integration done.
agf-wiring-multi-llm-sdkUse when wiring up or switching between China-domestic LLM providers (DeepSeek, Doubao/Volc Ark, Qwen/DashScope, MiniMax). Provides OpenAI-compatible adapter pattern, env-var contracts, fallback strategy, cost guardrails, and minimum verifications before declaring integration done.