| name | pull-request-review |
| description | Review a pull request by branch name or URL, using a git worktree |
Pull Request Review
Use this skill to review a pull request given a branch name or URL.
Input Formats
This skill accepts either:
- A branch name (e.g.,
feature/add-auth)
- A pull request URL from GitHub or GitLab (e.g.,
https://github.com/owner/repo/pull/123)
Workflow
Step 1: Parse Input
If given a URL, extract the pull request information:
gh pr view <url-or-number> --json headRefName --jq '.headRefName'
glab mr view <number> --output json | jq -r '.source_branch'
Step 2: Determine Repository Root
Find the root of the current git repository:
git rev-parse --show-toplevel
Step 3: Fetch and Verify the Branch
Fetch the branch from the remote and verify it exists:
git fetch origin <branch-name>
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.
Step 4: Create Worktree
Create a worktree in a sibling directory under worktree/:
REPO_ROOT=$(git rev-parse --show-toplevel)
WORKTREE_PATH="${REPO_ROOT}/../worktree/<branch-name>"
mkdir -p "${REPO_ROOT}/../worktree"
git worktree add "$WORKTREE_PATH" "origin/<branch-name>"
The worktree path follows the pattern ../worktree/<branch-name> relative to the repository root.
Step 5: Change to Worktree and Checkout Branch
Change the working directory to the new worktree and ensure the branch is checked out:
cd "$WORKTREE_PATH"
git checkout <branch-name>
git branch --show-current
Confirm the output matches the expected branch name before proceeding.
Step 6: Set Up the Repository
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.md
CONTRIBUTING.md
docs/ directory
DEVELOPMENT.md
SETUP.md
-
Follow the documented setup steps exactly. Common setup tasks include:
- Installing dependencies (
npm install, yarn, pip install, bundle install, etc.)
- Setting up environment variables
- Running database migrations
- Building assets or compiling code
-
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.
Step 7: Determine Base Branch
Identify the base branch for comparison:
gh pr view --json baseRefName --jq '.baseRefName'
glab mr view --output json | jq -r '.target_branch'
git branch -r | grep -E 'origin/(main|master)$' | head -1 | sed 's/.*origin\///'
Step 8: Load Code Review Skill
Load and follow the code-review skill to perform the actual review. The code-review skill provides guidance on:
- Scope determination using git diff
- Handling pre-existing code
- Convention compliance
- Test coverage philosophy
- Signal over noise (avoiding unactionable findings)
- Review checklist
Cleanup
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.
Error Handling
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:
- Branch does not exist remotely
- Worktree creation fails
- Checkout fails
- Setup commands fail
- CLI tools (gh, glab) are not available or not authenticated
Present the error output to the user and ask how they would like to proceed.