Communitygithub.com

lguidolin/ship-it

用于当用户想要发布工作时 — 推送、创建PR、归档决策记录、合并和清理。处理从提交最终更改到合并后清理的完整生命周期,包括将规格/计划转换为紧凑的决策记录。

ship-it 是什么?

该技能自动化了完整的工作发布生命周期,从暂存和提交更改到推送、创建PR、合并后归档决策记录以及清理。它执行严格的流程:首先验证测试套件通过(红色套件永远不能成为PR),确定分支状态(功能分支、分离HEAD、命名分支工作树),并确保仅通过PR合并,从不直接推送到main。PR标题用作squash-merge提交消息,成为变更日志条目。合并后,它将详细的规格/计划转换为紧凑的决策记录(~30-50行,带有YAML前言),并将原始文件移动到归档目录以降低令牌成本。它通过清除本地和远程分支以及修剪引用进行清理,智能地处理git工作树。该技能可在Claude Code、Cursor和其他AI代理平台上使用,引用`superpowers:finishing-a-development-branch`进行环境检测和测试运行,如果该技能不可用,则优雅地回退。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/ship-it

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Ship It

处理完整的发布生命周期:暂存、提交、推送、创建PR、合并后归档决策记录以及清理。

概述

每次更改都通过分支和PR进行。 永远不要直接推送到main。此技能处理完整的收尾周期,包括合并后的文档归档。

提交消息即文档。 PR标题成为main上的squash-merge提交,并出现在变更日志中。在创建PR时就要正确填写。

合并后归档,绝不提前。 在PR合并之前,规格和计划保持可访问。只有在合并后,我们才将它们转换为紧凑的决策记录。

何时使用

  • 用户说"push"、"ship it"、"let's ship"、"open a PR"、"create a PR"
  • 在PR打开后,用户说"merged"、"it's merged"、"pull and cleanup"
  • 用户已完成实现并希望收尾
  • 完成计划后,下一步是提交工作

何时不使用

  • 用户明确希望直接推送到main(首先确认这是有意的)
  • 仓库未配置远程
  • 更改是进行中的工作,用户尚未准备好推送
  • 用户只想提交而不发布(请使用conventional-commits-and-releases)

流程

阶段 0:验证和检测

红色套件永远不能成为PR。 首先运行项目的完整测试套件。如果 有任何失败,报告失败并停止 — 不要提交、推送或创建 PR。此门禁是团队策略,不可委托。

环境检测(普通仓库 vs. 命名分支工作树 vs. 分离HEAD) 以及基础分支确定委托给 superpowers:finishing-a-development-branch,它已经处理了所有三种情况。

以正确的方式检查可用性:在你自己的可用技能列表中查找finishing-a-development-branch。 如果它被列出,则可调用。如果未列出,则不可调用 — 继续执行回退。

不要通过文件系统探测它。~/.claude/plugins/cache/ 保存了所有 曾经获取过的版本,包括已安装但禁用的插件, 技能也可以通过插件缓存以外的机制提供。缓存中存在路径 并不能证明你可以调用该技能。

如果可用 — 调用它进行测试验证、环境检测和 基础分支确定,然后在其选项菜单之前停止。

集成决策已由团队规则决定,用户不能在此重新做出: 此项目仅通过PR合并,因为PR是 产生预览部署和CI门禁的方式。它的 “合并回 <base> 本地” 选项不可用。它的 “保持分支不变” 选项 仍然有效 — 这是一个推迟的决定,而不是绕过门禁。

如果缺失 — 回退,且不会丢失任何保证正确性的内容:

  • 直接运行测试套件。
  • 将分支的上游或 main 视为基础;在继续之前向用户确认。
  • 在阶段6跳过工作树清理;正常删除分支。

阶段 1:暂存和提交

git status --short
git branch --show-current
git log --oneline @{upstream}..HEAD 2>/dev/null || echo "No upstream set"

决策树:

  • 在main上且有未提交的更改 → 创建分支、提交、推送、PR
  • 在功能分支上且有未提交的更改 → 提交、推送、PR(或更新现有PR)
  • 在功能分支上且有未推送的提交 → 推送、PR(或更新现有PR)
  • 在功能分支上且有现有PR → 推送(PR已存在)

如果有未暂存的更改:

  • 询问用户是否应包含所有更改或特定文件
  • 如果更改涉及多个关注点,建议拆分

精心制作提交消息:

类型何时使用
feat新功能
fix错误修复
docs仅文档
chore配置、依赖项、工具
refactor代码重构,无行为变化
test添加或修改测试
ciCI/CD 工作流更改

格式:<type>[optional scope]: <imperative description>

规则:

  • 祈使语气("add",而不是 "added" 或 "adds")
  • 冒号后的首单词小写
  • 结尾无句号
  • 简短(主题50个字符或更少)
  • 描述提交做什么,而不是如何做

