🔍 Code Review Automation
Automated code review for GitHub pull requests using Claude LLM
Automatically analyze GitHub pull requests, provide intelligent code reviews, security scanning, and style checking using Claude AI.
✨ Features
- - PR Listing - View all pull requests in a repository
- PR Details - Get comprehensive information about any PR
- File Changes - See exactly what files changed
- PR Search - Search PRs by keyword
- Repository Info - Get general repository statistics
- Claude Analysis - AI-powered code review using Claude LLM
- Code Quality Scoring - Automated quality assessment (0-100)
- Security Scanning - Automated security vulnerability detection
- Style Checking - Automated style and linting checks
- Full Review - Complete review with all checks
- Configurable - Custom rules via INLINECODE0
🚀 Quick Start
1. Install Dependencies
CODEBLOCK0
2. Setup GitHub API Token
Get your GitHub Personal Access Token:
- 1. Go to GitHub Settings → Developer settings → Personal access tokens
- Generate a new token with
repo scope - Create
.env file:
CODEBLOCK1
3. Review Pull Requests
CODEBLOCK2
📋 Commands
list-prs
List pull requests from a repository.
CODEBLOCK3
Options:
- -
--state: PR state (open, closed, all) - default: open - INLINECODE5 : Maximum PRs to show - default: 10
pr-info
Show detailed information about a specific PR.
CODEBLOCK4
Shows:
- - Title and description
- Author and timestamps
- File change statistics
- Labels and merge status
pr-files
Show files changed in a PR.
CODEBLOCK5
Shows:
- - Changed files
- Status (added, modified, deleted)
- Additions and deletions per file
search-prs
Search pull requests by keyword.
CODEBLOCK6
Options:
- -
--query: Search keyword (required) - INLINECODE10 : PR state (open, closed, all) - default: open
- INLINECODE11 : Maximum PRs to show - default: 10
repo-info
Show general repository information.
CODEBLOCK7
Shows:
- - Repository name and description
- Programming language
- Stars and forks count
- Open issues and PRs
- Creation and update dates
review-pr
Analyze a pull request using Claude AI.
CODEBLOCK8
Shows:
- - AI-powered code review
- Code quality score (0-100)
- Security considerations
- Best practices
- Specific recommendations
Requires:
- -
GITHUB_TOKEN in INLINECODE15 - INLINECODE16 in INLINECODE17
security-scan
Scan a pull request for security vulnerabilities.
CODEBLOCK9
Detects:
- - Exposed secrets (API keys, tokens, passwords)
- SQL injection vulnerabilities
- Command injection vulnerabilities
- Hardcoded credentials
- Weak cryptography (MD5, SHA1, RC4, DES)
- Unsafe deserialization (pickle)
Options:
- -
--config: Configuration file path
style-check
Check a pull request for style and linting issues.
CODEBLOCK10
Checks:
- - Line length violations
- Naming convention violations
- Import order
- Blank lines
- Whitespace issues
- Missing docstrings
Options:
- -
--config: Configuration file path
full-review
Run full code review (LLM + Security + Style) on a pull request.
CODEBLOCK11
Combines:
- - LLM analysis (code quality score)
- Security scanning
- Style checking
Options:
- -
--config: Configuration file path - INLINECODE24 : Skip LLM analysis
- INLINECODE25 : Skip security scan
- INLINECODE26 : Skip style check
config-init
Initialize a default configuration file.
CODEBLOCK12
Creates a .reviewrc file with customizable settings for:
- - Security scanning rules
- Style checking rules
- LLM analysis settings
🔧 Technical Details
GitHub API Integration
- - Uses PyGithub library
- Authenticates with Personal Access Token
- Rate limit handled automatically
LLM Integration
- - Claude API for code analysis
- Intelligent code review comments
- Context-aware suggestions
- Code quality scoring
Security Scanning
- - Static analysis for common vulnerabilities
- Pattern-based detection
- Severity-based categorization
- Configurable rules
Style Checking
- - PEP8 compliance checks
- Naming convention validation
- Line length enforcement
- Import order verification
- Whitespace checks
Configuration
- - YAML/JSON config files
- Project-specific settings
- Customizable thresholds
- INLINECODE29 support
📊 Examples
CODEBLOCK13
🔐 Security
- - GitHub PAT stored in
.env file (never committed) - No secrets logged or displayed
- IP whitelist recommended
🚧 Roadmap
v0.2.0 - Claude Integration (Completed)
- - Claude API integration
- Automated PR analysis
- Intelligent review comments
- Code quality scoring
v0.3.0 - Security & Style (Current)
- - Security vulnerability scanning
- Style and linting checks
- Automated fix suggestions
- Configuration file support
- Full review command
v1.0.0 (Planned)
- - Multi-platform support (GitLab, Bitbucket)
- CI/CD integration
- Team collaboration features
- Review dashboard
📄 License
MIT
🙋 Support
For issues or questions:
- - Check the documentation
- Open an issue on GitHub
🔍 代码审查自动化
使用Claude LLM对GitHub拉取请求进行自动化代码审查
利用Claude AI自动分析GitHub拉取请求,提供智能代码审查、安全扫描和风格检查。
✨ 功能特性
- - PR列表 - 查看仓库中的所有拉取请求
- PR详情 - 获取任意PR的全面信息
- 文件变更 - 精确查看哪些文件发生了变更
- PR搜索 - 按关键词搜索拉取请求
- 仓库信息 - 获取仓库基本统计信息
- Claude分析 - 基于Claude LLM的AI驱动代码审查
- 代码质量评分 - 自动化质量评估(0-100分)
- 安全扫描 - 自动化安全漏洞检测
- 风格检查 - 自动化代码风格和lint检查
- 完整审查 - 包含所有检查的完整审查
- 可配置 - 通过.reviewrc自定义规则
🚀 快速开始
1. 安装依赖
bash
uv pip install PyGithub anthropic rich typer python-dotenv
2. 设置GitHub API令牌
获取您的GitHub个人访问令牌:
- 1. 前往GitHub设置 → 开发者设置 → 个人访问令牌
- 生成一个具有repo作用域的新令牌
- 创建.env文件:
env
GITHUB_TOKEN=您的GitHub个人访问令牌
3. 审查拉取请求
bash
列出开放的PR
code-review list-prs 所有者/仓库
显示PR详情
code-review pr-info 所有者/仓库 123
显示变更的文件
code-review pr-files 所有者/仓库 123
使用Claude AI分析PR
code-review review-pr 所有者/仓库 123
📋 命令
list-prs
列出仓库中的拉取请求。
bash
code-review list-prs 所有者/仓库
选项:
- - --state:PR状态(open, closed, all)- 默认:open
- --limit:最多显示的PR数量 - 默认:10
pr-info
显示特定PR的详细信息。
bash
code-review pr-info 所有者/仓库 123
显示内容:
- - 标题和描述
- 作者和时间戳
- 文件变更统计
- 标签和合并状态
pr-files
显示PR中变更的文件。
bash
code-review pr-files 所有者/仓库 123
显示内容:
- - 变更的文件
- 状态(新增、修改、删除)
- 每个文件的增删行数
search-prs
按关键词搜索拉取请求。
bash
code-review search-prs 所有者/仓库 --query bug
选项:
- - --query:搜索关键词(必填)
- --state:PR状态(open, closed, all)- 默认:open
- --limit:最多显示的PR数量 - 默认:10
repo-info
显示仓库基本信息。
bash
code-review repo-info 所有者/仓库
显示内容:
- - 仓库名称和描述
- 编程语言
- Star和Fork数量
- 开放的Issues和PRs
- 创建和更新日期
review-pr
使用Claude AI分析拉取请求。
bash
code-review review-pr 所有者/仓库 123
显示内容:
- - AI驱动的代码审查
- 代码质量评分(0-100)
- 安全考量
- 最佳实践
- 具体建议
需要:
- - .env中的GITHUBTOKEN
- .env中的ANTHROPICAPI_KEY
security-scan
扫描拉取请求中的安全漏洞。
bash
code-review security-scan 所有者/仓库 123
检测内容:
- - 泄露的密钥(API密钥、令牌、密码)
- SQL注入漏洞
- 命令注入漏洞
- 硬编码凭据
- 弱加密(MD5、SHA1、RC4、DES)
- 不安全的反序列化(pickle)
选项:
style-check
检查拉取请求中的代码风格和lint问题。
bash
code-review style-check 所有者/仓库 123
检查内容:
- - 行长度违规
- 命名规范违规
- 导入顺序
- 空行
- 空白字符问题
- 缺少文档字符串
选项:
full-review
对拉取请求运行完整代码审查(LLM + 安全 + 风格)。
bash
code-review full-review 所有者/仓库 123
组合内容:
选项:
- - --config:配置文件路径
- --skip-llm:跳过LLM分析
- --skip-security:跳过安全扫描
- --skip-style:跳过风格检查
config-init
初始化默认配置文件。
bash
code-review config-init --output .reviewrc
创建一个.reviewrc文件,包含以下可自定义设置:
🔧 技术细节
GitHub API集成
- - 使用PyGithub库
- 通过个人访问令牌进行身份验证
- 自动处理速率限制
LLM集成
- - 用于代码分析的Claude API
- 智能代码审查评论
- 上下文感知建议
- 代码质量评分
安全扫描
- - 常见漏洞的静态分析
- 基于模式的检测
- 基于严重性的分类
- 可配置规则
风格检查
- - PEP8合规检查
- 命名规范验证
- 行长度强制执行
- 导入顺序验证
- 空白字符检查
配置
- - YAML/JSON配置文件
- 项目特定设置
- 可自定义阈值
- .reviewrc支持
📊 示例
bash
运行完整审查
code-review full-review facebook/react 34567
仅安全扫描
code-review security-scan 所有者/仓库 123
仅风格检查
code-review style-check 所有者/仓库 123
仅AI分析
code-review review-pr 所有者/仓库 123
列出所有已关闭的PR
code-review list-prs 所有者/仓库 --state closed --limit 20
初始化配置
code-review config-init
🔐 安全
- - GitHub PAT存储在.env文件中(永不提交)
- 不记录或显示任何密钥
- 建议启用IP白名单
🚧 路线图
v0.2.0 - Claude集成(已完成)
- - Claude API集成
- 自动化PR分析
- 智能审查评论
- 代码质量评分
v0.3.0 - 安全与风格(当前版本)
- - 安全漏洞扫描
- 风格和lint检查
- 自动修复建议
- 配置文件支持
- 完整审查命令
v1.0.0(计划中)
- - 多平台支持(GitLab、Bitbucket)
- CI/CD集成
- 团队协作功能
- 审查仪表板
📄 许可证
MIT
🙋 支持
如有问题或疑问: