suryanshp1/code-reviewer-ci
0
๐ค AI Code Reviewer Agent
Production-ready AI-powered code review using CrewAI multi-agent framework
Automatically review code changes with specialized AI agents analyzing security, performance, code quality, and maintainability.
๐ Quick Start
API Endpoints
Health Check
curl https://YOUR-USERNAME-YOUR-SPACE.hf.space/healthCode Review
curl -X POST https://YOUR-USERNAME-YOUR-SPACE.hf.space/review \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"diff": "diff --git a/app.py b/app.py\n+def login(user, pwd):\n+ query = f\"SELECT * FROM users WHERE user='\''{user}'\''\"",
"language": "python",
"context": {
"repo": "myorg/myrepo",
"pr_number": 123
}
}'๐ Multi-Agent Architecture
This system uses 5 specialized AI agents working in parallel:
โ๏ธ Configuration
Environment Variables
Required (set in Space Settings โ Variables):
LLM_PROVIDER-openaiorgroqOPENAI_API_KEYorGROQ_API_KEY- Your LLM API keyREVIEW_API_KEY- API key for authenticating requests
Optional:
RATE_LIMIT_PER_MINUTE- Max requests per minute (default: 5)REQUEST_TIMEOUT_SECONDS- Review timeout (default: 90)MAX_FINDINGS_PER_REVIEW- Max findings to return (default: 15)
Recommended LLM Configuration
For Free Tier:
LLM_PROVIDER=groq
GROQ_API_KEY=gsk_your_key_here
GROQ_MODEL=llama-3.3-70b-versatileFor Production:
LLM_PROVIDER=openai
OPENAI_API_KEY=sk_your_key_here
OPENAI_MODEL=gpt-4o-mini๐ API Response Format
{
"summary": "Found 2 security issues and 1 performance concern",
"score": 7.5,
"findings": [
{
"category": "security",
"severity": "high",
"file": "app/auth.py",
"line": 24,
"message": "SQL injection vulnerability detected",
"suggestion": "Use parameterized queries instead of string interpolation"
}
],
"metadata": {
"execution_time_ms": 15234,
"tokens_used": 12453,
"agent_count": 5,
"model": "gpt-4o-mini"
}
}๐ง GitHub Integration
Integrate with your CI/CD pipeline:
# .github/workflows/code-review.yml
- name: AI Code Review
run: |
curl -X POST https://YOUR-SPACE.hf.space/review \
-H "Authorization: Bearer ${{ secrets.REVIEW_API_KEY }}" \
-d @review_request.json๐ Performance
โ ๏ธ Limitations on Free Tier
- Single worker: Can handle 1 request at a time
- Cold starts: First request after sleep takes ~60 seconds
- Resource limits: 2 vCPU, 16GB RAM
- Timeouts: Long reviews may timeout (increase
REQUEST_TIMEOUT_SECONDS)
๐ Security
- API key authentication required for
/reviewendpoint - Rate limiting prevents abuse
- No data persistence (stateless reviews)
- Secrets managed via HF Space settings
๐ Documentation
Full documentation: GitHub Repository
๐ก Tips
- Use Groq for free tier - Faster and free API calls
- Keep diffs small - Large changes may timeout
- Set rate limits - Prevent quota exhaustion
- Monitor usage - Track LLM API costs
๐ Credits
Built with:
Made with โค๏ธ for better code reviews
