Communitygithub.com

lguidolin/recording-decisions

在做出設計或架構決策時使用,用以記錄決策記錄(ADR)、更新決策索引、記錄暫緩想法或取代過去的決策。關鍵字:ADR、決策記錄、理由、被拒絕的替代方案、依賴索引。

recording-decisions 是什麼?

這個技能旨在將設計與架構決策轉化為結構化、持久且可查詢的記錄,解決團隊因記憶或聊天記錄遺失而反覆逆向工程意圖的問題。它強制使用固定格式的記錄(包含架構、資料模型、決策理由、介面、約束、陷阱與被拒絕的替代方案),並提供三項配套文件:決策索引(含依賴追蹤與取代關係)、未來考量清單(記錄暫緩想法與事件行動項目)、以及歷史歸檔(保留被取代的記錄而非刪除)。此技能支援 Claude Code、Cursor、Codex 等平台,內建兩個無依賴的 Bash 腳本(doc-archive.sh 用於找出缺少決策記錄的規格,index-rebuild.sh 用於從記錄的 YAML 前置資料自動重建索引),並將記錄縮減至約 30-50 行,大幅節省 AI 上下文成本,同時保留完整的理由與背景供人類查閱。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

記錄決策

概述

決策是持久的基礎設施;記憶與聊天記錄則不是。記錄的成本只需支付一次,而遺失決策的成本則在每次有人從程式碼逆向推斷意圖時重複支付。

記錄格式

每個非瑣碎的決策都會產生一個結構固定的記錄,讓任何閱讀者都知道去哪裡找資訊:

區段內容
架構解決方案的形狀與關鍵檔案
資料模型實體、欄位、關係
決策(附帶理由)每個選擇及其背後的理由 — 理由是強制性的
介面其他程式碼如何使用此功能
約束必須保持不變的條件
陷阱對下一個開發者而言不明顯的潛在問題
被拒絕的替代方案哪些方案被考慮過但被捨棄,以及原因 — 避免重新爭論已解決的問題

三個配套文件

  • 所有決策的索引,帶有明確的依賴追蹤(哪個決策建立在哪個之上)和被取代區段。將一堆記錄轉變為可導覽的圖表。
  • 「未來考量」文件 — 暫緩的想法與已知問題,在開始新工作時查閱,確保沒有任何事項被默默遺忘。事件行動項目與附帶觸發條件的暫緩決策放在這裡。
  • 歸檔 — 被取代的記錄移至此處而非刪除。歷史被保留,而非覆寫。

快速參考

  • 記錄放置慣例: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.

相關技能