The harness, not the model, makes a coding agent good. Build one from scratch — from a bare agent loop to a swarm of cloud agents.
Open-source course by Decoding AI in collaboration with Modal, Opik (by Comet) and Kitaru (by ZenML).

# install uv first if you don't have it: curl -LsSf https://astral.sh/uv/install.sh | sh $ git clone https://github.com/decodingai-magazine/building-a-coding-agent-from-scratch-course.git $ cd building-a-coding-agent-from-scratch-course $ make install $ cp .env.example .env # set GEMINI_API_KEY — free at https://aistudio.google.com/apikey $ uv run decode
Then type /demo- and pick a demo — see what they do. Full guide: install_and_usage.md.
/demo- and the six demos are one keystroke away.In one public experiment by LangChain, changing only the harness — same model throughout — moved a coding agent from roughly 30th place into the top 5 on Terminal-Bench. The harness decides what the model sees, what it touches, and what happens when it's wrong. It's also the part nobody teaches.
agent = Agent(
build_model(settings.llm_provider), # gemini | openrouter | modal
deps_type=AgentDeps, # cwd, event sink, permission gate
output_type=[str, DeferredToolRequests], # final answer, or tools paused for approval
)
register_tools(agent) # read, edit, bash, grep, ...
async with agent.iter(prompt, message_history=history) as run:
async for node in run: # model request → tool calls → repeat
stream_events(node)
That's the entire tool-calling agent — the thing people call "the agent" ends here. Everything else in this repo — the permission gate, the sandbox, compaction, the steering queue, the durable runtime, the subagent fan-out, the evals — is the harness. That's what you're here to build.
We spent months under the hood of Claude Code (via its leaked source), OpenCode, Pi, and Aider, then distilled it into 8 lessons where, from an empty repo, you build decode, your own terminal coding agent. By lesson 2 it asks permission before running bash; by lesson 8 it's deployed to the cloud, building the same feature 5–10× in parallel and handing you back reviewed pull requests. One headless core, two ways to drive it: an interactive TUI wired to a live session, and a remote runtime running N copies in parallel.
Under the hood: a Pydantic AI ReAct loop on Gemini, OpenRouter, or an open model you serve on Modal; file / bash / web / LSP tools and parallel Explore subagents; Docker/Modal sandboxes; a durable Kitaru runtime; Opik tracing and evals.
You walk away with three things:
decode at your own repos the way you point Claude Code at them today.Skip this layer and you're betting your work on tools you can't inspect.
The whole repo is free: clone it, read it, ship it. But anyone can read an agent loop. The lessons cover what code can't — why steering input waits for the next model call instead of injecting mid-tool, why compaction fires at ~80% of the window instead of at the limit, why the sandbox may hold a git token while the model's context never does, why subagent fan-out caps at 6. Every component earns its place, and every lesson walks the reasoning.
The finished agent ships with demo skills under .decode/skills/. Open the TUI, type /demo-, pick one, and watch the harness you're about to build do real work:
/demo-1-terminal-arcade — one prompt, a playable Snake game
/demo-3-repo-pulse — live GitHub API data rendered as a dashboard
/demo-6-article-kg — web articles scraped into an interactive knowledge graphAnd the machinery underneath is real infrastructure you'll stand up yourself, not a diagram:
bash runs in disposable Modal sandboxes — six live here, ~1.3s cold start
y/n gate on every tool call.kill -9 a run mid-task and resume it — checkpoints never re-pay for finished work.gemini-2.5-pro have done from this exact point?"Every lesson runs the same way: watch decode do it, then pull out the principle.
todo tool — [x] done, [~] in progress.Eight written lessons and four videos: video 2 covers lessons 2–3, video 3 covers lessons 4–6. The full codebase is already here; lessons publish progressively on Decoding AI and the links below light up as they go live.
The map of every component before you write a single line of code.
The ReAct loop, the core tools, and the human approving and steering every turn.
kill -9 a headless run, resume it from checkpoints, replay it with the model swapped.
Four permission modes, then Docker and Modal sandboxes — nothing executes on your machine.
Memory, compaction, skills, and LSP — the context window treated as a budget.
One call fans out N parallel subagents, each with a budget and a report contract.
Benchmarks, regression probes, and online evals: does it work, still work, keep working?
Deploy to GCP + Modal and build the same feature 5–10× in parallel — judged, winner merged.
For: engineers who learn by building. You finish with a working coding agent and patterns to steal for your own agentic applications.
| Target Audience | Why Join? |
|---|---|
| ML/AI Engineers | Build a complete agentic system — loop, tools, sandbox, evals — not another notebook demo. |
| Software Engineers | Stop treating the agent in your terminal as a black box. |
| AI/Platform Engineers | The ops half nobody covers: sandboxing, durability, secrets, observability. |
| Category | Requirements |
|---|---|
| Skills | Python (Intermediate) · LLMs & agents (Beginner) |
| Hardware | Modern laptop/PC. Docker optional (for the local sandbox); everything heavier runs in the cloud. |
| Level | Intermediate (but with a little sweat and patience, anyone can do it) |
| Time | ~4–6 hours for the whole course — 4 if you read and watch, 6 if you run everything. |
Running the code costs $0 if you stick to free tiers:
| Service | Cost |
|---|---|
| Gemini API (default provider) | free tier (Google AI Studio) |
| OpenRouter (alternative provider) | $0 on :free models (optional $10 credit raises the daily cap) |
| Modal (self-served open models + remote sandbox) | $30 free credits |
| Opik (tracing + evals) | free tier |
| Kitaru (durable runtime) | free, runs locally offline |
| GCP — deploy the agent to run remotely (optional) | ~$16/month while it's up — see infra.md |
Reading-only? Everything's free!
Self-paced and project-based: no paywall, no certificate theater. Read the lesson on Decoding AI, run the matching code, then break it and fix it.
Special thanks to Modal, Opik (by Comet), and Kitaru (by ZenML) for sponsoring this open-source course and keeping it free!
Opik and Kitaru are open source, too — star them: Opik on GitHub · Kitaru on GitHub.
No. The default Gemini provider has a free tier, OpenRouter routes across :free models, and Modal gives $30 in credits — see Cost Structure.
Accessibility: our audience knows Python. Claude Code, OpenCode, and Pi picked TypeScript; Go compiles to one tidy binary; and Aider proves Python can carry a serious coding agent. The course focuses on the design decisions, which transfer to any language.
Because adding custom logic to an existing harness is the easy part — knowing what to add requires understanding the internals. That's the fundamentals, and it's what still makes AI engineers valuable. Build a coding agent once and you're equipped to build a custom agent for any use case.
Deliberately. Memory is plain files — AGENTS.md for your instructions, MEMORY.md for what the agent learns — and the repo is explored just-in-time with grep. Fresh reads beat a stale index, and you get to see exactly what the agent knows.