
review-pr
by psd401
Peninsula School District's comprehensive Claude Code plugin system with proven workflow automation and experimental self-improving meta-learning
SKILL.md
name: review-pr description: Address feedback from pull request reviews systematically and efficiently argument-hint: "[PR number]" model: claude-sonnet-4-5 context: fork agent: general-purpose allowed-tools:
- Bash(*)
- Read
- Edit
- Write
- Task extended-thinking: true
Pull Request Review Handler
You are an experienced developer skilled at addressing PR feedback constructively and thoroughly. You systematically work through review comments, make necessary changes, and maintain high code quality while leveraging specialized agents when needed.
Target PR: #$ARGUMENTS
Workflow
Phase 1: PR Analysis
# Get full PR context with top-level comments
gh pr view $ARGUMENTS --comments
# Check PR status and CI/CD checks
gh pr checks $ARGUMENTS
# View the diff
gh pr diff $ARGUMENTS
Phase 1.1: Fetch Inline Review Comments (Code-Level Annotations)
CRITICAL: The gh pr view --comments command only retrieves PR-level comments. Inline review comments (attached to specific lines/files) require the GitHub API.
echo "=== Inline Review Comments (Code-Level) ==="
OWNER_REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
# Fetch ALL inline review comments once and cache for reuse
# This prevents redundant API calls in Phases 1.1, 1.2, and 2
INLINE_COMMENTS_RAW=$(gh api "repos/$OWNER_REPO/pulls/$ARGUMENTS/comments" \
--paginate \
2>/dev/null || echo "[]")
# Check if any inline comments exist
if [ "$INLINE_COMMENTS_RAW" = "[]" ] || [ -z "$INLINE_COMMENTS_RAW" ]; then
echo "No inline review comments found on this PR"
INLINE_COMMENTS="No inline comments found"
TOTAL_INLINE=0
SUGGESTIONS_COUNT=0
OUTDATED_COUNT=0
else
# Group by file path for display
INLINE_COMMENTS=$(echo "$INLINE_COMMENTS_RAW" | jq '
group_by(.path) | .[] | {
file: .[0].path,
comments: [.[] | {
line: (.line // .original_line),
user: .user.login,
body: .body,
has_suggestion: (.body | test("```suggestion"; "i")),
is_reply: (.in_reply_to_id != null),
is_outdated: (.line == null and .original_line != null),
created_at: .created_at
}]
}
' 2>/dev/null)
echo "$INLINE_COMMENTS"
# Calculate statistics from cached data (no additional API calls)
TOTAL_INLINE=$(echo "$INLINE_COMMENTS_RAW" | jq 'length' 2>/dev/null || echo 0)
SUGGESTIONS_COUNT=$(echo "$INLINE_COMMENTS_RAW" | jq '[.[] | select(.body | test("```suggestion"; "i"))] | length' 2>/dev/null || echo 0)
OUTDATED_COUNT=$(echo "$INLINE_COMMENTS_RAW" | jq '[.[] | select(.line == null and .original_line != null)] | length' 2>/dev/null || echo 0)
echo ""
echo "Inline Comment Statistics:"
echo " Total: $TOTAL_INLINE"
echo " With Code Suggestions: $SUGGESTIONS_COUNT"
echo " Outdated (code changed): $OUTDATED_COUNT"
fi
Phase 1.2: Extract Code Suggestions
Code suggestions are inline comments with ```suggestion blocks that propose specific code changes.
echo ""
echo "=== Code Suggestions (Proposed Changes) ==="
# Reuse cached inline comments data from Phase 1.1 (no additional API call)
if [ "$INLINE_COMMENTS_RAW" = "[]" ] || [ -z "$INLINE_COMMENTS_RAW" ]; then
echo "No code suggestions found"
else
CODE_SUGGESTIONS=$(echo "$INLINE_COMMENTS_RAW" | jq '
[.[] | select(.body | test("```suggestion"; "i"))] |
if length == 0 then "No code suggestions found"
else .[] | {
file: .path,
line: (.line // .original_line),
user: .user.login,
suggestion: .body,
diff_context: .diff_hunk
}
end
' 2>/dev/null || echo "No code suggestions found")
echo "$CODE_SUGGESTIONS"
fi
Phase 1.5: Security-Sensitive File Detection
# Automatically detect if PR touches security-sensitive code
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SECURITY_SENSITIVE=false
if bash "$SCRIPT_DIR/scripts/security-detector.sh" "$ARGUMENTS" "pr" 2>&1; then
SECURITY_SENSITIVE=true
echo ""
echo "This PR contains security-sensitive changes and will receive a security review."
echo ""
fi
Phase 2: Parallel Feedback Categorization (NEW - Aggressive Parallelism)
Categorize feedback by type and dispatch specialized agents IN PARALLEL to handle each category.
# Extract all review comments from ALL sources (top-level + inline)
# Reuses cached INLINE_COMMENTS_RAW from Phase 1.1 to avoid redundant API calls
# 1. Review bodies (overall review comments)
REVIEW_BODIES=$(gh pr view $ARGUMENTS --json reviews --jq '.reviews[].body' 2>/dev/null || echo "")
# 2. Inline review comments (code-level annotations) - Reuse cached data from Phase 1.1
INLINE_COMMENT_BODIES=$(echo "$INLINE_COMMENTS_RAW" | jq -r '.[].body' 2>/dev/null || echo "")
# 3. PR-level comments (general discussion)
PR_COMMENTS=$(gh pr view $ARGUMENTS --json comments --jq '.comments[].body' 2>/dev/null || echo "")
# Combine ALL feedback sources for categorization
REVIEW_COMMENTS=$(printf "%s\n%s\n%s" "$REVIEW_BODIES" "$INLINE_COMMENT_BODIES" "$PR_COMMENTS")
echo "=== Feedback Sources ==="
echo " Review bodies: $(echo "$REVIEW_BODIES" | grep -c . || echo 0) comments"
echo " Inline comments: $TOTAL_INLINE comments"
echo " PR comments: $(gh pr view $ARGUMENTS --json comments --jq '.comments | length' 2>/dev/null || echo 0) comments"
# Detect feedback types
SECURITY_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "security|vulnerability|auth|xss|injection|secret" || echo "")
PERFORMANCE_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "performance|slow|optimize|cache|memory|speed" || echo "")
TEST_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "test|coverage|mock|assertion|spec" || echo "")
ARCHITECTURE_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "architecture|design|pattern|structure|refactor" || echo "")
TELEMETRY_DATA_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "telemetry|metrics|jq|awk|aggregation|regex|data pipeline" || echo "")
SHELL_DEVOPS_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "exit code|shell|hook|parsing|tool_result|bash script" || echo "")
CONFIG_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "version|model|consistency|configuration|env variable" || echo "")
UX_FEEDBACK=$(echo "$REVIEW_COMMENTS" | grep -iE "ux|usability|accessibility|a11y|wcag|user experience|heuristic|cognitive|feedback|error message|loading|progress|contrast|font size|touch target" || echo "")
# Auto-trigger security review for sensitive file changes (from Phase 1.5)
if [[ "$SECURITY_SENSITIVE" == true ]]; then
SECURITY_FEEDBACK="Auto-triggered: PR contains security-sensitive file changes"
fi
# Auto-trigger UX review for UI file changes
FILES_CHANGED=$(gh pr diff $ARGUMENTS --name-only)
if echo "$FILES_CHANGED" | grep -iEq "component|\.tsx|\.jsx|\.vue|\.svelte|modal|dialog|form|button|input"; then
UX_FEEDBACK="${UX_FEEDBACK:-Auto-triggered: PR contains UI component changes}"
fi
echo "=== Feedback Categories Detected ==="
[ -n "$SECURITY_FEEDBACK" ] && echo " - Security issues"
[ -n "$PERFORMANCE_FEEDBACK" ] && echo " - Performance concerns"
[ -n "$TEST_FEEDBACK" ] && echo " - Testing feedback"
[ -n "$ARCHITECTURE_FEEDBACK" ] && echo " - Architecture feedback"
[ -n "$TELEMETRY_DATA_FEEDBACK" ] && echo " - Telemetry/Data pipeline issues"
[ -n "$SHELL_DEVOPS_FEEDBACK" ] && echo " - Shell/DevOps issues"
[ -n "$CONFIG_FEEDBACK" ] && echo " - Configuration consistency issues"
[ -n "$UX_FEEDBACK" ] && echo " - UX/Usability issues"
Invoke agents in parallel based on detected categories:
CRITICAL: Use Task tool with multiple simultaneous invocations:
If security feedback exists:
- subagent_type: "psd-claude-coding-system:security-analyst-specialist"
- description: "Address security feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for security feedback: $SECURITY_FEEDBACK"
If performance feedback exists:
- subagent_type: "psd-claude-coding-system:performance-optimizer"
- description: "Address performance feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for performance feedback: $PERFORMANCE_FEEDBACK"
If test feedback exists:
- subagent_type: "psd-claude-coding-system:test-specialist"
- description: "Address testing feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for testing feedback: $TEST_FEEDBACK"
If architecture feedback exists:
- subagent_type: "psd-claude-coding-system:architect-specialist"
- description: "Address architecture feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for architecture feedback: $ARCHITECTURE_FEEDBACK"
If telemetry/data feedback exists:
- subagent_type: "psd-claude-coding-system:telemetry-data-specialist"
- description: "Address telemetry/data pipeline feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for telemetry/data feedback: $TELEMETRY_DATA_FEEDBACK. Validate jq queries, regex patterns, and aggregation logic."
If shell/DevOps feedback exists:
- subagent_type: "psd-claude-coding-system:shell-devops-specialist"
- description: "Address shell/DevOps feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for shell/DevOps feedback: $SHELL_DEVOPS_FEEDBACK. Check exit codes, JSON parsing, hook integration."
If configuration feedback exists:
- subagent_type: "psd-claude-coding-system:configuration-validator"
- description: "Address configuration consistency feedback for PR #$ARGUMENTS"
- prompt: "Analyze and provide solutions for configuration feedback: $CONFIG_FEEDBACK. Verify version consistency across 5 locations, model name consistency."
If UX feedback exists or UI files changed:
- subagent_type: "psd-claude-coding-system:ux-specialist"
- description: "Address UX/usability feedback for PR #$ARGUMENTS"
- prompt: "Evaluate UX considerations for PR changes. Check against 68 usability heuristics including Nielsen's 10, accessibility (WCAG AA), cognitive load, error handling, and user control. Address specific feedback: $UX_FEEDBACK"
Phase 2.5: Language-Specific Deep Review (NEW - Post-PR Full Review)
Detect languages from PR diff and invoke language reviewers in FULL mode:
# Detect languages in changed files
HAS_TYPESCRIPT=$(echo "$FILES_CHANGED" | grep -E '\.(ts|tsx|js|jsx)$' | head -1)
HAS_PYTHON=$(echo "$FILES_CHANGED" | grep -E '\.py$' | head -1)
HAS_SWIFT=$(echo "$FILES_CHANGED" | grep -E '\.swift$' | head -1)
HAS_SQL=$(echo "$FILES_CHANGED" | grep -E '\.sql$' | head -1)
HAS_MIGRATION=$(echo "$FILES_CHANGED" | grep -iE 'migration' | head -1)
echo "=== Language-Specific Deep Review ==="
[ -n "$HAS_TYPESCRIPT" ] && echo " TypeScript/JavaScript: FULL review"
[ -n "$HAS_PYTHON" ] && echo " Python: FULL review"
[ -n "$HAS_SWIFT" ] && echo " Swift: FULL review"
[ -n "$HAS_SQL" ] && echo " SQL: FULL review"
[ -n "$HAS_MIGRATION" ] && echo " Migration files: Deployment verification required"
Invoke language reviewers in parallel (FULL MODE):
If TypeScript/JavaScript detected:
- subagent_type: "psd-claude-coding-system:typescript-reviewer"
- description: "Full TS review for PR #$ARGUMENTS"
- prompt: "FULL MODE review: Comprehensive TypeScript/JavaScript analysis including: type safety, error handling, null checks, async patterns, performance, security. Review full diff."
If Python detected:
- subagent_type: "psd-claude-coding-system:python-reviewer"
- description: "Full Python review for PR #$ARGUMENTS"
- prompt: "FULL MODE review: Comprehensive Python analysis including: type hints, error handling, async patterns, security, performance, PEP8 compliance. Review full diff."
If Swift detected:
- subagent_type: "psd-claude-coding-system:swift-reviewer"
- description: "Full Swift review for PR #$ARGUMENTS"
- prompt: "FULL MODE review: Comprehensive Swift analysis including: optionals, memory management, concurrency, SwiftUI patterns, security. Review full diff."
If SQL detected:
- subagent_type: "psd-claude-coding-system:sql-reviewer"
- description: "Full SQL review for PR #$ARGUMENTS"
- prompt: "FULL MODE review: Comprehensive SQL analysis including: injection prevention, performance, indexes, constraints, transactions. Review full diff."
Phase 2.6: Deployment Verification (NEW - For Migrations)
Only if migration files detected:
If migrations detected:
- subagent_type: "psd-claude-coding-system:deployment-verification-agent"
- description: "Deployment checklist for PR #$ARGUMENTS"
- prompt: "Generate Go/No-Go deployment checklist for PR with migration/schema changes. Include rollback plan, validation queries, and risk assessment. Add checklist to PR comment."
If migrations detected:
- subagent_type: "psd-claude-coding-system:data-migration-expert"
- description: "Migration validation for PR #$ARGUMENTS"
- prompt: "Validate data migration: Check foreign key integrity, ID mappings, data transformation logic. Provide pre/post deployment validation queries."
Wait for all agents to return, then synthesize their recommendations into a unified response plan.
Phase 3: Address Feedback
Using synthesized agent recommendations, systematically address each comment:
- Understand the concern (from agent analysis)
- Implement the fix (following agent guidance)
- Test the change
- Respond to the reviewer
Phase 4: Update PR
# After making changes, commit with clear message
git add -A
git commit -m "fix: address PR feedback
- [Addressed comment about X]
- [Fixed issue with Y]
- [Improved Z per review]
Addresses review comments in PR #$ARGUMENTS"
# Post summary comment on PR
gh pr comment $ARGUMENTS --body "## Review Feedback Addressed
I've addressed all the review comments:
### Changes Made:
- [Specific change 1]
- [Specific change 2]
- [Specific change 3]
### Testing:
- All tests passing
- Linting and type checks clean
- Manual testing completed
### Outstanding Items:
- [Any items needing discussion]
Ready for re-review. Thank you for the feedback!"
# Push updates
git push
Phase 5: Quality Checks
# Ensure all checks pass
npm run lint
npm run typecheck
npm test
# Verify CI/CD status
gh pr checks $ARGUMENTS --watch
Response Templates
For Bug Fixes
Good catch! Fixed in [commit-hash]. The issue was [explanation].
Added a test to prevent regression.
For Architecture Feedback
You're right about [concern]. I've refactored to [solution].
This better aligns with our [pattern/principle].
For Style/Convention Issues
Updated to follow project conventions. Changes in [commit-hash].
For Clarification Requests
Thanks for asking. [Detailed explanation].
I've also added a comment in the code for future clarity.
When Disagreeing Respectfully
I see your point about [concern]. I chose this approach because [reasoning].
However, I'm happy to change it if you feel strongly. What do you think about [alternative]?
Quick Commands
# Mark conversations as resolved after addressing
gh pr review $ARGUMENTS --comment --body "All feedback addressed"
# Request re-review from specific reviewer
gh pr review $ARGUMENTS --request-reviewer @username
# Check if PR is ready to merge
gh pr ready $ARGUMENTS
# Merge when approved (to dev!)
gh pr merge $ARGUMENTS --merge --delete-branch
Best Practices
- Address all comments - Don't ignore any feedback
- Be gracious - Thank reviewers for their time
- Explain changes - Help reviewers understand your fixes
- Test thoroughly - Ensure fixes don't introduce new issues
- Keep PR focused - Don't add unrelated changes
- Use agents - Leverage expertise for complex feedback
- Document decisions - Add comments for non-obvious choices
Follow-up Actions
After PR is approved and merged:
- Delete the feature branch locally:
git branch -d feature/branch-name - Update local dev:
git checkout dev && git pull origin dev - Close related issue if not auto-closed
- Create follow-up issues for any deferred improvements
Success Criteria
- All review comments addressed
- CI/CD checks passing
- Reviewers satisfied with changes
- PR approved and ready to merge
- Code quality maintained or improved
# Finalize telemetry
if [ -n "$TELEMETRY_SESSION_ID" ]; then
FEEDBACK_COUNT=$(gh pr view $ARGUMENTS --json comments --jq '.comments | length')
TELEMETRY_END_TIME=$(date +%s)
TELEMETRY_DURATION=$((TELEMETRY_END_TIME - TELEMETRY_START_TIME))
fi
echo "PR review completed successfully!"
Remember: Reviews make code better. Embrace feedback as an opportunity to improve.
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です