# Code Review

Get Agent-powered code reviews on your changes before committing.

Code Review analyzes your git changes and provides detailed feedback on code quality, security, bugs, and best practices. Get a senior developer perspective on your code before you commit.

## Starting a Review

### Make Changes

Edit files in your project. Changes can be staged or unstaged.

### Open Git Panel

Click the Git icon in the sidebar to open the Git Panel.

### Click Review

Click the **sparkles icon** (Review button) in the Git Panel header.

### Wait for Analysis

A progress bar shows the review stages:

- Preparing review  
- Getting git diff  
- Parsing changes  
- Running lint check (optional)  
- Analyzing with Agent  
- Processing results

### Review Results

Results appear in a collapsible panel showing issues, scores, and suggestions.

## What Gets Reviewed

The Agent reviews your **git diff**, focusing on:

| Review Type         | What It Analyzes                                   |
|---------------------|----------------------------------------------------|
| **Staged changes**  | Files added to git staging area                    |
| **Unstaged changes**| Modified files not yet staged                       |
| **All changes**     | Both staged and unstaged combined                   |

The Agent focuses on **added and modified lines** only. Deleted code is ignored since it will no longer be in your codebase.

### Additional Analysis

When available, the review also runs linting:

- Tries common lint commands (pnpm lint, npm run lint, yarn lint)  
- Lint output provides extra context for the Agent  
- Helps catch issues linters already detect

## Understanding Results

### Overall Score

A quality score from 0-100 appears in the review header:

| Score | Color | Meaning                   |
|-------|-------|---------------------------|
| 90-100| Green | Excellent quality          |
| 70-89 | Yellow| Good with minor issues     |
| 50-69 | Orange| Needs attention            |
| 0-49  | Red   | Significant problems       |

### Issue Summary

Badges show the count of issues by severity:

| Badge | Severity  | Description                                         |
|-------|-----------|-----------------------------------------------------|
| Red   | Critical  | Security vulnerabilities, data loss risks            |
| Yellow| Warning   | Bugs, logic errors, runtime issues                   |
| Blue  | Suggestion| Code quality improvements                             |
| Green | Praise    | Well-written code worth highlighting                 |

### File Breakdown

Each reviewed file shows:

- File path  
- Number of issues found  
- Individual quality score  
- Expandable list of comments

## Review Comments

Each comment includes detailed information:

### Comment Actions

| Action        | Description                                        |
|---------------|-----------------------------------------------------|
| **Apply Fix** | Automatically apply the suggested code change       |
| **View**      | Jump to the line in the editor                      |
| **Dismiss**   | Hide this issue from the results                     |

## Issue Categories

The Agent reviews code across six categories:

- Security
- Bugs
- Performance
- Maintainability
- Style
- Best Practices

**Security issues include:**

- SQL injection vulnerabilities  
- Cross-site scripting (XSS)  
- Command injection  
- Hardcoded secrets or credentials  
- Authentication flaws  
- Insecure data handling

**Bug detection includes:**

- Null pointer risks  
- Race conditions  
- Resource leaks  
- Logic errors  
- Unhandled edge cases  
- Type mismatches

**Performance issues include:**

- Inefficient algorithms  
- Unnecessary operations  
- Memory issues  
- Blocking operations  
- Redundant computations  
- Suboptimal patterns

**Maintainability concerns include:**

- Code duplication  
- High complexity  
- Poor naming conventions  
- Missing documentation  
- Tightly coupled code  
- Hard-to-test patterns

**Style issues include:**

- Formatting inconsistencies  
- Convention violations  
- Only flagged when significant  
- Generally lower priority

**Best practice suggestions include:**

- Modern patterns  
- Idiomatic code  
- Better approaches  
- Framework conventions  
- Industry standards

## Severity Levels

### Critical

Highest priority issues requiring immediate attention:

- Security vulnerabilities  
- Data loss risks  
- Breaking changes  
- Production-blocking bugs

### Warning

Important issues that should be fixed:

- Logic errors  
- Potential runtime failures  
- Resource management problems  
- Edge case handling

### Suggestion

Improvements to consider:

- Code quality enhancements  
- Readability improvements  
- Minor optimizations  
- Alternative approaches

### Praise

Positive feedback on well-written code:

- Good patterns identified  
- Clean implementations  
- Smart solutions  
- Encourages best practices

## Review Settings

Configure how code reviews work:

| Setting                  | Description                               | Default |
|--------------------------|-------------------------------------------|---------|
| **Auto-review on stage** | Automatically review when files are staged| Off     |
| **Categories**           | Which issue types to check                | All enabled |
| **Severity threshold**   | Minimum severity to show                  | Suggestion |
| **Max files**            | Maximum files per review                  | 20      |
| **Security scan**        | Extra focus on security                   | On      |

Settings persist in your browser and apply to all reviews.

## Review History

Invoke keeps your last 10 review sessions:

- Access previous reviews  
- Compare changes over time  
- Track improvement patterns

History is stored locally in your browser.

## Applying Fixes

When a comment includes a suggested fix:

### Review the Suggestion

Read the suggested code change in the green highlighted section.

### Click Apply Fix

Click the green **Apply Fix** button on the comment.

### Verify the Change

The fix is applied to your file. Review the change in the editor.

Always review applied fixes before committing. Agent suggestions should be verified for correctness in your specific context.

## Best Practices

### Before Reviewing

- Stage related changes together for coherent reviews  
- Keep reviews focused (under 20 files works best)  
- Ensure code compiles/runs before review

### During Review

- Start with critical issues  
- Apply fixes incrementally  
- Dismiss false positives  
- Use View to understand context

### After Review

- Re-run review after major fixes  
- Commit when score is acceptable  
- Document dismissed issues if intentional

## Limitations

| Limitation                | Details                                |
|---------------------------|----------------------------------------|
| **Max files**              | Reviews up to 20 files by default      |
| **Diff only**             | Reviews changes, not entire files      |
| **Language support**      | Best for common programming languages   |
| **Context**               | May miss project-specific conventions   |

For project-specific review guidelines, consider creating a custom agent with your team's coding standards in the Agent's settings.

## Integration with Git Workflow

The recommended workflow:

```
Make changes
        ↓
Run Agent Review
        ↓
Fix critical/warning issues
        ↓
Re-review if needed
        ↓
Stage changes
        ↓
Commit with confidence
```
