Skip to content

Lesson 2: Code Review with AI

Watch the AI code review agent in action:

Human code review is essential but has bottlenecks:

  • Latency: reviewers may not get to a PR for hours or days
  • Consistency: different reviewers catch different things
  • Fatigue: large PRs get superficial reviews

An AI review agent provides an instant first pass that catches common issues, checks style compliance, and flags potential bugs — before a human reviewer even opens the PR.

This does not replace human review. It makes human review faster and more focused on architecture and design decisions.

Terminal window
rearch review install --provider github --org acme

This installs the ReArch Review GitHub App on your organisation. You can scope it to specific repositories.

.rearch/review.yaml
review:
enabled: true
trigger: pull_request # Review every PR automatically
# What to check
checks:
- name: style
description: "Code style and conventions"
prompt: org-standards
severity: warning
- name: bugs
description: "Potential bugs and logic errors"
severity: error
- name: security
description: "Security vulnerabilities"
prompt: security
severity: error
- name: performance
description: "Performance concerns"
severity: info
- name: tests
description: "Test coverage and quality"
severity: warning
# Review behaviour
settings:
max_comments: 15 # Cap inline comments per review
group_similar: true # Group similar issues together
suggest_fixes: true # Include code suggestions
approve_if_clean: false # Never auto-approve (require human)
dismiss_on_push: true # Dismiss review when new commits push

When a PR is opened, the review agent posts:

A top-level comment with an overview:

## ReArch Review Summary
**3 issues found** (1 error, 1 warning, 1 info)
| Check | Status | Issues |
|-------|--------|--------|
| Style | ✓ Pass | 0 |
| Bugs | ✗ Fail | 1 |
| Security | ✓ Pass | 0 |
| Performance | ─ Info | 1 |
| Tests | ⚠ Warn | 1 |

The agent posts inline comments on specific lines:

📛 Bug (error): Possible null reference
Line 42 calls `user.name.toLowerCase()` but `user.name` can be
`null` based on the User type definition (src/types/user.ts:8).
Suggested fix:
- const normalized = user.name.toLowerCase();
+ const normalized = user.name?.toLowerCase() ?? '';

Every comment includes:

  1. Severity — error, warning, or info
  2. Category — what check found it
  3. Explanation — why it matters
  4. Suggestion — a concrete fix (when possible)

Different teams may have different review requirements:

# Frontend team — strict on accessibility
review:
checks:
- name: a11y
description: "Accessibility compliance"
rules:
- "All images must have alt text"
- "Interactive elements must be keyboard-accessible"
- "Color contrast must meet WCAG AA"
severity: error

Skip review for certain files:

review:
ignore:
- "**/*.test.ts" # Don't review test files for style
- "**/*.generated.ts" # Skip generated code
- "docs/**" # Skip documentation
- "*.lock" # Skip lockfiles

Require a minimum review quality before requesting human review:

review:
thresholds:
max_errors: 0 # Zero errors to proceed to human review
max_warnings: 5 # Up to 5 warnings allowed

If thresholds are exceeded, the agent requests changes and asks the PR author to fix the issues first.

A recommended workflow:

  1. Developer opens a PR
  2. ReArch Review agent runs immediately (< 2 minutes)
  3. Developer fixes any errors flagged by the agent
  4. Human reviewer sees a cleaner PR and focuses on design/architecture
  5. PR is approved and merged

This typically reduces human review time by 30-40% because the mechanical issues are already resolved.

In the final lesson, you will learn how to track team productivity and generate reports on ReArch usage.