Communitygithub.com

lguidolin/recording-decisions

当做出设计或架构决策并需要记录时使用——编写决策记录或ADR、更新决策索引、记录暂缓想法或取代旧决策。关键词:ADR、决策记录、理由、被拒绝的备选方案、依赖索引。

recording-decisions 是什么?

该技能用于在做出重要设计或架构决策时生成结构化记录,避免依赖容易丢失的记忆和聊天历史。它定义了一套固定的记录格式,包含架构、数据模型、决策理由、接口、约束、陷阱和被拒绝的备选方案等关键部分,确保任何读者都能快速理解意图。同时,它配套提供了三个辅助工件:决策索引(带依赖追踪和取代记录)、未来考虑文档(记录暂缓想法和触发条件)以及存档(保留被取代的历史记录)。此外,技能自带两个无依赖的Bash脚本(doc-archive.sh和index-rebuild.sh)和一个Markdown模板,可自动生成索引并检查未记录的规格和计划,适用于Claude Code、Cursor、Codex等平台。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/recording-decisions

在你喜欢的 AI 中提问

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

文档

记录决策

概述

决策是持久的基础设施;记忆和聊天历史不是。记录的成本只需支付一次,而丢失决策的成本则是每次有人从代码中逆向推导意图时都要支付。

记录结构

每个非琐碎的决策都会生成一个具有固定结构的记录,以便任何读者都知道去哪里查看:

部分内容
架构解决方案的形态和关键文件
数据模型实体、字段、关系
决策(含WHY)每个选择及其理由——为什么是强制性的
接口其他代码如何使用它
约束必须保持成立的条件
陷阱下一个人容易忽略的非显而易见的问题
被拒绝的备选方案考虑过但被放弃的方案,以及原因——避免重新讨论已解决的问题

三个配套工件

  • 一个索引:包含所有决策,带有明确的依赖追踪(哪个构建在哪个之上)以及一个被取代部分。将一堆记录变成一个可导航的图。
  • 一个“未来考虑”文档:记录暂缓的想法和已知问题,在开始新工作时查阅,以确保不会无声无息地遗忘任何事情。事件行动项和带有触发条件的暂缓决策都放在这里。
  • 一个存档:被取代的记录移动到这里,而不是被删除。历史被保留,而不是被覆盖。

快速参考

  • 记录位置约定:docs/superpowers/decisions/YYYY-MM-DD-<主题>.md,包含YAML前置元数据(title、date、component、status、supersedes、dependencies)。
  • 未来考虑文档位于 docs/superpowers/future-considerations.md。每个条目都有一个状态(open / triggered / done / dropped),以及一个适用的触发条件,用于重新激活该条目。在开始新工作时查阅它。
  • 前置元数据用于支撑自动生成的索引——请保持其准确。
  • 理由和被拒绝的备选方案是两个价值最高的部分。没有它们的记录就是一个地雷。
  • 在管道的记录阶段(参见 designing-before-building)编写记录,即在执行之后。

捆绑工具

此技能自带其脚本和模板,因此它们可以在安装该技能的任何仓库中工作。它们位于 SKILL.md 旁边:

recording-decisions/
  scripts/doc-archive.sh      查找缺少决策记录的规格/计划
  scripts/index-rebuild.sh    根据记录前置元数据重新生成索引
  templates/decision-record.md

找到它们——该技能可以按项目或全局安装:

for base in .claude/skills ~/.claude/skills; do
  d="$base/recording-decisions/scripts"
  [ -d "$d" ] && echo "$d" && break
done

doc-archive.sh [specs_dir] [plans_dir] [decisions_dir] [archive_dir] 列出没有匹配决策记录的规格,并打印一个基于模板的转换提示。默认目录为 docs/superpowers/{specs,plans,decisions,archive}。

index-rebuild.sh [decisions_dir] [output_file] 根据每条记录的前置元数据重写 docs/superpowers/index.md——一个活动表(组件、标题、日期、依赖项)和一个被取代表(组件、标题、被…取代)。整个重新生成,因此永远不要手动编辑它。

两者都是无依赖的Bash脚本:使用该技能的项目不需要yq、jq或任务运行器。如果脚本缺失,上述过程是自包含的——直接手动完成工作。

为何这对上下文很重要

规格和计划故意写得很冗长;它们是供人类跟随推理过程而写的。每次Claude打开一个时,这种冗长都会消耗上下文。而决策记录只需大约30-50行就能保留下一步所需的内容——决策、理由、接口、约束、陷阱、被拒绝的备选方案——同时原始规格移到archive/,那里对人类保持可读性,且除非故意打开,否则不消耗上下文。

何时不要使用

琐碎的、不言自明的更改不需要记录。判断标准是:以后会有人问“为什么这样实现?”吗? 如果是,就记录它。

完整理由:宪法第二条,捆绑在 engineering-constitution/references/engineering-constitution.md 中。

Individual skills in this repo

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

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/cloud-delivery-aks

Use when deploying to Kubernetes or Azure Kubernetes Service (AKS), configuring cloud secrets, setting up progressive rollout/canary, per-PR ephemeral environments, or k8s health probes. Keywords — Kubernetes, AKS, Key Vault, Argo Rollouts, Flagger, canary, blue-green, liveness, readiness, PodDisruptionBudget, HPA, rollback, GHCR.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/conventional-commits-and-releases

Use when committing, writing a commit message, opening a PR that will be squash-merged, or configuring automated versioning/changelogs. Keywords — conventional commits, release-please, semver, feat/fix/chore, breaking change, changelog.

lguidolin/defense-in-depth-security

Use when handling untrusted input, secrets, authentication/authorization, or dependencies — or threat-modeling a new surface. Keywords — STRIDE, threat model, least privilege, secrets management, supply chain, dependency scanning, input validation, audit log, defense in depth.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/engineering-constitution

Use when starting work in a project that follows the engineering constitution, orienting to its rules, or deciding which engineering practice applies to a task — spec writing, commits, testing, security, deploys, database, or UI work.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/performance-and-scale

Use when working on hot paths, list endpoints, pagination, data-access in loops, or public interfaces/schemas. Symptoms — unbounded queries, N+1 access, no latency budget, optimizing without measuring, or changing an interface many consumers depend on. Keywords — pagination, N+1, Hyrum's Law, performance budget, bundle size.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

相关技能