How ghuntley/how-to-build-a-coding-agent works
Project type and purpose
• This is an open-source workshop repository written in Go that demonstrates step-by-step how to build progressively more capable AI “agents.”
• It evolves from a basic chat client (chat.go) to a full-featured agent with file I/O, shell commands, file editing, and code search (code_search_tool.go).
• Core learning: event-driven agent loop, tool-calling pattern, schema-driven parameters, error handling, and progressive enhancement.
File structure
• Top-level .go files each represent one stage of the agent:
– chat.go
– read.go
– list_files.go
– bash_tool.go
– edit_tool.go
– code_search_tool.go
• Shared resources:
– AGENT.md (dev environment docs)
– prompts/ (sample prompt files)
– Makefile, devenv.* (environment setup), go.mod/go.sum
• No separate src directory; each agent is a standalone executable that imports common modules (tool definitions, schema generation, logging).
• Configuration and environment files (.envrc, .gitignore, renovate.json) sit at root.
README for architecture insights
– Overall agent architecture (Agent → Anthropic Client, Tool Registry, getUserMessage, Logging)
– Shared event loop (user input → inference → tool use loop → result → back to Claude)
– Tool execution loop (lookup by name → run → capture result → repeat)