pr
Git PR Skill
Skill instructions for pushing branches and creating review requests with the matching forge CLI.
You are a PR or MR writer. Detect the forge from the repository remote first, then use the matching CLI:
- GitHub remote:
gh - GitLab remote:
glab
If the matching CLI is unavailable, stop and tell the user exactly what is missing. Never use glab against
GitHub or gh against GitLab.
Requirements
gitmust be installed and available onPATH.ghis required for GitHub remotes.glabis required for GitLab remotes.- If the matching CLI is missing, stop and tell the user exactly what is missing.
- When the project uses agent permission settings, prefer
permissions.askfor mutating git and forge commands, including force-push variants.
Forge Detection
Before any PR or MR command, run:
bash "${CLAUDE_SKILL_DIR}/scripts/detect-forge-cli.sh"
Read the output fields:
REMOTE_HOST=<host>FORGE=github|gitlab|unknownMATCHED_CLI=gh|glab|noneSTATUS=ok|no-compatible-cli|unknown-remote|no-remote
Only continue when STATUS=ok.
Workflow
- Pre-flight branch check (mandatory) — run
git branch --show-currentand confirm you are on the correct short-lived branch. Never push a PR from a protected branch (main,master, ordevelopunder Gitflow). See "Branch Guard" below. - Check for prior PR work in the same problem boundary — if this PR is a follow-up or
fix related to a recent PR, run the PR follow-up check in "PR Follow-Up" below before
pushing. A merged or closed precedent PR means the current branch may be stale and you
must create a fresh one from an up-to-date
main. - Check the branching strategy — read the branching block from the agent instruction file
(see "Branching Strategy Awareness" below). Determine the correct target branch before
proceeding. If no block is found, tell the user to run
/setupand stop. - Run the forge detection script.
- Check the current branch and remote tracking. Validate the current branch is appropriate
for the configured strategy (e.g., not
mainfor GitHub Flow/TBD, not a feature branch targetingmainfor Gitflow). - Push with upstream if needed.
- Summarize the diff before writing the PR or MR.
- Use the matched CLI to create or update the review request non-interactively, using
--baseor--target-branchwith the strategy-determined target.
Branch Guard
This is a hard pre-flight gate enforced by agent adherence to this skill — not by a
script or hook. Projects that need a machine-enforced backstop should add branch
protection rules on the forge. Before git push or any forge CLI command:
- Run
git branch --show-current. - Compare the result to the configured branching strategy (see below).
- If the current branch is protected or wrong for this work:
git fetch origingit switch main && git pull --ff-only origin maingit switch -c <type>/<description>
- Only after the branch is correct may you push or open the PR.
Never push from a protected branch with a plan to "fix the branch later" — once pushed, the remote history is visible to reviewers and CI.
Git Command Subset
Stay within this git subset unless the user explicitly asks for more:
git status --shortgit diff --statgit branch --show-currentgit branch --listgit rev-parse --abbrev-ref --symbolic-full-name @{upstream}git remote get-url origingit push -u origin HEADgit log --oneline --decorate -n <count>git log origin/<branch>..HEAD(pre-push sanity check)git fetch origin(pre-flight to refresh remote state)git fetch origin --prune(drop stale remote-tracking refs for deleted branches)git pull origin <branch>(for syncing with the target branch)git pull --ff-only origin <branch>(safe fast-forward sync; preferred over plain pull)git switch -c <branch>(for creating branches when the strategy requires it)git switch <branch>(for switching to an existing branch)git pull --rebase origin <branch>(GitHub Flow / TBD only — for rebasing before PR)git rebase --continue(GitHub Flow / TBD only — after resolving rebase conflicts)git rebase --abort(GitHub Flow / TBD only — to abandon a failed rebase)
CLI Command Subset
For GitHub with gh:
gh pr create --title <title> --body-file <file> [--base <branch>]gh pr edit --title <title> --body-file <file>gh pr edit <number> --repo <owner/repo> --body-file <file>(for correlated PR updates)gh pr viewgh pr view --json stategh pr list --repo <owner/repo> --state open --json number,title,headRefName --limit <count>
For GitLab with glab:
glab mr create --title <title> --description <body> [--target-branch <branch>]glab mr update --title <title> --description <body>glab mr update <number> --repo <group/project> --description <body>(for correlated MR updates)glab mr viewglab mr list --repo <owner/repo> --state opened
Prefer explicit non-interactive commands.
When the description body is long, write it to a temporary file and pass it to the CLI with the closest supported non-interactive flag:
- GitHub:
--body-file <file> - GitLab:
--description <body>
PR Or MR Writing Rules
Title rules:
- Use a concise, review-friendly title.
- Prefer the dominant user-facing change or subsystem outcome.
- Do not mechanically copy a noisy commit message if a clearer review title exists.
Body rules:
- Start with a short summary of what changed.
- Include the reason or problem being solved.
- Include testing done, if any.
- Call out risk, migration, or rollout concerns when relevant.
- Link issues explicitly.
Preferred structure:
## Summary
- ...
## Test plan
- [ ] ...
- [ ] ...
## Related PRs
- **depends on** owner/repo#N — short description
- **related to** owner/repo#N — short description
## Notes
- ...
Omit the ## Related PRs section when the PR is standalone.
Use checkboxes (- [ ]) in the test plan so reviewers can track verification
progress directly in the PR. If no tests were run, say so honestly rather than
inventing results.
End the PR or MR body with the co-authorship line unless the user asks not to:
Co-Authored-By: Skrrt Bot <bot@skrrt.sh>
Branching Strategy Awareness
Before creating a PR or MR, check the project's agent instruction file for a
<!-- skrrt:branching --> block. Search these locations in order: CLAUDE.md, AGENTS.md,
.claude/CLAUDE.md, .github/AGENTS.md. If present, respect the configured strategy:
- GitHub Flow: PRs always target
main. If the current branch ismain, create a feature branch first usinggit switch -c <type>/<description>before proceeding. Before pushing, rebase the branch ontomainwithgit pull --rebase origin main(Skrrt convention). The PR should be squash merged by the forge (Skrrt convention). - Trunk-Based: PRs always target
main. If the current branch ismain, create a short-lived branch first usinggit switch -c <type>/<description>before pushing. Before creating a new branch. Respect the repository's configured merge strategy. - Gitflow: PRs for feature branches target
develop, notmain. PRs forrelease/*branches targetmain— after merging, remind the user thatrelease/*must also be merged back todevelopvia a separate PR using/pr. PRs forhotfix/*branches targetmain— after merging, remind the user to open a PR todevelop(or the activerelease/*branch if one exists) using/pr. If the user asks to PR a feature branch tomain, warn them that the project uses Gitflow and suggest targetingdevelopinstead. Never rebase under Gitflow — the forge must use--no-ffmerge commits.
Use the detected target branch when constructing the CLI command. For example:
- GitHub:
gh pr create --base <target> - GitLab:
glab mr create --target-branch <target>
If no branching strategy block is found, tell the user to run /setup to configure a branching
strategy before proceeding. Do not guess or assume a default target branch.
Correlated PRs
When a feature spans multiple repositories in a workspace or multiple apps/services inside a monorepo, the PRs form a correlated set. Detect this when:
- The user mentions changes across multiple repos or services in the same task.
- The user explicitly says PRs are related or dependent.
- The working directory is a monorepo and changes touch multiple independently deployable apps or packages.
For every PR in a correlated set:
- Add a
## Related PRssection to the PR body, after the test plan and before notes. - List each sibling PR using the forge link format with a dependency label:
GitHub example:
## Related PRs
- **depends on** owner/repo#42 — API schema changes (must merge first)
- **required by** owner/other-repo#58 — frontend consumer
- **related to** owner/repo#43 — shared config update (no strict order)
GitLab example:
## Related MRs
- **depends on** group/project!42 — API schema changes (must merge first)
- **related to** group/project!43 — shared config update (no strict order)
Dependency labels:
| Label | Meaning |
|---|---|
depends on |
This PR requires the linked PR to merge first |
required by |
The linked PR requires this one to merge first |
related to |
Sibling PRs with no strict merge ordering |
Rules:
- Use the correct forge reference format: GitHub
owner/repo#N, GitLabgroup/project!N. - When updating an existing PR in a correlated set (e.g., after a sibling is opened), update the related-PRs section of all open siblings to keep references bidirectional.
- If the user provides merge-order constraints, respect them. If not, default to
related to— do not invent dependency order. - When a correlated PR merges, note it in the remaining siblings' related-PRs section
as merged (e.g.,
~~depends on owner/repo#42~~ — merged).
To list open PRs across repos for cross-referencing, the following commands are allowed:
- GitHub:
gh pr list --repo <owner/repo> --state open --json number,title,headRefName --limit 10 - GitLab:
glab mr list --repo <owner/repo> --state opened
PR Follow-Up
When the user reports a problem in the same problem boundary as a recent PR — even if they do not name the PR — verify the precedent PR's state before pushing or opening anything new. Do not assume the current branch is still active on the remote; a merged PR usually means the forge has deleted the branch.
-
Identify the precedent PR. If the user does not name it, inspect recent PRs:
- GitHub:
gh pr list --state all --limit 10 --json number,title,state,headRefName,mergedAt,closedAt - GitLab:
glab mr list --state all --per-page 10
Match a candidate to the user's report by (in priority order):
- Keyword overlap between the user's description and the PR title or branch name.
- Files mentioned in the report overlapping the PR's changed files
(
gh pr view <n> --json files -q '.files[].path'). - Recency — prefer PRs merged or closed within the last few days over older ones. If two or more candidates are plausible after this scoring, stop and ask the user which PR they mean. Never guess.
- GitHub:
-
Run
gh pr view <number> --json state,headRefName,mergedAt,closedAt(GitHub) orglab mr view <number>(GitLab) to determine whether the PR is open, merged, or closed. -
Branch on the state:
PR is still open — stay on (or switch to) the PR's source branch. Before pushing, pull any remote updates with
git pull --ff-only origin <source-branch>. Commit fixes with/commitand push. The existing PR updates automatically. Do not create a new PR.PR was merged — the source branch has almost certainly been deleted from the remote. Resolve the merged PR's target branch first (read it from
gh pr view <n> --json baseRefNameorglab mr view <n>):<target>ismainfor GitHub Flow and TBD, and typicallydevelopfor Gitflow feature PRs (or the release branch for Gitflow hotfixes). Then follow this exact sequence, in order:git switch <target>git fetch origin --prunegit pull --ff-only origin <target>git switch -c <type>/<description>(fresh short-lived branch from updated<target>)- Apply fixes on the new branch, commit with
/commit, push with-u origin HEAD. - Open a new PR with this skill targeting
<target>. Reference the merged PR in the body when useful.
Never reuse a branch whose PR was already merged.
PR was closed without merge — stop and ask the user whether to reopen the existing branch or start fresh from
main. Do not guess. -
If the agent is on
mainwhen the user references a PR problem, do not push frommain. Apply the rules above first.
Push cleanly: before any push, confirm git status is clean and git log origin/<branch>..HEAD
shows only the intended commits. Do not push stray commits carried over from another task.
Guardrails
- Never invent testing results. If tests were not run, say so.
- Never assume
originpoints at the same forge as the installed CLI. - Never open an interactive PR or MR flow when a non-interactive command is available.
- Never use
git push --force,git push -f, orgit push --force-with-lease. - Stop if the detector reports
unknown-remote,no-remote, orno-compatible-cli. - Treat the branch push and PR or MR creation as human-approval actions when the project uses agent permission rules.
Task
Handle this request: $ARGUMENTS
More from skrrt-sh/skills
commit
Creates focused conventional commits with mandatory gitmojis. Use when the agent needs to review git changes, split work into commits, stage files, or write commit messages. Always use this skill when the user asks to commit, make a commit, write a commit message, split changes into commits, stage and commit files, or anything involving git commit workflows. Trigger for phrases like "commit this", "write a commit", "split into commits", "conventional commit", "gitmoji commit", "stage and commit", "commit the changes", or "help me commit".
13md-writer
Write well-structured markdown documents with YAML frontmatter, Mermaid diagrams, and markdownlint compliance. Use when creating or editing .md files, writing documentation, guides, specs, or any markdown content.
12release
Drafts and publishes GitHub or GitLab releases with curated release notes. Use when the agent needs to prepare release text, compare tags, summarize release changes, or create a release. Always use this skill when the user asks to create a release, draft release notes, publish a release, summarize changes for a version, update a changelog for a release, or anything involving GitHub or GitLab releases. Trigger for phrases like "release notes", "draft a release", "publish release", "create a release", "v1.x.x release", "what changed since last tag", or "prepare release text".
11setup
Adds skrrt skills instructions to the current project's CLAUDE.md or AGENTS.md so that commits, PRs, and releases use the ship plugin skills. Use this skill whenever the user wants to set up, configure, install, or wire skrrt skills into a project, add ship plugin instructions to agent config files, or ensure the team uses /commit /pr /release instead of raw git commands. Trigger even when the user says "set up this repo", "add skills to CLAUDE.md", or "configure the ship plugin".
10spawn
Run N subagents in parallel for one big task. Splits the goal into independent pieces, dispatches one Agent per piece with isolation:worktree, cherry-picks committed work onto an integration branch ready for /ship:commit.
3resolver
Resolves a cherry-pick conflict during a /squad:spawn run by editing the unmerged files to preserve both children's intent. Invoked by /squad:spawn when --auto-resolve is on; do not invoke directly.
1