Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CrewAI Code Reviewer

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.

Architecture

┌─────────────────────────────────────────────────────┐
│                  CODE REVIEW CREW                   │
├─────────────────────────────────────────────────────┤
│                                                     │
│  ┌──────────────────────────────────────────────┐  │
│  │  ROOT AGENT (Manager)                         │  │
│  │  - Coordinates review process                 │  │
│  └──────────────────────────────────────────────┘  │
│                     │                               │
│    ┌────────────────┼────────────────┐             │
│    │                │                │             │
│ ┌──┴────┐      ┌────┴───┐      ┌────┴────┐        │
│ │Code   │      │Quality │      │Security  │        │
│ │Review │      │Analyzer│      │Scanner   │        │
│ │er     │      │        │      │          │        │
│ └───────┘      └────────┘      └──────────┘        │
│                                                     │
└─────────────────────────────────────────────────────┘

Agents

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

Installation

1. Prerequisites

  • Python 3.10 or higher
  • OpenAI API key

2. Install Dependencies

cd backend
pip install -r requirements.txt

3. Set Up API Key

Create a .env file in the backend directory:

cd backend
touch .env

Add your OpenAI API key:

OPENAI_API_KEY=your_api_key_here

Or export as environment variable:

export OPENAI_API_KEY=your_api_key_here

Usage

Review a Single File

cd backend
python main.py path/to/your/code.py

Examples

# 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.js

Quick Test

Run the built-in sample:

cd backend
python crew.py

Output

The crew produces a comprehensive review report containing:

Code Review Report

  • Overall assessment (Pass/Needs Improvement/Fail)
  • Pattern violations with line references
  • Severity levels (Low/Medium/High)
  • Refactoring suggestions

Quality Analysis Report

  • Quality score (1-10)
  • Complexity analysis
  • Maintainability index
  • Technical debt indicators

Security Report

  • Security assessment (Secure/Moderate Risk/Critical)
  • Vulnerability list with CVSS scores
  • Remediation recommendations

File Structure

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

Customization

Change Model

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 effective

Add New Agents

See 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
    )

Troubleshooting

"API key not found" Error

Make sure your .env file exists and contains:

OPENAI_API_KEY=sk-...

Import Errors

Reinstall dependencies:

pip install -r requirements.txt --upgrade

Verbose Output

The agents run in verbose mode by default. You'll see detailed logs of each agent's work.

References

About

CrewAI Code Reviewer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages