Community程式設計與開發github.com

alfathafp/portofolio-web-design

準備生產環境上線。用於準備部署到生產環境,或詢問在發佈前需要做好哪些準備。也用於需要上線前檢查清單、設定監控、規劃分階段上線或需要回滾策略時。

portofolio-web-design 是什麼?

此技能提供一個全面的生產環境上線框架,幫助開發者和團隊安全且有信心地部署功能。它不僅止於部署,更強調可觀察性、回滾計劃和漸進式上線策略。技能涵蓋從程式碼品質、安全性、效能、無障礙性到基礎設施和文件等完整的預上線檢查清單,並詳細說明功能旗標策略、分階段上線流程(從內部測試到金絲雀發佈再到全面開放)以及回滾決策門檻。此外,還包括監控與可觀測性設定、錯誤預算釋出閘道和常見的合理化藉口與危險信號提醒,幫助團隊避免常見的部署陷阱。此技能適用於任何有風險的部署情境,特別是需要第一次上線生產環境、釋出重大變更或進行資料遷移的專案。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/shipping-and-launch

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

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

說明文件

上線與發佈

概述

帶著信心上線。目標不僅是部署——而是安全地部署,並同時設置監控、準備好回滾計畫,且清楚了解成功長什麼樣子。每個上線都應是可逆的、可觀察的,並且是漸進的。

使用時機

  • 首次將功能部署到生產環境
  • 向用戶釋出重大變更
  • 遷移資料或基礎設施
  • 開放 Beta 版或早期體驗計畫
  • 任何有風險的部署(所有部署都有風險)

上線前檢查清單

程式碼品質

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

安全性

  • 程式碼或版本控制中無機密資訊
  • 生態系相依性稽核(npm audit、pip-audit、cargo audit、...)顯示無關鍵或高風險漏洞
  • 所有面向使用者的端點皆有輸入驗證
  • 已設定身分驗證和授權檢查
  • 已設定安全標頭(CSP、HSTS 等)
  • 對身分驗證端點設有速率限制
  • CORS 設定為特定來源(非萬用字元)

效能

  • Core Web Vitals 在「良好」門檻內
  • 關鍵路徑無 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. 清理               → 全面上線後移除旗標和死路徑

規則:

  • 每個功能旗標都有負責人和到期日
  • 全面上線後兩週內清理旗標
  • 不要嵌套功能旗標(會產生指數級組合)
  • 在 CI 中測試兩種旗標狀態(開啟和關閉)

分階段上線

上線順序

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

2. 部署到生產環境(功能旗標關閉)
   └── 確認部署成功(健康檢查)
   └── 檢查錯誤監控(無新錯誤)

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

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

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

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

上線決策門檻

使用這些門檻來決定在每個階段是否前進、暫停或回滾:

指標前進(綠色)暫停調查(黃色)回滾(紅色)
錯誤率在基準線的 10% 以內高於基準線 10-100%高於基準線 2 倍以上
P95 延遲在基準線的 20% 以內高於基準線 20-50%高於基準線 50% 以上
用戶端 JS 錯誤無新的錯誤類型新錯誤發生在 <0.1% 工作階段新錯誤發生在 >0.1% 工作階段
商業指標中性或正向下降 <5%(可能為雜訊)下降 >5%

何時回滾

在以下情況下立即回滾:

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

監控與可觀測性

要監控的項目

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

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

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

錯誤回報

// 設定帶有回報功能的錯誤邊界
class ErrorBoundary extends React.Component {
  state = { hasError: false };

  static getDerivedStateFromError() {
    return { hasError: true };
  }

  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] 有回滾:[已驗證的命令或執行手冊連結]
- 新功能插入的資料:[保留 / 清理]

### 回滾時間
- 功能旗標:< 1 分鐘
- 重新部署先前版本:< 5 分鐘
- 資料庫回滾:< 15 分鐘

另請參閱

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

常見合理化藉口

合理化藉口現實
「在 staging 能運作,在生產環境就能運作」生產環境有不同的資料、流量模式和邊界情況。部署後仍需監控。
「這個功能不需要功能旗標」每個功能都能從中斷開關中受益。即使是「簡單」的變更也可能出錯。
「監控是多餘的開銷」沒有監控意味著你從用戶抱怨中發現問題,而非從儀表板。
「我們之後再加監控」在上線前就加上。你無法除錯你看不見的東西。
「回滾等於承認失敗」回滾是負責任的工程。釋出有問題的功能才是失敗。
「錯誤率看起來正常,繼續釋出吧」檢查消耗速率,而不僅僅是當前的錯誤率。消耗預算速度快於基準線是暫停訊號,即使各個門檻仍是綠色。

危險信號

  • 沒有回滾計畫的部署
  • 生產環境中沒有監控或錯誤回報
  • 大爆炸式釋出(一次全部,無 staging)
  • 沒有到期日或負責人的功能旗標
  • 部署後第一小時無人監控
  • 生產環境設定靠記憶而非程式碼
  • 「今天是星期五下午,我們釋出吧」
  • 錯誤預算已耗盡但功能開發仍未改變

驗證

部署前:

  • 上線前檢查清單已完成(所有部分皆為綠色)
  • 功能旗標已設定(如適用)
  • 回滾計畫已記錄
  • 監控儀表板已設定
  • 團隊已收到部署通知

部署後:

  • 健康檢查回傳 200
  • 錯誤率正常
  • 延遲正常
  • 關鍵用戶流程可運作
  • 日誌正在流動
  • 回滾已測試或確認準備就緒

對於每個已出貨的服務:

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

Individual skills in this repo

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

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

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.

alfathafp/portofolio-web-design

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.

alfathafp/portofolio-web-design

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. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

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.

alfathafp/portofolio-web-design

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.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

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.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

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".

alfathafp/portofolio-web-design

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.

相關技能