/pr-prepare:pr-preparefrom pr-prepare
Creates GitHub or Gitea pull requests with AI-authorship disclosure, change classification, reviewer verification steps, and optional screenshots or Mermaid diagrams. Automates branching, committing, pushing, and PR creation.
Ships in pr-prepare. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Produce a reviewable PR and, unless the user explicitly requests a draft-only result, carry it through the safe sequence:
branch -> verify -> commit -> push -> create PR -> verify PR
Never skip forward after a failed step. Preserve unrelated user changes and never force-push.
Read each file at the step that needs it; they hold exact commands and templates, while this file holds the rules and stop conditions.
| File | Read at |
|---|---|
| references/github.md | Step 1, Step 11, Step 11b when the provider is GitHub |
| references/gitea.md | Step 1, Step 11, Step 11b when the provider is Gitea |
| references/pr-body-template.md | Step 8 |
| references/evidence.md | Step 6b, only when evidence is needed |
Gather the current state before making changes:
git status --short
git branch --show-current
git remote -v | sed -E 's#://[^/@]*@#://***@#g'
git config --get "branch.$(git branch --show-current).remote" || echo "no tracking remote configured"
git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' 2>/dev/null || echo "no upstream configured"
git log --oneline -20
A missing tracking remote or upstream is expected before the first push; treat both as informational.
Remote URLs can carry credentials in their userinfo, so pipe every command that echoes a remote URL through the same sed mask. It deliberately masks any scheme-qualified userinfo, even a harmless git@, because a narrower pattern risks missing a real token; scheme, host, and path survive for provider detection.
Determine the base branch from repository configuration or the remote default branch. If it is still unclear, ask the user; common values are main and develop.
In Execute mode, resolve a writable push remote instead of assuming it is named origin:
git remote get-url --push <push-remote> | sed -E 's#://[^/@]*@#://***@#g'.Detect the hosting provider from the selected remote URL — GitHub uses gh, Gitea uses gt — then verify the CLI and resolve its base-repository context as described in the matching provider file. If the hostname or provider is ambiguous, ask the user instead of guessing. Never print or persist access tokens in the PR body or command output.
Stop before mutation when any of these conditions apply:
HEAD is detached.Collect issue identifiers only from reliable context: the user's request, an explicit GitHub/Gitea issue URL or Jira browse URL, or a plan or task document that clearly identifies the work item. Recognize #123, issue 123, /issues/123, and Jira keys such as GAIA-5375 or /browse/GAIA-5375.
Do not guess an issue from similar titles, and do not treat an ambiguous #123 as an issue when it may be a PR number. If more than one repository-host issue or more than one Jira issue could be primary, ask the user.
Build the branch name as <type>/<identifiers>-<slug>:
feat/add-consent-flow
feat/123-add-consent-flow
fix/GAIA-5375-handle-expired-token
feat/GAIA-5375-123-add-consent-flow
Use the repository's prefix convention when one exists; otherwise use a concise type such as feat, fix, docs, refactor, test, ci, or chore. Keep Jira keys uppercase and first, strip # from issue numbers, keep the lowercase slug short, and shorten the slug before dropping identifiers. Validate with git check-ref-format --branch <branch>.
In Draft-only mode, skip this step. In Execute mode, ensure the work is on a dedicated head branch before staging or committing:
git switch -c <branch>; uncommitted changes move with it.HEAD or from the base branch. Do not silently include unrelated commits.-2; never overwrite or delete it.Record the base branch, head branch, push remote, and existing upstream for the push and PR commands.
Inspect committed and uncommitted changes that would enter the PR:
git log <base>..HEAD --oneline
git diff <base>...HEAD --stat
git diff <base>...HEAD
git diff --stat
git diff
git diff --cached --stat
git diff --cached
For large diffs, read the stat and the important sections. Identify files, packages, services, public interfaces, and call relationships.
Classify the whole PR using the stricter applicable category:
If the blast radius is unclear, ask: "If this code is buggy, how far would the failure spread?"
Reviewers cannot see a UI change or judge a performance claim from text alone, so decide from the diff and the stated goal whether this PR needs visual or quantitative evidence. Apply every row that matches; a PR can need both:
| Signal in diff / goal | Evidence |
|---|---|
Changed *.tsx, *.jsx, *.vue, *.svelte, *.css, *.scss, *.html, templates, UI components, user-visible copy, or layout | Web screenshots (before/after) |
| Goal mentions performance, optimization, latency, throughput, or memory; or the diff touches hot paths, DB queries or indexes, caching, concurrency, bundle size, or algorithmic complexity | Performance report |
| Pure backend logic, docs, CI, or a dependency bump without a performance claim | N/A with a one-line reason |
Ask the user only when the signals are ambiguous, such as a backend change that may alter what a page renders. Record an evidence plan for Step 6b: pages, states, viewports, data, and account role for screenshots; benchmark or workload, metrics, and dataset size for performance; or the one-line N/A reason.
Use this default disclosure without asking for confirmation:
None — not yet reviewed by a human.Lack of human review is not a reason to stop; make the disclosure conspicuous in the PR body and final handoff. If the user supplies more specific authorship or review information, use that instead.
Use repository instructions and existing scripts to run the relevant formatter, lint, tests, and build checks.
Not run when no read-only variant exists or its behavior is uncertain.Ask only about checklist items that cannot be established from repository evidence:
must not modify, were respected.Also run git diff --check and, after staging, git diff --staged --check.
In Execute mode, if a required check fails or cannot be verified, stop. Leave the local head branch intact, but do not commit, push, or create the PR. In Draft-only mode, continue preparing the body and report failed checks as Failed and skipped or unavailable checks as Not run, with reasons; do not claim the draft is verified or ready to merge.
Record the working directory, prerequisites, exact commands or actions, and observed results while verifying so Step 8 can turn them into reproducible reviewer instructions. Keep expected behavior separate from observed results; a proposed check is not evidence that it passed.
Skip this step when Step 4b marked both evidence types N/A; otherwise read references/evidence.md for capture recipes.
Choose the source in this order, because the user knows their environment best and repository tooling reflects how the team already measures:
package.json scripts, Makefile bench targets, existing e2e or Playwright configuration, documented benchmark commands.PATH or in the repository's dependencies, such as Playwright or another headless browser, go test -bench with benchstat, hyperfine, Lighthouse CLI, or k6. A browser skill such as /browse may be used when installed, but do not assume one exists. Do not install global tools or fetch packages that are not already present without asking.Capture base and head under the same conditions so the comparison means something:
git worktree outside the repository so the user's working tree is never touched. If base cannot be built or run, capture head only and say so rather than presenting a one-sided result as a comparison.${TMPDIR:-/tmp}/pr-evidence/<head-branch>/, never inside the repository, and never git add them. Name screenshots <before|after>-<page>-<state>[-mobile].png; the name without the extension is the evidence ID used in Step 8 and Step 11b.Draft-only mode may capture, since that does not modify tracked files, but never uploads.
When evidence cannot be captured, record Not run with the reason and the environment or access needed. An evidence gap does not block commit, push, or PR creation, and it never overrides or relaxes Step 6's Execute-mode required-check gate; like reviewer-only checks, it is reported, not enforced.
For a non-trivial change, add a Mermaid diagram derived from the actual diff:
| Change shape | Diagram |
|---|---|
| Calls or handshakes over time | sequenceDiagram |
| Decisions, control flow, or pipeline | flowchart TD |
| Modules, packages, or services | flowchart LR with subgraph |
| Status or lifecycle transitions | stateDiagram-v2 |
Map every changed node to a touched file, function, package, or service; mark new or modified nodes with per-node style lines; stay below roughly 15-20 nodes and prefer TD when LR would be too wide; do not use click handlers or theme initialization directives. Omit the diagram for a one-line fix, copy change, or dependency bump.
Match an existing repository PR template when present, including .github/ templates for GitHub and .gitea/ templates for Gitea; put the verification and evidence content in its equivalent sections, or add sections it lacks. Otherwise fill references/pr-body-template.md. Never invent evidence.
The PR body must let a reviewer verify the intended behavior without the author's local state or this conversation. Scale detail to the change, but never reduce verification to "tests pass" or "test manually."
Passed, Failed, or Not run, and record actual results separately from expected ones. For checks not run, give the reason and the access or environment needed. Reviewer-only checks do not count as completed verification or override Step 6's Execute-mode gate.Fill ## Evidence from Step 4b and Step 6b with the same Passed / Failed / Not run vocabulary. For an evidence type marked N/A, write a single N/A — <reason> line instead of a table. Put each image cell as an <!-- evidence:<id> --> placeholder so Step 11b can replace it reliably. Never describe a screenshot that was not captured or fill a metric that was not measured. Flag every evidence item marked Not run in the Reviewer guide so reviewers know what to check themselves.
Before finalizing, walk through the body as a fresh reviewer: can they prepare the environment, follow each step, and decide whether the flow meets the acceptance conditions? Fill every placeholder from repository evidence, and omit inapplicable fields with a brief reason.
In Draft-only mode, skip this step. First determine whether the intended change is already committed:
git log <base>..HEAD --oneline
git diff <base>...HEAD --stat
git status --short
<base>..HEAD already contains the complete intended change and no task-related uncommitted changes remain, inspect those commits, skip staging and commit creation, and continue to push.git add . or git add -A in a dirty worktree.When staging is needed, inspect exactly what will be committed:
git add <task-file-1> <task-file-2>
git diff --staged --stat
git diff --staged
git diff --staged --check
Stop if a non-empty staged diff contains unrelated changes, violates the announced scope, or fails verification. Evidence artifacts from Step 6b must never be staged; if any appear, stop and unstage them. An empty staged diff is valid only when <base>..HEAD already contains the complete intended commits; otherwise stop.
Match recent repository commit style; otherwise prefer a focused conventional commit:
<type>(<scope>): <imperative summary>
<important change bullets, if useful>
Create the commit directly, since Execute mode already expresses the intent to commit. Then verify the intended commit range and git show --stat --oneline HEAD, and report any intentionally unstaged user changes.
Push only after the intended commit was created or verified as already present.
git push.git push -u <push-remote> <head-branch> with the remote resolved in Step 1.HEAD, skip the push.Never force-push. If authentication, policy, hooks, or network errors prevent the push, stop and report the exact failure; keep the local branch and commit and do not create the PR.
Use the commands in the provider file, always pinned to the base repository context resolved in Step 1, so a fork clone cannot redirect the lookup, creation, or verification to the wrong repository.
A PR creation failure leaves the remote branch intact for retry.
Skip this step in Draft-only mode or when Step 6b captured no screenshots. Run it only after Step 11 verified the PR, following the provider file: Gitea uploads attachments and replaces placeholders with image links; GitHub has no upload API, so keep the placeholders, append a pending-attachment note, and never claim an automatic upload or commit images. The only body change allowed here is replacing <!-- evidence:<id> --> placeholders and adding that note.
Not run and does not block commit, push, or PR creation.git reset --hard, branch deletion, or force-push as automatic recovery.Report:
Not run with its reason.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub appleboy/skills --plugin pr-prepareOther plugins' skills for the same job