Loading...
Loading...
Automated AI-powered code review that runs on git hooks with progressive disclosure design. Use when setting up automated code review for a project, installing git hooks for code review, creating or modifying review rules, or configuring review behavior. Triggers on requests like "set up AI code review", "install review hooks", "create review rules", or "configure code reviewer".
npx skill4agent add yulong-me/skills ai-code-reviewer.ai-reviewer/rules/mkdir -p .ai-reviewer/{rules,hooks}
cp <skill-path>/assets/config.yaml .ai-reviewer/
cp <skill-path>/assets/rules/*.md .ai-reviewer/rules/
cp <skill-path>/assets/hooks/*.template .ai-reviewer/hooks/python3 <skill-path>/scripts/install_hook.py install --hook-type pre-commit.ai-reviewer/config.yamlai_backend: claude-apiclaude_api_keyai_backend: claude-cli# Stage some changes
git add .
# Run review manually to test
python3 <skill-path>/scripts/run_review.py --project-root .
# If review passes, commit will proceed normally
git commit -m "test commit"git commit --no-verify -m "message"User wants to:
│
├─ "Set up AI code review"
│ └─ Go to Initial Setup
│
├─ "Add review rules"
│ └─ Go to Creating Rules
│
├─ "Configure review behavior"
│ └─ Go to Configuration
│
├─ "Install/uninstall hooks"
│ └─ Go to Managing Git Hooks
│
├─ "Debug review issues"
│ └─ Go to Troubleshooting
│
└─ "Review staged changes manually"
└─ Run: python3 <skill-path>/scripts/run_review.py --project-root .project-root/
└── .ai-reviewer/
├── config.yaml # Configuration
├── rules/ # Review rules
│ ├── rule1.md
│ └── rule2.md
└── hooks/ # Git hook templates
├── pre-commit.template
└── pre-push.template# Create directories
mkdir -p .ai-reviewer/{rules,hooks}
# Copy example config
cp <skill-path>/assets/config.yaml .ai-reviewer/
# Copy example rules
cp <skill-path>/assets/rules/*.md .ai-reviewer/rules/
# Copy hook templates
cp <skill-path>/assets/hooks/*.template .ai-reviewer/hooks/.ai-reviewer/config.yamlreview_mode: block
ai_backend: claude-api
claude_api_key: "sk-ant-api03-..." # Or use ANTHROPIC_API_KEY env var
model: claude-sonnet-4-5-20250929review_mode: block
ai_backend: claude-clipython3 <skill-path>/scripts/install_hook.py install --hook-type pre-commitpython3 <skill-path>/scripts/install_hook.py install --hook-type pre-push# Run manual review
python3 <skill-path>/scripts/run_review.py --project-root .
# If successful, try a commit
git add .
git commit -m "test commit"references/rule_format.md---
id: unique-rule-id
keywords: ["keyword1", "keyword2"]
file_patterns: ["*.py", "src/**/*.js"]
priority: high | medium | low
description: Brief one-line description
---
# Rule Title
## Specification
Detailed explanation...
## Checklist
- Check item 1
- Check item 2
## Positive Examples
```python
# Good code# Bad code
### Rule Matching Logic
A rule triggers if **either** condition is met:
1. **File pattern match**: Changed file matches a pattern in `file_patterns`
2. **Keyword match**: Keyword appears in diff content
Both use OR logic - either triggers the rule.
### Creating a New Rule
1. Create `.ai-reviewer/rules/your-rule.md`
2. Add frontmatter with `id`, `keywords`, `file_patterns`, `priority`, `description`
3. Add sections: `Specification`, `Checklist`
4. Optionally add: `Positive Examples`, `Negative Examples`
5. Test by running review on sample code
**Example:**
```yaml
---
id: no-todo-comments
keywords: ["TODO", "FIXME", "HACK"]
file_patterns: ["*.py", "*.js", "*.ts"]
priority: medium
description: No TODO comments in production code
---
# No TODO Comments
## Specification
TODO comments should not be committed. Fix the issue or create a ticket.
## Checklist
- No TODO comments present
- No FIXME comments present
- No HACK comments present
## Negative Examples
```python
# TODO: Refactor this later
def bad_example():
pass
## Configuration
### Review Modes
**Block mode** (strict):
```yaml
review_mode: block--no-verifyreview_mode: warnreview_mode: advisoryai_backend: claude-api
claude_api_key: "sk-ant-api03-..."
model: claude-sonnet-4-5-20250929
max_tokens: 4096ANTHROPIC_API_KEYai_backend: claude-clinpm install -g @anthropic-ai/claude-cliskip_patterns:
- "*.min.js"
- "vendor/**"
- "node_modules/**"
- "*.pb.go"references/config_format.mdpython3 <skill-path>/scripts/install_hook.py install --hook-type pre-commitpython3 <skill-path>/scripts/install_hook.py uninstall --hook-type pre-commitls -la .git/hooks/.git/hooks/pre-commit.git/hooks/pre-push.ai-reviewerpython3 <skill-path>/scripts/run_review.py --project-root .python3 <skill-path>/scripts/load_rules.py .ai-reviewer/rulesls -la .git/hooks/pre-commitchmod +x .git/hooks/pre-commitls -la .ai-reviewer/export ANTHROPIC_API_KEY=sk-ant-api03-...config.yamlai_backend: claude-clipython3 <skill-path>/scripts/load_rules.py .ai-reviewer/rules*.pysrc/**/*.jsmax_diff_sizemax_diff_size: 50000log_level: debug
log_file: .ai-reviewer/review.logidkeywordsfile_patternsprioritydescriptionload_rules.pyRuleMetadatapython3 scripts/install_hook.py install --hook-type pre-commitpython3 scripts/run_review.py --project-root .from load_rules import RuleLoader, RuleMetadata, FullRuleerror-handling.mdnaming-convention.mdpre-commit.templatepre-push.templatereview_mode: blockpriority: highmax_tokensid: security-001
id: style-001
id: performance-001## Specification
When reviewing this rule, pay special attention to edge cases involving...file_patterns: ["*.py"] # Python only
file_patterns: ["*.js", "*.ts"] # JavaScript/TypeScript
file_patterns: ["*"] # All files- name: AI Code Review
run: python3 scripts/run_review.py --project-root .