buildcraft

go · intermediate

Build Your Own Coding Agent in Go

Implement a coding agent in Go, one stage at a time. You start with a tiny OpenAI-compatible client and finish with the pieces a tool-using agent needs, including a loop, context limits, and permissions.

0 of 9 stages passed. Copy courses/coding-agent-go/starter and work through the map. The reference solution used by CI is not what you submit.

  1. 01A minimal LLM API clientSend a chat completion to an OpenAI-compatible endpoint and return the assistant text. Tests use a mock server, so you do not need an API key.Free
  2. 02A chat loop with historyRead lines from the user, keep the transcript, and print each reply. The harness stubs the model with a function.Free
  3. 03Tool calls and a registryParse OpenAI tool_calls payloads and dispatch them through a small in-process registry.
  4. 04A workspace file-read toolLet the model read files inside the project, and reject paths that escape the workspace.
  5. 05A file edit toolApply one unique search-and-replace edit inside the workspace.Preview
  6. 06A shell toolRun a command in the workspace with a timeout and captured output.Preview
  7. 07The agent loopAlternate model calls and tool execution until the model stops requesting tools.Preview
  8. 08Context managementKeep the transcript inside a character budget without dropping the system prompt.Preview
  9. 09Safety and permissionsGate each tool behind an explicit policy so a prompt cannot grant itself shell access.Preview