Closes the loop on a reviewed issue. After confirming the pull request qualifies (approved by someone else, checks passing, no conflicts) and the person confirms in writing, it archives the change specification, squash-merges, closes the issue and tidies up. It never approves anything. Use only when asked to ship a specific issue. It merges code, so it never starts on its own.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ship?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/elalfner-ship)
---
name: ship
description: Closes the loop on a reviewed issue. After confirming the pull request qualifies (approved by someone else, checks passing, no conflicts) and the person confirms in writing, it archives the change specification, squash-merges, closes the issue and tidies up. It never approves anything. Use only when asked to ship a specific issue. It merges code, so it never starts on its own.
argument-hint: "[issue-number]"
disable-model-invocation: true
---
# Relevo ship
Merge the pull request of the issue `$ARGUMENTS` and close the issue. This is the step that cannot be taken back, so it happens only after a script confirms the pull request qualifies **and** the person confirms in writing.
Scripts live in `${CLAUDE_PLUGIN_ROOT}/scripts/`. Run them with `node`. They hold the rules that must not vary (whether a pull request may be merged, what the archive may touch, scanning, labels); use them instead of judging those things yourself.
## What you must never do
- Never approve a pull request. Approval is a person's decision, made in GitHub before you run.
- Never merge, archive or push anything before the person's written confirmation.
- Never bypass branch protection, required checks or required reviews: no `--admin`, no `--auto` to sidestep a rule, no merging while `ship-check` says to stop.
- Never use `git add .` or `-A`, never force-push, and never ship a pull request you did not look up from the issue's own branch.
- Never create or release anything on the release branch. Releasing is a separate pull request.
## Files project
When `tracker` in `relevo.yml` is `files` there is no pull request, no remote and no reviewer: shipping is a local merge of the branch into the base branch, and these steps replace steps 0 to 6 below. Read and write the issue only through `node ${CLAUDE_PLUGIN_ROOT}/scripts/tracker.mjs`, never through `gh`.
- Local refs: this project has no remote, so wherever this skill, a reference it points to or a script's usage says `origin/<base>` or `origin/<branch>`, use the local `<base>` and `<branch>`, and skip every `git fetch`, `git pull` and `git push`. The scan of step 3 and every check use the local `<base>` and `<branch>`; the `ship-local.mjs` commands already do.
1. **Where you are.** `git branch --show-current` must equal `branches.base` and `git status --porcelain` must be empty. If not, say which one is wrong and stop: nothing of the person's may be mixed into the merge.
2. **What would stop it.** `node ${CLAUDE_PLUGIN_ROOT}/scripts/ship-local.mjs check --issue $ARGUMENTS`. It exits 0 when the issue was built and reviewed, the validation gate passed on the commit that would be merged, and the branch merges cleanly into the base branch. On exit 1 it prints every reason, with its command (`/relevo:review`, the gate, `/relevo:fix`): show them, change nothing and stop.
3. **Scan what will be merged.** `git diff <base>...<branch> | node ${CLAUDE_PLUGIN_ROOT}/scripts/scan-diff.mjs`. If it reports anything, stop and show the file and line.
4. **Confirm, in writing.** Show the issue, its branch, how many commits it holds and what will happen: the specification is archived on the branch, the branch is squash-merged into `<base>` as one commit, the branch and its worktree are deleted, and the issue is closed. Say that nothing is sent anywhere. Wait for a clear written yes; **without it nothing is archived or merged.**
5. **Archive the specification on the branch.** Do it where the branch is checked out: if another worktree holds it (`branch-worktree.mjs --branch <branch> --base <base> --json`) work there, otherwise check the branch out and come back to `<base>` afterwards. Run the archive exactly as step 3 below says (`archive-state.mjs`, `openspec validate`, `fix-tasks.mjs --stage after`, `openspec archive -y`, `check-archive.mjs`, `stage.mjs`, and the commit `chore(openspec): archive <change folder name> (#$ARGUMENTS)`), and **do not push**. This commit does not make the review or the gate stale.
6. **Check again, then merge.** From `<base>`: `node ${CLAUDE_PLUGIN_ROOT}/scripts/ship-local.mjs check --issue $ARGUMENTS`, and only on exit 0 `node ${CLAUDE_PLUGIN_ROOT}/scripts/ship-local.mjs merge --issue $ARGUMENTS --title "<title> (#$ARGUMENTS)"`. It makes the one squash commit, deletes the branch, removes its worktree when git allows it, and closes the issue and clears its Relevo state. It refuses and changes nothing if the base branch is not checked out or the tree is not clean; if it reports a worktree it could not remove, give its path.
7. **Report.** The issue, the merge commit, that the issue is closed, and that the work is only in this repository. Nothing else of the report of a merge below applies: there is no pull request to promote it with.
A stop at any of these steps ends its report as "Stopped without merging" below says, reading the labels as it says. When the cause is not the review (another branch checked out, a dirty tree) and the review recorded as passed still holds, because `ship-local.mjs check` asks for neither `/relevo:review` nor `/relevo:fix`, run instead `node ${CLAUDE_PLUGIN_ROOT}/scripts/next-step.mjs --conversation --state in-review --reason local --issue $ARGUMENTS`.
## Steps
### 0. Preflight
Stop with a clear message, changing nothing, if any of these fails:
- `node ${CLAUDE_PLUGIN_ROOT}/scripts/validate-config.mjs relevo.yml` exits non-zero. Show its output.
- `openspec --version` does not run. Tell the person to run `/relevo:doctor`.
- `gh auth status` fails: ship needs the GitHub command line to read and merge the pull request.
- The working tree has uncommitted changes.
Find the repository (`$GITHUB_REPOSITORY`, or `gh repo view --json nameWithOwner -q .nameWithOwner`), the person running this (`gh api user --jq .login`), the issue's branch (`git branch -r --list "origin/feature/$ARGUMENTS-*"`) and its change folder (`openspec/changes/$ARGUMENTS-*`).
### 1. Check that it qualifies
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/ship-check.mjs --repo <owner/name> --branch <branch> --invoker <login> --issue $ARGUMENTS --labels "<the issue's labels, comma separated>"
```
It prints a decision and exits 0 when the pull request may be merged, 1 when it must stop. On exit 1, show the person every reason and stop, changing nothing. The reasons say what to do: run the command that is missing (the issue must be `pr-open`: `/relevo:review` or `/relevo:fix`), open the pull request, wait for an approval on the current code, resolve requested changes, synchronise the branch, wait for the checks, or let an eligible person run ship (a member of the team who is not the author or the spec writer).
If the only reason is "GitHub has not finished checking whether the pull request can be merged", GitHub is still computing it, and the state usually settles within a minute: run the same command again about 10 seconds later, up to 6 times, before stopping. Stop on any other reason at once. If it is still the only reason after the last try, say that the state never settled and that the person can run ship again in a minute.
If the only reason is that checks are still running, wait for them instead of stopping: `gh pr checks <number> --repo <owner/name> --watch --fail-fast`, at most 20 minutes, then run the same command again. Stop at once if a check fails, or if any other reason appears besides the running checks. If they are still running after that time, stop and say which checks, and that the person can run ship again. This wait is not the confirmation of step 2: nothing is archived or merged during it.
Record the head the approval was given on, to use after the archive: `git fetch origin <branch>` then `git rev-parse origin/<branch>`. Call it `<baseline>`.
Then scan what will be merged. First ask whether another worktree holds the branch, because `git switch` refuses it with an error that names nothing: `node ${CLAUDE_PLUGIN_ROOT}/scripts/branch-worktree.mjs --branch <branch> --base <base> --json`. If it exits 1 it prints JSON with `holder` (the path of that worktree; a run of `go` that failed keeps its worktree, for example), `removable`, `reasons` and `holds`. Stop before anything is archived, pushed or merged, say that the branch is held by that worktree and its path, and then:
- when `removable` is true, say that the worktree holds nothing that is not on the remote, give `git worktree remove "<holder>"` and ask the person whether to remove it; archive, push and merge nothing until the person answers. Only on a yes run that command (never with `--force`, which would discard what git refuses to) and go on with the scan. On any other answer stop;
- otherwise name each of `reasons`, remove nothing, say that the person can ship from there or save that work first and run ship again, and stop.
If the scan reports anything, stop and show the file and line:
```bash
git fetch origin <base> <branch>
git switch <branch>
git pull --ff-only origin <branch>
git diff origin/<base>...HEAD | node ${CLAUDE_PLUGIN_ROOT}/scripts/scan-diff.mjs
```
While the change is not archived yet, check that its specification still fits the main specifications that the archive will write into. A requirement that a sibling issue already added, or one that no longer exists, makes `openspec archive` stop, and running ship again cannot fix that:
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/delta-check.mjs --change "<change folder name>" --issue $ARGUMENTS
```
If it exits 1, stop before the confirmation, changing nothing, and show what it printed: the capability, the requirement and what the delta must become (an ADDED requirement that already exists is a MODIFIED one with its full text). The way out is `/relevo:fix $ARGUMENTS`, which updates the specification first. If it exits 2, show what it printed and stop. If the change is already archived, skip this check.
### 2. Confirm, in writing
Show the person a summary from the decision: the pull request (number, title, author), who approved, the state of the checks, and what will happen next: the specification will be archived and pushed to the branch, the pull request will be squash-merged into `<base>`, the issue will be closed and the branch deleted.
If the decision's `confirm` list includes `not-approver`, the person running ship did not approve this pull request. Say so, and ask them to confirm in writing that they run it without having approved it.
If the decision's `confirm` list includes `no-ci`, say plainly that the repository has **no checks**, so nothing but the review vouches for this code, and ask about that explicitly as well.
Wait for a clear written yes. If the person does not confirm, **stop: nothing is archived, pushed or merged.**
### 3. Archive the specification
First see whether it is already archived (a previous `ship` archived and pushed it, and the merge then failed):
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/archive-state.mjs --change "<change folder name>"
```
It prints `archived` (skip the rest of this step and go to step 4), `active` (go on) or `missing` (exit 1: stop and say the change cannot be found).
Before archiving, validate the change and check that no task is open:
```bash
openspec validate "<change folder name>"
node ${CLAUDE_PLUGIN_ROOT}/scripts/fix-tasks.mjs --file openspec/changes/<change folder name>/tasks.md --stage after
```
If either fails, stop before archiving and show what it printed.
```bash
openspec archive "<change folder name>" -y
node ${CLAUDE_PLUGIN_ROOT}/scripts/check-archive.mjs
```
The check exits non-zero if the archive changed anything outside `openspec/`, or changed nothing. In that case stop and show its message. Do not commit.
Otherwise stage and commit it:
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/stage.mjs openspec/changes openspec/specs
git commit -m "chore(openspec): archive <change folder name> (#$ARGUMENTS)"
git push origin <branch>
```
Do not add links to this session or attribution lines to the commit.
### 4. Check again
The push may start new checks or dismiss an approval. Wait for any running checks (`gh pr checks <number> --repo <owner/name> --watch`), then run `ship-check.mjs` again, exactly as in step 1 and adding `--baseline <baseline>`, so an approval given on the head before the archive still counts. When the archive commit has no checks of its own and changes only `openspec/`, `ship-check` judges the checks of `<baseline>` instead, and its summary says `checksFrom: baseline`; do not ask about `no-ci` then. If it now says the pull request has conflicts, see below. If it says anything else to stop, show the reasons and stop. The most common one is an approval dismissed by the push: tell the person that the repository must not dismiss approvals on new commits (`/relevo:doctor` checks it).
**The archive left conflicts.** If the only reason is `CONFLICTING`, the base branch changed the specifications the archive wrote. Recover with normal pushes only, never a force-push:
1. `git revert --no-edit <the archive commit>`, then `git merge origin/<base>`. If the merge conflicts, `node ${CLAUDE_PLUGIN_ROOT}/scripts/conflict-scope.mjs` says whether every conflicted file is under `openspec/`. If it exits 1, run `git merge --abort`, show the files and stop: a conflict in code is for the author.
2. Archive again on top of the updated specifications (`openspec validate`, `openspec archive`, `check-archive.mjs`, stage, commit, as in step 3) and `git push origin <branch>`.
3. The head has moved by more than the archive, so do not pass `--baseline`: run `ship-check.mjs` as in step 1. If the repository does not dismiss approvals, the approval of the old code is reported as given on an older commit and a new approval is needed; say so and stop.
### 5. Merge
```bash
gh pr merge <number> --repo <owner/name> --squash --delete-branch --subject "<the pull request title>" --body "Issue #$ARGUMENTS"
```
If GitHub refuses the merge with "Base branch was modified", another pull request entered `<base>` a moment ago: run `ship-check.mjs` again, exactly as in step 4, and if it still qualifies merge it a second time. Stop on any other reason, and on a second refusal show GitHub's message and say that ship can be run again; never a third attempt. The written confirmation still covers it, because the pull request is the same one.
The subject is the pull request title, which already ends with the issue number. The body holds only the reference to the issue: no list of commits, no links, no attribution lines.
### 6. Close out
1. Close the issue explicitly if it is still open: `gh issue view $ARGUMENTS --json state,stateReason`, then `gh issue close $ARGUMENTS --reason completed`. GitHub only closes an issue by itself when the merge goes into the repository's default branch, and the base branch here usually is not.
2. Remove every Relevo label: `node ${CLAUDE_PLUGIN_ROOT}/scripts/label-change.mjs --clear --current "<current labels>"`, applied with `gh issue edit`.
3. Tidy the local copy, but only where that is possible: in the main checkout, when no other worktree holds the base branch.
```bash
[ "$(git rev-parse --git-dir)" = "$(git rev-parse --git-common-dir)" ] && ! git worktree list --porcelain | grep -qx "branch refs/heads/<base>"
```
If it succeeds, run `git switch <base>`, `git pull --ff-only origin <base>`, and `git branch -d <branch>` (ignore it if the branch is already gone). If it does not (a separate worktree, or the base branch is checked out elsewhere), run none of them, because `git branch -d` also fails on the branch the working tree is standing on: say which branch the working tree stays on. If one of the commands fails, say so as a note: the pull request is already merged, so it never changes the outcome or what the report says.
## Report
### Merged
Finish with one short block: the issue, the pull request, the merge commit, that the issue is closed and the labels removed, and which commit's checks it relied on: the merged commit, or `<baseline>` (the summary's `checksOid`) when the archive commit had none of its own, and that the checks of the merged commit were finished and passing, or that it had none of its own.
Then the step of a closed issue, from the same table the comments use, printed as it is:
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/next-step.mjs --state closed --issue $ARGUMENTS --conversation
```
Add that the promotion is from `<base>` to `<release>`, with a version tag, and that `ship` does not do it.
When the repository has the ship workflow (`.github/workflows/relevo-ship.yml`), add one line: next time, the person who ships can apply the `relevo:ship` label to the issue instead, and GitHub ships it with the same checks, without a local copy.
### Stopped without merging
Every call of this report has `--conversation`, which adds the recommendation of a new conversation when the person can run the step; never write it yourself and never post it on the issue. A stop that keeps an instruction of its own to run a command adds after it the line of `node ${CLAUDE_PLUGIN_ROOT}/scripts/next-step.mjs --note`.
This applies to every stop above, at whatever step. After the reasons, read the issue as it is now (`node ${CLAUDE_PLUGIN_ROOT}/scripts/tracker.mjs issue-get $ARGUMENTS --fields labels,state`) and end with its state and its next step:
```bash
node ${CLAUDE_PLUGIN_ROOT}/scripts/next-step.mjs --labels "<the issue's labels, comma separated>" --issue $ARGUMENTS --conversation
```
When the issue is closed, run `node ${CLAUDE_PLUGIN_ROOT}/scripts/next-step.mjs --conversation --state closed --issue $ARGUMENTS` instead. Name the state the script prints and give the step it prints: never say that the issue is on a state you did not read.