smart-git-review
v1.0.4
Published
基于 Git Hooks 和 AI 大模型的自动化代码审查工具。支持 commit/push/pull 时自动审查,可植入质量规范到 Claude Code / Kilo Code / Cline 等 AI 编码工具。
Downloads
650
Maintainers
Readme
smart-git-review
基于 Git Hooks 和 AI 大模型的自动化代码审查工具。
安装
npm install smart-git-review --save-dev快速开始
# 1. 安装 Hooks
npx git-ai-review install
# 2. 正常使用 git (commit/push 时自动触发审查)
git commit -m "feat: 新功能"审查触发时机
| Hook | 触发时机 | 默认 | 配置项 |
|------|----------|------|--------|
| pre-commit | git commit 前 | ✅ 开启 | reviewOnCommit |
| pre-push | git push 前 | ❌ 关闭 | reviewOnPush |
| post-merge | git pull 后 | ❌ 关闭 | reviewOnPull |
预设规则库
开箱即用的审查规则,涵盖安全、性能、架构、代码质量等维度:
内置规则
| 规则 ID | 描述 | 适用场景 |
|---------|------|----------|
| security | 深度安全审查 | 所有项目 |
| architecture | 架构与设计审查 | 中大型项目 |
| react-typescript | React & TypeScript 深度审查 | React/TS 项目 |
| vue-typescript | Vue & TypeScript 深度审查 | Vue/TS 项目 |
| vibe-coding | Vibe Coding 专项排雷 | AI 辅助编程项目 |
| database | 数据库与 ORM 性能审查 | 需要数据库的项目 |
| performance | 性能专项审查 | 所有项目 |
| code-smells | 代码坏味道审查 | 所有项目 |
| business-design | 业务设计审查 | 需要业务上下文的项目 |
| grill-me | 深度代码挑战审查 | 代码质量审核场景 |
| impeccable | 无瑕代码质量审查 | 追求高品质代码 |
| systematic-debugging | 系统化调试审查 | Bug 修复和调试场景 |
| caveman-review | 极简代码审查 | 需要降低复杂度的项目 |
来自 skills.sh 生态的规则
| 规则 ID | 描述 | 来源 |
|---------|------|------|
| web-design-guidelines | Web 界面设计规范审查 | vercel-labs/agent-skills |
| react-best-practices | React & Next.js 性能优化最佳实践 (70 条规则) | vercel-labs/agent-skills |
| verification-before-completion | 完成前验证 — 先跑验证再声称完成 | obra/superpowers |
| supabase-postgres-best-practices | Postgres 性能优化与最佳实践 | supabase/agent-skills |
| supabase | Supabase 全产品审查 (Auth/Edge Functions/RLS 等) | supabase/agent-skills |
| receiving-code-review | 代码审查接收准则 — 技术严谨而非盲从 | obra/superpowers |
| test-driven-development | 测试驱动开发 (TDD) 规范 | obra/superpowers |
| webapp-testing | Web 应用测试工具包 (Playwright) | anthropics/skills |
| code-review | 双轴代码审查 (规范 + 需求) | mattpocock/skills |
| resolving-merge-conflicts | Git 合并冲突解决 | mattpocock/skills |
| improve-codebase-architecture | 代码库架构改进 | mattpocock/skills |
| diagnosing-bugs | Bug 诊断循环 | mattpocock/skills |
| setup-pre-commit | Pre-commit 钩子设置 (Husky + lint-staged) | mattpocock/skills |
规则管理
# 列出所有可用规则
npx git-ai-review rules
# 启用规则
npx git-ai-review enable security
npx git-ai-review enable grill-me
# 禁用规则
npx git-ai-review disable vibe-coding配置
在项目根目录创建 .gitaireviewrc.json:
{
"model": "qwen3.6-plus",
"apiUrl": "https://coding.dashscope.aliyuncs.com/v1/chat/completions",
"blockOnCritical": true,
"reviewOnCommit": true,
"reviewOnPush": false,
"reviewOnPull": true,
"presetRules": ["security", "react-typescript", "vibe-coding", "grill-me"]
}环境变量
| 变量名 | 说明 | 默认值 |
|--------|------|--------|
| GIT_AI_REVIEW_API_KEY | API 密钥 | - |
| GIT_AI_REVIEW_MODEL | AI 模型 | qwen3.6-plus |
| GIT_AI_REVIEW_API_URL | API 地址 | 阿里云 DashScope |
规则植入
将质量规范植入到 AI 编码工具(Claude Code / Kilo Code / Cline):
# 自动检测并植入
npx git-ai-review inject
# 指定工具和规则
npx git-ai-review inject --tool claude --rules security,performance许可证
MIT
