Alpha — CodeAnvil is under active development and not yet publicly announced.

AI Code Review

CodeAnvil can automatically review pull requests using AI. The AI analyzes your code diff, provides feedback, and stores the review as a git note alongside human reviews.

Advanced

Overview

AI code review in CodeAnvil:

  • Runs automatically when a PR is created for a branch with AI review enabled
  • Reviews asynchronously without blocking the PR
  • Analyzes full source — not just the diff, but related files for context
  • Stores results in git — reviews are preserved as git notes
🤖 AI Review vs Human Review

AI review is not a replacement for human code review. It's a first pass that can catch common issues before human reviewers look at the code. Human approvals are still required for merging.

Enabling AI Review

Enable AI review in your .anvil/config.yml:

yaml
# .anvil/config.yml
branch_protection:
  main:
    required_signatures: 2
    ai_review:
      enabled: true
      provider: "zhipu"
      model: "glm-4.7"
  
  develop:
    required_signatures: 1
    ai_review:
      enabled: true

Configuration Options

Option Type Default Description
enabled boolean false Enable AI code review
💡 Server Configuration

The AI provider and model are configured by the server administrator. Users only need to enable or disable AI review for their branches.

Review Results

AI reviews are stored as git notes in refs/notes/ai-reviews:

text
AI-Review-Status: COMPLETED
Reviewed-At: 2024-01-15T10:30:00Z

## Summary
The changes implement a new feature for user authentication. The code is 
generally well-structured but has a few issues that should be addressed.

## Findings

### ⚠️ Warning: Security (auth.rs:45)
Hardcoded API key detected. Consider using environment variables.

**Suggestion:** Move the API key to configuration and reference via env var.

### 💡 Suggestion: Performance (db.rs:120)
N+1 query pattern detected in getUserRoles function.

**Suggestion:** Consider using a JOIN or batch query to fetch all roles at once.

### ✅ Good Practice (utils.rs:30)
Proper error handling with custom error types.

Review Status

  • COMPLETED: Review finished successfully
  • FAILED: Review failed (check server logs)

Fetching AI Reviews

bash
# Fetch the ai-reviews notes ref
git fetch origin refs/notes/ai-reviews:refs/notes/ai-reviews

# List all AI review notes
git notes --ref=refs/notes/ai-reviews list

# Show a specific review
git notes --ref=refs/notes/ai-reviews show 

What's Next?