skills/pull-request-review/SKILL.md
Review a pull request by branch name or URL, using a git worktree
npx skillsauth add alexanderguy/skills pull-request-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to review a pull request given a branch name or URL.
This skill accepts either:
feature/add-auth)https://github.com/owner/repo/pull/123)If given a URL, extract the pull request information:
# GitHub PR URL format: https://github.com/owner/repo/pull/123
# GitLab MR URL format: https://gitlab.com/owner/repo/-/merge_requests/123
# For GitHub, use gh CLI to get branch name
gh pr view <url-or-number> --json headRefName --jq '.headRefName'
# For GitLab, use glab CLI or parse the MR page
glab mr view <number> --output json | jq -r '.source_branch'
Find the root of the current git repository:
git rev-parse --show-toplevel
Fetch the branch from the remote and verify it exists:
# Fetch the specific branch
git fetch origin <branch-name>
# Verify the branch exists
if ! git rev-parse --verify "origin/<branch-name>" >/dev/null 2>&1; then
echo "Error: Branch '<branch-name>' does not exist on the remote."
exit 1
fi
If the branch does not exist, inform the user of the error and stop. Do not proceed with worktree creation or review.
Create a worktree in a sibling directory under worktree/:
# From repository root
REPO_ROOT=$(git rev-parse --show-toplevel)
WORKTREE_PATH="${REPO_ROOT}/../worktree/<branch-name>"
# Create the worktree directory if needed
mkdir -p "${REPO_ROOT}/../worktree"
# Add the worktree
git worktree add "$WORKTREE_PATH" "origin/<branch-name>"
The worktree path follows the pattern ../worktree/<branch-name> relative to the repository root.
Change the working directory to the new worktree and ensure the branch is checked out:
cd "$WORKTREE_PATH"
# Checkout the branch
git checkout <branch-name>
# Verify you are on the correct branch
git branch --show-current
Confirm the output matches the expected branch name before proceeding.
Before reviewing, the repository must be properly set up. Look for developer documentation that describes how to install dependencies and prepare the codebase:
Search for setup instructions in these common locations:
README.mdCONTRIBUTING.mddocs/ directoryDEVELOPMENT.mdSETUP.mdFollow the documented setup steps exactly. Common setup tasks include:
npm install, yarn, pip install, bundle install, etc.)Do not assume the setup process. Every repository has its own conventions and requirements.
If no setup documentation exists, ask the user how to set up the repository before proceeding.
Identify the base branch for comparison:
# For GitHub PRs
gh pr view --json baseRefName --jq '.baseRefName'
# For GitLab MRs
glab mr view --output json | jq -r '.target_branch'
# If working from branch name only, assume main or master
git branch -r | grep -E 'origin/(main|master)$' | head -1 | sed 's/.*origin\///'
Load and follow the code-review skill to perform the actual review. The code-review skill provides guidance on:
After the review is complete, the worktree can be removed:
git worktree remove "$WORKTREE_PATH"
Inform the user that the worktree remains available for further investigation and can be removed manually when no longer needed.
If any command fails during the workflow, do not retry or attempt workarounds. Stop immediately and ask the user for guidance. Common failure scenarios include:
Present the error output to the user and ask how they would like to proceed.
development
Perform a code review or pull request review on a branch
development
Write scripts using opsh and its built-in libraries. Load this skill when writing, reviewing, or debugging opsh scripts.
testing
Reshape git history with rebase — edit-in-place to fix an earlier commit, squash/fixup, drop, split, reword, or validate every replayed commit. Load whenever you need to change a commit that is not HEAD, or for any branch-history cleanup before push. Covers driving every editor invocation non-interactively so the rebase runs without a human at the keyboard.
tools
Conduct an iterative multiple-choice interview using AskUserQuestion. Returns the Q&A inline. Use as a utility when a caller needs structured user input on a topic.