Review pr

From NJX-njx/opensoul · View interactive version

Review pr is an AI agent skill from the GitHub repository NJX-njx/opensoul. Review-only GitHub pull request analysis with the gh CLI. Use when asked to review a PR, provide structured feedback, or assess readiness to land. Do not merge, push, or make code changes you intend to keep.

How to use this skill

Skill file

Review PR

See also: pr-workflow for the full PR workflow and maintainer checkpoints.

Overview

Perform a thorough review-only PR assessment and return a structured recommendation on readiness for /preparepr.

Inputs

Safety

Execution Rule

Known Failure Modes

Writing Style for Output

Completion Criteria

First: Create a TODO Checklist

Create a checklist of all review steps, print it, then continue and execute the commands.

Setup: Use a Worktree

Use an isolated worktree for all review work.

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT"
# Sanity: confirm you are in the repo
git rev-parse --show-toplevel

WORKTREE_DIR=".worktrees/pr-<PR>"
git fetch origin main

# Reuse existing worktree if it exists, otherwise create new
if [ -d "$WORKTREE_DIR" ]; then
  cd "$WORKTREE_DIR"
  git checkout temp/pr-<PR> 2>/dev/null || git checkout -b temp/pr-<PR>
  git fetch origin main
  git reset --hard origin/main
else
  git worktree add "$WORKTREE_DIR" -b temp/pr-<PR> origin/main
  cd "$WORKTREE_DIR"
fi

# Create local scratch space that persists across /reviewpr to /preparepr to /mergepr
mkdir -p .local

Run all commands inside the worktree directory.

Start on origin/main so you can check for existing implementations before looking at PR code.

Steps

  1. Identify PR meta and context
gh pr view <PR> --json number,title,state,isDraft,author,baseRefName,headRefName,headRepository,url,body,labels,assignees,reviewRequests,files,additions,deletions --jq '{number,title,url,state,isDraft,author:.author.login,base:.baseRefName,head:.headRefName,headRepo:.headRepository.nameWithOwner,additions,deletions,files:.files|length,body}'
  1. Check if this already exists in main before looking at the PR branch
# Use keywords from the PR title and changed files
rg -n "<keyword_from_pr_title>" -S src packages apps ui || true
rg -n "<function_or_component_name>" -S src packages apps ui || true

git log --oneline --all --grep="<keyword_from_pr_title>" | head -20

If it already exists, call it out as a BLOCKER or at least IMPORTANT.

  1. Claim the PR

Assign yourself so others know someone is reviewing. Skip if the PR looks like spam or is a draft you plan to recommend closing.

gh_user=$(gh api user --jq .login)
gh pr edit <PR> --add-assignee "$gh_user"
  1. Read the PR description carefully

Use the body from step 1. Summarize goal, scope, and missing context.

  1. Read the diff thoroughly

Minimum:

gh pr diff <PR>

If you need full code context locally, fetch the PR head to a local ref and diff it. Do not create a merge commit.

git fetch origin pull/<PR>/head:pr-<PR>
# Show changes without modifying the working tree

git diff --stat origin/main..pr-<PR>
git diff origin/main..pr-<PR>

If you want to browse the PR version of files directly, temporarily check out pr-<PR> in the worktree. Do not commit or push. Return to temp/pr-<PR> and reset to origin/main afterward.

# Use only if needed
# git checkout pr-<PR>
# ...inspect files...

git checkout temp/pr-<PR>
git reset --hard origin/main
  1. Validate the change is needed and valuable

Be honest. Call out low value AI slop.

  1. Evaluate implementation quality

Review correctness, design, performance, and ergonomics.

  1. Perform a security review

Assume OpenSoul subagents run with full disk access, including git, gh, and shell. Check auth, input validation, secrets, dependencies, tool safety, and privacy.

  1. Review tests and verification

Identify what exists, what is missing, and what would be a minimal regression test.

  1. Check docs

Check if the PR touches code with related documentation such as README, docs, inline API docs, or config examples.

  1. Check changelog

Check if CHANGELOG.md exists and whether the PR warrants an entry.

  1. Answer the key question

Decide if /preparepr can fix issues or the contributor must update the PR.

  1. Save findings to the worktree

Write the full structured review sections A through J to .local/review.md.

Create or overwrite the file and verify it exists and is non-empty.

ls -la .local/review.md
wc -l .local/review.md
  1. Output the structured review

Produce a review that matches what you saved to .local/review.md.

A) TL;DR recommendation

B) What changed

C) What is good

D) Security findings

E) Concerns or questions (actionable)

F) Tests

G) Docs status

H) Changelog

I) Follow ups (optional)

J) Suggested PR comment (optional)

Guardrails

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.