A 12-File Refactor for $0.01: Three Models, Three Jobs
How Tacavar ran a 12-file refactor for $0.01 using a three-model triangle: Opus plans, Haiku audits, Codex executes. Cost breakdown and the pattern behind it.
Opus planned it, Haiku audited it, Codex executed it. Total cost: one penny.
That's not a gimmick stat pulled from a cherry-picked demo. It's what happened when the Tacavar team needed to migrate three MCP servers across two droplets — a refactor spanning twelve files — and refused to pay frontier-model rates for work that is mostly mechanical. The lesson generalizes far beyond this one migration, so let's break down exactly how the run worked, where every fraction of the penny went, and how you can apply the same triangle to your own refactors.
The Problem: 3 MCPs, 2 Droplets, 12 Files, One Tiny Budget
The job: move three MCP integrations from one droplet to two, which meant rewiring connection configs, updating transport layers, and touching twelve files in total. Nothing conceptually hard. But the surface area was large — the full implementation would involve generating well over 120,000 tokens of code and config changes across those twelve files.
The naive approach is to hand the whole thing to your strongest model and let it grind. Run the numbers and you'll see why that's a mistake. A single frontier model both planning and writing 120k+ tokens of output produces an ai refactor cost measured in dollars per run, and every iteration — every "actually, also update the retry logic" — multiplies it. Worse, the model spends most of its capacity doing work that doesn't require its intelligence. You're paying Opus prices for work a cheaper model does identically well.
At Tacavar, we treat model selection as an engineering decision, not a default. So we split the job.
The Triangle: Architect, Auditor, Executor
The structure we used — and now use routinely — is a three-role delegation triangle:
- Architect. Claude Opus 4.6 received a short, dense prompt describing the migration and produced a structured brief: which files change, in what order, with what constraints. Critically, Opus never touched a file. Its entire output was the plan.
- Auditor. Haiku 4.5 then read the brief adversarially, hunting for logical gaps: missed dependencies, files that referenced endpoints the plan didn't cover, ordering constraints that would break at deploy time. Audit cost: roughly $0.001.
- Executor. Codex, running under a ChatGPT Pro subscription where marginal token cost is effectively $0, took the audited brief and executed the full 120k+ token implementation across all twelve files.
Three models, three jobs, one handoff chain. This is the core of the multi-model delegation approach: the expensive model produces compressed judgment, the cheap model stress-tests it, and the flat-rate model converts it into output volume.
Why Each Model Got the Job It Is Actually Best At
The triangle isn't only about ai cost optimization — it's a quality optimization, and that's the part most teams miss.
Opus is better at architecture than execution. Its planning quality is elite, but asking it to also emit 120k tokens of implementation means paying premium rates for the portion of the job where it has no edge. So we capped it at the brief: short prompt in, structured plan out, minimal tokens billed at the expensive rate.
Haiku is better at finding logical gaps than writing code. A frontier model reviewing its own plan tends to rubber-stamp it — same model, same blind spots. A different model, even a small one, attacks the plan with fresh failure modes. Haiku caught the kind of dependency and ordering issues that would have surfaced as failed deploys later. For a tenth of a cent.
Codex is better at large-scale file manipulation than staying concise. Execution across twelve files is a volume problem, not a reasoning problem, once a solid plan exists. A flat subscription made its marginal cost zero, which meant the biggest and most token-hungry phase of the job was also the cheapest.
Claude Opus, Haiku, and Codex each have a distinct cost-quality curve. This llm orchestration pattern works because every model is assigned to the segment of the curve where it dominates — and never asked to do the thing it's worst at.
Isolated Workspaces and Bypass Flags Without the Blast Radius
The execution step used Codex with --dangerously-bypass-approvals, and yes, that flag name deserves the reaction you're having. Used carelessly on your working tree, it's exactly as dangerous as it sounds. Used correctly, it's how you let an executor run unattended without babysitting approval prompts.
The Tacavar setup makes the blast radius structurally small:
- Isolated workspace. Codex ran in a sandboxed checkout — a disposable clone, never the live droplet or the main branch. Worst case, you delete the workspace.
- Pre-audited plan. The executor wasn't improvising. It was following a brief that Haiku had already stress-tested, so the space of reasonable mistakes was narrow.
- Diff review as the gate. No mid-run approvals; instead, a single human review of the complete diff before anything merged. Approval moved from "confirm each step" to "inspect the result," which is the only review that actually catches integration-level errors anyway.
Bypass flags are a tooling decision; isolation is an architecture decision. Get the architecture right and the scary flag becomes routine.
Cost Breakdown: Where the Penny Went
Here's the full ledger for the run:
| Role | Model | Cost |
|---|---|---|
| Architect | Claude Opus 4.6 | ~$0.009 |
| Auditor | Haiku 4.5 | ~$0.001 |
| Executor | Codex (subscription) | $0 marginal |
| Total | $0.01 |
The architect's call dominates the bill because Opus is expensive per token — but the entire prompt and output were brief-sized, so "expensive" here means less than a cent. Haiku's audit was a rounding error. The 120k+ token implementation — the part that would have cost dollars per run on a single frontier model — cost nothing marginal because it rode on a flat subscription.
Compare that to the single-model baseline: same refactor, one model doing planning and execution, 120k+ premium-rate output tokens, plus re-runs on every iteration. The ai refactor cost differential isn't 10%; it's two orders of magnitude. And because the triangle also produced a cleaner plan and a human-readable audit trail, we didn't pay for it in rework.
Generalizing the Pattern to Your Own Refactors
You don't need our exact models to run this — you need the role structure. Any refactor with high output volume and low per-file complexity is a candidate:
- Keep the architect's prompt short. The expensive model's job is judgment compression, not volume. If your brief is bloated, you're paying premium rates for filler.
- Make the auditor adversarial and cross-model. The audit is only worth a tenth of a cent if it uses a different model than the planner. Same-model review inherits same-model blind spots.
- Give the executor flat-rate tokens plus isolation. Marginal cost near zero changes your iteration economics completely — you can afford full re-runs instead of patch attempts.
- Move human review to the diff. Stop gating every step; gate the merge.
Once the triangle is wired, the pattern repeats for migrations, dependency bumps, config sweeps, test scaffolding — anywhere the work is big but the thinking is bounded. This is the llm orchestration pattern we've standardized on inside Tacavar: route by job shape, not by habit, and let each model do the one thing it's actually best at.
See how Tacavar orchestrates model routing across its agent stack at tacavar.com.