CodeRabbit-style PR review with security scanning, test coverage, and one-click fixes
Comprehensive CodeRabbit-style PR review with automated security scanning, test coverage analysis, and one-click fix generation. Use it to get deep code reviews before merging.
/plugin marketplace add bejranonda/LLM-Autonomous-Agent-Plugin-for-Claude/plugin install bejranonda-autonomous-agent@bejranonda/LLM-Autonomous-Agent-Plugin-for-Claudedev/Execute a comprehensive CodeRabbit-style review of a pull request with automated analysis, security scanning, and one-click fixes.
/dev:pr-review [PR_NUMBER|BRANCH_NAME]
Examples:
/dev:pr-review 123 # Review PR #123
/dev:pr-review feature/auth # Review branch against main
/dev:pr-review # Review current branch changes
Execute comprehensive review via pr-reviewer agent:
const review_result = await delegate_to_pr_reviewer({
pr_number: pr_number,
pr_data: {
title: pr_title,
author: pr_author,
description: pr_description,
files: changed_files,
diff: full_diff,
commits: commit_history
}
});
The PR reviewer agent executes:
A. Summary Generation (5-10s):
B. Line-by-Line Analysis (30-60s):
C. Security Scan (20-40s via security-auditor):
D. Test Coverage Analysis (15-30s):
E. Automated Fix Generation (10-20s):
F. Risk Assessment (5-10s):
G. Related PR Detection (5-10s):
Generate comprehensive review report:
# Pull Request Review: #{PR_NUMBER}
## ๐ Summary
**Risk Level**: {RISK_LEVEL} ({RISK_SCORE}/100)
Files: {COUNT} | +{ADDITIONS} -{DELETIONS} | Complexity: {SCORE}/100
## ๐ Security ({VULN_COUNT} issues)
๐ด Critical: {COUNT} | ๐ High: {COUNT} | ๐ก Medium: {COUNT}
## ๐ Test Coverage
{COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%) | Untested: {COUNT}
## ๐ก Code Review ({ISSUE_COUNT} issues)
{DETAILED_REVIEWS_BY_FILE}
## โก Performance ({ISSUE_COUNT} concerns)
{PERFORMANCE_ISSUES}
## ๐ฏ Recommendations
### Critical ({COUNT})
### Suggested ({COUNT})
### Nice to Have ({COUNT})
## โ
Approval Checklist
- [ ] All critical issues resolved
- [ ] Test coverage adequate
- [ ] No new vulnerabilities
- [ ] Performance acceptable
Provide one-click fix application:
# Auto-fixable issues presented with "Apply Fix" option
# User can select fixes to apply
# System applies fixes and creates commit
This command leverages:
ast-analyzer:
security-patterns:
contextual-pattern-learning:
code-analysis:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
PR REVIEW COMPLETE: #{PR_NUMBER}
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Overview
Risk Level: {RISK_LEVEL} ({RISK_SCORE}/100)
Files: {COUNT} | +{ADDITIONS} -{DELETIONS}
Complexity: {SCORE}/100
๐ Security Analysis
๐ด Critical: {COUNT} | ๐ High: {COUNT} | ๐ก Medium: {COUNT}
Total New Vulnerabilities: {COUNT}
๐ Test Coverage
Coverage: {COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%)
Untested Functions: {COUNT}
๐ก Top 3 Issues
1. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
2. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
3. {SEVERITY} - {FILE}:{LINE} - {ISSUE}
๐ฏ Top 3 Recommendations
1. {CRITICAL_RECOMMENDATION}
2. {SUGGESTED_IMPROVEMENT}
3. {NICE_TO_HAVE}
โ
Auto-fixable Issues: {COUNT}/{TOTAL}
๐ Detailed Report: .data/reports/pr-review/pr-{NUMBER}-{DATE}.md
โฑ๏ธ Review completed in {DURATION}
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Saved to: .data/reports/pr-review/pr-{NUMBER}-{YYYY-MM-DD}.md
Full Report Structure:
# Pull Request Review: #{PR_NUMBER}
**Generated**: {TIMESTAMP}
**Review Time**: {DURATION}
**Reviewer**: Autonomous PR Review Agent v1.0
---
## Table of Contents
1. [Summary](#summary)
2. [Security Analysis](#security-analysis)
3. [Test Coverage](#test-coverage)
4. [Code Review](#code-review)
5. [Performance Analysis](#performance-analysis)
6. [Recommendations](#recommendations)
7. [Related PRs](#related-prs)
8. [Approval Checklist](#approval-checklist)
---
## Summary
**Title**: {PR_TITLE}
**Author**: {AUTHOR}
**Status**: {STATUS}
**Risk Level**: {RISK_LEVEL} ({RISK_SCORE}/100)
### Changes Overview
- **Files Changed**: {COUNT}
- **Lines Added**: +{ADDITIONS}
- **Lines Removed**: -{DELETIONS}
- **Complexity Score**: {SCORE}/100
### Change Categories
- โจ **Features**: {COUNT} files
- {FILE_LIST}
- ๐ **Bug Fixes**: {COUNT} files
- {FILE_LIST}
- โป๏ธ **Refactoring**: {COUNT} files
- {FILE_LIST}
- ๐ **Documentation**: {COUNT} files
- {FILE_LIST}
- โ
**Tests**: {COUNT} files
- {FILE_LIST}
### Risk Factors
| Factor | Score | Weight | Impact |
|--------|-------|--------|--------|
| Size | {SCORE}/100 | 20% | {IMPACT} |
| Complexity | {SCORE}/100 | 25% | {IMPACT} |
| Test Coverage | {SCORE}/100 | 25% | {IMPACT} |
| Critical Files | {SCORE}/100 | 20% | {IMPACT} |
| Security | {SCORE}/100 | 10% | {IMPACT} |
---
## Security Analysis
**New Vulnerabilities Detected**: {COUNT}
### Critical Issues (๐ด)
#### {VULN_TITLE_1}
- **File**: `{FILE_PATH}`
- **Line**: {LINE_NUMBER}
- **Severity**: CRITICAL
- **CWE**: CWE-{NUMBER} - {CWE_NAME}
- **OWASP**: {OWASP_CATEGORY}
**Vulnerable Code**:
```{LANGUAGE}
{VULNERABLE_CODE}
Description: {DETAILED_DESCRIPTION}
Remediation:
{FIXED_CODE}
Explanation: {EXPLANATION}
Auto-fixable: {YES/NO}
[Apply Fix] (One-click button)
{SIMILAR_STRUCTURE}
{SIMILAR_STRUCTURE}
{SIMILAR_STRUCTURE}
Overall Coverage: {COVERAGE}% ({DELTA > 0 ? '+' : ''}{DELTA}%)
| File | Before | After | Delta | Untested Functions |
|---|---|---|---|---|
| {FILE} | {BEFORE}% | {AFTER}% | {DELTA}% | {COUNT} |
{FUNCTION_NAME} (line {LINE}){FUNCTION_NAME} (line {LINE})Suggested Test:
{SUGGESTED_TEST_CODE}
Severity: {CRITICAL/HIGH/MEDIUM/LOW} Category: {CODE_QUALITY/BEST_PRACTICE/PERFORMANCE}
Original Code:
{ORIGINAL_CODE}
Issue: {DETAILED_ISSUE_DESCRIPTION}
Suggested Fix:
{SUGGESTED_CODE}
Explanation: {WHY_THIS_IS_BETTER}
Auto-fixable: {YES/NO} Confidence: {CONFIDENCE}%
[Apply Fix] (One-click button)
{SIMILAR_STRUCTURE}
Potential Performance Impact: {LOW/MEDIUM/HIGH}
Detected Pattern: Loop with database query inside
Current Code:
{CURRENT_CODE}
Optimized Code:
{OPTIMIZED_CODE}
Performance Improvement: {ESTIMATED_IMPROVEMENT}
{SIMILAR_STRUCTURE}
{SIMILAR_STRUCTURE}
{SIMILAR_STRUCTURE}
{CRITICAL_ISSUE_1}
{CRITICAL_ISSUE_2} {SIMILAR_STRUCTURE}
{IMPROVEMENT_1}
{IMPROVEMENT_2} {SIMILAR_STRUCTURE}
Review Generated: {TIMESTAMP} Review Time: {DURATION} Auto-fixable Issues: {COUNT}/{TOTAL} Confidence Score: {AVERAGE_CONFIDENCE}%
Reviewer Agent: pr-reviewer v1.0 Security Scanner: security-auditor v1.0 AST Analyzer: ast-analyzer v1.0 Pattern Learner: contextual-pattern-learning v3.0
{COUNT} issues can be fixed automatically. Apply all fixes with:
/apply-pr-fixes {PR_NUMBER}
Or apply individual fixes:
/apply-fix {ISSUE_ID}
End of Report
---
## Implementation Details
### Git Integration
```python
def fetch_pr_data(pr_identifier):
"""Fetch PR data from git or GitHub CLI."""
if pr_identifier.isdigit():
# Use gh CLI for PR number
pr_data = subprocess.run(
["gh", "pr", "view", pr_identifier, "--json",
"title,author,body,files,additions,deletions"],
capture_output=True
)
else:
# Use git for branch comparison
diff = subprocess.run(
["git", "diff", f"origin/main...{pr_identifier}"],
capture_output=True
)
commits = subprocess.run(
["git", "log", f"origin/main..{pr_identifier}",
"--oneline"],
capture_output=True
)
return parse_pr_data(pr_data)
def apply_fix(issue_id):
"""Apply automated fix for specific issue."""
issue = load_issue(issue_id)
if not issue.auto_fixable:
print("Issue not auto-fixable")
return False
# Apply Edit tool
Edit(
file_path=issue.file,
old_string=issue.original_code,
new_string=issue.suggested_code
)
# Run tests to verify
test_result = run_tests()
if test_result.success:
# Create commit
git_commit(f"Fix: {issue.title}\n\nAuto-applied fix from PR review")
return True
else:
# Rollback
git_checkout(issue.file)
return False
After each PR review, the learning engine captures:
Review Patterns:
Project Patterns:
Performance Metrics:
Continuous Improvement:
try:
review_result = comprehensive_pr_review(pr_number)
except GitError as e:
print(f"Git error: {e.message}")
print("Ensure you're in a git repository and PR exists")
except SecurityScanError as e:
print(f"Security scan failed: {e.message}")
print("Review will continue with partial results")
except Exception as e:
print(f"Review failed: {e}")
print("Saving partial results...")
save_partial_review(partial_data)
| PR Size | Files | Lines | Review Time |
|---|---|---|---|
| Small | 1-5 | <200 | 30-60s |
| Medium | 6-15 | 200-500 | 1-2min |
| Large | 16-30 | 500-1000 | 2-4min |
| XLarge | 31+ | 1000+ | 4-8min |
After review:
/apply-pr-fixes {PR_NUMBER} # Apply all auto-fixable issues
/apply-fix {ISSUE_ID} # Apply specific fix
/dev:pr-review-history # Show review history
/learn:analytics # Review performance analytics
This command provides comprehensive, CodeRabbit-level PR review capabilities with deep integration into the autonomous learning system.
/pr-reviewConduct comprehensive PR review from multiple perspectives (PM, Developer, QA, Security)
/pr-reviewRevisรฃo sistemรกtica de Pull Request para garantir qualidade do cรณdigo e sanidade da arquitetura.