src/claude/skills/pr-captain-land/SKILL.md
--- name: pr-captain-land description: Captain-only. Land an agent's prepared branch — switch, verify receipt, bump agency_version, create PR, watch CI, merge, release, notify agent. The single-writer serialization point for agency_version and PR creation. Companion to /pr-submit (the-agency#296 Phase 1 pilot). The `captain-` qualifier in the name signals scope at a glance (complements `paths: []` scoping and the Step-1 runtime precondition). agency-skill-version: 2 when_to_use: Captain on maste
npx skillsauth add the-agency-ai/the-agency src/claude/skills/pr-captain-landInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Captain-side skill that lands an agent's prepared branch as a merged PR + GitHub release + fleet notification. Companion to /pr-submit. This is the single-writer serialization point for agency_version and PR creation — eliminates the version-bump and receipt-hash races the pre-v2 distributed model created.
Name pattern: pr- prefix groups with the PR skill family (so /pr<tab> autocomplete shows the full kit). captain- qualifier flags captain-only scope in the skill listing without requiring the reader to open SKILL.md.
Per the-agency#296 — one captain, one writer, one serialization point. Every PR, every version bump, every release goes through this skill when driven by an agent's /pr-submit.
Pre-v2 (distributed PR ownership) failure modes this skill eliminates:
/pr-prep + /pr-create concurrently → both bump agency_version → one loses, the other's release tag is wrong./pr-prep and that agent's /pr-create → the receipt's diff-hash no longer matches → pr-create blocks with a confusing error.Captain-owned: captain is serialized by definition (one captain), captain re-verifies the receipt at the moment of landing, captain authors a fleet-aware PR body that references agent + scope + receipt.
Before running, Read the files listed in required_reading: frontmatter.
REFERENCE-CODE-REVIEW-LIFECYCLE.md — end-to-end PR flowREFERENCE-RECEIPT-INFRASTRUCTURE.md — five-hash chain, receipt re-verification semanticsREFERENCE-GIT-MERGE-NOT-REBASE.md — merge discipline (pr-captain-merge enforces)REFERENCE-SAFE-TOOLS.md — the safe-tool family this skill composesThis skill's reference.md is the step-by-step land protocol with failure-mode recovery.
/pr-captain-land <agent-branch>
/pr-captain-land <agent-branch> --dry-run
/pr-captain-land <agent-branch> --title "Custom PR title"
/pr-captain-land <agent-branch> --no-release
<agent-branch>: required. The branch that /pr-submit identified.--dry-run: walk the preflight + preview the PR body; no mutation.--title: override the default PR title (which derives from the agent's scope).--no-release: skip Step 8 (release creation). Used when landing a PR that explicitly shouldn't cut a release (rare).The script enforces all of these before any mutation; any failure exits non-zero with a clear error and no state change:
git worktree list). Not in a .claude/worktrees/ path.master or main.git status --porcelain empty)../agency/tools/post-merge-state check exits 0. If exit 1, a prior landed PR has not had its release cut — run /pr-captain-post-merge <pending-PR> first, then re-invoke.<agent-branch> exists on origin (git ls-remote --heads origin <agent-branch> non-empty).<agent-branch> passes safe-name validation: regex ^[a-zA-Z0-9][a-zA-Z0-9/_.-]*$, no .., no leading -.<agent-branch> vs origin/master matches a QGR receipt at agency/workstreams/**/qgr/*qgr-pr-prep-*-{hash}.md.Any failure → zero mutation, clean error message, exit 1.
The script at scripts/pr-captain-land walks these nine steps. Full failure-mode detail is in reference.md.
Verify all six preconditions. If any fail, exit 1.
./agency/tools/git-captain switch-branch <agent-branch>
Main checkout is now on agent's branch.
./agency/tools/diff-hash --base origin/master --json
Find receipt at agency/workstreams/**/qgr/*qgr-pr-prep-*-{hash}.md. If missing, agent's state drifted — switch back to master, exit 1, tell agent to re-run /pr-prep + /pr-submit.
agency_versionRead agency/config/manifest.json. Bump minor (e.g., 1.8 → 1.9). Refresh updated_at to current UTC timestamp.
Security note: version-bump is done via Python env-var substitution (MANIFEST=... NEW_VER=... python3 -c '...os.environ[...]...'), not f-string interpolation. This blocks code-injection via adversarial branch names. (Fix landed in ccf054ad per MAR finding F-SEC-1 / CRITICAL-3.)
Commit via git-safe-commit:
chore(manifest): bump agency_version {old} → {new} for PR landing (captain)
Push to origin.
./agency/tools/pr-create --title "<title>" --body "<captain-authored fleet-aware body>"
Title derives from agent's --scope or --title override. Body wraps agent's scope with:
pr-captain-land (the-agency#296 Phase 1)"v{new} will follow on merge"./agency/tools/git-captain switch-branch master
Captain sits on master during the CI-wait phase. Avoids any accidental commit on the PR branch.
Poll gh pr view {num} --json statusCheckRollup every 20 seconds. Only gates on lint-and-test.
| State | Action | |---|---| | SUCCESS | proceed to Step 8 | | FAILURE | exit 1 — agent must fix + push + resubmit | | PENDING / IN_PROGRESS | wait 20s, poll again |
Max 30 attempts = 10 minutes. On timeout, exit 1.
deploy-preview-backend is environmental flake and ignored by this skill.
Merge:
./agency/tools/pr-merge {pr-num} --principal-approved
True merge commit — never squash, never rebase (enforced by pr-captain-merge / underlying pr-merge).
Sync master:
./agency/tools/git-captain fetch
./agency/tools/git-captain merge-from-origin
Release (unless --no-release):
./agency/tools/gh-release create v{new-version} --target master --title "..." --notes "..."
Release notes: captain-authored, references PR number + agent.
./agency/tools/dispatch create \
--to <agent-address> \
--type master-updated \
--subject "PR #{num} landed — v{new} released" \
--body "<PR URL, release URL, version bump, Phase 1 pilot feedback request>"
Agent picks up on next /session-resume or via dispatch monitor.
/pr-prep + /pr-submit.pr-create blocks on receipt (Step 5): re-verify hash, retry once; on second failure, exit 1 and ask captain to investigate./pr-submit. Version doesn't re-bump on retry (captain detects current == target)./pr-captain-merge <num> --principal-approved.gh release create. Skill returns 0 because merge is the primary outcome. (MAR follow-up H13 tracks stricter semantics.)pr-captain-merge enforces true merge commit per framework discipline.Defense in depth against accidental invocation from the wrong context:
paths: [] (intentionally empty) — no file-path auto-activation. (Contrast with pr-submit which has paths: [.claude/worktrees/**].)captain- — any human or agent browsing the skill list sees scope at a glance.Any single layer failing is caught by the next. All three must fail simultaneously for an unauthorized invocation to land a PR.
(Historically disable-model-invocation: true was a fourth layer. That flag was removed 2026-04-20 because the captain session IS the principal's session — DMI was blocking the captain from invoking captain-* skills. See REFERENCE-SKILL-CONVENTIONS.md §1.)
active (v2, agency-skill-version 2 from birth — Phase 1 pilot for the-agency#296). Scripts hardened in ccf054ad per MAR findings (Python env-var substitution + branch-name validation). Ready for fleet-wide dogfood on next agent PRs.
/pr-submit — agent-side companion; this skill consumes its dispatch/pr-captain-merge — the merge primitive this skill calls at Step 8/pr-prep — the QG-before-PR-create that signs the receipt this skill re-verifies/pr-captain-post-merge — alternative entry for post-merge tasks (release + fleet-notify) when landing was done manuallyagency/tools/pr-create — PR creation tool (receipt-aware)agency/tools/pr-merge — safe-merge primitive (underlies /pr-captain-merge)agency/tools/gh-release — release creation wrapperagency/tools/dispatch — ISCP dispatch toolagency/tools/diff-hash — receipt-matching hashreference.md — full step-by-step protocol + recovery flowsexamples.md — happy-path + failure-mode examplesOFFENDERS WILL BE FED TO THE — CUTE — ATTACK KITTENS!
business
Sync worktree with master — merge, copy settings, run sandbox-sync, report changes
tools
List all git worktrees with status info (branch, clean/dirty, deps)
tools
Remove a git worktree and optionally delete its branch
development
Create a new git worktree with dedicated branch and bootstrapped dev environment