Communitygithub.com

addyosmani/agent-skills

準備產品上線。在準備部署到正式環境,或詢問上線前需要準備哪些事項時使用。當你需要上線前檢查清單、設定監控、規劃階段性發布,或需要復原策略時使用。

agent-skills 是什麼?

此技能提供一個全面的「出貨與上線」框架,幫助開發者和團隊安全且有信心地將功能部署至正式環境。它涵蓋從程式碼審查、安全檢查、效能優化、無障礙標準到基礎設施設定等完整的上市前檢查清單,確保每個環節都到位。此技能的核心原則包括:所有部署皆可逆、可觀察且增量進行。它支援功能旗標策略,讓部署與發布分離,並提供從團隊內部測試、少量嚐鮮到全面發布的階段性發布藍圖。此外,該技能還包含詳盡的監控與可觀測性指南、錯誤預算釋出閘門、復原策略與常見的合理化藉口,協助團隊避免常見陷阱。無論使用 Claude Code、Cursor 或其他 AI 代理,只要涉及重大變更或風險部署,此技能都是不可或缺的指南。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/addyosmani/agent-skills/tree/main/skills/shipping-and-launch

在你喜歡的 AI 中提問

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

說明文件

出貨與上線

概述

帶著信心出貨。目標不只是部署——而是要安全地部署,做好監控、準備好復原計畫,並清楚了解什麼是成功。每一次上線都應該是可逆、可觀察且漸進的。

何時使用

  • 首次將功能部署到正式環境
  • 向用戶發布重大變更
  • 遷移資料或基礎設施
  • 開啟 Beta 或早期存取計畫
  • 任何帶有風險的部署(所有部署都是)

上線前檢查清單

程式碼品質

  • 所有測試通過(單元測試、整合測試、端對端測試)
  • 建置成功且無警告
  • Lint 和型別檢查通過
  • 程式碼已審查並核准
  • 沒有應在上線前解決的 TODO 註解
  • 正式程式碼中沒有 console.log 除錯陳述
  • 錯誤處理涵蓋預期的失敗模式

安全性

  • 程式碼或版本控制中沒有機密
  • 生態系的相依性稽核(npm audit、pip-audit、cargo audit……)沒有重大或高風險漏洞
  • 所有面向用戶的端點都有輸入驗證
  • 已設置身分驗證和授權檢查
  • 已設定安全標頭(CSP、HSTS 等)
  • 身分驗證端點有速率限制
  • CORS 設定為特定來源(非萬用字元)

效能

  • 核心網頁指標在「良好」門檻內
  • 關鍵路徑中沒有 N+1 查詢
  • 圖片已最佳化(壓縮、響應式尺寸、延遲載入)
  • 套件大小在預算內
  • 資料庫查詢有適當的索引
  • 已為靜態資產和重複查詢設定快取

無障礙

  • 所有互動元素都支援鍵盤導航
  • 螢幕閱讀器能傳達頁面內容和結構
  • 色彩對比符合 WCAG 2.1 AA(文字 4.5:1)
  • 焦點管理在模態框和動態內容中正確
  • 錯誤訊息具有描述性並與表單欄位關聯
  • axe-core 或 Lighthouse 中沒有無障礙警告

基礎設施

  • 正式環境中已設定環境變數
  • 資料庫遷移已套用(或準備套用)
  • DNS 和 SSL 已設定
  • 已為靜態資產設定 CDN
  • 已設定記錄和錯誤回報
  • 健康檢查端點存在且有回應

文件

  • README 已更新任何新的設定需求
  • API 文件已更新
  • 任何架構決策已撰寫 ADR
  • 變更日誌已更新
  • 面向用戶的文件已更新(若適用)

功能旗標策略

透過功能旗標出貨,將部署與發布分離:

// 功能旗標檢查
const flags = await getFeatureFlags(userId);

if (flags.taskSharing) {
  // 新功能:任務分享
  return <TaskSharingPanel task={task} />;
}

// 預設:既有行為
return null;

功能旗標生命週期:

1. 部署時旗標關閉     → 程式碼在正式環境中但未啟用
2. 對團隊/Beta 啟用    → 在正式環境中進行內部測試
3. 逐步推送            → 5% → 25% → 50% → 100% 的用戶
4. 每個階段監控        → 觀察錯誤率、效能、用戶回饋
5. 清理                → 全面發布後移除旗標和死路徑程式碼

規則:

  • 每個功能旗標都有擁有者和到期日
  • 全面發布後 2 週內清理旗標
  • 不要巢狀功能旗標(會產生指數級組合)
  • 在 CI 中測試兩種旗標狀態(開啟和關閉)

