explaingit

ghuntley/how-to-build-a-coding-agent

5,559GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

A hands-on Go workshop that walks you through building a coding assistant step by step, starting from a basic chatbot and adding file reading, shell commands, code editing, and pattern search until you have a local AI coding agent like Cursor or Cline.

Mindmap

mindmap
  root((coding agent))
    What it does
      Chatbot base
      File reading
      Shell commands
      Code search
    Tech stack
      Go 1.24
      Claude API
      ripgrep
    Use cases
      Learn agent patterns
      Build own assistant
      Understand Cursor
    Audience
      Go developers
      AI learners
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build your own AI coding assistant in Go that can read files and run shell commands

USE CASE 2

Learn how tool-calling works in AI agents by adding features one step at a time

USE CASE 3

Understand how tools like Cursor and Cline work under the hood

USE CASE 4

Create a local code search agent powered by ripgrep and the Claude API

Tech stack

GoAnthropic Claude APIripgrep

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Go 1.24.2 or later and an Anthropic API key.

In plain English

This repository is a hands-on workshop that walks you through building a coding assistant similar to tools like Cursor or Cline. You start with a basic chatbot that talks to the Claude API, then add capabilities one step at a time until you have a local assistant that can read files, list directories, run shell commands, edit code, and search a codebase by pattern. The workshop is written in Go. The project is structured as six separate programs, each building on the last. The first is a minimal chatbot that accepts your text and sends it to Claude. The second adds a tool that lets the assistant read a file you name. Each subsequent program adds one more tool until the final version can run arbitrary shell commands and search code with ripgrep. All six programs share the same basic loop. The program waits for your input, sends it to Claude, and inspects the response. If Claude wants to use a tool, such as reading a file or running a command, the program executes that tool, sends the result back to Claude, and asks Claude for a final answer. This cycle repeats until Claude responds with plain text rather than a tool request. Tools are defined as Go structs with a name, a description, and a function. The schema describing what inputs a tool needs is generated automatically from the struct definition, which keeps the tool definitions short and consistent. This pattern is the same one real coding agents use. Running the workshop requires Go 1.24.2 or later and an Anthropic API key. Each program is run directly with the Go command, and a verbose flag is available to show the full exchange between your code and the Claude API.

Copy-paste prompts

Prompt 1
Using the pattern from ghuntley/how-to-build-a-coding-agent, help me add a tool to my Go chatbot that lists all files in a directory and returns them as a JSON array.
Prompt 2
I am building a coding agent in Go following the how-to-build-a-coding-agent workshop. Show me how to add a ripgrep-based code search tool using the same struct-based tool definition pattern.
Prompt 3
Based on the how-to-build-a-coding-agent architecture, explain how the tool-calling loop works: how does the program detect when Claude wants to use a tool, execute it, and send the result back?
Prompt 4
I have finished the how-to-build-a-coding-agent workshop. Help me extend the final program with a write-file tool that lets the agent create or overwrite files on disk.
Open on GitHub → Explain another repo

← ghuntley on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.