Welcome! 👋 This workshop will guide you through building your own AI-powered coding assistant — starting from a basic chatbot, and adding powerful tools like file reading, shell command execution, and code searching.
You don’t need to be an AI expert. Just follow along and build step-by-step!
🌐 Want a detailed overview? Check out the blog post: ghuntley.com/agent
By the end of this workshop, you’ll understand how to:
You’ll build 6 versions of a coding assistant.
Each version adds more features:
graph LR
subgraph "Application Progression"
A[chat.go
Basic Chat] --> B[read.go
+ File Reading]
B --> C[list_files.go
+ Directory Listing]
C --> D[bash_tool.go
+ Shell Commands]
D --> E[edit_tool.go
+ File Editing]
E --> F[code_search_tool.go
+ Code Search]
end
subgraph "Tool Capabilities"
G[No Tools] --> H[read_file]
H --> I[read_file
list_files]
I --> J[read_file
list_files
bash]
J --> K[read_file
list_files
bash
edit_file]
K --> L[read_file
list_files
bash
code_search]
end
A -.-> G
B -.-> H
C -.-> I
D -.-> J
E -.-> K
F -.-> L
At the end, you’ll end up with a powerful local developer assistant!
Each agent works like this:
We call this the event loop — it's like the agent's heartbeat.
graph TB
subgraph "Agent Architecture"
A[Agent] --> B[Anthropic Client]
A --> C[Tool Registry]
A --> D[getUserMessage Function]
A --> E[Verbose Logging]
end
subgraph "Shared Event Loop"
F[Start Chat Session] --> G[Get User Input]
G --> H{Empty Input?}
H -->|Yes| G
H -->|No| I[Add to Conversation]
I --> J[runInference]
J --> K[Claude Response]
K --> L{Tool Use?}
L -->|No| M[Display Text]
L -->|Yes| N[Execute Tools]
N --> O[Collect Results]
O --> P[Send Results to Claude]
P --> J
M --> G
end
subgraph "Tool Execution Loop"
N --> Q[Find Tool by Name]
Q --> R[Execute Tool Function]
R --> S[Capture Result/Error]
S --> T[Add to Tool Results]
T --> U{More Tools?}
U -->|Yes| Q
U -->|No| O
end
Option 1: Recommended (using devenv)
devenv shell # Loads everything you need
Option 2: Manual setup
# Make sure Go is installed
go mod tidy
export ANTHROPIC_API_KEY="your-api-key-here"
chat.go — Basic ChatA simple chatbot that talks to Claude.
go run chat.go
--verbose to see detailed logsread.go — Read FilesNow Claude can read files from your computer.
go run read.go
list_files.go — Explore FoldersLets Claude look around your directory.
go run list_files.go
bash_tool.go — Run Shell CommandsAllows Claude to run safe terminal commands.
go run bash_tool.go
edit_tool.go — Edit FilesClaude can now modify code, create files, and make changes.
go run edit_tool.go
code_search_tool.go — Search CodeUse pattern search (powered by ripgrep).
go run code_search_tool.go
fizzbuzz.js: for file reading and editingriddle.txt: a fun text file to exploreAGENT.md: info about the project environmentAPI key not working?
echo $ANTHROPIC_API_KEYGo errors?
go mod tidyTool errors?
--verbose for full error logsEnvironment issues?
devenv shell to avoid config problemsTools are like plugins. You define:
read_file)Example tool definition in Go:
var ToolDefinition = ToolDefinition{
Name: "read_file",
Description: "Reads the contents of a file",
InputSchema: GenerateSchema[ReadFileInput](),
Function: ReadFile,
}
Schema generation uses Go structs — so it’s easy to define and reuse.
| Phase | What to Focus On |
|---|---|
| 1 | chat.go: API integration and response handling |
| 2 | read.go: Tool system, schema generation |
| 3 | list_files.go: Multiple tools, file system |
| 4 | bash_tool.go: Shell execution, error capture |
| 5 | edit_tool.go: File editing, safety checks |
| 6 | code_search_tool.go: Pattern search, ripgrep |
If you use devenv, it gives you:
devenv shell # Load everything
devenv test # Run checks
hello # Greeting script
Once you complete the workshop, try building:
This workshop helps you:
Have fun exploring and building your own AI-powered tools! 💻✨
If you have questions or ideas, feel free to fork the repo, open issues, or connect with the community!
$ claude mcp add how-to-build-a-coding-agent \
-- python -m otcore.mcp_server <graph>