AI-powered code review for GitHub Pull Requests using Claude AI. Automatically analyzes code changes and posts contextual comments on PRs.
This tool automates code reviews by:
- Fetching PR diffs from GitHub
- Analyzing code changes using AI
- Posting review comments directly on specific lines
- Using customizable review guidelines from skills files
The web interface lets you paste any GitHub Pull Request URL, track review progress in real time, and see PR metadata — all from a clean dark-themed dashboard. Key UI elements:
- Pull Request URL input with one-click Reviewing... trigger
- Review Progress tracker (Initializing → Parsing → Fetching → AI Analysis → Validate → Post Comments)
- PR summary card showing branch info, files changed, and diff size
# Clone and setup
git clone <repository-url>
cd ReviewPulse
./setup.sh
# Configure API keys
cp .env.example .env
# Edit .env with your GitHub and Anthropic API keys
# Run a review
python src/review_pr.py https://github.com/owner/repo/pull/123See SETUP.md for detailed installation instructions.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ GitHub API │────▶│ PR Review Agent │────▶│ Claude AI API │
│ (PR/Diff) │ │ │ │ (Code Analysis) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────┐
│ Skills DB │
│ (Review │
│ Guidelines) │
└──────────────┘
Handles all GitHub interactions:
- DiffParser: Parses PR diffs to identify changed lines and file positions
- GitHubClient: Uses GitHub CLI (
gh) to fetch PR data and post reviews - Line Mapping: Accurately maps diff positions to actual file line numbers
Key features:
- Converts PR URLs to owner/repo/number tuples
- Extracts added/modified lines from diffs
- Posts review comments in pending state (batch mode)
- Handles existing pending reviews
AI-powered code analysis engine:
- ReviewComment: Dataclass for individual review findings
- ReviewSummary: Aggregated review results
- LLMReviewer: Orchestrates AI analysis
Key features:
- Smart pattern extraction from skills.md (only loads relevant patterns)
- Structured prompting for consistent AI responses
- Retry logic with multiple attempts
- Severity-based prioritization (Critical → Info)
Utility module for accurate line positioning:
- Parses diff headers (
@@ -old,old_count +new,new_count @@) - Maps diff positions to actual file line numbers
- Verifies comment placement accuracy
- Provides line reference tables for debugging
Claude Desktop integration:
- Implements Model Context Protocol (MCP)
- Exposes tools for Claude Desktop to invoke
- Handles
review_prandanalyze_prcommands - Returns structured JSON responses
CLI interface and orchestration:
- Validates environment (GitHub CLI, API keys)
- Filters and adjusts AI-generated comments
- Deduplicates comments by file/line
- Sorts by severity (critical first)
- Posts comments or shows dry-run preview
1. User provides PR URL
↓
2. Parse URL → owner/repo/PR#
↓
3. Fetch PR metadata + diff (via GitHub CLI)
↓
4. Parse diff → Map line numbers
↓
5. Load relevant patterns from skills.md
↓
6. Send to Claude AI with structured prompt
↓
7. Parse AI response → ReviewComment objects
↓
8. Filter/validate comments against diff
↓
9. Sort by severity + deduplicate
↓
10. Post to GitHub (or dry-run preview)
The skills/skill.md file contains domain-specific review patterns:
## Topics
- Error Handling (1233 patterns)
- External API Design
- Type Safety
- Testing
- Security
- Performance
...Smart Loading: The system only loads patterns relevant to the PR:
- Extracts keywords from PR diff (connector names, struct names, patterns)
- Scores each pattern by relevance (0-100)
- Loads top-scoring patterns up to 40,000 char limit
- Ensures AI receives focused, actionable guidance
- No credentials in code: API keys loaded from
.envfile (gitignored) - Minimal GitHub permissions: Only requires
reposcope - Local processing: All code stays local, only API calls go to external services
- Audit trail: All actions logged to stdout
ReviewPulse/
├── src/ # Core source code
│ ├── review_pr.py # CLI entry point
│ ├── github_client.py # GitHub API integration
│ ├── llm_reviewer.py # AI review generation
│ ├── mcp_server.py # Claude Desktop MCP server
│ └── line_number_helper.py # Line number utilities
├── skills/
│ └── skill.md # Review guidelines database
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
├── setup.sh # Setup script
├── review_pr.sh # Convenience wrapper
├── run_review.sh # Quick test script
├── claude-desktop-config.json # MCP configuration template
├── README.md # This file
└── SETUP.md # Detailed setup guide
# Dry run (review only, don't post)
python src/review_pr.py https://github.com/owner/repo/pull/123
# Post comments to GitHub
POST_COMMENTS=true python src/review_pr.py <URL>
# Alternative formats
python src/review_pr.py owner/repo#123
python src/review_pr.py owner/repo/pull/123
# Using wrapper script
./review_pr.sh https://github.com/owner/repo/pull/123 --post| Variable | Description | Default |
|---|---|---|
GITHUB_TOKEN |
GitHub Personal Access Token | required |
ANTHROPIC_API_KEY |
Claude AI API key | required |
ANTHROPIC_BASE_URL |
Custom API endpoint | anthropic.com |
ANTHROPIC_MODEL |
Model selection | claude-3-5-sonnet-20241022 |
POST_COMMENTS |
Enable posting to GitHub | false |
MAX_COMMENTS |
Maximum comments per review | 30 |
SKILLS_PATH |
Path to skill guidelines | ./skills/skill.md |
| Level | Icon | Description |
|---|---|---|
| Critical | 🔴 | Crashes, data loss, security vulnerabilities |
| High | 🟠 | Functional issues, major bugs |
| Medium | 🟡 | Code quality, potential issues |
| Low | 🟢 | Style, minor suggestions |
| Info | ℹ️ | Documentation, observations |
Configure Claude Desktop to use this as an MCP tool:
- Open Claude Desktop → Settings → Developer → Edit Config
- Add the MCP server configuration from
claude-desktop-config.json - Replace paths and API keys with your values
- Restart Claude Desktop
Now you can ask Claude:
Review this PR: https://github.com/owner/repo/pull/123
Edit skills/skill.md to add your team's review standards:
## Pattern N
### Insight
Description of the pattern/rule
### Example
```language
// Good code example// Bad code example
Patterns are automatically scored and filtered based on PR content.
## Troubleshooting
| Issue | Solution |
|-------|----------|
| "GITHUB_TOKEN not found" | Check `.env` file exists and token is valid |
| "Failed to fetch PR diff" | Verify `gh auth status` and token has `repo` scope |
| "No comments posted" | Set `POST_COMMENTS=true` in `.env` |
| Comments on wrong lines | Check line number mapping in debug output |
| Empty review | Verify API key and check skills.md patterns |
## Development
### Running Tests
```bash
# Activate environment
source venv/bin/activate
# Test line number helper
python -c "from src.line_number_helper import calculate_line_numbers; print('OK')"
# Dry run test
python src/review_pr.py <URL> --dry-run
- New AI Provider: Extend
LLMReviewerclass with new client - New Review Rules: Add patterns to
skills/skill.md - Custom Filters: Modify
filter_and_adjust_comments()inreview_pr.py
- Never commit
.envfiles (already in.gitignore) - Rotate API keys regularly
- Use GitHub tokens with minimal scopes (
repoonly) - Review code before enabling
POST_COMMENTS=true - Run in dry-run mode first to validate behavior
MIT License - Feel free to modify for your team!
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check SETUP.md for setup help
- Review this README for usage examples
- Open an issue on GitHub
