This guide covers how to use the automated code review framework for day-to-day development.
# Interactive PR selection
./scripts/review-pr.sh --interactive
# Review specific PR by name
./scripts/review-pr.sh --pr-name "Fix authentication bug"
# Dry run (show what would happen)
./scripts/review-pr.sh --pr-name "Test PR" --dry-run
# Verbose output for debugging
./scripts/review-pr.sh --pr-name "Test PR" --verbose| Option | Description | Example |
|---|---|---|
--pr-name NAME |
Review specific PR by name | --pr-name "Bug fix" |
--interactive |
Select from list of open PRs | --interactive |
--config PATH |
Use custom config directory | --config ./custom-config |
--dry-run |
Show analysis without creating comments | --dry-run |
--verbose |
Detailed output and logging | --verbose |
--help |
Show help message | --help |
Before running a review:
# Ensure your config is up to date
cat config/repositories.yaml
# Check available patterns
ls patterns/*/
# Verify MCP servers are working
superclaude "Test GitHub MCP by listing my repositories"The framework performs multi-stage analysis:
- Fetch PR Data: Gets diff, changed files, and metadata
- Pattern Matching: Applies detection rules from pattern library
- Sequential Analysis: Deep reasoning for complex architectural issues
- Issue Categorization: Groups and prioritizes findings
- Comment Generation: Creates targeted, actionable feedback
Review the generated analysis:
# Example output during analysis
[INFO] Starting code review for PR: Fix authentication bug
[INFO] Analyzing PR with sequential thinking and pattern detection...
[INFO] Found 3 critical issues, 5 high priority issues
[SUCCESS] Analysis complete! Results saved to /tmp/analysis_results.json| Severity | Description | Action Required |
|---|---|---|
| 🚨 Critical | Security vulnerabilities, data leaks | Must fix before merge |
| Code quality, breaking changes | Should fix before merge | |
| 🔵 Medium | Refactoring opportunities | Consider fixing |
| 🟢 Low | Style suggestions | Optional improvements |
- Architectural: System-wide patterns affecting multiple components
- File-level: Issues within individual modules or files
- One-liners: Simple fixes requiring minimal changes
- Integrations: Third-party library usage patterns
{
"pr_name": "Fix authentication bug",
"total_issues": 8,
"issues": [
{
"pattern": "manual-authorization-bypass",
"severity": "critical",
"category": "architectural",
"file": "lib/auth/permissions.ex",
"line": 45,
"description": "Manual role checking bypassing Bodyguard policies",
"time_minutes": 45,
"breaking_change_risk": "medium"
}
],
"summary": {
"critical": 1,
"high": 2,
"medium": 3,
"low": 2,
"total_time_hours": 2.5,
"estimated_cost_savings": 2250
}
}# Use custom config for different projects
./scripts/review-pr.sh --config ./project-specific-config --pr-name "PR Name"
# Override severity thresholds
# Edit config/severity-levels.yaml to customize# Review multiple PRs (script example)
for pr in "PR 1" "PR 2" "PR 3"; do
./scripts/review-pr.sh --pr-name "$pr" --dry-run
done# GitHub Actions example
name: Automated Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Code Review
run: |
git clone https://github.com/VMWepinion/elixir-code-review.git
cd elixir-code-review
./scripts/install.sh
- name: Run Review
run: |
cd elixir-code-review
./scripts/review-pr.sh --pr-name "${{ github.event.pull_request.title }}"For security-focused reviews:
# Focus on critical security patterns
./scripts/review-pr.sh --pr-name "Security fix" --config security-focused-configThe framework will prioritize:
- Manual authorization bypasses
- PubSub data leaks
- Authentication vulnerabilities
- Data exposure risks
For library integration reviews:
# Focus on specific integration patterns
# Configure patterns/integrations/ directory with relevant patternsCommon integration reviews:
- Ecto: Schema, migration, and query patterns
- Phoenix: Controller, view, and PubSub patterns
- Bodyguard: Authorization and policy patterns
- Mock: Testing and mocking patterns
🚨 **CRITICAL** Anti-pattern detected: Manual Authorization Bypass
**Issue**: Custom authorization logic bypassing established Bodyguard patterns
**Location**: `lib/auth/permissions.ex:45`
**Problem**:
```elixir
def can_access?(user, resource) do
user.role == "admin" || user.id == resource.owner_id
endRequired Fix:
case Bodyguard.permit(ResourcePolicy, :access, user, resource) do
:ok -> true
{:error, _} -> false
endTime Estimate: ~45 minutes to fix Breaking Change Risk: medium
### Summary Comment Example
```markdown
## 🤖 Automated Code Review Summary
**Total Issues Found**: 8
**Estimated Fix Time**: 2.5 hours
**Estimated Cost Savings**: $2,250
### Issues by Severity:
- 🚨 **Critical**: 1 (must fix before merge)
- ⚠️ **High**: 2
- 🔵 **Medium**: 3
- 🟢 **Low**: 2
### Quick Wins (< 10 min each):
- Fix variable naming in user_controller.ex:23
- Remove unused import in circle.ex:5
**Next Steps**:
1. Address critical security issues first
2. Focus on high-priority items
3. Batch similar issues for efficiency
- Start with Critical: Always address security issues first
- Batch Similar Issues: Group related problems for efficient fixing
- Use Dry Run: Test analysis before creating actual comments
- Regular Updates: Keep pattern library current with team learnings
- Shared Config: Use consistent configuration across team
- Pattern Contributions: Add team-specific patterns to the library
- Review Metrics: Track time savings and issue resolution rates
- Pattern Refinement: Update detection rules based on false positives
- New Patterns: Add patterns for newly discovered anti-patterns
- Feedback Loop: Incorporate team feedback into pattern descriptions
No issues found in obviously problematic code
- Check pattern files are properly formatted
- Verify detection rules match the code structure
- Test with
--verboseto see detailed analysis
Too many false positives
- Refine regex patterns in detection rules
- Add exclusion patterns to config
- Improve semantic analysis prompts
GitHub comments not appearing
- Check GitHub MCP server authentication
- Verify repository permissions
- Test with
--dry-runfirst
Analysis taking too long
- Limit file patterns in configuration
- Focus on specific pattern categories
- Use smaller PR sizes for testing
- Targeted Patterns: Only enable patterns relevant to your codebase
- File Filtering: Use specific file patterns to reduce analysis scope
- Incremental Reviews: Focus on changed files only
- Parallel Analysis: The framework supports concurrent pattern detection
- Learn Architecture: docs/architecture.md
- Add Custom Patterns: docs/adding-patterns.md
- View Examples: docs/examples/
- Customize Templates: Edit
config/github-templates.yaml
Last updated: 2025-08-19