Tag Archives: Claude

My Multi-Agent Coding Setup to Lower LLM Cost

AI coding tools are now good enough that the question is no longer “Should I use them?” For me, the more useful question is: how do I use them without letting LLM cost grow unnecessarily?

The obvious answer is to use cheaper models. That helps, but it is not the full answer. In practice, the bigger unlock is designing the coding workflow so that I can switch between tools and models without changing the way I work.

My setup is based on separating three things that often get blurred together:

  • Editor: where I view and manually edit code.
  • Harness: the coding agent layer that reads files, edits code, runs commands, applies patches, and manages repo context.
  • Model: the LLM doing the reasoning underneath the harness.

Once these are separated, I can optimize cost more intelligently. I can use premium models when reasoning quality matters, and use lower-cost models for exploration, boilerplate, summarization, first-pass refactors, or less risky changes.

The Architecture

At a high level, my setup looks like this:

The important part is that the editor, harness, and model are not the same thing.

VS Code is usually my editor. Codex, Claude Code, OpenCode, Copilot, and VS Code extensions are the harness layer or harness-like coding environments. Claude, GPT/Codex models, GLM, Qwen, DeepSeek, and other models are the reasoning engines underneath.

That distinction matters because cost optimization becomes easier when the harness is portable and the model is replaceable.

Shared Project Context

The foundation of the setup is shared project context.

I try to keep repo-specific guidance in files such as:

  • AGENTS.md
  • CLAUDE.md
  • architecture notes
  • test commands
  • coding conventions
  • reusable task prompts

This avoids re-explaining the project every time I switch tools. The goal is simple: if I move from Claude Code to Codex, or from Codex to OpenCode, the new harness should still understand the important repo conventions.

This also saves tokens. Instead of dumping long explanations repeatedly into every chat, I keep durable instructions close to the codebase.

Approach 1: VS Code as Editor, Harnesses Through Extensions

This is the setup I use most often for complex projects.

Here, VS Code is the editor. It is where I read code, navigate files, review diffs, and make manual edits.

The AI harness is usually provided through VS Code extensions or integrations.

Examples:

Editor: VS Code
Harness: Copilot extension / Codex extension or CLI integration / Claude extension / OpenCode extension
Model: OpenAI / Claude / Copilot-supported models / OpenRouter-supported models
Context: AGENTS.md / CLAUDE.md / repo docs / prompts

This setup works well for me because I still want to see the code clearly. I like reviewing changes in the editor, understanding the file structure, and staying close to the diff. Maybe that is old-fashioned, but for larger projects it helps me avoid blindly accepting agent output.

The cost benefit comes from keeping VS Code constant while changing the harness or model depending on the task.

For example:

  • I may use Copilot for quick inline completions.
  • I may use Claude through a VS Code extension for complex reasoning-heavy changes.
  • I may use Codex for agentic repo work.
  • I may use OpenCode when I want more model flexibility.

The key point is that VS Code is not the whole AI coding system. It is the editor. The harness and the model can still vary underneath.

Approach 2: Harness-First Workflow

The second setup is when I work directly inside the harness.

This applies to tools like:

  • Codex CLI
  • Claude Code
  • OpenCode app

In this workflow, there may not be a separate editor involved at every step. The harness becomes the main interface. It inspects files, proposes changes, applies patches, runs tests, and iterates.

Editor: Optional / secondary
Harness: Codex CLI / Claude Code / OpenCode app
Model: Native model for that harness, or configurable provider if supported
Context: AGENTS.md / CLAUDE.md / repo docs / prompts

I use this less for complex projects because I prefer to look at the code and review changes directly in the editor. But it works well for smaller modifications, scripts, quick utilities, and contained tasks where I can verify the output easily.

For small projects, the harness-first approach can be efficient because the agent can inspect files, make changes, run commands, and iterate without needing much manual navigation.

Cost-wise, this also helps because the harness can do local exploration. It can search files, inspect only what matters, and avoid loading unnecessary context.

