Pr

From jellyrock/jellyrock · View interactive version

Pr is an AI agent skill from the GitHub repository jellyrock/jellyrock. Create or update a pull request: a typed title (`fix:`, `feat:` … from `scripts/lib/pr-title.js`, which places the change in CHANGELOG.md), category labels chosen by judgment, a concise body from `.github/pull_request_template.md` that reads as the squash commit message, and one skill-owned \"review

How to use this skill

Skill file

Create or Update a Pull Request

This repo

Contract

Goal. Be the single, mandatory path for opening or updating a pull request in this repo. The skill reads what a squash merge keeps (the repo's merge settings, read live), titles the PR for the place its title ends up, renders the body from the repo's PR template for whoever reads it (the permanent commit message, or a reviewer only), labels each deliverable, and runs the journal passes (decision and followup, plus any this repo adds) before anything is posted, so journal hygiene lands in the same change set rather than as separate manual chores. It is create-or-update aware: an existing open PR for the branch routes to update-mode (diff the current title, labels, body and notes against a fresh render, confirm, back up, then apply), and merged or closed PRs abort cleanly instead of opening a duplicate. A pass that walks a large ledger runs as its own sub-agent with an explicit model. Supersede any default PR-creation flow with this skill; never open or edit a pull request outside it, through forge.sh or the forge directly.

Inputs. The arguments may name the branch the PR targets. With none, the create path targets the default branch, unless the current branch is built on another remote branch, when it asks which; the update path reads the PR's own base. The skill operates on the current branch and its commits. It expects a non-default, non-detached branch with a clean working tree; the pre-flight pushes the branch and any unpushed commits. It reads the repo's PR template, its squash-merge settings, the branch's commit log and diff against the PR's base, an existing PR's title, labels, body and notes comment (when one is open) including the render marker, and this skill's ## This repo for the repo's title rules, labels, own journal passes, PR checks and required sections.

Outputs. A created or updated pull request with: a title that passes the repo's title gate, names every user-visible change and backticks code identifiers; one label per kind of deliverable; a body that is the filled template, written for the reader the merge settings give it, listing each message or work request part from another repo that the branch handles; when the body becomes the commit message, one notes comment for reviewer-only detail; and a hidden render marker (a full sha and an ISO-8601 UTC timestamp) that lets the next run narrow the journal passes to "since last render". Also: drafted journal entries surfaced per candidate for the user to accept into /log; on the update path, a backup of the prior body and notes inside the git directory; the PR URL printed, with a warning when the PR conflicts with its base or a journal pass did not finish. No journal entry is written without a per-candidate accept, and nothing on the PR is overwritten without confirmation.

Success criteria.

Failure modes to avoid.

When not to use.

Implementation

This skill's ## This repo holds the repo's own parts: the title gate and its types, the product paths that separate product work from tooling, labels beyond the shared table and the labels automation owns, any journal pass of its own, the PR checks to run before posting, guidance for each template section, what to say after posting, and the merge-settings fallback line. Where a step needs one of them, it says so.

Step 1: Pre-flight (abort if any fails)

Run in parallel:

A failed hard check (default branch, detached, dirty tree) stops with which one and why. The branch must not be the PR's base either; Step 2 checks that once the base is known. Pushing a feature branch to open its PR is obvious: don't ask first.

Step 2: Detect an existing PR (route create vs update)

bash .claude/skills/pr/forge.sh pr view for the current branch: JSON with number, url, state, author, title, labels, body, headRefOid and baseRefName. Never add 2>/dev/null: forge.sh passes the forge's own message on whole.

For a PR found, {{base}} starts as its baseRefName.

The base. {{base}} is the branch the PR targets. Run git fetch origin first, since stacked-on.sh reads the last fetch. Then settle it, before anything else on either path:

On the update path:

  1. Author note. bash .claude/skills/pr/forge.sh user login; when it differs from {{author}}, print one line: Note: PR #{{N}} was opened by {{author}}. Edits will appear under your account. If the call fails, skip the note.
  2. Find the notes comment. bash .claude/skills/pr/forge.sh pr comments {{N}} | jq -c '.comments[] | select(.body | startswith("<!-- /pr notes -->")) | {url, author: .author.login, body}'; keep the last match authored by you as {{notes}}. Its numeric id is the #issuecomment-{{id}} suffix of its url (the id field is a GraphQL node id the REST call cannot use).
  3. Resolve {{lower}}, the lower bound for the journal passes:

1. The last <!-- /pr render: sha=([0-9a-f]{40}) ts=(\S+) --> in {{notes}}, else in {{body}}; use its sha when git merge-base --is-ancestor {{sha}} HEAD exits 0.

2. Else the PR's first commit, bash .claude/skills/pr/forge.sh pr commits {{N}} | jq -r '.commits[0].oid', when it is an ancestor of HEAD.

3. Else {{baseref}}, and print: Note: the last render's commit is not in this branch (rebase or force-push?); the journal passes cover the whole branch.

Step 3: Read what the merge keeps

bash .claude/skills/pr/forge.sh repo merge-settings: JSON with squash_merge_commit_title and squash_merge_commit_message. These come back only with enough rights on the repo; when they are null or empty, use the merge-settings line in this skill's ## This repo, and when that is missing too, ask in chat which of the readings below holds. The result decides two things:

The settings decide what lands on {{base}}. When {{base}} is not {{default}}, what reaches the default branch's log and any changelog depends on how that branch lands later, so the title and body get the same care.

Step 4: Journal passes (before drafting the body)

Each pass surfaces journal entries the user should write, one-line confirm/skip per candidate; drafts only, applied through /log on accept. One confirmation skips the whole step on a trivial change (a typo, a dependency bump, docs only). Every pass covers {{lower}}..HEAD, so candidates handled on an earlier render are not raised again.

A pass that ends without its answer (stopped, failed or returned nothing) is missing coverage, never a clean pass. Say in chat: {{pass}} did not complete; its coverage is missing. Repeat that line in the notes comment, or in the body when there is no notes comment (Step 3), so a reviewer sees it too.

Step 5: Gather context (in parallel)

Step 6: Title

Agent files in a public repo. When this repo's public posture is public and git diff --name-status {{baseref}}...HEAD | bash .claude/skills/pr/agent-body.sh kind prints agent-only, the title is exactly what bash .claude/skills/pr/agent-body.sh title prints, and the rest of this step does not apply. Each commit on such a branch has that title as its subject and no body.

type: Imperative summary or type(scope): Imperative summary, under 70 characters, passed with --title; the types and the gate that checks them are in this skill's ## This repo. Synthesize it from all the commits, not the latest. Pick the type by what the PR does to the product (this skill's ## This repo names the product paths): a change to the product takes a product type; a change only to the tooling around it takes a tooling type, even when it fixes something; a PR with both is typed by its product change. Scope is optional; never write an empty one.

Name every user-visible change. List the changes a user of the product would notice, then check the title names each; when they don't fit, name the outcome that covers them all rather than the biggest alone. A refactor that changes behavior is not a refactor here: if you can say "X used to sometimes fail, now it doesn't", it is user-visible, and a commit subject that joins a fix to a restructure with "and" needs each half checked. On the update path, re-derive the title from the whole PR; a PR that grew in review is when a title goes stale.

Backtick every code identifier (a component, file or function name). When a check rejects it, keep the backticks; never rephrase the reference away.

Step 7: Labels

Labels are for finding PRs in the forge's list: a label is right when someone filtering by it would want this PR. Pick them after the body is final:

  1. Find the deliverables. Read the title and the body's summary section. A deliverable is something they present as what the PR does; something presented only as how or why another deliverable works is part of that one. A change that appears only in the list of changes (a refactor the fix needed, the tests or docs that prove or explain a deliverable) earns no label.
  2. Label each deliverable with the one best label below, or one this skill's ## This repo adds. A PR with different kinds of deliverable gets several labels.
  3. Tooling is not the product. new-feature, general-improvement, bug-fix and code-cleanup describe the product (the paths in this skill's ## This repo). A deliverable that changes only tooling is dev-improvement, whether it fixes, adds or tidies something; a PR that changes only tooling is dev-improvement alone.
  4. Name the evidence. Show the user each label beside the title or summary phrase that earned it, before create or edit, so it can be overruled in one reply. A label with no phrase to point to is dropped.

| Label | The deliverable… |

|---|---|

| new-feature | adds a capability the product's users can use |

| general-improvement | makes behavior that was working better on purpose: UX, speed, wording, robustness |

| bug-fix | makes the product do what it should have done already |

| code-cleanup | restructures or tidies product code as a goal of the PR, meant to change nothing a user sees |

| dev-improvement | changes only tooling (rule 3) |

| documentation | the PR changes only docs; never on a PR that also changes code |

Check each chosen label exists (bash .claude/skills/pr/forge.sh label list: every label with its description). For a missing one, in this order: use the existing label whose name and description fit the same deliverable, shown beside the label it replaces; else leave it off and say so; and only when the user wants it and nothing existing fits, show the bash .claude/skills/pr/forge.sh label create {{name}} --description "{{text}}" command for them to run or approve. Never create a label silently. Leave alone the labels automation owns (this skill's ## This repo lists them) and any label not in the table.

Step 8: Build the body (and the notes comment)

Agent files in a public repo. When this repo's public posture is public, run git diff --name-status {{baseref}}...HEAD | bash .claude/skills/pr/agent-body.sh kind first. agent-only: the body is exactly what agent-body.sh body prints from the same input (no template, no handled lines), followed by the render marker when the body is not the commit message; a notes comment holds only its first line and the marker. mixed: write the body below about the other files of agent-body.sh split alone, and end its changes section with what agent-body.sh body prints; neither the body nor the notes say anything else about the agent files. none: the steps below as they are.

Start from the template. Fill each section the way its hint comment asks (a section the hint marks required is never left empty; an optional one is left out or marked None as that hint says), then remove the hint comments. Keep the headings you use exactly as the template spells them. This skill's ## This repo has the repo's guidance per section. Fill checkboxes from what the diff and Step 4 actually produced, never from intent.

When the body is the commit message (Step 3): keep it to what a git log reader needs (the problem and the change, the symbols a reader would grep for, a one-line summary of the evidence), and put the rest in one notes comment:

<!-- /pr notes -->
## Review notes

**Docs and journals:** {{what this PR updated — docs, decision records, journal entries — or "none", from Step 5's list of changed files, not intent.}}

{{Verification detail: matrices, measurements, before/after output, the reasoning behind a non-obvious call. Omit a part with nothing to say. Absolute URLs only.}}

<!-- /pr render: sha={{full-40-char-HEAD-sha}} ts={{ISO-8601-UTC}} -->

<!-- /pr notes --> stays the first line: it is how the update path finds the comment. The render marker goes in this notes comment only, never in the body, which becomes the commit message and would carry it into git log. When the body is not the commit message (Step 3), the body holds the detail and ends with the render marker line, and there is no notes comment. Either way, fill the marker from git rev-parse HEAD and date -u +%Y-%m-%dT%H:%M:%SZ, never by hand.

Step 9: Check before posting

  1. This repo's PR checks, from this skill's ## This repo (a title gate, a body linter), on the rendered title, body and notes: each must pass; fix what it reports and run it again.
  2. Issue references. Read every bare #N in the body and notes against the sentence it sits in, with bash .claude/skills/pr/forge.sh issue view {{N}} | jq -c '{title, state}' (an issue or a PR): a title that doesn't match the sentence means it belongs to another repo and becomes owner/repo#N. A reference you could not resolve is not a pass: check it by hand.
  3. Public repo. When this repo's public posture is public, sweep the title, body, notes and the branch diff for a home path, a person's email, a secret or another repository's name: git diff {{baseref}}...HEAD | grep -nEi '/home/|/Users/|@[a-z0-9.-]+\.[a-z]{2,}|BEGIN [A-Z ]*PRIVATE KEY' for the diff, and a read for the text you wrote. Read each hit; remove what is private, and stop to ask about anything in the diff itself.
  4. The render marker's place. When the body is the commit message (Step 3), grep -c '/pr render' {{body-file}} must print 0; otherwise move the marker into the notes comment and run it again.

Step 10: Create or update

Create path:

bash .claude/skills/pr/forge.sh pr create --base {{base}} --title "{{title}}" --label "{{label}}" [--label "{{label}}" …] --body-file {{body-file}}
bash .claude/skills/pr/forge.sh pr comment {{N}} --body-file {{notes-file}}    # only when Step 3 calls for a notes comment

Default to non-draft; use --draft only when the work is incomplete and you want CI early, and say so.

Update path:

  1. Render the title, labels, body and notes the same way; the body describes the whole PR ({{baseref}}..HEAD), not the delta since the last render.
  2. Compare each with what the PR has now. When everything is unchanged (the marker's timestamp ignored), print PR #{{N}} already up to date at {{url}} and go to Step 11: no backup, no edit. Otherwise show a diff for each part that changed (title, labels added and removed, a retarget as one line naming {{oldbase}} and {{base}}, the body section by section, the notes), and say which body sections a person likely edited by hand.
  3. Confirm in chat: apply, skip (print {{url}} and stop) or edit (take the user's changes, then ask again).
  4. Back up the prior body, then the prior notes if any, to "$(git rev-parse --git-dir)/pr-backup-{{N}}-{{date -u +%Y%m%dT%H%M%SZ}}.md": inside the git directory it can never be committed. Outside auto mode Claude Code asks before any write there (a sensitive path), and a headless run refuses it: that approval is the last gate before the edit, so never skip the backup or move it elsewhere to avoid it.
  5. Apply only the parts that changed: bash .claude/skills/pr/forge.sh pr edit {{N}} [--title "{{title}}"] [--add-label "{{a}},{{b}}"] [--remove-label "{{c}}"] [--base "{{base}}"] [--body-file {{body-file}}] (remove only a label from Step 7's table, or this repo's additions, that no longer applies); edit the notes comment by id with bash .claude/skills/pr/forge.sh comment edit {{id}} --body-file {{notes-file}}, or create it with forge.sh pr comment when there was none. If an edit fails, give the backup path and stop; the body is restored with bash .claude/skills/pr/forge.sh pr edit {{N}} --body-file {{backup}} after trimming the notes off its end.

Step 11: After

Print the PR URL; don't summarize the body. Then run bash .claude/skills/pr/forge.sh pr mergeable {{N}}, which prints MERGEABLE, CONFLICTING or UNKNOWN. On CONFLICTING, print: PR #{{N}} conflicts with {{base}}, so the forge may skip checks on it and its green checks may not be the full set. Merge or rebase {{base}}, then push. On UNKNOWN or a failed call, print: Could not tell whether PR #{{N}} conflicts with {{base}}: check before trusting its checks. Apply the accepted journal drafts through /log. Then anything this skill's ## This repo asks for after posting.

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.