Communitygithub.com

lguidolin/弹性与部署安全

用于规划部署、设计回滚、响应事件或撰写事后审查。关键词——部署安全、回滚、不可变制品、渐进式交付、金丝雀、爆炸半径、事件响应、无指责事后审查、错误预算。

弹性与部署安全 是什么?

该技能旨在帮助团队建立可靠的部署和事件响应实践,核心原则是“小故障、快恢复、每次学习”。它强调通过不可变制品(基于内容摘要的镜像)渐进式交付,确保每次部署可逆,并通过扩展/收缩模式协调基础设施与应用的独立回滚。对于事件处理,技能提倡无指责事后审查,将失败视为学习输入,并通过错误预算控制可靠性投资与功能开发的优先级。支持平台包括容器环境(如K8s)、静态站点以及托管平台,通过机制组合(如健康检查、金丝雀、预览环境)实现安全交付。

兼容平台~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 中构建一次并由其内容摘要标识,不变地在预览→预发布→生产环境中移动。为每个环境重建意味着部署你从未测试过的东西。
  • 标签是可变的指针;摘要是身份。 标签可以被覆盖,静默地指向新位置。内容摘要不能。每个环境记录它验证过的摘要,生产环境只运行已被较低环境验证过的摘要——因此“我们测试过的确切东西”是流水线强制执行的属性,而非需要某人记住的纪律。
  • 部署到生产前需要人为决策。 对于单个维护者,这指的是有意的暂停和审计记录,而非职责分离。请明确具体是哪种情况;不要过度宣传。
  • 运行中的版本在部署时注入,从不内嵌到镜像中。 作为构建参数内嵌的版本强制重建以标记发布,而重建恰恰是晋升要避免的。
  • 当基础设施独立存在于自己的仓库时,通过扩展/收缩协调。 基础设施先扩展(增量的、向后兼容的),应用程序在后续部署中消耗新能力,只有当没有活跃制品依赖旧结构时基础设施才收缩——这与数据库模式变更的纪律相同(参见零停机迁移)。不变条件:绝不交付需要尚未上线的基础设施变更的应用制品。 遵循此条件,每个仓库独立可逆,这使两者不同步时回滚可行。
  • 只有能回滚时才向前滚动。 回滚路径在风险变更上线前就已存在并经过测试。“我们如何撤销这个?”在计划中回答,而非在事件中。
  • 回滚即重新部署之前良好的摘要。 该摘要仍存在于注册表中且不可变,因此回滚是反向晋升——绝不重建,也绝不“按原样”重建。
  • 渐进式暴露。 新版本逐渐到达用户(健康检查门控的金丝雀部署,若支持),因此不良发布只影响一小部分,而非所有人。
  • 模式变更与代码部署解耦,遵循扩展/收缩模式(参见零停机迁移)。部署绝不能要求同时进行破坏性迁移。
  • 部署就绪检查清单门控生产: 可观测性到位、回滚已验证、迁移扩展安全、SLO 无中断。

事件响应——失败是学习的输入

  • 按严重级别分类并相应响应;有已知路径联系合适的人。
  • 对每个面向用户的事件进行无指责事后审查。 书面时间线、促成原因(系统性的,非个人的)、具体行动项。问题是“系统哪方面导致了这事”,从不问“谁搞砸了”。
  • 行动项被追踪,而非遗忘——它们流入未来考量文档(参见记录决策)并成为实际工作。
  • 错误预算主导。 当可靠性已耗尽时,可靠性工作优先级高于功能,直至预算恢复。

快速参考

风险部署前确认项
制品在 CI 中构建一次;通过摘要晋升;预发布验证的同一个
门控部署到生产前记录人为决策
回滚路径存在且已验证
暴露渐进式/金丝雀,而非一次性全部
模式扩展安全,与代码部署解耦
可观测性你能看到是否出错吗?

何时扩展此实践

本地/预启动项目现在编写这些规则,在第一批真实用户时启用。这些属性是可移植的——构建一次、晋升已验证内容、上线前决策、能够回滚——但机制并非如此:摘要晋升在容器主机上有意义,但对静态站点基本无关;托管平台可能免费提供预览环境和即时回滚。在项目交付技能中命名具体机制;此处保持属性。组合机制(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.

相关技能