Approach 3: Harness Plus OpenRouter for Model Flexibility

The third setup is where the harness/model separation becomes most explicit.

Some harnesses can be configured to talk to OpenRouter or other compatible model providers. That means I can keep the same coding workflow but change the model underneath.

Editor: Optional
Harness: Codex CLI / Claude Code / OpenCode
Model: OpenRouter-routed models
Context: AGENTS.md / CLAUDE.md / repo docs / prompts

For example:

Codex CLI harness
|
v
OpenRouter provider
|
v
z-ai/glm-5.2, Claude, Qwen, DeepSeek, etc.

This is useful for experimentation and lower-cost first passes. I do not need every task to use the strongest model. Some tasks are mostly repo search, summarization, simple code generation, or mechanical refactoring. Those are good candidates for cheaper models.

Then, when I need better reasoning, I can move back to a premium model.

That said, I do not personally rely on this approach much for daily coding. It may be stable enough for some workflows, but the interface between a coding harness and a third-party model router can change. Codex, Claude Code, or OpenRouter can update their API behavior, headers, tool-calling assumptions, or model compatibility. If that breaks, the workflow breaks.

So for me, Approach 3 is useful to know and useful for experiments, but it is not my default daily setup.

Using OpenRouter with Codex CLI

Codex can be configured with profiles. That lets the default codex command keep using the normal OpenAI/Codex setup, while a separate command uses OpenRouter.

Create:

~/.codex/openrouter.config.toml

Example config:

model_provider = "openrouter"
model = "z-ai/glm-5.2"
model_reasoning_effort = "medium"
[model_providers.openrouter]
name = "OpenRouter"
base_url = "https://openrouter.ai/api/v1"
env_key = "OPENROUTER_API_KEY"
wire_api = "responses"
http_headers = { "HTTP-Referer" = "https://chatgpt.com/codex", "X-Title" = "Codex" }

Add your OpenRouter key:

echo 'OPENROUTER_API_KEY=your_key_here' >> ~/.codex/.env

Add a shell alias:

alias codex-openrouter='codex --profile openrouter'

Now:

codex

uses the normal Codex/OpenAI setup, while:

codex-openrouter

starts Codex through OpenRouter using the configured model.

Inside Codex, verify the active configuration with:

/status

To use a different OpenRouter model for one run:

codex --profile openrouter -m anthropic/claude-sonnet-4.6

The important point is that I do not have to replace my main setup. I keep the default Codex workflow intact and add OpenRouter as a separate profile.

Claude Code with OpenRouter

At a high level, the idea for Claude Code is similar: configure the harness to talk to an OpenAI-compatible endpoint or route requests through OpenRouter, where supported.

The exact setup depends on how Claude Code exposes provider configuration at that time. This is one reason I treat this approach as experimental rather than my default daily workflow.

The pattern is:

Claude Code harness
|
v
OpenRouter or compatible endpoint
|
v
Selected model

If you use this path, I would treat it as a flexible experiment rather than a guaranteed stable interface. The harness, provider, or model compatibility can change.

How I Think About Model Routing

I do not try to use the cheapest model for everything. That can backfire. A cheap model that creates bad code, misses context, or causes extra cleanup may cost more in time than it saves in tokens.

Instead, I route tasks by risk and complexity.

For example:

TaskModel Strategy
Inline completionsCopilot or editor-native tools
Repo explorationLower-cost model or configurable harness
BoilerplateLower-cost model
Simple refactorStart with lower-cost model
Complex debuggingPremium model
Architecture decisionsPremium model
Final reviewStrongest available model

The pattern is:

Use cheaper models for reversible work. Use stronger models when mistakes are expensive.

That single rule handles most cases.

My Actual Usage Pattern

My own usage looks roughly like this.

Approach 1 is my default for complex projects.

I use VS Code as the editor and switch between harnesses through extensions or integrations. I prefer this because I can inspect code, review diffs, and stay oriented.

