AI-powered multi-agent system for automated React performance analysis in Pull Requests using Google's Agent Development Kit (ADK) and Gemini models.
- π€ Multi-Agent Analysis: Four-stage AI pipeline (Parser β Analyzer β Reasoner β Reporter)
- π§ Smart Memory System: Tracks patterns across files, detects recurring issues, learns project conventions
- π Inline PR Comments: Posts detailed review comments on specific lines
- π― Smart Detection: Identifies critical React performance issues
- βοΈ Configurable: Severity thresholds and auto-approval settings
- π³ Docker Ready: One-command deployment anywhere
- π PR URL Support: Analyze PRs by URL, no manual configuration needed
- π GitHub Action: Automated reviews on every PR
- Inline functions/objects breaking
React.memo - Stale closures in hooks
- Missing dependency arrays causing infinite loops
- Unstable hook dependencies
- Unnecessary re-renders
- Derived state anti-patterns
- Inline JSX expressions
- Props not used in render
- State management issues
- Minor optimizations
- Best practice suggestions
5-Agent Multi-Agent System orchestrated via Google ADK's SequentialAgent:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PR Analysis Flow β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β File N β [Memory Agent] β "Pattern summary: 10 inline functions..." β
β β β
β [Sequential Agent Pipeline] β
β ββ Parser Agent (Babel AST parsing) β
β ββ Analyzer Agent (Issue detection - 8 tools) β
β ββ Reasoner Agent (Prioritization + context) β
β ββ Reporter Agent (GitHub/JSON output) β
β β β
β Store Summary β DatabaseSessionService β
β β
β PR Done β Clear Database β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 5-AGENT MULTI-AGENT SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π§ Memory Agent β Cross-file pattern detection β
β Provides ~50 word summary to pipeline β
β β
β π Parser Agent β parse_code() - Babel AST extraction β
β π Analyzer Agent β 8 specialized tools for issue detection β
β π‘ Reasoner Agent β Prioritizes issues, adds suggestions β
β π Reporter Agent β Formats output for GitHub PR reviews β
β β
β [SequentialAgent orchestration: Parser β Analyzer β Reasoner β Reporter] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Configuration: Set USE_MULTI_AGENT=false for single-agent mode (faster, less specialized)
Tech Stack:
- π§ Google Gemini 2.5 Flash Lite
- π§ Google ADK (Agent Development Kit) with SequentialAgent
- πΎ DatabaseSessionService (Persistent SQLite)
- π€ 5 Specialized Agents (Memory, Parser, Analyzer, Reasoner, Reporter)
- π Babel Parser (AST analysis)
- π Python 3.12+
- π¦ Node.js 20+
- π³ Docker & Docker Compose
# 1. Clone the repository
git clone <repository-url>
cd code-review-agent
# 2. Copy and configure environment
cp .env.example .env
# Edit .env with your API keys
# 3. Build and run
docker-compose build
docker-compose run code-review-agent python3 agents/main.py examples/UserList.tsx
# 4. Analyze a PR
docker-compose run code-review-agent ./review-pr.sh <PR_URL> --analyze-only# 1. Install dependencies
cd parser && npm install && npm run build && cd ..
cd agents && pip install -r requirements.txt && cd ..
# 2. Configure environment
cp .env.example agents/.env
# Edit agents/.env with your API keys
# 3. Run analysis
python3 agents/main.py examples/UserList.tsx
# 4. Review a PR
./review-pr.sh <PR_URL> --analyze-only-
Google AI API Key
- Get from: https://makersuite.google.com/app/apikey
- Set as:
GOOGLE_API_KEYin.env
-
GitHub Personal Access Token (for PR reviews)
- Get from: https://github.com/settings/tokens
- Required scopes:
repo(full control) - Set as:
GITHUB_TOKENin.env
- Docker: 20.10+ (recommended), or
- Python: 3.12+
- Node.js: 20+
- Memory: 2GB minimum
- Storage: 500MB
# Docker
docker-compose run code-review-agent python3 agents/main.py examples/UserList.tsx
# Local
python3 agents/main.py examples/UserList.tsx [markdown|json|github]# Dry run (no comments posted)
./review-pr.sh https://github.com/owner/repo/pull/123 --analyze-only
# Post review with default settings
./review-pr.sh https://github.com/owner/repo/pull/123
# High severity only
./review-pr.sh https://github.com/owner/repo/pull/123 --severity high
# Auto-approve if no critical issues
./review-pr.sh https://github.com/owner/repo/pull/123 --auto-approveThe action runs automatically on PRs that touch React/TypeScript files.
Setup:
- Add
GOOGLE_API_KEYto repository secrets - Workflow file is already configured at
.github/workflows/react-perf-review.yml - Push changes and open a PR
# Required
GOOGLE_API_KEY=your-google-api-key-here
GITHUB_TOKEN=your-github-token-here
# Optional
GITHUB_REPOSITORY=owner/repo # Not needed if using PR URLs
DEBUG_ANALYSIS=0 # Set to 1 for debug output
SEVERITY_THRESHOLD=medium # low|medium|high|critical
AUTO_APPROVE=false # Auto-approve clean PRs| Level | Reports | Blocks Merge |
|---|---|---|
critical |
Only critical issues | Yes |
high |
Critical + High | On critical only |
medium |
Critical + High + Medium | On critical only |
low |
All issues | On critical only |
# React Performance Analysis Report
## Summary
- π¨ 2 critical issues
- β οΈ 1 high-priority issues
- π‘ 3 medium-priority issues
## π¨ Critical Issues
### `src/Button.tsx:42` - Button
**Inline function breaks memoization**
**Problem:** Arrow function recreates on every render...
**Suggestion:** Use useCallback...{
"issues": [
{
"file": "src/Button.tsx",
"line": 42,
"severity": "critical",
"title": "Inline function breaks memoization",
"problem": "...",
"suggestion": "..."
}
],
"summary": {
"critical_count": 2,
"high_count": 1,
"files_analyzed": 3
}
}Posted as inline review comments on specific lines with:
- π¨ Severity indicator
- Problem description
- Suggestion with code examples
- Runtime Impact explanation
docker-compose build# Analyze file
docker-compose run code-review-agent python3 agents/main.py examples/UserList.tsx
# Review PR
docker-compose run code-review-agent ./review-pr.sh <PR_URL> --analyze-only
# Interactive shell
docker-compose run code-review-agent /bin/bash# 1. Copy files to server
scp -r . user@server:/app/code-review-agent
# 2. SSH into server
ssh user@server
# 3. Run with docker-compose
cd /app/code-review-agent
docker-compose build
docker-compose run code-review-agent <command>docker-compose run code-review-agent \
python3 agents/main.py examples/UserList.tsxOutput: Identifies inline function creating new reference on each render.
docker-compose run code-review-agent \
./review-pr.sh https://github.com/facebook/react/pull/28977 --analyze-onlyOutput: Analyzes all React files in the PR and shows results.
./review-pr.sh https://github.com/owner/repo/pull/123 --severity highResult: Posts inline comments on high and critical issues.
code-review-agent/
βββ parser/ # TypeScript AST parser (Babel)
β βββ src/
β β βββ analyzer.ts # AST analysis logic
β β βββ cli.ts # CLI interface
β β βββ types.ts # Type definitions
β βββ package.json
β
βββ agents/ # Python agents
β βββ agents.py # ADK agent definitions
β βββ main.py # Orchestrator
β βββ tools.py # Analysis tools
β βββ github_integration.py # PR integration
β βββ requirements.txt
β
βββ .github/workflows/ # GitHub Actions
β βββ react-perf-review.yml
β
βββ examples/ # Sample React files
βββ Dockerfile # Docker image
βββ docker-compose.yml # Docker Compose config
βββ README.md
- SETUP.md - Detailed installation guide
- PROJECT_SUMMARY.md - Architecture overview
1. "GOOGLE_API_KEY not set"
# Make sure .env file exists and is loaded
cp .env.example .env
# Edit .env with your key2. Parser errors
# Rebuild parser
cd parser && npm run build3. Docker build fails
# Clean build
docker-compose build --no-cache4. Analysis returns empty results
- File may be too large (>1000 lines)
- Check DEBUG_ANALYSIS=1 for details
- Try analyzing smaller files first
Built with:
- Google Gemini - AI models
- Google ADK - Agent framework
- Babel - JavaScript parser
- GitHub API - PR integration
If you find this useful, please star the repo! It helps others discover the project.
Made with β€οΈ for the React community
Catch performance issues before they reach production π