階段性發布

發布順序

1. 部署到暫存環境
   └── 在暫存環境執行完整測試套件
   └── 手動冒煙測試關鍵流程

2. 部署到正式環境(功能旗標關閉)
   └── 驗證部署成功(健康檢查)
   └── 檢查錯誤監控(無新錯誤)

3. 對團隊啟用(對內部用戶開啟旗標)
   └── 團隊在正式環境中使用該功能
   └── 24 小時監控視窗

4. 少量發布(對 5% 用戶開啟旗標)
   └── 監控錯誤率、延遲、用戶行為
   └── 比較指標:少量發布組 vs. 基準組
   └── 24-48 小時監控視窗
   └── 僅在通過所有門檻時前進(見下方表格)

5. 逐步增加(25% -> 50% -> 100%)
   └── 每個步驟相同的監控
   └── 能夠隨時回復到前一個百分比

6. 全面發布(對所有用戶開啟旗標)
   └── 監控 1 週
   └── 清理功能旗標

發布決策門檻

使用這些門檻來決定在每個階段前進、暫緩或復原:

指標前進(綠色)暫緩調查(黃色)復原(紅色)
錯誤率在基準線的 10% 以內高於基準線 10-100%高於基準線 >2 倍
P95 延遲在基準線的 20% 以內高於基準線 20-50%高於基準線 >50%
用戶端 JS 錯誤無新錯誤類型新錯誤發生在 <0.1% 的會話新錯誤發生在 >0.1% 的會話
業務指標中性或正面下降 <5%(可能為雜訊)下降 >5%

何時復原

在以下情況立即復原:

  • 錯誤率超過基準線 2 倍
  • P95 延遲增加超過 50%
  • 用戶回報問題激增
  • 偵測到資料完整性問題
  • 發現安全漏洞

監控與可觀測性

監控項目

應用程式指標:
├── 錯誤率(總計和按端點)
├── 回應時間(p50、p95、p99)
├── 請求量
├── 活躍用戶
└── 關鍵業務指標(轉換率、參與度)

基礎設施指標:
├── CPU 和記憶體使用率
├── 資料庫連線池使用率
├── 磁碟空間
├── 網路延遲
└── 佇列深度(若適用)

用戶端指標:
├── 核心網頁指標(LCP、INP、CLS)
├── JavaScript 錯誤
├── 從用戶端視角的 API 錯誤率
└── 頁面載入時間

錯誤回報

// 設定含回報功能的錯誤邊界
class ErrorBoundary extends React.Component {
  componentDidCatch(error: Error, info: React.ErrorInfo) {
    // 回報到錯誤追蹤服務
    reportError(error, {
      componentStack: info.componentStack,
      userId: getCurrentUser()?.id,
      page: window.location.pathname,
    });
  }

  render() {
    if (this.state.hasError) {
      return <ErrorFallback onRetry={() => this.setState({ hasError: false })} />;
    }
    return this.props.children;
  }
}

// 伺服器端錯誤回報
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  reportError(err, {
    method: req.method,
    url: req.url,
    userId: req.user?.id,
  });

  // 不要向用戶暴露內部實作
  res.status(500).json({
    error: { code: 'INTERNAL_ERROR', message: 'Something went wrong' },
  });
});

上線後驗證

上線後的第一個小時內:

1. 檢查健康端點是否回傳 200
2. 檢查錯誤監控儀表板(無新錯誤類型)
3. 檢查延遲儀表板(無回歸)
4. 手動測試關鍵用戶流程
5. 驗證日誌是否正常產出且可讀
6. 確認復原機制正常運作(若可能,進行乾執行)

錯誤預算釋出閘門

你的服務的錯誤預算——SLO 允許失敗的請求或時間比例——決定了是否安全出貨。將其作為一個客觀的閘門,而不是一個可以協商的事項:

預算剩餘 > 20%  →  正常出貨;密切監控
預算剩餘 0–20%  →  僅限緩慢發布;無高風險變更
預算耗盡        →  凍結功能開發;專注於可靠性
預算重置        →  恢復正常步調;融入修復預算的修正

在少量發布期間,高消耗率(消耗預算速度快於基準線步調)是上方發布決策門檻表中的一個暫緩訊號——應與錯誤率升高同等對待。

復原策略

每次部署都需要一個在事前準備好的復原計畫:

## [功能/版本] 的復原計畫

### 觸發條件
- 錯誤率 > 基準線 2 倍
- P95 延遲 > [X]ms
- 用戶回報 [特定問題]

### 復原步驟
1. 停用功能旗標(若適用)
   或