向用户展示提议的提交消息,并在提交前确认。

阶段 2:分支和推送

如果在main上,创建一个分支:

<type>/<short-description>

示例:

  • feat/oauth-login
  • fix/null-response-handling
  • docs/release-workflow-permissions

推送:

git push -u origin $(git branch --show-current)

阶段 3:创建PR

PR标题 = 常规提交消息(用于main上的squash-merge)。

PR正文结构:

## 更改内容

[添加/修改/删除的具体描述]

## 原因

[动机 — 这解决了什么问题?]

使用gh CLI创建:

gh pr create --title "<conventional commit message>" --body "<PR body>"

如果 gh 不可用,则从git push输出中提供PR URL或直接构建。

验证预览环境是否已启动。 如果项目为每个PR部署 预览,请等待该工作流并确认环境可达, 然后再交出PR:

gh pr checks --watch

如果预览部署失败,报告它并停止。没有人能审查的PR不算 发布。

此技能停止的位置。 ship-it 的部署感知到此为止,在 预览处。暂存和生产环境的提升不是它的职责 — 它们属于 项目的交付技能(cloud-delivery-aks 或其等价物)。下面的4-6阶段 是git和文档卫生,而不是部署。

阶段 4:等待合并

在PR创建后,询问:"合并后告诉我,我会处理清理和归档。"

等待用户确认(例如 "merged"、"done"、"it's merged")。

阶段 5:合并后 — 归档决策记录

规格和计划设计为详细 — 对人类阅读历史很好,但每次Claude加载时都很昂贵。将它们转换为紧凑的决策记录使关键决策读取成本低廉,而完整的叙述保留在磁盘上归档,除非有人特意打开,否则不花费任何成本。

仅在PR合并后,检查是否有未转换的规格/计划:

ls docs/superpowers/specs/ 2>/dev/null
ls docs/superpowers/decisions/ 2>/dev/null

recording-decisions 技能附带两个助手用于此目的。找到它们 — 该技能可能安装在项目中或全局:

for base in .claude/skills ~/.claude/skills; do
  d="$base/recording-decisions/scripts"
  [ -d "$d" ] && echo "$d" && break
done

如果找到,$d/doc-archive.sh 列出未转换的规格并打印转换提示,$d/index-rebuild.sh 重新生成索引。如果未找到,使用下面的步骤手动执行相同的工作 — 它们是自包含的。

如果存在未转换的规格/计划:

  1. 询问用户:"我找到了可能与此工作对应的规格/计划。是否要将它们转换为紧凑的决策记录并归档原始文件?"

  2. 如果是,对于每个规格:

    • 读取规格内容
    • 生成带有YAML前言的决策记录:
      ---
      title: <从规格中提取>
      date: <从规格文件名>
      component: <从内容推断>
      status: implemented
      supersedes: null
      dependencies: [<推断>]
      ---
      
    • 编写约30-50行,捕获:关键决策、接口、约束
    • 保存到 docs/superpowers/decisions/<date>-<topic>.md
    • 将原始规格移动到 docs/superpowers/archive/specs/
    • 将匹配的计划移动到 docs/superpowers/archive/plans/
  3. 重新构建主索引 — 从每个决策记录的前言重新生成 docs/superpowers/index.md,分组为活跃决策表(组件、标题、日期、依赖项)和已取代表(组件、标题、被取代者)。如果之前找到了 $d/index-rebuild.sh,运行它;否则直接写入文件。

  4. 提交归档:

    git add docs/superpowers/
    git commit -m "docs: archive specs and update decision index"
    git push
    

阶段 6:清理

git checkout main
git pull
git branch -d <branch-name>
git push origin --delete <branch-name> 2>/dev/null || true
git fetch --prune

验证干净状态:

git branch --show-current
git log --oneline -3

如果工作发生在git工作树中,将拆卸委托给 superpowers:finishing-a-development-branch(其基于来源的清理 — 它知道它拥有哪些工作树,并保留外部管理的工作树)。 如果该技能不可用,使用 git worktree remove <path> 手动移除工作树,并首先向用户确认。

关键原则

  • 红色套件永远不能成为PR — 先验证(阶段0)
  • 永远不要直接推送到main — 始终分支 + PR。PR就是预览 部署和CI门禁;本地合并会跳过两者。这会覆盖任何 提供在本地合并作为选项的工作流。
  • 发布在预览处结束 — 合并、归档和清理是卫生操作;提升到暂存和生产环境是单独技能的职责
  • 常规提交 — PR标题就是变更日志条目
  • 仅在合并后归档 — 规格在审查期间保持可访问
  • 决策记录紧凑 — 约30-50行,YAML索引,LLM优化
  • 完全清理 — 不留陈旧分支或跟踪引用

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/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

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.

相关技能