Ask your agent
What it does
It takes pr url as input and performs in depth pr review with you sharing any token using git cli
SKILL.md
--- name: pr-review description: In-depth Bitbucket PR review via git CLI — checks duplicacy, runtime errors, coding standards, reusability, edge cases, test quality. Posts findings as comments. Use for "review PR", "pr-review", "bitbucket review", or "PR review". --- # Bitbucket PR Review Skill Deep-review a Bitbucket Server pull request using git CLI. No Bitbucket token needed for reading — git SSH handles that. Token only needed to post comments. ## Input The user provides a Bitbucket PR URL, e.g.: `` Parse it → project key, repo slug, PR number. ## Step 1: Fetch PR Branch and Determine Target ```bash # Fetch the PR source branch git fetch origin refs/pull-requests/<PR_NUMBER>/from:pr-<PR_NUMBER> # CRITICAL: Ask the user which branch the PR targets, or determine from context. # Bitbucket Server does not expose the target ref via git. # Common targets: release/staging/migration, master, develop # Fetch the target branch: git fetch origin <TARGET_BRANCH> # Use the TARGET branch for diffing, NOT origin/master (unless that IS the target) TARGET=origin/<TARGET_BRANCH> ``` ## Step 2: Gather Context ```bash # List commits unique to PR (against correct base!) git log --oneline pr-<PR_NUMBER> --not $TARGET # Diff stats against correct base git diff $TARGET...pr-<PR_NUMBER> --stat # Get full diff for source files only (skip lock files, generated, configs) git diff $TARGET...pr-<PR_NUMBER> -- '*.rs' '*.py' '*.ts' '*.js' '*.java' '*.go' '*.sh' # IMPORTANT: Only review code CHANGED in this diff. Do not flag issues # that exist in the target branch — those are pre-existing, not introduced by this PR. ``` ## Step 3: Review Checklist Perform exhaustive review across these dimensions: ### 3.1 Duplicacy & Reusability - Find duplicate code blocks (>5 lines similar) - Identify functions that could be extracted and shared - Check if existing utility functions are being reinvented - Look for copy-paste patterns across files (especially in similar modules) - `grep -rn` for identical logic in different files ### 3.2 Runtime Errors - Unwrap/expect on Option/Result without context (Rust) - Null/None dereferences - Integer overflow/underflow - Division by zero - Index out of bounds - Unclosed resources (files, connections, locks) - Race conditions in concurrent code - Panic paths in non-panic-safe contexts ### 3.3 Coding Standards - Naming conventions (snake_case for Rust, consistent across codebase) - Function length (flag >50 lines) - File organization (mod.rs, lib.rs structure) - Error handling patterns (use `?` not `.unwrap()` in library code) - Import organization - Dead code / unused imports - Magic numbers/strings that should be constants ### 3.4 Edge Cases - Empty collections / zero-length inputs - Unicode / special characters in string processing - Boundary values (0, MAX, negative) - Concurrent access patterns - Network timeouts / retries - Missing/null fields in deserialization - Large input sizes (memory/performance) ### 3.5 Test Quality - **Do NOT blindly trust test cases** — verify they actually test the right thing - Check test assertions match the function contract, not just "it doesn't crash" - Look for tests that always pass (tautological assertions) - Missing negative test cases - Missing edge case coverage - Mocked dependencies that hide real bugs - Test data that doesn't represent production scenarios - Tests that test implementation details instead of behavior ### 3.6 Security - SQL injection / command injection - Hardcoded credentials or secrets - Insecure deserialization - Path traversal - Improper input validation at API boundaries - Sensitive data in logs ### 3.7 Performance - N+1 queries or loops - Unnecessary cloning/copying - Missing indexes for DB queries - Unbounded collections growth - Blocking calls in async context ## Step 4: Output Format Generate findings in severity order: ``` ## 🔴 Critical - [file:line] Description of critical issue ## 🟡 Warning - [file:line] Description of warning ## 🔵 Suggestion - [file:line] Suggestion for improvement ## 🟢 Positive - Notable good patterns worth keeping ``` ## Step 5: Post Comments (Optional) If user provides a Bitbucket token, use the comment script: ```bash # General summary comment ~/.claude/scripts/bb-pr-comment.sh \ --url "<PR_URL>" \ --token "<TOKEN>" \ --comment "Review summary text" # Inline comment on specific file:line ~/.claude/scripts/bb-pr-comment.sh \ --url "<PR_URL>" \ --token "<TOKEN>" \ --file "src/foo.rs" \ --line 42 \ --comment "Issue description" # Batch from review file ~/.claude/scripts/bb-pr-comment.sh \ --url "<PR_URL>" \ --token "<TOKEN>" \ --from-file /tmp/review.md ``` Review file format: ``` ## General Summary of PR review findings... --- ## File: src/foo.rs:42 Inline comment about this line... --- ``` ## Strategy for Large PRs For PRs with 100+ files: 1. Start with most recent commits (they represent latest intent) 2. Focus on source code, skip generated/config/lock files 3. Group files by module — review module-by-module 4. Use `grep` to find cross-cutting concerns (error handling, logging patterns) 5. Prioritize new code over moved/renamed code 6. Spot-check tests rather than reading every test file 7. Use subagents for parallel file review when possible ## Notes - Always `git fetch` fresh before review - Compare against `origin/master` (or whatever the PR target branch is) - For Rust projects, check if `cargo clippy` and `cargo test` pass if available - Read CLAUDE.md / project conventions before applying standards
1 file
- SKILL.md5.5 KB