Approach 2 is useful for smaller changes.

I use harness-first tools like Codex CLI, Claude Code, or OpenCode for scripts, contained edits, and smaller projects where the blast radius is low.

Approach 3 is mostly experimental for me.

OpenRouter gives useful model flexibility, but I do not depend on it heavily for daily coding because the connection between the harness and the model provider can change.

Where the Savings Come From

The savings are not just from cheaper tokens.

They come from a few habits:

  • keeping project context reusable
  • avoiding repeated explanations
  • using harnesses that can inspect the repo directly
  • starting with cheaper models for low-risk work
  • reserving premium models for hard reasoning
  • avoiding huge chat histories when a fresh session with repo instructions is enough
  • choosing the right harness for the task

The most expensive workflow is often the one where I paste too much context into a chat, ask an unclear question, get a partial answer, then spend more tokens correcting it.

A good harness plus good project context reduces that waste.

What about smaller Models That can run locally?

One more workflow I am watching closely is smaller models that can run locally.

I have tried a few Qwen and DeepSeek models through Ollama. My Mac has 48 GB RAM, so it can run some reasonably capable local models. But for the coding tasks I care about, the quality has not yet been strong enough for me to use them as a primary workflow.

That said, I expect this to improve. Smaller models are getting better, and coding harnesses like OpenCode can make this workflow practical if they integrate cleanly with local runtimes such as Ollama.

If this becomes good enough, the stack could look like this:

Editor: VS Code or optional
Harness: OpenCode
Model: Smaller coding-capable model running through Ollama
Cost: No per-token API cost

That would be a meaningful cost-saving path. It would not be completely free in an absolute sense, because there is still hardware cost, electricity, latency, memory pressure, and quality tradeoff. But the marginal API cost per coding task could be zero.

For now, I see this as promising but not yet my default for serious coding work. I expect that to change as smaller coding models improve.

The Tradeoffs

This setup is not free.

There are tradeoffs:

  • Different harnesses support different features.
  • Some models are better at tool use than others.
  • OpenRouter compatibility can vary by model and API behavior.
  • Cheaper models may need tighter prompts and smaller tasks.
  • Switching tools too often can hurt flow.

So I do not treat this as a rigid system. It is a practical routing strategy.

If a task is important, ambiguous, or risky, I use a stronger model. If a task is routine, exploratory, or easy to verify, I am comfortable using a cheaper model.

Final Thought

My approach to lowering LLM coding cost is not just “use cheaper models.”

It is:

Make the harness portable, make the project context reusable, and make the model replaceable.

Once those layers are separated, I can choose the right level of spend for each coding task.

VS Code can remain my editor. Codex, Claude Code, OpenCode, or Copilot can act as the harness. OpenAI, Anthropic, OpenRouter, or other providers can supply the model.

Over time, smaller models that can run locally may become another important part of this setup. If a model running through Ollama can provide good enough coding quality through a harness like OpenCode, then some workflows could move from lower-cost API models to zero marginal API cost local inference.

That flexibility is what lowers cost without forcing me to give up the benefits of high-quality AI coding tools.

The Rise of CLI-Based AI Coding Agents: Claude code vs Gemini CLI

Introduction

I have been a Cursor user for vibe coding for 3 months. I was very skeptical about using Claude Code and Gemini CLI at first, since I wasn’t comfortable with the idea of using a terminal as an AI agent. But in the last 1–2 months, I’ve been trying them both — and it completely changed my opinion.

In this blog, I’ll share my experiences of using them, my favorite pick between the two, and a comparison of the three broad categories of AI-assisted coding approaches that exist today.


The Three Approaches to AI-Assisted Coding

I see broadly 3 kinds of AI-assisted coding approaches:

  • Chat interface with canvas → ChatGPT, Claude
  • IDE integrated AI tools → Cursor, Windsurf, Replit, Lovable
  • CLI-based AI agent tools → Claude Code, Gemini CLI, Warp
