githubJanuary 11, 2026
How to Build a Coding Agent (Repository)
A hands-on Go workshop that builds a coding agent incrementally through six files, each adding one capability - proving agents need only simple primitives composed in a loop.
Overview
This repository accompanies Geoffrey Huntley's workshop on building coding agents from scratch. The code demonstrates that functional coding assistants require nothing exotic - just Go, the Anthropic API, and five core tools composed in an event loop.
Key Features
- Incremental build structure - Six progressive files, each adding one capability
- Minimal dependencies - Uses only Go standard library and Anthropic SDK
- Complete tool implementations - Read, list, bash, edit, and ripgrep-based search
- Event loop architecture - The "agent heartbeat" pattern that powers all coding assistants
Progressive Build Structure
The workshop builds capability layer by layer:
flowchart LR
A[chat.go
Basic LLM] --> B[read.go
+File Read]
B --> C[list_files.go
+Directory List]
C --> D[bash_tool.go
+Shell Exec]
D --> E[edit_tool.go
+File Edit]
E --> F[code_search.go
+Ripgrep Search]
Code Snippets
Installation
# Clone and set up
git clone https://github.com/ghuntley/how-to-build-a-coding-agent
cd how-to-build-a-coding-agent
# Set your Anthropic API key
export ANTHROPIC_API_KEY=your-key-here
Running Each Stage
# Start with basic chat
go run chat.go
# Progress through stages
go run read.go
go run list_files.go
go run bash_tool.go
go run edit_tool.go
go run code_search_tool.go
Technical Details
Tools function as plugins defined by three components: name, input schema (generated from Go structs), and execution function. The agent loop follows a consistent pattern:
- Accept user input
- Send to Claude
- Check for tool calls
- Execute requested tools
- Return results to context
- Repeat until complete
Connections
- how-to-build-a-coding-agent - The workshop article that explains the concepts this code implements
- building-effective-agents - Anthropic's guide reinforcing the same "simplicity first" philosophy demonstrated here