Communitygithub.com

lguidolin/resilience-and-deploy-safety

在規劃部署、設計回滾、應對事件或撰寫事後檢討時使用。關鍵字:部署安全、回滾、不可變工件、漸進式交付、金絲雀、爆炸半徑、事件應對、無責備事後檢討、錯誤預算。

resilience-and-deploy-safety 是什麼?

此技能提供了一份結構化指南,用於構建可靠的部署管道和事件應對流程。其核心哲學是「小規模失敗、快速恢復、每次學習」,而非試圖防止所有故障。技能詳細說明了實務做法,例如使用基於摘要的不可變工件(而非可變標籤)、透過擴張/收縮模式協調基礎架構變化,以及部署前的檢查清單(包括可觀察性、已驗證的回滾路徑、無破壞性遷移)。在事件應對方面,它提倡依嚴重性進行分類、進行無責備事後檢討(重點在於系統性原因),以及使用錯誤預算來決定何時優先處理可靠性工作。該方法論可應用於多種平台(容器化工作負載、靜態網站、託管服務),並提供一份快速參考表,以協助團隊在風險部署前確認關鍵事項。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/resilience-and-deploy-safety

在你喜歡的 AI 中提問

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

說明文件

恢復力與部署安全

概述

事情總會出錯。我們的立場不是「預防所有失敗」,而是小規模失敗、快速恢復、每次學習。可靠性並非沒有失敗,而是在失敗發生時,能夠控制爆炸半徑並縮短恢復時間。

部署安全 — 每個部署都可逆且漸進式暴露

  • 工件是不可變的,並且透過晉升而非重建。 一個映像檔,在 CI 中建構一次並由其內容摘要識別,依序在預覽 → 暫存 → 生產環境之間移動,不做任何變更。為每個環境重建等同於部署了你從未測試過的內容。
  • 標籤是可變的指標;摘要是身份。 標籤可以被覆寫,並默默地指向新的位置。內容摘要則無法。每個環境會記錄它驗證過的摘要,而生產環境只會執行經過較低環境驗證的摘要 — 因此「我們測試過的確切內容」是管道強制執行的屬性,而非需要某人記住的紀律。
  • 生產環境的部署需要經過人為決策。 對於獨立維護者而言,這是一個刻意的暫停和審計記錄,而非職責分離。請說明是哪一種情況;不要過度承諾。
  • 執行中的版本是在部署時注入的,永遠不應內建到映像檔中。 將版本作為建構參數內建會迫使為了標記版本而重建,而重建正是晉升機制所要避免的。
  • 當基礎架構存在於自己的儲存庫時,透過擴張/收縮來協調。 基礎架構先擴張(新增、向後相容),應用程式在後續部署中使用新功能,然後收縮基礎架構(僅在沒有任何線上工件依賴舊結構時才進行)— 這與資料庫綱要變更的紀律相同(參見 zero-downtime-migrations)。不變條件:絕不部署一個需要尚未上線的基礎架構變更的應用程式工件。 遵守這點,每個儲存庫都能獨立回滾,這使得在兩者不同步時回滾變得可行。
  • 僅在能夠回滾時才向前推進。 在風險變更上線之前,就需要存在並測試過回滾路徑。「我們要如何撤銷這個?」這個問題應在計劃中回答,而非在事件發生期間。
  • 回滾就是重新部署先前良好的摘要。 該摘要仍然存在於登錄檔中且不可變,因此回滾就是反向的晉升 — 永遠不需要重建,也永遠不需要「照原樣」重建。
  • 漸進式暴露。 新版本逐步到達使用者手中(健康檢查門控的金絲雀部署),因此壞版本只會影響一部分使用者,而非所有人。
  • 綱要變更與程式碼部署解耦,並遵循擴張/收縮模式(參見 zero-downtime-migrations)。部署絕不能要求同時執行破壞性遷移。
  • 部署就緒檢查清單門控生產環境: 可觀察性到位、回滾已驗證、遷移擴張安全、SLO 未中斷。

事件應對 — 失敗是學習的輸入

  • 依嚴重性分類並按比例回應;要有已知的途徑來聯繫適當的人員。
  • 每個影響使用者的事件都要進行無責備事後檢討。 記錄時間線、促成原因(系統性,而非個人)、具體行動項目。問題是「系統的哪個部分讓這件事發生」,絕非「誰搞砸了」。
  • 行動項目應被追蹤,而非遺忘 — 它們應流入未來考量文件(參見 recording-decisions)並成為實際工作。
  • 由錯誤預算來治理。 當可靠性預算已用盡時,可靠性工作的優先級高於功能,直到預算恢復。

快速參考

風險部署前確認事項
工件在 CI 中建構一次;透過摘要晉升;與暫存環境驗證過的相同
關卡在進入生產環境前記錄人為決策
回滾存在路徑並已測試
暴露漸進式/金絲雀,而非一次全部
綱要擴張安全,與程式碼部署解耦
可觀察性你能看出它是否出錯了嗎?

何時擴展此技能

本地/發佈前專案現在就遵循這些規則,在第一批真實使用者上線時啟用。這些屬性是可移植的 — 建構一次、晉升經過測試的內容、在生產前決策、能夠回滾 — 但其機制並非如此:摘要晉升在容器主機上有意義,但對靜態網站來說 largely moot,而託管平台可能免費提供預覽環境和即時回滾。請在專案的交付技能中命名該機制;在此技能中保留屬性。疊加機制(k8s 探針、金絲雀、每個 PR 的環境):cloud-delivery-aks。

完整理由:章程第十二條,捆綁在 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/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

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.

相關技能