🧑‍💻 Category💬 Chat Interface🛠️ IDE Integrated Assist⚡ CLI-based AI Agent
Where it operatesBrowserStandalone IDE or browser (Cursor uses IDE, Lovable uses browser)Terminal or IDE
Use casePrototyping, small functions, quick answers, “throwaway weekend projects.”Augmenting the core coding loop: writing, refactoring, debugging.Automating workflows: multi-step tasks, system commands, project-wide changes.
Vibe coding stylePure “vibe coding” (conversational prompting).Hybrid of “vibe coding” + “developer assist.”Agentic + autonomous (give AI a goal and let it execute).

For a vibe coder like me, a CLI-based AI agent inside VS Code works perfectly — I get the best of both IDE and terminal with AI agent powers.


My Project: A 2-Way Translator App 🌍

To test these tools, I built a translation application.

When I visited Vietnam a few months back, I noticed cab drivers and restaurants using Google Translate effectively. But one problem stood out: only one device could be used for back-and-forth communication.

So, I decided to build a two-way translation application that solved this problem.

I drafted the following prompt (with ChatGPT’s help):

Global Translator App – MVP Requirements (Web Application)

  • Build a web app that lets two users communicate in real time via text translation.
  • Users connect via QR code or unique ID.
  • Support both text and speech.
  • Translate automatically for seamless conversation.

(Details moved to the appendix 👇)

Pre-requisites:

  • Google Translate API with GCP
  • Firebase backend

Claude Code vs Gemini CLI ⚡

🔎 Feature🤖 Claude Code🌐 Gemini CLI
📍 Location of useStandalone terminal or inside VS Code. In VS Code, Claude Code has IDE context — lets you select code and ask about it.Standalone terminal only. In VS Code, Gemini CLI has no IDE context (though Google offers Gemini Code Assist for IDE, without terminal capability).
💻 Terminal capabilityExcellent — can view files, execute commands, analyze outputs.Limited — shell commands can’t run in foreground, stateless (no persistent cd), no command completion.
⚙️ AI agent capabilityStrong coding performance; required multiple iterations but reliable.Decent, though not as strong as Claude Code.
🧪 Debugging & TestingSuperb. With terminal + MCP integration, I could run unit tests from both terminal and frontend.Limited debugging/testing due to terminal restrictions and weaker MCP tool support.
🔌 MCP integrationVery good. I integrated Playwright (UI automation) + Firebase.Okay. Playwright struggled (e.g., no 2-browser instance support). Firebase worked fine.
💸 Cost & model$20/month plan (Sonnet). Didn’t use Opus ($200/month). Sometimes hit daily quota limits.Free with generous limits (Gemini 2.5 Pro).

Verdict so far: Claude Code > Gemini CLI for most features, especially debugging and testing.
But Gemini CLI’s pricing (free) and generous usage limits are a big plus.

If Google can merge Gemini CLI with Code Assist and improve Playwright integration, it will become a fantastic package. On the other hand, Claude Code really needs a more flexible pricing tier between $20 and $200.


Project Output

  • Translation app built with Claude Code → [Demo link here]
  • Translation app built with Gemini CLI → [Demo link here]

Flow of the app:

  1. User logs in with a username (no auth to keep simple).
  2. Picks language + connects with another user via QR code or username.
  3. Supports both text + voice translation in real time.
  4. Built as a PWA → works on web + mobile.

Debugging & Testing with Claude Code 🔍

This is where Claude Code really shines:

  • Console errors are debugged + fixed automatically.
  • AI agent generates unit test cases, executes them, finds failures, and fixes them.
  • Even frontend integration testing works — thanks to MCP integration:
    • It inspects browser console logs.
    • Takes screenshots to analyze UI/UX issues (!).

I even asked Claude Code to:

  • Make a 90-second demo video of the app.
  • Simulate two users chatting with translations in the app. It worked beautifully.

