Skip to content

Built-in Code Review (`/review`)

POST /review on the daemon HTTP gateway runs a structured diff analysis using the currently configured LLM and returns a typed ReviewResult.

1. getGitDiffForReview(projectPath, target)
→ executes git diff synchronously (30s timeout, 2 MB buffer)
2. If diff is empty → return { findings: [], overall_correctness: "patch is correct" }
3. Build system prompt (buildReviewSystemPrompt)
→ instructs the model to act as a code reviewer
→ outputs ONLY a JSON object matching the review schema
4. gateway.complete({ profileId, model?, messages, responseFormat: json_schema })
→ uses structured output (json_schema) for reliable schema adherence
5. Parse and return ReviewResult
target valueWhat is diffed
uncommitted (default)git diff --cached + git diff (staged + unstaged)
stagedgit diff --cached only
<file path>git diff HEAD -- <file> for a single file
type ReviewFinding = {
title: string; // ≤80 chars, imperative, prefixed [P0]–[P3]
body: string; // Markdown, one paragraph max
confidence_score: number; // 0.0–1.0
priority?: 0 | 1 | 2 | 3 | null;
code_location: {
absolute_file_path: string;
line_range: { start: number; end: number };
};
};
type ReviewResult = {
findings: ReviewFinding[];
overall_correctness: 'patch is correct' | 'patch is incorrect';
overall_explanation: string; // 1-3 sentences
overall_confidence_score: number;
};
PriorityLabelMeaning
P0Drop everythingBlocking bug or security issue — do not merge
P1UrgentSignificant correctness or performance problem
P2NormalShould be addressed before release
P3Nice-to-haveStyle, naming, minor improvement

The review uses a separate provider/model setting from the agent, allowing a different (e.g. stronger) model for code review:

Terminal window
/review settings # interactive picker in TUI

Stored in runtime-preferences.json as reviewProvider and reviewModel. Falls back to the active provider profile if not set.

Review guidelines baked into the system prompt

Section titled “Review guidelines baked into the system prompt”
  • Flag only issues introduced in the diff, not pre-existing ones
  • Finding body: one paragraph max, concise
  • No findings for nitpicks below P3 that don’t affect correctness or maintainability
  • If no real issues: return empty findings array
  • overall_correctness: "patch is incorrect" only when there are blocking bugs