Skip to content
Agent Search Engine

Guide · Coding

How to build a coding agent: choosing your stack when the harness is the product

Building a coding agent looks like a prompting problem and is really a systems problem — the model is the easy part, the loop around it is the work. This guide walks that stack the way a senior engineer would: one fork at the top — adopt an agent, or build your own harness — then the layers you own if you build. No rankings for hire, no vendor’s roadmap — just the trade-offs.

Independent · sponsor-blind · updated 2026-07-21 · how we choose

A coding agent is a loop, not a prompt. It reads code, makes an edit, runs something — a test, a build, the program itself — reads what broke, and goes again, over and over, until the task is done or it’s hopelessly lost. The model picks the next move; everything that makes that move safe, informed, and reversible is the harness around it — showing the agent the right slice of a large repo, running its code without handing it your laptop, catching a bad edit before it lands. That harness is the product. Teams that treat the prompt as the hard part ship a demo that writes a clean function on a toy file and falls apart the moment it meets a real codebase: it edits the wrong module, can’t see why the test failed, or confidently calls an API that doesn’t exist because it never actually read the code.

So don’t start by writing the system prompt. The decision that shapes your next month is more basic: do you adopt an agent someone else already built and get on with shipping, or build your own harness because you need something the off-the-shelf ones won’t give you? Everything else follows from that answer.

The core decision: adopt an existing agent, or build your own harness

There are two honest ways to get a coding agent, and only one of them is a project.

Adopting an existing agent is the right call for most teams, most of the time. The mature options are commercial products — not in our index, and not what we compare: Cursor, GitHub Copilot, Claude Code, OpenAI Codex, Windsurf, Devin, and Aider are the field’s standard picks, and they’ve each sunk years into the loop, the context handling, and the editor integration you’d otherwise rebuild from scratch. If you want that shape without the license or the lock-in, the open CLIs are in our index: gemini-cli brings a capable agent into the terminal, goose goes past suggestions to install, execute, edit, and test with any model, grok-cli is the same idea on the Grok API, and openinterpreter is a lightweight agent tuned for open models like Deepseek, Kimi, and Qwen. Adopting needn’t mean a single agent, either: wshobson/agents is a marketplace of subagents and plugins for the commercial CLIs, and if you want several agents in one place, claude_codex_bridge, HolyClaude, and open-cowork are workspaces that run and mix Codex, Claude, Gemini, and others — open-cowork adds one-click install and sandbox isolation on the desktop. If an off-the-shelf agent clears your hardest task, stop here. You don’t have a harness to build.

Building your own harness is a real project, and you should be able to name why you’re taking it on. Good reasons: control the products won’t give you, a specific workflow baked into the loop, on-prem or air-gapped operation, small or local models the commercial tools don’t target, reviewability you can defend to a security team, or — the big one — you’re building a coding-agent product and the harness is what you sell. Bad reasons: it looks fun, or you assume the off-the-shelf agents are thin wrappers you’ll beat in a weekend. They aren’t; the loop is deceptively deep. If you can’t point to a requirement the commercial and open agents genuinely fail, adopt one and move on.

Between adopt and build sits a middle path — open harness SDKs that hand you the loop without a blank page. jcode is a coding-agent harness; harness-sdk lets you build and control a harness end-to-end across any model and cloud, in Python or TypeScript; CoreCoder is a minimal, roughly thousand-line Claude-Code-like agent you can actually read and modify — think nanoGPT for coding agents. Start here when you want to own the loop but not reinvent it.

Honestly: if your job is to ship features, adopt an agent — you’ll be productive this afternoon, and you can graduate later. Take the build path only when a real requirement forces it, and even then start from an open harness SDK, not an empty file. A good tell: run your hardest real task — a change spanning a few files in your actual repo, not a toy script — through an off-the-shelf agent first. If it handles that, the harness you were about to build is a harness you don’t need.

The layers, if you build

Six layers of the harness, roughly in the order you’ll reach for them. For each: the decision, a recommended default, and the one mistake that quietly costs you.

1 · The agent loop / harness

This is the spine: read, edit, run, read the result, repeat — and the decision is how much of it you own. Adopt the loop wholesale from an open SDK — jcode, harness-sdk, or the readable ~1k-line CoreCoder — when you want a working cycle you can modify, or hand-roll it only when your workflow is genuinely unusual. fast-agent is a fuller framework if you want strong MCP and skills support built in; little-coder is tuned for smaller local models, which behave differently enough that a harness built for frontier models will thrash on them; and ORG2 wraps the loop in a Cursor-style IDE built for reviewability, on its own Rust harness. When the loop calls the model many times per task, the enemy is non-determinism — teaql-agent-kit exists to make execution repeatable — and when you need to chain agent runs into a longer pipeline, CodeMachine-CLI orchestrates them into repeatable workflows. Default: adopt an SDK’s loop, keep it short and observable, and don’t add orchestration until a single agent visibly can’t do the job.

