From git-workflow
Review any Pull Request with AI-assisted analysis and inline comments (GitHub/GitLab/Bitbucket)
npx claudepluginhub julien92/claude-code-marketplace --plugin git-workflow[PR number]## Context - Current branch: !`git branch --show-current` - Uncommitted changes: !`git status --porcelain` - Remote URL: !`git remote get-url origin` - Provider cache: !`cat .claude/jc-marketplace/git-workflow/cache.md 2>/dev/null || echo "not cached"` ## Your task Help the user review a Pull Request with AI-assisted analysis. You will: 1. Save current context (stash) 2. List and checkout the PR 3. Analyze each file and suggest comments 4. Post inline comments 5. Restore context 6. Show final summary with PR link **If Provider cache shows "not cached"**, create the cache file at `.claud...
git branch --show-currentgit status --porcelaingit remote get-url origincat .claude/jc-marketplace/git-workflow/cache.md 2>/dev/null || echo "not cached"Help the user review a Pull Request with AI-assisted analysis. You will:
If Provider cache shows "not cached", create the cache file at .claude/jc-marketplace/git-workflow/cache.md following the plugin-cache skill, then continue.
Based on the provider in cache:
github โ use gh CLIgitlab โ use glab CLIbitbucket โ use curl API with bitbucket_workspace and bitbucket_repo from cacheStore the current branch name for later restoration.
If there are uncommitted changes (git status --porcelain is not empty):
git stash push -m "git-review-context-$(date +%s)"
For Bitbucket repos, use these values from the Provider cache throughout:
bitbucket_workspace โ use in API URLs as the workspacebitbucket_repo โ use in API URLs as the repository nameGitHub:
gh pr list --state open --limit 20 --json number,title,author,headRefName,additions,deletions
GitLab:
glab mr list --state opened --per-page 20
Bitbucket: (replace <bitbucket_workspace> and <bitbucket_repo> with values from Provider cache)
curl -sN -u "${BITBUCKET_EMAIL}:${BITBUCKET_API_TOKEN}" \
"https://api.bitbucket.org/2.0/repositories/<bitbucket_workspace>/<bitbucket_repo>/pullrequests?state=OPEN&pagelen=20" \
> /tmp/bitbucket_prs.json && \
jq -r '.values[] | "PR #\(.id) | \(.source.branch.name) -> \(.destination.branch.name) | \(.title) | by \(.author.display_name)"' /tmp/bitbucket_prs.json
Display the list and ask the user which PR they want to review.
GitHub:
gh pr checkout <pr-number>
GitLab:
glab mr checkout <mr-iid>
Bitbucket: Get the source branch from the PR, then:
git fetch origin <source-branch>
git checkout <source-branch>
GitHub:
COMMIT_ID=$(gh pr view <pr-number> --json headRefOid -q .headRefOid)
BASE_BRANCH=$(gh pr view <pr-number> --json baseRefName -q .baseRefName)
REPO_OWNER=$(gh repo view --json owner -q .owner.login)
REPO_NAME=$(gh repo view --json name -q .name)
GitLab:
PROJECT_ID=$(glab api projects/:fullpath -q .id)
BASE_SHA=$(glab api projects/:fullpath/merge_requests/<mr-iid> -q .diff_refs.base_sha)
HEAD_SHA=$(glab api projects/:fullpath/merge_requests/<mr-iid> -q .diff_refs.head_sha)
START_SHA=$(glab api projects/:fullpath/merge_requests/<mr-iid> -q .diff_refs.start_sha)
BASE_BRANCH=$(glab api projects/:fullpath/merge_requests/<mr-iid> -q .target_branch)
Bitbucket: (use workspace/repo from Provider cache)
curl -sN -u "${BITBUCKET_EMAIL}:${BITBUCKET_API_TOKEN}" \
"https://api.bitbucket.org/2.0/repositories/<bitbucket_workspace>/<bitbucket_repo>/pullrequests/{pr_id}" > /tmp/pr_info.json
BASE_BRANCH=$(jq -r '.destination.branch.name' /tmp/pr_info.json)
Get the absolute path of the repository root and fetch the changed files:
REPO_ROOT=$(git rev-parse --show-toplevel)
git fetch origin $BASE_BRANCH
git diff origin/$BASE_BRANCH...HEAD --name-only
Before analyzing files individually, read the complete diff to understand the overall changes:
git diff origin/$BASE_BRANCH...HEAD
This gives you the full picture of all modifications. Use this context to provide better, more coherent suggestions during the file-by-file review (e.g., understanding how a new field flows through layers, spotting inconsistencies across files).
For each changed file:
Read the full file and explore related files if needed: Read the changed file to understand the context. If understanding the changes requires additional context (imported modules, interfaces, base classes, called functions, etc.), read those files too. Use your judgment to determine what's relevant.
Get the diff (you will display it to the user in step 4):
git diff origin/$BASE_BRANCH...HEAD -- <file>
Also extract FIRST_LINE from the first @@ hunk header (e.g. @@ -97,6 +97,7 @@ โ line 97).
Analyze the code in context and provide:
Present to user โ IMPORTANT: Follow this exact format for IDE clickability:
๐ [X/Y] (+N/-M lines)
โธ $REPO_ROOT/<filepath>:$FIRST_LINE
๐ฏ PR: <brief one-line description of the PR objective>
๐ Changes:
<Show the diff content here so user can see the modifications>
๐ Analysis:
<Brief explanation of what this code does and how it fits in the existing structure>
๐ฌ Review comments:
1. L:<line> [<type>] <issue description>
โ "<comment text to post>"
2. L:<line> [<type>] <issue description>
โ "<comment text to post>"
Types: [bug] [security] [perf] [style] [logic] [question]
Actions:
- "1" โ post comment 1
- "2" โ post comment 2
- "edit 1 <your text>" โ modify and post
- "add L:<line> <message>" โ custom comment
- "next" โ next file
- "done" โ finish review
GitHub:
gh api repos/$REPO_OWNER/$REPO_NAME/pulls/<pr-number>/comments \
-f body="<comment>" \
-f path="<filepath>" \
-f commit_id="$COMMIT_ID" \
-f line=<line_number> \
-f side=RIGHT
For deleted lines, use side=LEFT.
GitLab:
glab api projects/$PROJECT_ID/merge_requests/<mr-iid>/discussions -X POST \
-f body="<comment>" \
-f "position[base_sha]=$BASE_SHA" \
-f "position[head_sha]=$HEAD_SHA" \
-f "position[start_sha]=$START_SHA" \
-f "position[new_path]=<filepath>" \
-f "position[new_line]=<line_number>" \
-f "position[position_type]=text"
For deleted lines, use old_path and old_line instead.
Bitbucket: (use workspace/repo from Provider cache)
curl -X POST -u "${BITBUCKET_EMAIL}:${BITBUCKET_API_TOKEN}" \
"https://api.bitbucket.org/2.0/repositories/<bitbucket_workspace>/<bitbucket_repo>/pullrequests/{pr_id}/comments" \
-H "Content-Type: application/json" \
-d '{
"content": {"raw": "<comment>"},
"inline": {
"path": "<filepath>",
"to": <line_number>
}
}'
Ask the user how to finalize:
GitHub:
gh pr review <pr-number> --approve
# or
gh pr review <pr-number> --request-changes --body "<summary>"
# or
gh pr review <pr-number> --comment --body "<summary>"
GitLab:
glab mr approve <mr-iid>
# or post a summary note
glab mr note <mr-iid> --message "<summary>"
Bitbucket: (use workspace/repo from Provider cache)
# Approve
curl -X POST -u "${BITBUCKET_EMAIL}:${BITBUCKET_API_TOKEN}" \
"https://api.bitbucket.org/2.0/repositories/<bitbucket_workspace>/<bitbucket_repo>/pullrequests/{pr_id}/approve"
# or Request changes (post comment)
curl -X POST -u "${BITBUCKET_EMAIL}:${BITBUCKET_API_TOKEN}" \
"https://api.bitbucket.org/2.0/repositories/<bitbucket_workspace>/<bitbucket_repo>/pullrequests/{pr_id}/comments" \
-H "Content-Type: application/json" \
-d '{"content": {"raw": "<summary>"}}'
git checkout <original-branch>
If we stashed changes earlier:
git stash pop
Present a complete summary of the review:
โ
PR Review Complete
๐ Summary:
- PR: #<number> - <title>
- Status: <approved โ
| changes requested ๐ | commented ๐ฌ | skipped โญ๏ธ>
- Files reviewed: X/Y
- Comments posted: N
๐ฌ Comments posted:
1. <filepath>:L<line> - "<comment summary>"
2. <filepath>:L<line> - "<comment summary>"
...
๐ View PR: <pr-url>
Get the PR URL:
gh pr view <pr-number> --json url -q .urlglab mr view <mr-iid> --web (or construct from remote URL)https://bitbucket.org/<bitbucket_workspace>/<bitbucket_repo>/pull-requests/{pr_id}curl | jq), prefer saving to a temporary file first then processing, as direct pipes may fail in some execution contexts:
# Instead of: curl -s "url" | jq '...'
# Use: curl -s "url" > /tmp/file.json && jq '...' /tmp/file.json
Do not use any other tools or do anything else beyond the PR review workflow described above.