Skill v1.0.0
currentAutomated scan100/100version: "1.0.0" model: sonnet effort: medium description: Commit changes, push the branch, and open (or update) a PR with a thorough description (--split partitions the dirty tree into several focused PRs) argument-hint: "[--draft] [--no-verify] [--split] [--dry-run] [hint text]" disable-model-invocation: true allowed-tools: Bash(node "${CLAUDE_PLUGIN_ROOT}/scripts/ship-prep.mjs":), Bash(node "${CLAUDE_PLUGIN_ROOT}/scripts/ship-apply.mjs":), Bash(node "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-git-config.mjs":), Bash(git status:), Bash(git diff:), Bash(git branch:), Bash(git remote:), Bash(git log:), Bash(git rev-parse:), Bash(git checkout:), Bash(git pull:), Bash(git add:), Bash(git commit:), Bash(git push:), Bash(git stash:), Bash(git reset:), Bash(git clean:), Bash(gh pr list:), Bash(gh pr view:), Bash(gh pr create:), Bash(gh pr edit:), Bash(gh label list:), Bash(gh label create:), Bash(gh auth status:)
Ship: commit, push, and open a PR
Stage, commit, push, and open (or update) a PR whose description covers the problem, the solution, and anything else useful for a reviewer.
This project's resolved git config — the branch flow and gates every step below refers to:
!node "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-git-config.mjs"
Parse `$ARGUMENTS` first: pull out recognized flags, treat the remaining free text as a hint about what/why (used for the commit message and PR body). If no hint, infer intent from the diff and recent commits. Flags:
--draft— open the PR as a draft.--no-verify— skip the pre-flight quality gates (only when the user asks; note it in your report).--split— the working tree holds several unrelated concerns; partition it into N topic branches
→ N focused PRs. Replaces steps 2–8 with [Split mode](#split-mode---split) below (step 1's survey and step 4's gates still run, per group). The free-text hint, if any, biases the grouping.
--dry-run— only meaningful with--split: produce and show the grouping preview, then stop
without creating any branch, commit, or PR.
This command ships everyday work into the integration tier (and hotfixes into the production tier). Movement along the promotion chain is separate, dedicated commands — do not open them from here:
- integration → pre-production → `/git:promote`.
- pre-production → production (then tag) → `/git:release`.
If the user asks to "release" or "promote" while running ship, point them at those.
Respect this repo's git flow
The config block above is authoritative for the names; the rules that bind ship:
- Every tier in the chain is protected — never commit or push directly to any of them.
Everyday work branches off the integration tier and merges back into it via PR (this command's job).
- Hotfixes cut from the production tier (using the configured hotfix prefix) and PR back into
it. After a hotfix merges, the fix must be merged back down the chain so no tier loses it — remind the user of this in your report.
- Merges use the project's configured merge method; when it preserves every commit (a merge
commit), each one lands verbatim in history — write messages accordingly.
- Whether merged source branches are auto-deleted is a repo setting, not this command's business.
Steps
- Survey the change — one call. Run
node "${CLAUDE_PLUGIN_ROOT}/scripts/ship-prep.mjs" --out <scratchpad>/brief.json (add --no-gates when the user passed --no-verify; add --base <ref> only if the user overrode it). Always pass `--out` and then Read that file — the brief embeds the whole diff, so piping stdout into a parser truncates it (a class of failure that has silently wasted a full gate run). With --out, stdout is only a compact digest (ok, blockers, flow, a gates summary, existingPr) — enough to decide next steps; the file holds the full brief. It does the whole deterministic pre-flight in a single process (progress → stderr). Parse the file — do not re-run the individual git/gh probes it already did.
- Scope the gates to what you'll actually ship (
--only <p1,p2,…>, paths or dir prefixes):
by default gates key off the whole dirty tree, so unrelated dirty files can drag their layer's suites into a ship that doesn't touch them. When the free-text hint clearly narrows scope or the tree obviously spans concerns you won't all stage, pass --only with the subset so layer selection matches the PR. If you can't predict the subset until you've read the diff, do a --no-gates survey first, decide the stage set (step 5), then re-run ship-prep --only <stage-set> for correctly-scoped gates before ship-apply. The brief echoes the applied subset as gateScope (null = whole tree). Its fields drive the rest of the run:
branch,detachedHead,remoteUrl,isProtected,cleanTreeconfig— the resolved chain, roles, prefixes, labels, merge method, and any project deploy
notes / ship reminders. Write your report in these names.
flow`{ base, needsBranch, isHotfix, recommendFreshBranch, freshBranchReason,
branchAheadOfBase, readyForPrOnly } — feeds step 2 (don't re-derive the base). recommendFreshBranch is true when you're on a non-protected branch that carries its own in-flight commits but the pending changes touch **none** of that branch's files — i.e. the changes don't belong here (a stray checkout); needsBranch already folds this in. readyForPrOnly is true when the tree is clean and every commit is already pushed, but the branch is still ahead of base with no open PR — e.g. a prior ship pushed successfully and then failed or was skipped before opening the PR. This is **not** a blocker (see below); it means step 5's plan should skip stage/commit entirely and go straight to pr`.
changedFiles[]— each{ status, path, oldPath? }. `path` is always the current file
(for a rename it's the new path; oldPath carries the source), so you can copy these paths verbatim into plan.stage — including deletions and renames — without splitting -> strings or filtering vanished paths (ship-apply stages with git add -A --, which stages a removal instead of erroring). untracked[] (path + already-read content, truncated flag), diff (capped; diffTruncated ⇒ git diff HEAD -- <path> for more), diffStat, recentCommits[].
unpushedCommits[],existingPr({ url, state, number, body }ornull; already the
highest-numbered, and suppressed on protected branches so old promotion PRs don't false-match).
layers[]— one{ name, touched, forcesFullSuite }per configured gate layer: the
gate-selection inputs, already applied in step 4's run, computed over the ship scope (--only subset if you passed one, else the whole tree). gateScope echoes that subset. A project that configures no layers has an empty list — only the lint gate runs, which is correct, not a fault.
guesses{ branchType, label, slug }— starting points to confirm/override from the
diff, not authoritative (feed steps 3 & 7).
gates— see step 4.blockers[]— human-readable stop reasons (detached HEAD, no origin, **nothing to
ship, PR already MERGED). Non-empty ⇒ report them and stop. (If the user actually wanted a promotion, point them at `/git:promote` or `/git:release`.) Note: "nothing to ship" does not** fire when flow.readyForPrOnly is true — that's a real, if unusual, ship (see above), not a stop condition.
The script exits non-zero when blockers is non-empty or a gate failed, so a non-zero exit with an empty blockers means a gate failed — see step 4. In --split mode this single-PR brief doesn't apply the same way; run the script with --no-gates for the survey and follow Split mode (gates run per isolated group there).
- Determine flow, base, and whether to branch. The brief's
flowalready encodes this
(base, needsBranch, isHotfix, recommendFreshBranch) — use it rather than re-deriving. For reference, the rules it applies (first match wins):
- On a hotfix branch → base is the production tier. (To start a hotfix you must branch from
production: check it out and pull, then step 3.)
- On any protected tier → base is the integration tier;
needsBranchis true (step 3). - On a non-protected branch whose in-flight work is unrelated to the pending changes
(recommendFreshBranch) → base is the integration tier; needsBranch is true, so cut a fresh branch rather than commit onto the mismatched one. Surface flow.freshBranchReason in your report so the re-route is visible; if it looks wrong (the brief judged relatedness by file overlap only), confirm with the user before proceeding.
- Otherwise, already on a non-protected branch → base is the integration tier (or production for
a hotfix); keep the branch. If flow.readyForPrOnly is true, there's nothing to stage or commit — skip straight to step 7 for the PR content, and build step 5's plan with stage omitted.
- Name the branch (when
flow.needsBranch). Decide the<prefix><slug>here; you don't run
git — ship-apply cuts it in step 6 from `flow.base` (not the checked-out HEAD, so a stray branch's commits can't leak in — it carries only the uncommitted changes and aborts if any foreign commit comes along), and treats an existing name as a continuation. Derive a slug from the hint, else the dominant theme of the diff — the brief's guesses.slug/guesses.branchType are naive starting points (basename-derived), so prefer the hint and the actual diff: lowercase kebab-case, 2–4 words, ≤40 chars. Use the project's configured branch prefixes (in config.branchPrefixes) for the type: new functionality, bug fix, tooling/refactor/docs, or urgent production fix. If the name might already exist and it's not an obvious continuation, add a short disambiguator.
- Quality gates — already run in step 1 (unless
--no-verify, which passes--no-gates). The
pre-flight script already ran the diff-scoped gates, in order: any layer marked buildsFirst builds first and alone; then each in-scope layer's typecheck; then lint with one fixer retry; then each in-scope layer's tests — the incremental testChanged form when the layer offers one and nothing in scope forces the full suite, otherwise the full suite, and skipped with a note when a layer's requiresService probe finds the service unreachable. Layer selection is over the ship scope (--only if you passed it — step 1), so a subset ship only pays for the layers it actually touches. Each gate prints a ▸ <name>… marker to stderr as it starts, and a layer marked streamOutput streams live to stderr — so a backgrounded ship shows real-time progress instead of a silent wait. Read the brief's gates:
gates.results[]— one{ name, status: pass|fail|skipped, detail }per gate. Anyfail⇒
stop and report the detail tail; don't commit broken code unless the user says to. A skipped test layer (service unreachable) is a caveat to carry into step 8, not a blocker.
gates.lintFixRewroteFiles: true⇒ the lint fixer edited the working tree; those edits are
part of what you stage in step 5.
gates.ran: false⇒ gates were skipped (--no-gates/--no-verify, or nothing to ship) — note it.gates.cached: true⇒ results were reused from a prior run on the identical tree (same
content, HEAD, base, scope, and gate commands) within the cache TTL, not re-run — the detail is prefixed (cached …s ago). Trust them as if fresh (any content change busts the key). Pass --no-cache to force a re-run if you want to be certain.
- Only re-run a gate yourself if you need to reproduce a failure or the script couldn't (e.g. a
service came up after the fact) — run that layer's configured command.
- Project ship reminders (
config.shipReminders) apply even with--no-verify— they are
correctness checks, not gates. Echo each verbatim and confirm it before committing.
- Build the ship plan. This is the irreducible generation — the parts a script can't do. Assemble
a JSON plan (write it to a scratchpad file) that ship-apply.mjs executes deterministically in step 6. You decide, from the brief and the hint:
- `stage` — the explicit path list to commit (avoid a blind
"all"). Use the brief's
changedFiles[].path values verbatim — they're already the current paths (renames give the new path; deletions give the removed path), and ship-apply stages with git add -A --, so deletions and renames just work; no ->-splitting or existence-filtering. If the diff spans clearly unrelated concerns, stage only the set matching the hint and ask about the rest. (The script verifies something is actually staged and refuses an empty commit.) Omit `stage` entirely (and commit) when flow.readyForPrOnly is true — the commits are already pushed, so the plan is PR-only: ship-apply skips straight to the pr step and never touches the working tree.
- `branch` —
{ "create": true, "name": "<prefix><slug>" }whenflow.needsBranch(step 3),
else { "create": false } to commit on the current branch. The script cuts the branch from plan.base (override with "from" only for a deliberate stacked branch), carrying the uncommitted changes over; a name that already exists is treated as a continuation. (Exception: to start a hotfix, set "from" to the production tier — or check it out and pull first — so it bases off production, then set branch.create.)
- `commit` —
{ "subject", "body" }: concise subject + a body explaining the why. Follow-up
commits on a branch with an open PR still need a clear subject — under a merge-commit method every commit persists verbatim in history. The Co-Authored-By: trailer is appended by the script if you omit it (commit only, never the PR body).
- `pr` — see step 7 for
action/title/body/labels/draft.
- Apply the plan.
node "${CLAUDE_PLUGIN_ROOT}/scripts/ship-apply.mjs" --plan <file>(prepend
--dry-run first for a large or unusual change to preview the ordered actions). It creates the branch, stages the listed paths, commits (trailer ensured), pushes -u origin <branch>, and opens/updates the PR with assignee + labels — as one call, with guards you don't have to police: it refuses to commit/push on any protected tier, never force-pushes (a non-fast-forward push stops and reports), and creates any missing label. When stage is omitted (the readyForPrOnly plan from step 5), it skips staging/commit/push entirely and goes straight to the pr step — this is how a prior ship that pushed but failed to open the PR gets cleanly retried, without fabricating an empty commit. Read its JSON result: ok/error + done[] (how far it got — a partial run like pushed but PR failed is recoverable) and { branch, sha, pr: { action, url } }. On error, report done[] + error and stop.
- PR content (feeds `plan.pr`). Set
actionfrom the brief'sexistingPr:
- `null` →
"create"withtitle(the commit subject; most-recent subject on a multi-commit
branch), body (the template below), labels, and draft if requested.
- Open PR (
state: "OPEN") →"update"with itsnumber. The push refreshes the branch; only
include body when step 1's fetched body is now inaccurate (new files/dirs, or a materially different problem/solution). The script re-asserts assignee + labels either way.
- Closed, not merged → ask whether to reopen or create a new PR (don't guess). (A
MERGED
PR was already caught as a blocker in step 1.)
- Assignee + labels are mandatory on every PR. The script always self-assigns
@me; you must
always supply ≥1 label. `plan.pr.labels` is a JSON array of strings (["bug"], ["enhancement","documentation"]) — not a comma-joined string. Label mapping comes from config.labels, keyed by the branch type you chose in step 3. Add more if they clearly fit — in particular add documentation when the change is mostly docs (only *.md / docs/ paths). The script creates any that don't exist yet, so never drop the flag. The body follows the PR description template below (Summary / Changes / Context / Testing / Notes for reviewers), ending with:
`` 🤖 Generated with [Claude Code](https://claude.com/claude-code) ``
- If
ghis unauthenticated/missing,ship-applystill commits and pushes and returns the failure
in error (with done: [...,"pushed"]); report the push succeeded and give the manual compare URL.
- Report: the PR URL (from the apply result), whether it was created or updated, and a one-line
summary of what landed. Include caveats (skipped/failed gate, a service that was unreachable) and — for a hotfix — the reminder to merge the fix back down the chain from production to integration.
Split mode (--split)
Partition the dirty working tree into several cohesive topic branches, each its own focused PR — for the checkout that accumulated unrelated concerns. This replaces the single-PR steps 2–8; steps 1 (survey) and 4 (gates) still apply, per group.
Split operates only on uncommitted changes (staged + unstaged + untracked). If the branch also has unpushed commits, split leaves them alone — say so and ship them normally afterwards, or ask. Every group branches from the integration tier (or production for a hotfix set), so you must be able to reach it clean: on a protected tier that's automatic; if you're on a topic branch, its committed work is out of scope. Confirm the base is the intended one.
S1. Survey & group
Run step 1's survey, then partition every changed path into the fewest groups that are each independently reviewable — following the repo's own architecture seams, which the configured gate layers describe:
- Keep a logically atomic change together even across layers — a change to a shared layer and
the code consuming it belong in one group; splitting them breaks review and the build order that buildsFirst encodes. Isolated gates (S3d) will expose this if you get it wrong.
- Separate genuinely independent concerns: an unrelated bug fix, a docs-only edit, a chore/tooling
change, a distinct feature each stand alone.
- Untracked (
??) files carry no diff — read them to place them with the group they support. - If the tree is really one concern, say so and fall back to a normal single-PR ship (don't
manufacture splits).
- Each group gets: a branch type + kebab slug (step 3's rules, using the configured prefixes), its
file list, a one-line rationale, and a proposed PR title.
S2. Preview — always, and confirm before executing
Present the grouping as a table (group #, branch, files, rationale, proposed title). Explicitly flag any file that plausibly belongs to two groups and any overlap — a real split can't put one file in two PRs, so assign it to one group and note the coupling. Creating N branches + N PRs is outward-facing and awkward to undo, so stop and get a plain-text go-ahead before creating anything (not an AskUserQuestion modal). --dry-run stops here unconditionally.
S3. Execute — one clean branch per group
Cut every group's branch from a clean base tier and apply only that group's paths, so no group's changes leak into another:
- Stash the whole tree once:
git stash push -u -m git-split(includes untracked; ignored files
are untouched). The tree is now clean at the base tier, and everything is recoverable from the stash.
- For each group, in the order previewed:
a. Clean base: git checkout -f <base> && git clean -fd (safe — all changes live in the stash). b. git checkout -b <prefix><slug>. c. Bring changes back and stage only this group: git stash apply → git reset (unstage all) → git add <this group's paths> (include its untracked files). d. Commit now (step 5's message rules + Co-Authored-By trailer), then isolate the tree to exactly this group: git checkout -f HEAD && git clean -fd (discards the other groups' working-tree changes — still safe, they're in the stash). The working tree now equals this group on top of the base tier. e. Run step 4's gates against that isolated tree (any buildsFirst layer first; typechecks; lint — git add + git commit --amend --no-edit if the fixer rewrote files; scoped tests). A gate failing in isolation usually means the group depends on another and was mis-grouped: stop, report, and suggest merging it with its dependency rather than shipping a PR that can't build on its own. f. git push -u origin <branch> (step 6), then open the PR with label + assignee (step 7). Always pass `--base <base>` explicitly — a bare gh pr create targets the repo default branch, which is typically the protected production tier, silently mis-basing the PR. (ship-apply.mjs sets the base from plan.base; the raw gh pr create in this split path does not, so it's on you here.)
- After the last group, return to a clean base (
git checkout -f <base> && git clean -fd). **Drop
the stash now — every group is committed and pushed, so the branches together reconstruct the original tree and the `git-split` stash is redundant: find its entry (`git stash list`) and `git stash drop stash@{N}`. The stash is a leftover-by-design trap otherwise — retaining it "for the user to drop later" is exactly what accumulates stale `git-split` stashes. Only keep it if the split aborted** before every group shipped (a gate failed mid-way and the tree is half-partitioned) — then it's a genuine recovery net; say so, and don't drop it.
S4. Report
One line per PR (URL + what it contains), the group count, any file you had to assign to a single group despite cross-group coupling, and confirmation the git-split stash was dropped (or, on a mid-split abort, that it was retained as the recovery net). All PRs share the same base, so groups that touch overlapping files may need sequential merging — say so.
PR description template
## Summary<!-- What this PR does and the problem it solves. Closes #ISSUE if applicable. -->## Changes--## Context<!-- Decisions, trade-offs, alternatives considered. Omit for trivial PRs. -->## Testing<!-- How to verify. What's covered by automated tests, what isn't. Screenshots for UI changes. -->## Notes for reviewers<!-- Focus areas, breaking changes, migration/deploy steps, follow-up work. Omit if none. -->
Filling it in: lead with intent in the Summary (one or two sentences — what changed and why, not how). List Changes grouped logically; keep each bullet concrete (path/to/file.ts when helpful). Add Context only when the approach is non-obvious or alternatives were weighed. In Testing, name what ran (which gates, which layers) and its result; call out anything not covered. Use Notes for reviewers to flag breaking changes, migrations, or known gaps — never leave these buried in the diff.
Keep each section tight and factual — describe what actually changed, not what could change. Confirm before anything hard to reverse when the situation is ambiguous (diff unrelated to the hint, or unexpected pre-staged files).