Review Component
The <Review> component performs AI-powered code reviews against specified criteria, with options to post to GitHub or git notes.
Basic Usage
import { Review } from "smithers";
<Review
target={{ type: "diff", ref: "main" }}
criteria={[
"No security vulnerabilities",
"Tests cover edge cases",
]}
onFinished={(review) => {
if (review.approved) {
console.log("Review passed!");
} else {
console.log("Issues found:", review.issues);
}
}}
/>
Props
What to review.// Review diff against a branch
{ type: "diff", ref: "main" }
// Review a specific commit
{ type: "commit", ref: "abc123" }
// Review a pull request
{ type: "pr", ref: "123" }
// Review specific files
{ type: "files", paths: ["src/auth.ts", "src/api.ts"] }
Review criteria to check against.criteria={[
"No hardcoded secrets",
"Input is validated",
"Error handling is comprehensive",
"Code follows project conventions",
]}
Custom agent configuration for the review.
model
'opus' | 'sonnet' | 'haiku'
default:"sonnet"
Model to use for the review.
Whether failures should block the workflow.
Post review comments to GitHub PR.
Store review in git notes.
Callbacks
onFinished
(result: ReviewResult) => void
Called when review completes.
ReviewResult Type
interface ReviewResult {
approved: boolean;
summary: string;
issues: ReviewIssue[];
}
interface ReviewIssue {
severity: 'low' | 'medium' | 'high' | 'critical';
file: string;
line?: number;
description: string;
suggestion?: string;
}
Review Workflow Example
function ReviewWorkflow() {
const [phase, setPhase] = createSignal("implement");
return (
<Ralph maxIterations={5}>
{phase() === "implement" && (
<Claude
allowedTools={["Edit", "Write"]}
onFinished={() => setPhase("review")}
>
Implement the feature.
</Claude>
)}
{phase() === "review" && (
<Review
target={{ type: "diff", ref: "main" }}
criteria={[
"No security vulnerabilities",
"No hardcoded secrets",
"Tests are included",
"Code is documented",
]}
onFinished={(review) => {
if (review.approved) {
setPhase("done");
} else {
// Log issues and go back to implement
console.log("Issues:", review.issues);
setPhase("implement");
}
}}
/>
)}
</Ralph>
);
}
PR Review Example
<Review
target={{ type: "pr", ref: "123" }}
model="opus"
criteria={[
"Changes are backwards compatible",
"Performance impact is acceptable",
"Security considerations addressed",
]}
postToGitHub
onFinished={(review) => {
if (!review.approved) {
// Block merge
process.exit(1);
}
}}
/>
Blocking Reviews
Make reviews gate the workflow:
<SmithersProvider db={db} executionId={executionId}>
<Orchestration
stopConditions={[
{ type: "report_severity", value: "critical" }
]}
>
<Review
blocking
target={{ type: "diff", ref: "main" }}
criteria={["No critical security issues"]}
onFinished={async (review) => {
if (!review.approved) {
await db.vcs.addReport({
type: "finding",
severity: "critical",
title: "Review Failed",
content: review.summary,
});
}
}}
/>
</Orchestration>
</SmithersProvider>