Pr submit

From the-agency-ai/the-agency · View interactive version

Pr submit is an AI agent skill from the GitHub repository the-agency-ai/the-agency. Agent-side signal to captain that your branch is ready for PR landing. Runs preconditions (clean tree, pushed, matching QGR receipt) then dispatches captain with a structured payload. Captain's /pr-captain-land picks it up. Replaces the distributed "agent creates PR" model with a captain-owned PR li

How to use this skill

Skill file

<!--

allowed-tools intentionally omitted — inherits Bash(*) from

.claude/settings.json. Subcommand-level restriction at the skill level

silently blocked fleet agents in the past (flag #62/#63; devex dispatch

#171). This skill composes git-safe, dispatch, and diff-hash — tool-level

narrow restriction would work but needs maintenance as composed tools

evolve. Inherit Bash(*) is safer.

-->

pr-submit

Agent-side handoff to captain: "my branch is ready for PR landing." Captain picks up the dispatch and runs /pr-captain-land to own the remaining PR lifecycle (version bump, PR creation, CI wait, merge, release, fleet-notify).

Why this exists

Per the-agency#296: the distributed "agent creates PR, captain merges" model causes four failure modes that the captain-owned lifecycle eliminates:

Solution: captain owns the PR lifecycle end-to-end. Agent owns substance + QG. /pr-submit is the single handoff point — a structured dispatch with branch, SHA, diff-hash, receipt path, and scope summary.

Required reading

Before running, Read the files listed in required_reading: frontmatter.

The dispatch payload schema itself is in this skill's reference.md.

Usage

/pr-submit --scope "one-line PR summary"
/pr-submit --scope "..." --priority high

Preconditions

The script enforces all of these before dispatching; any failure exits non-zero with a clear error and no dispatch is sent:

  1. Running in an agent worktree (.claude/worktrees/<name>/), not the main checkout.
  2. Current branch is not master / main / HEAD (not detached).
  3. Tree is clean — git status --porcelain empty.
  4. Current branch is pushed to origin and origin/<branch> equals local HEAD.
  5. A QGR receipt exists at agency/workstreams/**/qgr/*qgr-pr-prep-*-{hash}.md where {hash} matches the current diff-hash against origin/<default-branch> (resolved, not hardcoded).

If preconditions 3 or 4 fail, fix them (commit/push via /git-safe-commit or /sync) and retry. If precondition 5 fails, you need to re-run /pr-prep to sign a fresh receipt.

Flow / Steps

Step 1: Preflight

scripts/pr-submit computes all preconditions. If any fail, exit 1 with a one-line reason. No partial state.

Step 2: Resolve identity + branch state

  1. Resolve agent identity via ./agency/tools/agent-identity (principal + agent + repo).
  2. Capture BRANCH = git rev-parse --abbrev-ref HEAD.
  3. Capture SHA = git rev-parse HEAD.
  4. Verify git rev-parse "origin/$BRANCH" equals SHA.

Step 3: Compute diff-hash

./agency/tools/diff-hash --base "origin/$DEFAULT_BRANCH" --json   # default branch resolved, not hardcoded

Capture the full SHA-256 and the 7-char short form. The 7-char short form is what matches the receipt filename suffix.

Step 4: Locate receipt

Glob for agency/workstreams/**/qgr/*qgr-pr-prep-*-{hash-short}.md. Exactly one receipt should match. If zero, exit 1 — agent must re-run /pr-prep. If multiple, pick the most recent and warn.

Step 5: Compose dispatch payload

Follow the schema in reference.md (protocol v1.0). Envelope:

to:       <org>/{principal}/captain
type:     pr-submit
priority: normal | high
subject:  "Ready for PR landing: {branch} — {scope}"

Body is the markdown template in reference.md — branch, SHA, diff-hash, receipt path, scope, captain-action list.

Step 6: Emit dispatch

./agency/tools/dispatch create \
  --to <org>/{principal}/captain \
  --type pr-submit \
  --subject "<subject>" \
  --body "<body>"

Capture the dispatch ID. Report to the agent: "Submitted to captain as dispatch <id>. Captain will run /pr-captain-land <branch>; you'll receive a master-updated dispatch when the PR lands."

Step 7: Stand by

Agent does NOT:

Agent stands by to respond to review comments via /pr-respond if any come. On merge, a master-updated dispatch arrives with PR URL + release tag.

Failure modes

What this does NOT do

Status

active (v2, agency-skill-version 2 from birth — this skill is the Phase 1 pilot for the-agency#296 captain-owned PR lifecycle). Ready for fleet-wide dogfood on designex / patient / of-mobile next PRs.

Related

OFFENDERS WILL BE FED TO THE — CUTE — ATTACK KITTENS!

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.