Skip to main content
Review your code changes before pushing using AI-powered analysis. Powered by CodeRabbit, wit review catches issues before they hit the remote repository.

Overview

The wit review command analyzes your changes and provides AI-powered feedback, helping you catch bugs, security issues, and code quality problems before they reach code review.
wit review [options]

Quick Start

# Review all uncommitted changes
wit review

# Review only staged changes
wit review --staged

# Review branch changes
wit review --branch

Options

OptionDescription
--staged, -sReview only staged changes
--branch, -bReview all changes since branching from main
--commits <range>Review specific commit range
--base <branch>Compare against specific branch (default: main)
--jsonOutput as JSON
--verbose, -vShow detailed output
--strictExit with error if critical/high issues found
--configureConfigure CodeRabbit API key
--statusShow configuration status

Review Modes

Uncommitted Changes

Review all changes in your working directory (staged and unstaged).
wit review

Staged Changes

Review only what’s staged for commit. Useful as a pre-commit check.
wit review --staged

Branch Changes

Review all changes since branching from the base branch.
# Review against main (default)
wit review --branch

# Review against a specific branch
wit review --branch --base develop

Commit Range

Review specific commits.
# Review last 3 commits
wit review --commits HEAD~3..

# Review commits between branches
wit review --commits main..HEAD

# Review a specific commit
wit review --commits abc123

Example Output

🐰 CodeRabbit Review
   Reviewing: branch feature/auth vs main

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 Summary
   Files changed: 5
   Additions: 156
   Deletions: 23

🔍 Issues Found: 3

🔴 HIGH: SQL Injection Risk
   src/db/queries.ts:42
   
   The query string is constructed using string concatenation
   which could allow SQL injection attacks.
   
   Suggestion: Use parameterized queries instead.
   
   - const query = `SELECT * FROM users WHERE id = ${id}`;
   + const query = 'SELECT * FROM users WHERE id = ?';
   + db.query(query, [id]);

🟡 MEDIUM: Missing Error Handling
   src/api/handler.ts:28
   
   This async function doesn't have error handling.
   Consider wrapping in try/catch.

🟢 LOW: Console.log Statement
   src/utils/debug.ts:15
   
   Debug console.log statement should be removed before merge.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✓ Review complete
  1 high, 1 medium, 1 low issue(s) found

CI Integration

Use --strict mode to fail builds when issues are found.

Pre-push Hook

#!/bin/sh
# .wit/hooks/pre-push

wit review --branch --strict

CI Pipeline

# .wit/workflows/ci.yml
name: Code Review

on:
  pull_request:
    branches: [main]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      
      - name: AI Code Review
        run: wit review --branch --strict
        env:
          CODERABBIT_API_KEY: ${{ secrets.CODERABBIT_API_KEY }}

Configuration

Setup CodeRabbit

  1. Get an API key from coderabbit.ai
  2. Configure it:
wit review --configure
Or set the environment variable:
export CODERABBIT_API_KEY=your-api-key

Check Status

wit review --status
🐰 CodeRabbit Status

API Key:   ✓ Configured
           cr_abc1...xyz9
CLI:       ✓ Installed
           Version: 1.2.3

Ready to review!
Try: wit review

JSON Output

Get structured output for programmatic use.
wit review --json
{
  "success": true,
  "summary": {
    "filesChanged": 5,
    "additions": 156,
    "deletions": 23
  },
  "issues": [
    {
      "severity": "high",
      "type": "security",
      "file": "src/db/queries.ts",
      "line": 42,
      "message": "SQL Injection Risk",
      "description": "The query string is constructed...",
      "suggestion": "Use parameterized queries..."
    }
  ]
}

Workflow Examples

Pre-commit Workflow

# Make changes
vim src/feature.ts

# Stage changes
wit add src/feature.ts

# Review before committing
wit review --staged

# If issues found, fix them
vim src/feature.ts

# Review again
wit review --staged

# Commit when clean
wit commit -m "Add feature"

Pre-push Workflow

# Before pushing a feature branch
wit review --branch --strict

# If clean, push
wit push

Pull Request Workflow

# Create PR
wit pr create -t "Add feature"

# Get AI review on the PR
wit pr review 42

Issue Severity Levels

LevelDescriptionAction
🔴 CriticalSecurity vulnerabilities, data loss risksMust fix before merge
🔴 HighBugs, significant logic errorsShould fix before merge
🟡 MediumCode quality, maintainabilityConsider fixing
🟢 LowStyle, minor improvementsOptional