Back to agents
Agent #1

šŸ‘ļø Automated Code Review Agent

This agent performs comprehensive code reviews by analyzing code files, checking for quality issues, security vulnerabilities, and suggesting improvements. It can review pull requests or individual files. python 01_code_review.py /path/to/code.py python 01_code_review.py "Review this function for bugs"

Key Features

  • āœ“Security vulnerability detection
  • āœ“Code quality analysis
  • āœ“Best practice enforcement
  • āœ“Performance issue identification
  • āœ“Actionable feedback

Implementation

Download .py
01_code_review.py
#!/usr/bin/env python3
"""
Automated Code Review Agent

This agent performs comprehensive code reviews by analyzing code files,
checking for quality issues, security vulnerabilities, and suggesting
improvements. It can review pull requests or individual files.

Usage:
    python 01_code_review.py /path/to/code.py
    python 01_code_review.py "Review this function for bugs"
"""

import asyncio
import sys
from anthropic import Anthropic

def main():
    if len(sys.argv) < 2:
        print("Usage: python 01_code_review.py <file_path_or_description>")
        sys.exit(1)

    target = " ".join(sys.argv[1:])

    client = Anthropic()

    system_prompt = """You are an expert code reviewer. Your job is to:
1. Analyze code for bugs, security issues, and code smells
2. Check for adherence to best practices and conventions
3. Identify performance issues and optimization opportunities
4. Provide constructive, actionable feedback
5. Suggest specific improvements with examples

Be thorough but encouraging. Format your review with clear sections:
- Summary of findings
- Critical issues (security, bugs)
- Code quality improvements
- Best practice violations
- Performance opportunities
- Positive aspects to keep doing"""

    task = f"""Please perform a comprehensive code review for the following:

{target}

Provide a detailed analysis covering:
1. Security vulnerabilities
2. Code quality and maintainability
3. Performance concerns
4. Test coverage gaps
5. Documentation issues"""

    print("šŸ” Starting Code Review Agent...\n")
    print("=" * 60)

    try:
        with client.messages.stream(
            model="claude-opus-4-7",
            max_tokens=2000,
            system=system_prompt,
            messages=[{"role": "user", "content": task}],
        ) as stream:
            for text in stream.text_stream:
                print(text, end="", flush=True)

        print("\n" + "=" * 60)
        print("\nāœ… Code review complete!")

    except Exception as e:
        print(f"\nāŒ Error: {e}")
        sys.exit(1)


if __name__ == "__main__":
    main()

How to Use

This agent is designed to be run from the command line:

python 01_code_review.py <input>

The agent will stream its response to the console as it works through the task. Use Ctrl+C to interrupt at any time.

Quick Download

01_code_review.py
File
01_code_review.py
Language
Python 3.8+
Dependencies
anthropic

Setup

  1. 1. Install: pip install anthropic
  2. 2. Download the .py file
  3. 3. Set ANTHROPIC_API_KEY
  4. 4. Run: python 01_code_review.py