Multi-agent code review system using CrewAI framework. A team of specialized AI agents that work together to review your code for best practices, quality, and security.
┌─────────────────────────────────────────────────────┐
│ CODE REVIEW CREW │
├─────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ ROOT AGENT (Manager) │ │
│ │ - Coordinates review process │ │
│ └──────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────────┼────────────────┐ │
│ │ │ │ │
│ ┌──┴────┐ ┌────┴───┐ ┌────┴────┐ │
│ │Code │ │Quality │ │Security │ │
│ │Review │ │Analyzer│ │Scanner │ │
│ │er │ │ │ │ │ │
│ └───────┘ └────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────┘
| Agent | Role | Focus Area |
|---|---|---|
| Code Reviewer | Senior Engineer | Best practices, design patterns, SOLID principles |
| Quality Analyst | Code Metrics Expert | Complexity, maintainability, technical debt |
| Security Scanner | Security Expert | Vulnerabilities, OWASP compliance |
- Python 3.10 or higher
- OpenAI API key
cd backend
pip install -r requirements.txtCreate a .env file in the backend directory:
cd backend
touch .envAdd your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
Or export as environment variable:
export OPENAI_API_KEY=your_api_key_herecd backend
python main.py path/to/your/code.py# Review a Python file
python main.py ../sample_code.py
# Review a TypeScript file
python main.py /path/to/project/src/auth.ts
# Review a JavaScript file
python main.py /path/to/project/src/utils.jsRun the built-in sample:
cd backend
python crew.pyThe crew produces a comprehensive review report containing:
- Overall assessment (Pass/Needs Improvement/Fail)
- Pattern violations with line references
- Severity levels (Low/Medium/High)
- Refactoring suggestions
- Quality score (1-10)
- Complexity analysis
- Maintainability index
- Technical debt indicators
- Security assessment (Secure/Moderate Risk/Critical)
- Vulnerability list with CVSS scores
- Remediation recommendations
crewai-code-reviewer/
├── README.md # This file
├── planning.md # Project planning documentation
└── backend/
├── main.py # CLI entry point
├── crew.py # Agents & Tasks definition
└── requirements.txt # Python dependencies
Edit crew.py to use a different model:
# In main.py, change the model parameter:
crew = CodeReviewCrew(model="gpt-4") # More powerful
# or
crew = CodeReviewCrew(model="gpt-4o-mini") # Cost effectiveSee crew.py - add new agents following the same pattern:
def _create_new_agent(self) -> Agent:
return Agent(
role="Your Agent Role",
goal="What this agent achieves",
backstory="Agent's expertise background",
verbose=True,
llm=self.llm
)Make sure your .env file exists and contains:
OPENAI_API_KEY=sk-...
Reinstall dependencies:
pip install -r requirements.txt --upgradeThe agents run in verbose mode by default. You'll see detailed logs of each agent's work.