Skip to content
Back to the catalog
Project coding-agentToolingBeginnerBeta

Build a Coding Agent

Learn the core foundations of AI coding assistants from scratch: model basics, API key security, why use OpenRouter as a universal model router, tool schemas, and the autonomous ReAct loop.

Build it in your language

The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

Tools like Claude Code, Codex, Pi, and OpenCode are reshaping software engineering. For junior developers and beginners, they might feel like magic black boxes. In reality, their architecture rests on clean, approachable software principles: communicating with model APIs through a universal router like OpenRouter, defining tools with JSON schemas, and safely inspecting and editing code within an iterative loop.

In this project, you will build a coding agent runtime from the absolute fundamentals. You will understand what an API key is and how to protect it with environment variables, why model routers prevent vendor lock-in, how to structure tools with line context and surgical patching, and how to orchestrate the autonomous Reason-Act (ReAct) loop.

Roadmap

7 stages across 3 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 12 stages

    Model Foundations, API Keys, and Routers

    Understand language models, API key authentication, why to use OpenRouter as a universal model router, and how to declare standard tool schemas.

    1. 01Models, API Keys, and Why We Use OpenRouter
    2. 02Tool Declarations in Standard OpenRouter / OpenAI Format
  2. Phase 23 stages

    Workspace Tools

    Implement the tools the agent uses to inspect and modify code: line-numbered reading, file creation, and surgical patching.

    1. 01Line-Context File Reading
    2. 02File Creation and Writing
    3. 03Surgical Search-and-Replace Patching
  3. Phase 32 stages

    Execution Protocol and ReAct Loop

    Unify tools in a dispatcher that isolates recoverable errors and orchestrate the autonomous ReAct reasoning and acting loop.

    1. 01Tool Dispatcher and Execution Protocol
    2. 02The Autonomous ReAct Loop

Before you start

A CLI coding agent engine that declares OpenRouter/OpenAI-compatible tool schemas, inspects and edits code via surgical patching, dispatches structured tool calls, and drives the ReAct execution loop to completion.

  • grep
    Beta

    Build your own grep

    Read stdin, filter by pattern and honour exit codes. The gateway to Unix tooling.

    Beginner7 stages~6 hTooling
    regexclistdin

    Go · Python · Zig

  • git
    Beta

    Build your own Git

    Blobs, trees and commits. Discover that Git is a content-addressed object store, and little else.

    Advanced12 stages~18 hTooling
    hashingzlibdag+1

    Go · Python · Rust