AI Code Review Tool
Overview
A minimalist code review tool that performs automated code reviews using AI
models. Available as both a CLI tool and a GitHub Action. Analyzes Git branch
differences and generates comprehensive review reports with structured output
for consistent, machine-parseable results.
Core Features
Deployment Options
- GitHub Action: Automated PR reviews with inline comments and summary
- CLI/Docker: Local reviews with markdown output
CLI Interface
Simple command-line interface with sensible defaults:
- Target Branch:
main (default) or user-specified (supports branch names
and commit hashes)
- Output File:
review_{current_branch_name}.md (default) or user-specified
- Additional Instructions: Optional markdown file with custom review
guidelines
- Verification Mode: Optional
--verify flag enables
Chain-of-Verification to reduce false
positives
- SAST Integration: Optional
--sast flag runs an
OpenGrep pre-scan to augment the AI
review with static analysis findings
The tool always reviews the currently checked out branch against the target
branch.
GitHub Action
The action wraps the CLI and provides:
- Inline review comments on specific lines
- Summary comment with all issues
- Automatic resolution of previous review threads on re-runs
- Filtering by confidence level (when verification is enabled)
Git Integration
- Works exclusively with Git repositories
- Analyzes differences between current branch (HEAD) and target branch
- Provides context-aware file analysis
AI Model Integration
- Multi-provider support:
- AWS Bedrock (default)
- Anthropic API
- Ollama (local models)
- Moonshot
- Factory pattern architecture: Each provider in separate file, easy to extend
- Framework: LangChain for AI orchestration
Context & Tools
The AI agent receives all review context upfront in the initial message:
- Commits: Full commit history between target branch and HEAD
- Changed files: List of files with change types and line counts
- Diffs: Complete diff content (truncated at 10k chars per file)
The agent also has access to these tools for additional analysis:
- read_file_part: Read specific sections of files (with line numbers)
- list_files: List files in the repository or specific directories
- search_in_files: Search for specific patterns or text across files
Design Principles
Minimalism
- Keep dependencies minimal
- Simple, focused functionality
- Clean, readable codebase
- No unnecessary features
Token Efficiency
- All tools support partial/chunked operations
- Avoid loading entire files when possible
- Smart diff viewing (context-aware snippets)
Extensibility
- Factory pattern for AI providers (function-based, matching tools pattern)
- Easy to add new model providers (one file + registry entry)
- Pluggable tool system
Architecture
Components
Python CLI:
- CLI Parser: Handle command-line arguments and defaults
- Git Interface: Interact with Git to get diffs, file lists, and content
- AI Provider Layer: Factory pattern with support for Bedrock, Anthropic,
Ollama, and Moonshot
- LangChain Agent: Orchestrate tools and AI to perform reviews
- Report Generator: Format and write Markdown review reports
GitHub Action (TypeScript):
- Docker Runner: Execute CLI via Docker with
--json output
- GitHub API: Post comments and reviews via Octokit
- Renderer: Convert JSON output to markdown comments
Workflow
- User invokes CLI with optional parameters
- Tool validates Git repository and determines current branch
- Extract changed files between current branch (HEAD) and target
- Initialize LangChain agent with tools
- Agent analyzes changes using available tools
- Generate comprehensive review in Markdown
- Write to output file
Output Format
All reviews use structured output rendered to markdown:
Summary Section
High-level overview of changes including:
- Overview of the main purpose
- Key changes made
- Potentially risky areas
Issues Summary Table
Quick overview of all issues with:
- Severity indicators (🔴 CRITICAL, 🟠 HIGH, 🟡 MEDIUM, 🟢 LOW)
- Title, category, and location
Detailed Issues
Each issue includes:
- Category: LOGIC, SECURITY, ACCESS_CONTROL, PERFORMANCE, QUALITY,
SIDE_EFFECTS, TESTING, DOCUMENTATION
- Severity: CRITICAL, HIGH, MEDIUM, LOW
- Location: File paths with optional line numbers
- Explanation: Detailed description of the problem
- Suggested Fix: Concrete recommendation with code snippets
Technology Stack
- Language: Python 3.11+
- AI Framework: LangChain + LangGraph
- AI Providers:
- AWS Bedrock (langchain-aws 1.1.0, boto3 1.42.15)
- Anthropic API (langchain-anthropic 1.3.0)
- Ollama (langchain-ollama 1.0.1)
- Moonshot (langchain-openai - OpenAI-compatible API)
- VCS: Git (via subprocess)
- CLI: argparse
- Output: Markdown (with mdformat for consistent formatting)
Success Criteria
- Simple one-command usage
- Fast and token-efficient
- High-quality, actionable reviews
- Easy to extend with new AI providers
- Minimal setup and configuration
1---2name: ai-code-review-tool3description: A minimalist code review tool that performs automated code reviews using AI models. Available as both a CLI tool and a GitHub Action.4---5# AI Code Review Tool67## Overview89A minimalist code review tool that performs automated code reviews using AI10models. Available as both a CLI tool and a GitHub Action. Analyzes Git branch11differences and generates comprehensive review reports with structured output12for consistent, machine-parseable results.1314## Core Features1516### Deployment Options1718- **GitHub Action**: Automated PR reviews with inline comments and summary19- **CLI/Docker**: Local reviews with markdown output2021### CLI Interface2223Simple command-line interface with sensible defaults:2425- **Target Branch**: `main` (default) or user-specified (supports branch names26 and commit hashes)27- **Output File**: `review_{current_branch_name}.md` (default) or user-specified28- **Additional Instructions**: Optional markdown file with custom review29 guidelines30- **Verification Mode**: Optional `--verify` flag enables31 [Chain-of-Verification](https://arxiv.org/abs/2309.11495) to reduce false32 positives33- **SAST Integration**: Optional `--sast` flag runs an34 [OpenGrep](https://github.com/opengrep/opengrep) pre-scan to augment the AI35 review with static analysis findings3637The tool always reviews the currently checked out branch against the target38branch.3940### GitHub Action4142The action wraps the CLI and provides:4344- Inline review comments on specific lines45- Summary comment with all issues46- Automatic resolution of previous review threads on re-runs47- Filtering by confidence level (when verification is enabled)4849### Git Integration5051- Works exclusively with Git repositories52- Analyzes differences between current branch (HEAD) and target branch53- Provides context-aware file analysis5455### AI Model Integration5657- **Multi-provider support:**58 - AWS Bedrock (default)59 - Anthropic API60 - Ollama (local models)61 - Moonshot62- Factory pattern architecture: Each provider in separate file, easy to extend63- Framework: LangChain for AI orchestration6465## Context & Tools6667The AI agent receives all review context upfront in the initial message:6869- **Commits**: Full commit history between target branch and HEAD70- **Changed files**: List of files with change types and line counts71- **Diffs**: Complete diff content (truncated at 10k chars per file)7273The agent also has access to these tools for additional analysis:74751. **read_file_part**: Read specific sections of files (with line numbers)762. **list_files**: List files in the repository or specific directories773. **search_in_files**: Search for specific patterns or text across files7879## Design Principles8081### Minimalism8283- Keep dependencies minimal84- Simple, focused functionality85- Clean, readable codebase86- No unnecessary features8788### Token Efficiency8990- All tools support partial/chunked operations91- Avoid loading entire files when possible92- Smart diff viewing (context-aware snippets)9394### Extensibility9596- Factory pattern for AI providers (function-based, matching tools pattern)97- Easy to add new model providers (one file + registry entry)98- Pluggable tool system99100## Architecture101102### Components103104**Python CLI:**1051061. **CLI Parser**: Handle command-line arguments and defaults1072. **Git Interface**: Interact with Git to get diffs, file lists, and content1083. **AI Provider Layer**: Factory pattern with support for Bedrock, Anthropic,109 Ollama, and Moonshot1104. **LangChain Agent**: Orchestrate tools and AI to perform reviews1115. **Report Generator**: Format and write Markdown review reports112113**GitHub Action (TypeScript):**1141151. **Docker Runner**: Execute CLI via Docker with `--json` output1162. **GitHub API**: Post comments and reviews via Octokit1173. **Renderer**: Convert JSON output to markdown comments118119### Workflow1201211. User invokes CLI with optional parameters1222. Tool validates Git repository and determines current branch1233. Extract changed files between current branch (HEAD) and target1244. Initialize LangChain agent with tools1255. Agent analyzes changes using available tools1266. Generate comprehensive review in Markdown1277. Write to output file128129## Output Format130131**All reviews use structured output** rendered to markdown:132133### Summary Section134135High-level overview of changes including:136137- Overview of the main purpose138- Key changes made139- Potentially risky areas140141### Issues Summary Table142143Quick overview of all issues with:144145- Severity indicators (🔴 CRITICAL, 🟠 HIGH, 🟡 MEDIUM, 🟢 LOW)146- Title, category, and location147148### Detailed Issues149150Each issue includes:151152- **Category**: LOGIC, SECURITY, ACCESS_CONTROL, PERFORMANCE, QUALITY,153 SIDE_EFFECTS, TESTING, DOCUMENTATION154- **Severity**: CRITICAL, HIGH, MEDIUM, LOW155- **Location**: File paths with optional line numbers156- **Explanation**: Detailed description of the problem157- **Suggested Fix**: Concrete recommendation with code snippets158159## Technology Stack160161- **Language**: Python 3.11+162- **AI Framework**: LangChain + LangGraph163- **AI Providers**:164 - AWS Bedrock (langchain-aws 1.1.0, boto3 1.42.15)165 - Anthropic API (langchain-anthropic 1.3.0)166 - Ollama (langchain-ollama 1.0.1)167 - Moonshot (langchain-openai - OpenAI-compatible API)168- **VCS**: Git (via subprocess)169- **CLI**: argparse170- **Output**: Markdown (with mdformat for consistent formatting)171172## Success Criteria173174- Simple one-command usage175- Fast and token-efficient176- High-quality, actionable reviews177- Easy to extend with new AI providers178- Minimal setup and configuration