Install
openclaw skills install openclaw-code-reviewAutomated code review assistant. Analyzes code changes, PRs, and files for quality issues, best practices, security concerns, and style violations. Provides actionable feedback with line-by-line comments and summary reports.
openclaw skills install openclaw-code-review自动化代码审查助手,分析代码变更、PR 和文件,检测质量问题、最佳实践违规、安全隐患和风格问题。
Version: 1.0
Features: 多层级分析、AST 解析、安全检查、Git 集成
python3 scripts/main.py review file src/main.py
python3 scripts/main.py review staged
python3 scripts/main.py review commit abc123
python3 scripts/main.py review file src/*.py --format json --output report.json
| 命令 | 说明 | 示例 |
|---|---|---|
review file | 审查文件 | main.py review file src/*.py |
review staged | 审查暂存区 | main.py review staged |
review commit | 审查提交 | main.py review commit abc123 |
review diff | 审查 diff 文件 | main.py review diff changes.patch |
创建 .code-review.json 在项目根目录:
{
"max_complexity": 10,
"max_function_lines": 50,
"max_file_lines": 500,
"ignore": [
"tests/**",
"vendor/**",
"node_modules/**"
],
"severity": "warning"
}
python3 main.py review file src/main.py
输出包含:
python3 main.py review file src/main.py --format json
适合 CI/CD 集成:
{
"summary": {
"files_reviewed": 5,
"total_issues": 12,
"errors": 0,
"warnings": 3,
"info": 9
},
"files": [...]
}
# .git/hooks/pre-commit
#!/bin/bash
python3 /path/to/code-review/scripts/main.py review staged --fail-on-error
# .github/workflows/code-review.yml
name: Code Review
on: [push, pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Code Review
run: |
python3 skills/code-review/scripts/main.py review file src/ --format json --output review.json
- name: Upload Report
uses: actions/upload-artifact@v3
with:
name: code-review-report
path: review.json
# 1. 添加变更到暂存区
git add src/
# 2. 审查暂存区代码
python3 main.py review staged
# 3. 如果有错误,修复后再提交
# 获取 PR 的最新提交
python3 main.py review commit $(git rev-parse HEAD)
# 审查所有 Python 文件
python3 main.py review file src/**/*.py --format json --output report.json
# 设置更严格的阈值
python3 main.py review file src/ --max-complexity 5 --max-function-lines 30
| 语言 | 质量检查 | 安全检查 | 风格检查 |
|---|---|---|---|
| Python | ✅ | ✅ | ✅ |
| JavaScript | ✅ | ✅ | ✅ |
| TypeScript | ⚠️ | ⚠️ | ⚠️ |
skills/code-review/
├── SKILL.md # 本文件
└── scripts/
├── main.py # ⭐ 统一入口
└── analyzer.py # 核心分析引擎
| 代码 | 含义 |
|---|---|
| 0 | 成功,无错误 |
| 1 | 发现错误或 --fail-on-error 且有问题 |