Model chooser / Build or fix software / Recurring
Automated code review, test generation and small fixes run hundreds of times. Sonnet 5 gives near-Opus coding quality at a medium cost tier with the same 1M context, which is the trade a pipeline needs.
Why Claude Sonnet 5
How to use it
effort: "medium"; if acceptance holds, keep the cheaper setting.Claude API, TypeScript
Edit the parts in capitals, then run it.
import Anthropic from "@anthropic-ai/sdk";
import { readFileSync } from "node:fs";
const client = new Anthropic(); // reads ANTHROPIC_API_KEY
const diff = readFileSync("pr.diff", "utf8");
const res = await client.messages.create({
model: "claude-sonnet-5",
max_tokens: 16000,
thinking: { type: "adaptive" },
output_config: { effort: "medium" },
system: [
{ type: "text", text: readFileSync("REVIEW_RULES.md", "utf8"), cache_control: { type: "ephemeral" } },
],
messages: [{ role: "user", content: `Review this pull request against the rules. List only real problems, each with file:line.\n\n${diff}` }],
});
for (const block of res.content) if (block.type === "text") console.log(block.text);
Alternatives that also work
Pick it when the job is multi-step and agentic, such as fixing a failing build end to end, and a wrong fix is expensive.
Pick it when volume is very high and cost dominates. It is MIT-licensed, has a cheap hosted API with off-peak pricing, and scores 74.2 on DeepSWE on its model card.
Pick it when code must stay on your own machine. It is Apache 2.0, fits one 24GB GPU at 4-bit, and reports 61.7 on SWE-bench Pro.
Watch out for
budget_tokens and assistant prefill. Code copied from older tutorials will return a 400.Sources
Checked . Models change monthly; we re-check this page when they do.
Wiring it into a workflow that runs every week, with evals, fallbacks and a cost you can predict, is the work. Fifteen minutes, no deck.