Skip to content

Pull request pipeline (canonical)

This file is the single source of truth for how an agent opens or updates a pull request in this repository. Title format stays in commit-messages.md and branch names in branch-names.md; this file covers the route a pull request takes. Commits come first, through the commit pipeline.

Adapted from the Agent-kit pr-pipeline Pattern guide (v1.0.0-beta.9). Agent-kit does not install or upgrade it, so these files are consumer-owned and not part of the kit-owned paths.

Parts

Part File Job
Skill .claude/skills/create-pull-request/SKILL.md Checks the branch, calls the drafter, writes the body file, runs the runner, repairs a failure. Load it whenever you open or update a pull request.
Drafter .claude/agents/pr-drafter.md, .cursor/agents/pr-drafter.md Read-only. Drafts the title, labels, merge base and body from the branch's commits, diff and linked issues.
Runner scripts/development/pr-runner.sh The only place an agent pushes a branch and creates or edits a pull request. Re-checks the draft first and ends a failure with a trailer.
Label allowlist pr-labels.txt The only labels the drafter may choose and the runner accepts.

Rules

  • Agents open and update pull requests only through the runner: bash scripts/development/pr-runner.sh --title <text> --body-file <path> --merge-base <sha>. Never git push, gh pr create or gh pr edit directly.
  • The drafter returns the merge base it computed with git merge-base origin/<base> HEAD, and the runner recomputes it and refuses a missing, abbreviated or different SHA. That proves the branch was inspected, not that the body is accurate. The main agent never fills the SHA in, and never puts one in the drafter's prompt.
  • The drafter is read-only. The Cursor wrapper enforces it with readonly: true. The Claude wrapper grants Bash and narrows it with a PreToolUse hook, scripts/development/pr-drafter-guard.sh, that allows only git status, diff, log, show, merge-base, rev-parse, rev-list, git branch --show-current and gh issue view, with no shell operators (the same approach as commit-drafter-guard.sh).
  • Every body starts with > *This was generated by AI.* and ends with a ## Merge risk block: whether a revert undoes the merge, and the blast radius in one word.
  • The test plan reports commands already run, with their results; anything unverified goes under Still to check:.
  • No label by default, and only labels from pr-labels.txt. Workflow labels (agent:*, team:*, ready-for-*, needs-*, release) are never set by this pipeline; only mnaimfaizy adds agent:review.
  • No reviewers unless the user names them. The runner assigns the pull request to the gh user it runs as.
  • Fixes #<n> only for an issue the branch resolves, never inside backticks. An issue the branch only touches is Related: #<n>.
  • An open pull request for the branch is reused: its title and body are replaced, and allowed labels are added. Labels a person or bot added are left alone.
  • Never force-push. A remote branch with commits the local branch lacks is refused; merge it in (this repository merges main into a branch rather than rebasing).
  • Ready for review by default. --draft only when the user or the run's route asks for it (orchestrate.config.yml does).
  • If the drafter fails, stop. Do not fall back to a body built from commit subjects.
  • The runner never merges and never deletes a branch. A person merges.

The draft format

TITLE: <type>(<scope>): <summary>
LABELS: <comma-separated names from pr-labels.txt; the line is left out when none fit>
MERGE-BASE: <full SHA from git merge-base>

> *This was generated by AI.*

## Why
## Changes
## Issues
## Test plan
Still to check:
## Merge risk
**Reversible:** <yes or no> — <for no: the part a revert does not undo>
**Blast radius:** <one word from RADIUS_WORDS in pr-runner.sh> — <at most two sentences>

The blast radius words are listed once, as RADIUS_WORDS in scripts/development/pr-runner.sh; the runner's RADIUS_LINE check and its error message are built from it.

The three header lines sit above the AI notice, so the main agent strips them and they never reach the published body. Empty sections are left out, except ## Merge risk.

Reversible is no when a revert would not undo the merge: an Alembic migration that drops or rewrites data, a change to the Redis token allowlist key format, JWT claims or password hashing that strands live sessions or stored hashes, a removed or renamed API response field the web app or another client reads, or a change to a stored format.

The runner's checks

In order, before anything is pushed: the arguments, gh auth status, not on the base branch, the merge base (full 40-character SHA, equal to the runner's own), at least one commit, no header line left in the body, the AI notice as the first line, readable **Reversible:** and **Blast radius:** lines, no closing keyword inside backticks, every label on the allowlist, and no secret-looking path added on the branch (the same file-name rule as commit-runner.sh). Then it pushes without force, creates the pull request with gh pr create or updates the open one, assigns it, and adds labels and reviewers. It prints the pull request's URL.

gh pr edit fails on this repository's classic Projects field, so every change after creation (title, body, assignee, labels, reviewers) goes through gh api.

Failure trailer

Every failure ends with:

---
pr-runner: failed
reason: <reason>
scope: <only when the check named one>
paths: <only for reason secret>
hint: <the command to run next>
---

Field names and the reason set are an interface that agents parse: add reasons, do not rename them. The shape matches the commit runner's trailer.

The reasons, with what each means, are listed once, in the comment above fail() in scripts/development/pr-runner.sh. Each failure's hint line says what to do next; the create-pull-request skill adds the agent-side rules (send the draft back, never force-push).

What was adapted, and what was left out

  • The runner's base is main, its allowlist is pr-labels.txt, and its title rule is commit-messages.md. The body sections are the pattern's, with this repository's > *This was generated by AI.* first line.
  • The irreversible cases and the blast radius words are this repository's (Alembic, the Redis token allowlist, JWT, the web app's API contract).
  • Added to the pattern: the commit runner's failure trailer, a check for the AI notice and the **Blast radius:** word, the closing-keyword-in-backticks check (the pattern states the rule; the runner now enforces it), the header-line check from the skill's own checklist, and the secret-path check from commit-runner.sh.
  • Changed: every edit after creation goes through gh api, because gh pr edit fails here.
  • Left out: --force-with-lease. Agents never force-push in this repository, and a branch is updated by merging main in, so a diverged remote is always refused.
  • Left out: syncing labels by removing allowlisted labels the draft no longer chose. The pattern leaves it as a TODO; labels are only added.
  • Left out: a .github/pull_request_template.md. The repository has none, and the human template in docs/contributing.md stays for people.
  • The runner is Bash. On Windows, use Git Bash.

Trying a failure on purpose

Run the runner with a made-up merge base, with a body whose **Reversible:** line ends in a full stop, and with --label agent:review, and check that each ends with the merge-base, risk and label trailers before anything is pushed. Then run it with a body holding See `Fixes #12` here (refused with reason: body) and one holding Rename `foo` to `bar`; resolves #12 (passes the body check: the keyword is outside every code span).