Skip to content
Download

DOCS / PULL REQUESTS

AI code review

Birch can review a pull request with AI and produce a structured markdown report — summary, issues, suggestions. Auto-review runs on newly discovered PRs when you opt in; on-demand review is a CLI command today. Both are Anthropic API features and need the ANTHROPIC_API_KEY environment variable.

Each review is a markdown report headed Review: PR #N — <title> with three sections, in order:

  • Summary — what the PR does.
  • Issues — problems found, citing file paths and line context.
  • Suggestions — improvements worth making.

The report is written to the app’s artifacts folder, under artifacts/review/<job-id>/report.md in Birch’s data directory. It’s a plain markdown file — birch review run prints its path, and any markdown viewer (or the agent in your workspace) can work from it. (A report-viewer window that renders these reports inside the app exists, but it currently has no entry point in the shipped build.)

  • ANTHROPIC_API_KEY must be set in the environment of whichever process runs the review — the app for auto-review, your shell for the CLI. Without it, starting a review fails with “AI provider is not configured. Set ANTHROPIC_API_KEY.”
  • Reviews run on a Claude Sonnet model chosen by the app.
  • Every review is real API usage, billed to your key. A small PR is one request; a large PR is one request per chunk plus a consolidation request (see below).

Opt in via Settings → AI → “Automatically review new PRs” (off by default). The pane’s own help text states the two rules: “Requires ANTHROPIC_API_KEY. Does not run on the first sync of a repository.”

  • Reviews trigger when the background PR sync (roughly every 10 minutes, plus once shortly after app start) discovers PRs it hasn’t seen before.
  • A repository’s first-ever sync never triggers reviews — importing a repo with 40 open PRs won’t fire 40 API calls.
  • If the toggle is on but the key is missing, the sync logs a warning and skips the review instead of failing.

Failures and timeouts are retried automatically — up to 3 attempts, with a 20-minute cap per review.

terminal
birch review run <pr-id>

<pr-id> is a PR number or id — URLs are not accepted here. With the app running, the review is relayed into it; otherwise the CLI runs it standalone. Output is the job status and the report path:

text
Completed /Users/you/Library/Application Support/birch/artifacts/review/<job-id>/report.md

With --json you get jobId, status, reportPath, error, attempts, and chunks. Exit code is 0 when the review completed and 3 when it didn’t; the CLI reference has the full exit-code table.

A diff up to 32,000 characters is reviewed in a single pass. Beyond that, Birch chunks by file:

  1. Per-file diffs are packed into chunks of up to 32,000 characters each (a single file larger than the cap is truncated to it).
  2. Each chunk is reviewed separately, with the PR title, description, and its file list for context.
  3. A final consolidation pass merges the partial reports into one — deduplicating overlapping issues and preserving file/line citations.

A chunked report opens with a note like “Review produced from 3 chunks (total diff size: 96,000 chars)” so you know how it was assembled.

Work the Issues section like reviewer comments: each item cites where it applies, so you can hand the report path to the agent in your workspace and ask it to address specific findings. The report is a whole-PR pass; for a targeted patch to one reviewer comment, the per-comment Fix suggestion in Review & manage PRs is the sharper tool.

Birch can post to a Microsoft Teams channel when a review completes — and when one fails or times out. Configure the incoming-webhook URL and enable the review toggles under Settings → AI; both are off by default. See Notifications.