1. 部署前一個版本:`git revert <commit> && git push`
2. 驗證復原:健康檢查、錯誤監控
3. 溝通:通知團隊復原

### 資料庫考量
- 遷移 [X] 有復原步驟:`npx prisma migrate rollback`
- 由新功能插入的資料:[保留 / 清理]

### 復原時間
- 功能旗標:< 1 分鐘
- 重新部署前一個版本:< 5 分鐘
- 資料庫復原:< 15 分鐘

其他參考

  • 如需每個變更在執行此檢查清單前必須通過的專案級「完成定義」,請參閱 ../../references/definition-of-done.md
  • 如需上線前安全檢查,請參閱 ../../references/security-checklist.md
  • 如需上線前效能檢查清單,請參閱 ../../references/performance-checklist.md
  • 如需上線前無障礙驗證,請參閱 ../../references/accessibility-checklist.md
  • 如需警示規則和 SLO 相關門檻,請參閱 observability-and-instrumentation

常見的合理化藉口

合理化藉口現實
「在暫存環境能跑,在正式環境也能跑」正式環境有不同的資料、流量模式和邊緣案例。部署後要監控。
「我們不需要功能旗標」每個功能都受益於一個緊急終止開關。即使是「簡單」的變更也可能出錯。
「監控是開銷」沒有監控意味著你從用戶抱怨中發現問題,而不是儀表板。
「我們之後再加監控」在上線前加上。你無法除錯你看不到的東西。
「復原就是承認失敗」復原是負責任的工程。出貨一個有問題的功能才是失敗。
「錯誤率看起來還好,繼續出貨吧」檢查消耗率,而不僅是當前錯誤率。消耗預算速度快於基準線,即使個別門檻是綠燈,也是一個暫緩訊號。

紅旗

  • 沒有復原計畫就部署
  • 正式環境中沒有監控或錯誤回報
  • 大爆炸式發布(一次全部,沒有暫存)
  • 沒有到期日或擁有者的功能旗標
  • 部署後第一個小時沒有人監控
  • 正式環境設定靠記憶,而非程式碼
  • 「今天星期五下午,讓我們出貨吧」
  • 錯誤預算已耗盡,但功能開發仍持續進行

驗證

部署前:

  • 上線前檢查清單已完成(所有部分皆為綠色)
  • 功能旗標已設定(若適用)
  • 復原計畫已文件化
  • 監控儀表板已設定
  • 團隊已收到部署通知

部署後:

  • 健康檢查回傳 200
  • 錯誤率正常
  • 延遲正常
  • 關鍵用戶流程正常
  • 日誌正常產出
  • 復原測試或確認準備就緒

對於每個出貨的服務:

  • 錯誤預算政策已就緒:知道當預算低於 20% 及耗盡時應採取什麼行動

Individual skills in this repo

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

addyosmani/agent-skills

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

addyosmani/agent-skills

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

addyosmani/browser-testing-with-devtools

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

addyosmani/ci-cd-and-automation

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

addyosmani/code-review-and-quality

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch.

addyosmani/code-simplification

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

addyosmani/constraint-driven-development

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

addyosmani/debugging-and-error-recovery

Guides systematic root-cause debugging. Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need a systematic approach to finding and fixing the root cause rather than guessing.

addyosmani/deprecation-and-migration

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.

addyosmani/documentation-and-adrs

Records decisions and documentation. Use when making architectural decisions, changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

addyosmani/doubt-driven-development

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production, security-sensitive logic, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

addyosmani/git-workflow-and-versioning

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.

addyosmani/idea-refine

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

addyosmani/incremental-implementation

Delivers changes incrementally. Use when implementing any feature or change that touches more than one file. Use when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

addyosmani/interview-me

Extracts what the user actually wants instead of what they think they should want. Achieves this through one-question-at-a-time interview until ~95% confidence about the underlying intent. Use when an ask is underspecified ("build me X" without "for whom" or "why now"), when the user explicitly invokes ("interview me", "grill me", "are we sure?", "stress-test my thinking"), or when you catch yourself silently filling in ambiguous requirements before any plan, spec, or code exists.

addyosmani/observability-and-instrumentation

Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

addyosmani/performance-optimization

Optimizes application performance. Use when performance requirements exist, when you suspect performance regressions, or when Core Web Vitals or load times need improvement. Use when profiling reveals bottlenecks that need fixing.

addyosmani/planning-and-task-breakdown

Breaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.

addyosmani/security-and-hardening

Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services.

addyosmani/source-driven-development

Grounds every implementation decision in official documentation. Use when you want authoritative, source-cited code free from outdated patterns. Use when building with any framework or library where correctness matters.

相關技能