Watch outan agent that edits but never runs anything is just an expensive autocomplete; the thing that makes it an agent is reading its own test and build output and acting on it, so wire the feedback in before you polish the prompt.

2 · Code context & retrieval

This is the number-one lever on output quality, and it’s not close — a coding agent is only as good as the slice of the codebase it can see. The naive approach (paste everything, or grep-and-read whole files) burns tokens and drowns the signal; the job is to fetch the few functions that actually matter. semble does fast code search the project clocks at around 98% fewer tokens than grep-plus-read; cocoindex-code indexes code by AST for structure-aware search that saves tokens the same way; and serena goes further — a semantic retrieval-and-editing MCP that acts like an IDE for your agent, navigating and changing code by symbol rather than by string. For the other half of context, the libraries your code calls, Context7 pipes up-to-date library docs into the model so it stops guessing at APIs that changed since training. Embeddings themselves are external infrastructure (an off-the-shelf embedding model, none in our index). Default: index the repo for structural or semantic search and retrieve narrowly — never let the agent’s context grow linearly with the size of the codebase.

Watch outdumping the whole repo into the prompt is the beginner move that feels thorough and quietly wrecks everything: it blows the token budget, buries the one relevant file in noise, and gets slower and dumber as the codebase grows.

3 · Execution & sandboxing

An agent that can’t run code is barely an agent, and an agent that runs code on your laptop is a liability. You need an isolated, disposable environment — a fresh sandbox per task with a limited filesystem, restricted network, and no standing credentials — that you throw away when the run ends. daytona is purpose-built secure, elastic infrastructure for running AI-generated code; the field’s other standard pick here is E2B, which isn’t in our index. If the agent needs to drive a browser or a full desktop rather than just a shell, cua provides computer-use sandboxes and SDKs, and steel-browser is a browser sandbox built for agents. Default: run every piece of generated code in a sandbox from day one — retrofitting isolation after something escapes is the expensive way to learn this.

Watch outnever run untrusted generated code on your host; one hallucinated “rm -rf”, a curl-to-bash, or a quiet exfiltration call and the blast radius is your machine, your keys, and your network — the sandbox is a safety control, not a nice-to-have.

4 · The model / brain

The models aren’t in our index — they’re the brain you rent, and the standard picks are OpenAI, Anthropic, and Google. For a coding agent the selection criteria aren’t raw benchmark IQ: you want reliable tool- and function-calling (the agent acts by calling tools, and a model that malforms those calls breaks the loop), long-context handling that stays coherent deep into a large file, and a cost-per-token you can pay on every step of a chatty loop, not just once. Default: start with a strong general model, then test a cheaper or faster one on your actual tasks — the loop calls the model constantly, so a small per-call saving compounds hard. Don’t marry a provider; keep the model behind a seam you can swap.

Watch outthe smartest model isn’t automatically the right one; a coding agent lives on tool-calling reliability and long-context handling, and a model that reasons beautifully but calls tools sloppily will stall the loop while looking brilliant in a chat window.

5 · Memory & state

A real task runs long — dozens of edits, test runs, and dead ends — and stuffing the entire history back into every prompt hits the context ceiling and gets costly and confused on the way there. The decision is what state to persist and how to recall it: a running summary, the task plan, what’s been tried, the key decisions. byterover-cli is a portable memory layer built specifically for coding agents, so context can survive across sessions and even across different agents; ai-devkit is a control plane for coding agents that manages this state and configuration around the loop. Default: keep an explicit, compact working state — plan plus salient facts — rather than leaning on an ever-growing transcript, and reach for a persistent memory layer only once tasks genuinely span sessions.

Watch outa long task will overflow the context window, and the lazy fix — keep appending the whole history — makes every step slower and more expensive while burying the current goal; decide what to carry forward and what to drop.

6 · Review, trust & eval

This is the layer that turns plausible output into output you’ll actually ship, and it’s the one teams skip. Three parts: a diff you review before anything lands, tests and checks that gate the change, and an honest eval so you know whether the agent is getting better or just louder. zeroshot is built around exactly this — an autonomous CLI whose loop is gated by non-negotiable feedback from independent reviewers, so the output is trustworthy in prod — and ORG2 makes the diff reviewable by construction. For guardrails on an autonomous agent — policy, identity, sandboxed permissions — agent-governance-toolkit enforces them. For measuring capability, SWE-bench is the field’s standard benchmark for resolving real GitHub issues; treat it as a sanity check, not a target, because the score that matters is performance on your codebase, not someone else’s. Default: require human diff review plus green tests before merge, and build a small eval of real tasks from your own repo before you trust any headline number.

