Skip to main content
TACAVAR
Build in Public

A 12-File Infrastructure Refactor for $0.01 with Three AI Models

Opus planned, Haiku audited, Codex executed. Total cost: one cent.

That sentence is not a flex. It's the clearest argument I've seen for why Tacavar's agent routing exists: because the right multi-model orchestration turns infrastructure work that usually eats an afternoon into a machine-checked pipeline that costs less than a gumball. I ran a 12-file infrastructure refactor for $0.01 by using three different AI models for three different jobs—none of them doing the job they're worst at.

The Refactor: 3 MCPs, 2 Droplets, 12 Files

The task was boring in the best way. Three MCP servers needed to be migrated across two droplets. The change touched twelve files: configuration, environment variables, service definitions, auth credentials, and the small glue code that keeps them from falling over. It's exactly the kind of work that every founder eventually does by hand on a Friday night and regrets.

The interesting part wasn't the size. It was the bill. The entire refactor cost one cent of marginal compute. That's not a benchmark from a lab; it's a production migration run through a delegation pattern that most teams still don't use.

Tacavar's whole thesis is that the model routing layer matters as much as the models themselves. When you wire models the right way, you're not just saving money—you're getting better outcomes than a single frontier model could produce alone.

Why One Model Shouldn't Do Everything

The default instinct is to throw the biggest model at the whole task. Send the full context to Claude Opus, ask it to plan and edit all twelve files, and hope for the best. That approach has two problems.

First, it's expensive. You're paying premium token rates for the parts of the job that don't need premium reasoning: rewriting config blocks, updating service files, moving authentication logic. It's like flying a private jet to move a couch—you can do it, but the couch doesn't care how nice the plane is.

Second, and more importantly, one model can't be world-class at every stage of a task. Claude Opus is exceptional at architecture, but it's not built to manipulate 120,000 tokens of files across a codebase. Haiku is extraordinarily cheap and fast, but you don't want it writing complex migrations alone. Codex is excellent at executing large file changes, but it's not the model you want making subtle architectural trade-offs.

LLM cost optimization isn't about finding the cheapest model for the whole job. It's about routing each subtask to the model where its marginal dollar buys the most quality. That's the foundation of the AI delegation pattern that made this refactor work.

The Delegation Triangle: Architect, Auditor, Executor

The pattern is simple: three roles, three models, one pipeline. No model does the job it's worst at.

The architect is Claude Opus. It received a short prompt describing the goal and produced a tight implementation brief. That brief specified every file to change, the order of operations, and the rollback plan. Crucially, Opus never touched a file. It only produced text. That keeps its context small, its output focused, and its cost near zero. You're not paying architecture brain to write boilerplate.

The auditor is Haiku 4.5. It read Opus's brief and looked for logical gaps. This is a role that most people skip, and it's exactly the role where Haiku shines. Haiku isn't trying to impress you with clever code. It's checking: Are there variables referenced but never defined? Are the files in the right order? Does the rollback plan cover a failed droplet? That audit pass cost $0.001. For a tenth of a cent, the plan got a second pass from a model that has no ego about the solution.

The executor is Codex, running through a ChatGPT Pro subscription. Its marginal token cost was $0, which is why the total bill stayed at a penny. Codex took the audited brief and executed the 120k+ token implementation across all twelve files. It ran with --dangerously-bypass-approvals in an isolated workspace, which is the right way to use that flag: only after the plan has been audited and the workspace can be thrown away. Codex execution is at its best when there are many files to change and the plan is already locked. Codex is built for large-scale file manipulation, and it's better at that than trying to be concise.

That's the delegation triangle. It's a concrete example of multi-model orchestration: let each model operate where its strengths pay off.

Cost Breakdown: $0.01 vs a Single-Model Approach

Let's put the numbers side by side.

The actual run: Opus planned for roughly $0.009. Haiku audited for $0.001. Codex executed for $0 of marginal token cost because it was on a subscription. Total: $0.01.

The single-model approach would have looked different. If you sent the entire migration to Claude Opus—architecture, file edits, and all—you'd be paying premium rates for 120k+ tokens of implementation. The cost would have been an order of magnitude higher, and the process would have been slower, because Opus has to think about every file as if it's a new architectural problem.

If you sent it to a cheap model, the architecture would have been the weak point. The plan would have been missing migration order or rollback details, and you'd discover that after the first file got corrupted.

The point isn't that one cent versus fifty cents is going to change your burn rate. It's that the cheapest option was also the best option. That almost never happens with the default approach.

The Hidden Quality Win of Model Specialization

This is the part that doesn't fit in a cost spreadsheet. Multi-model delegation isn't just LLM cost optimization—it's quality optimization.

The architecture was better because Opus only had to write a brief. It didn't have to hold twelve files in its head while also generating code. The audit was better because Haiku's entire job was to find holes, not to defend a solution it had written. The execution was better because Codex could spend 120k tokens manipulating files without worrying about whether its response was concise enough for a chat window.

Each model did the thing it's actually good at. Opus is better at architecture than execution. Haiku is better at finding logical gaps than writing code. Codex is better at large-scale file manipulation than staying concise.

A single model forced to do all three has to compromise on all three. The architect compromises by also being the executor. The auditor compromises by being the same model that wrote the plan, so it has a blind spot for its own assumptions. The executor compromises by trying to be a generalist instead of a tool built for broad file operations.

The quality win is the real reason to build this pattern into your pipeline. The one cent is just the visible evidence that you're not wasting tokens on tasks the model isn't good at.

How to Replicate This Pattern in Your Own Pipeline

You don't need to reinvent orchestration. You need to start treating delegation as a first-class step in how you use AI.

First, split every task into three artifacts: a brief, an audit, and an execution patch. Don't ask one model to produce all three. That separation of concerns is the AI delegation pattern that drives the quality win.

Second, choose the architect model for the shortest, highest-leverage artifact. Use an expensive reasoning model only for the brief. Keep the prompt short, and don't let it touch files.

Third, route the brief to a cheap auditor model. Make it look for gaps, not write code. If the audit fails, send the plan back to the architect. This step alone will catch more bugs than any code review you've done by hand.

Fourth, hand the audited brief to an executor model in an isolated workspace. Use bypass flags only after the audit has passed. Let the executor spend as many tokens as it needs to make the changes mechanically correct.

Finally, put this pipeline somewhere it can run without you. That's where Tacavar's agent routing comes in. Tacavar routes each stage to the right model, passes the architect's brief to the auditor, and hands the verified plan to the executor. It makes delegation patterns like this turnkey rather than a one-off script you have to maintain.

Tacavar's agent routing makes delegation patterns like this turnkey. See tacavar.com/agents.