Community编程与开发github.com

alfathafp/portofolio-web-design

准备生产发布。用于准备部署到生产环境,或询问上线前需要完成哪些事项。用于需要上线前检查清单、设置监控、规划分阶段发布或制定回滚策略时。

portofolio-web-design 是什么?

该技能提供了一个全面的生产发布准备框架,旨在帮助开发者和AI Agent安全、可靠地部署功能。它涵盖了从代码质量、安全性、性能到可访问性、基础设施和文档的完整上线前检查清单,确保没有遗漏。技能的核心是倡导通过功能标志(feature flags)实现部署与发布解耦,并详细描述了分阶段发布(staged rollout)的流程,包括内部测试、金丝雀发布和逐步扩大范围,以及每个阶段的决策阈值。此外,它还包含监控与可观测性指导(如错误报告、核心网页指标)、基于错误预算(error budget)的发布门控机制,以及标准化的回滚策略模板。该技能适用于Claude Code、Cursor等AI Agent平台,强调任何上线操作都应是可逆、可观察且增量式的。

兼容平台~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
  • Changelog已更新
  • 面向用户的文档已更新(如适用)

功能标志策略

在功能标志后面发布,以将部署与发布解耦:

// 功能标志检查
const flags = await getFeatureFlags(userId);

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

// 默认:现有行为
return null;

功能标志生命周期:

1. DEPLOY with flag OFF     → 代码已在生产环境但未激活
2. ENABLE for team/beta     → 在生产环境中进行内部测试
3. GRADUAL ROLLOUT          → 5% → 25% → 50% → 100%的用户
4. MONITOR at each stage    → 关注错误率、性能、用户反馈
5. CLEAN UP                 → 完全发布后移除标志和死代码路径

规则:

  • 每个功能标志都有负责人和过期日期
  • 完全发布后2周内清理标志
  • 不要嵌套功能标志(会导致指数级组合)
  • 在CI中测试标志的两种状态(开启和关闭)

分阶段发布

发布序列

1. DEPLOY to staging
   └── 在预发环境中运行完整测试套件
   └── 对关键流程进行手动冒烟测试

2. DEPLOY to production (feature flag OFF)
   └── 验证部署成功(健康检查)
   └── 检查错误监控(无新错误)

3. ENABLE for team (flag ON for internal users)
   └── 团队在生产环境中使用新功能
   └── 24小时监控窗口

4. CANARY rollout (flag ON for 5% of users)
   └── 监控错误率、延迟、用户行为
   └── 对比指标:金丝雀 vs. 基线
   └── 24-48小时监控窗口
   └── 仅当所有阈值通过时前进(见下表)

5. GRADUAL increase (25% -> 50% -> 100%)
   └── 每个步骤相同的监控
   └── 能够随时回退到之前的百分比

6. FULL rollout (flag ON for all users)
   └── 监控1周
   └── 清理功能标志

发布决策阈值

使用这些阈值来决定在每个阶段是前进、暂停还是回滚:

指标前进(绿色)暂停并调查(黄色)回滚(红色)
错误率在基线±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]有回滚方案:<已验证的命令或Runbook链接>
- 新功能插入的数据:[保留 / 清理]

### 回滚耗时
- 功能标志:< 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.

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.

相关技能