Watch outautonomy you haven’t earned is the fastest way to lose trust in the whole system; an agent that merges its own unreviewed diffs will eventually break main with total confidence, and then you turn it off — ratchet autonomy up only as evidence accumulates.

The mistakes that sink coding agents

  • Dumping the whole repo into context. It feels thorough and does the opposite — blows the token budget, buries the one file that matters, and degrades as the codebase grows. Retrieval beats brute force at every size.
  • Running generated code on your own machine. One hallucinated shell command and the blast radius is your filesystem, your credentials, and your network. Sandbox from the first run, not after the first incident.
  • Shipping without diff review. An agent that merges its own work will eventually break main with total confidence. The review step is what makes the output usable — it’s not bureaucracy, it’s the product.
  • Chasing the benchmark instead of your codebase. SWE-bench (the standard eval) tells you an agent can resolve some strangers’ GitHub issues, not that it can navigate your monorepo, your conventions, and your flaky tests. Build a small eval from your own repo and trust that.
  • Granting autonomy you haven’t earned. Let the agent propose before it acts, act before it merges, and merge before it deploys — opening each gate only when the evidence says to. Full autonomy on day one is how you lose trust in the whole system on day two.
  • Ignoring the token cost of the loop. A coding agent calls the model over and over per task; a fat system prompt or a bloated context is a bill you pay on every step, not once. What’s trivial per call is your dominant line item at scale.

Which should you pick?

  • You just want to ship features, limited time for tooling → adopt an off-the-shelf agent: a commercial pick (Cursor, GitHub Copilot, Claude Code, Codex) or an open CLI like gemini-cli or goose. Don’t build.
  • You’re building a coding-agent product or a custom harness → start from an open harness SDK: harness-sdk or jcode, or the minimal CoreCoder to learn the loop before you extend it.
  • Small, local, or on-prem models little-coder, a harness tuned for smaller LLMs rather than frontier ones.
  • You need reviewability and control ORG2, a Cursor-style agent IDE built for review, with its own Rust harness.

Frequently asked

Should I build my own coding agent or use Cursor / Copilot?
For almost everyone, use the off-the-shelf agent. Cursor, Copilot, Claude Code, and Codex (all commercial, none in our index) have poured years into the loop, context handling, and editor integration — you won’t beat that in a sprint, and while you try, you’re not shipping. Build your own only when a real requirement forces it: control, on-prem, small or local models, reviewability, or you’re selling the agent itself. Even then, start from an open harness SDK like harness-sdk or jcode rather than an empty file. Rule of thumb: if you can’t name the requirement the existing agents fail, you have your answer.
What’s the hardest part of building a coding agent?
Not the prompt — the harness, and specifically two things: getting the right code context into the model (a large repo doesn’t fit, and dumping it in degrades quality), and running the agent’s code safely (you can’t let generated commands loose on your machine). The prompt is a weekend; context and safe execution are the project. Most “the agent is dumb” complaints are really “the agent couldn’t see the right code” or “we never trusted it enough to let it run and check its own work.”
How do coding agents get code context?
Not by pasting the whole repo — that’s the mistake. Good agents index the codebase and retrieve narrowly: keyword or structural search (semble, or cocoindex-code by AST), semantic symbol-level navigation (serena), and up-to-date library docs on the side (Context7). The goal is to put the few relevant functions in context, not the whole tree, because quality drops and cost climbs as you add irrelevant code. It’s retrieval — the same discipline as RAG, applied to source.
How do I run agent-generated code safely?
In a sandbox, never on your host. Give each task a fresh, disposable environment with a limited filesystem, restricted network, and no standing access to your real credentials, then discard it when the run ends. Daytona (in our index) and E2B (the standard external pick) are built for exactly this; cua and steel-browser cover the cases where the agent needs a full desktop or a browser rather than a shell. One hallucinated destructive command is all it takes, so isolate from the first run — retrofitting containment after an escape is the hard way.
How do I evaluate a coding agent?
On your own code, not just the leaderboard. SWE-bench is the field’s standard benchmark — can an agent resolve real GitHub issues — and it’s a useful sanity check, but a high score doesn’t mean the agent understands your monorepo, your conventions, or your flaky test suite. Build a small eval set of real tasks from your repo with known-good outcomes, and gate every change on human diff review plus green tests. Tools like zeroshot and ORG2 bake reviewability into the loop, but the discipline matters more than the tool.

More stack guides