Lesson 2: Code Review with AI
Video Demo
Section titled “Video Demo”Watch the AI code review agent in action:
Why AI Code Review?
Section titled “Why AI Code Review?”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.
Setting Up a Review Agent
Section titled “Setting Up a Review Agent”GitHub App Installation
Section titled “GitHub App Installation”rearch review install --provider github --org acmeThis installs the ReArch Review GitHub App on your organisation. You can scope it to specific repositories.
Configuration
Section titled “Configuration”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 pushReview Output
Section titled “Review Output”When a PR is opened, the review agent posts:
Summary Comment
Section titled “Summary Comment”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 |Inline Comments
Section titled “Inline Comments”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() ?? '';Actionable Feedback
Section titled “Actionable Feedback”Every comment includes:
- Severity — error, warning, or info
- Category — what check found it
- Explanation — why it matters
- Suggestion — a concrete fix (when possible)
Customising Review Behaviour
Section titled “Customising Review Behaviour”Per-Team Rules
Section titled “Per-Team Rules”Different teams may have different review requirements:
# Frontend team — strict on accessibilityreview: 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: errorIgnore Patterns
Section titled “Ignore Patterns”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 lockfilesReview Thresholds
Section titled “Review Thresholds”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 allowedIf thresholds are exceeded, the agent requests changes and asks the PR author to fix the issues first.
Integrating with Your Review Workflow
Section titled “Integrating with Your Review Workflow”A recommended workflow:
- Developer opens a PR
- ReArch Review agent runs immediately (< 2 minutes)
- Developer fixes any errors flagged by the agent
- Human reviewer sees a cleaner PR and focuses on design/architecture
- PR is approved and merged
This typically reduces human review time by 30-40% because the mechanical issues are already resolved.
What’s Next
Section titled “What’s Next”In the final lesson, you will learn how to track team productivity and generate reports on ReArch usage.