Demo video created by Claude

Global Translation – User1

Global Translation – User2


Summary ✨

AI-assisted coding has matured tremendously in the last year and is now a top revenue driver among AI apps.

In my first blog on Vibe coding, I complained about limited debugging and testing with the AI coding tools. With these new coding agents, that problem feels largely solved.

Next, I’d love to see AI agents:

  • Do better system design.
  • Produce more modular code.
  • Integrate smoothly with existing codebases.

Between Claude Code and Gemini CLI → Claude Code wins hands down 🏆.
But I’m confident Gemini CLI will close the gap soon.


Appendix

Detailed prompt given for the translation application:

Tech Stack

  • Frontend Framework: React (or a similar modern JavaScript framework like Vue/Angular, but React aligns with future React Native plans)
  • Backend: Firebase (Firestore/Realtime Database for real-time chat, Authentication, Cloud Functions for server-side logic if needed)
  • Translation API: Google Cloud Translation API
  • QR Code: Open-source JavaScript libraries for QR code generation and scanning (e.g., qrcode.react, html5-qrcode)
  • Authentication: Anonymous sign-in (extendable to Gmail sign-in later)
  • Chat History: Local browser storage (e.g., LocalStorage, IndexedDB – no cloud sync for MVP)
  • Encryption: Not required for MVP
  • UI/UX: Simple, intuitive, and modern chat interface inspired by leading web messaging apps (e.g., WhatsApp Web, Telegram Web)
  • Dark Mode: Full support for dark mode from MVP

Core Features (MVP)

  • User Onboarding
    • Anonymous sign-in (no registration required for MVP)
    • Generate a unique user ID and QR code for each user upon entering the app
    • Users can choose and save a unique username, which is validated against a central Firestore database to prevent conflicts.
  • Connection Mechanism
    • QR Code Scanning: Allow users to scan another user’s QR code using their device’s webcam/camera (if available and permission granted).
    • Manual ID Entry: Provide an option to manually enter another user’s unique ID to initiate a chat.
    • Display your own QR code for others to scan.
    • The application remembers the last 5 friends you’ve connected with, allowing for quick selection from a dropdown menu.
  • Progressive Web App (PWA):
    • The application is designed to be installable on mobile and desktop

devices, offering an app-like experience with potential offline capabilities.

  • The layout is optimized to adapt and display correctly across various screen sizes, including iOS and Android mobile browsers.
  • Chat Interface
    • Real-time text chat between two users.
    • Each user selects their preferred language from a dropdown/selector. This language is the language to be used by the friend on the other side. 
    • Messages are automatically translated to the recipient’s language using Google Translate API.
    • Show both original and translated text in the chat bubble.
    • Support for dark mode.
    • Friend Online Status (Basic): It displays whether a friend is currently “Online” or “Offline” (with a “Last seen” timestamp). Note: The “offline” status is not automatically updated on browser close in the current setup.
  • Session Management
    • One-to-one chat sessions.
    • Simple chat history stored locally in the browser.
  • Language Support
    • Initial support for: Hindi, Telugu, Tamil, Kannada, English, and French.
  • Misc
    • A version number is displayed on the screen, making it easy to identify the deployed application version.

Non-Functional Requirements

  • Responsive and intuitive UI/UX, adapting well to different screen sizes (desktop, tablet, mobile browsers).
  • Fast translation and message delivery.
  • Minimal data usage.
  • Accessibility support.
  • Dark mode support.
  • Cross-browser compatibility (Chrome, Firefox, Safari, Edge).

Future Extensions (Post-MVP)

  • Native mobile applications (Android & iOS) using React Native.
  • Gmail sign-in and user profiles.
  • Speech-to-text and text-to-speech for voice communication.
  • Discover nearby users (if feasible for the web, e.g., using WebRTC data channels or location APIs).
  • Group chats.
  • Persistent chat history with cloud sync.
  • End-to-end encryption.
  • Support for additional languages.