how-to-build-a-coding-agent

(★ 5,811)

A workshop that teaches you how to build your own coding agent. Similar to Roo code, Cline, Amp, Cursor, Windsurf or OpenCode.

File Explorer

  • .envrc
  • .gitignore
  • AGENT.md
  • bash_tool.go
  • chat.go
  • code_search_tool.go
  • devenv.lock
  • devenv.nix
  • devenv.yaml
  • edit_tool.go
  • go.mod
  • go.sum
  • list_files.go
  • Makefile
  • read.go
  • README.md
  • renovate.json
  • riddle.txt

# Installation Guide

go
Prerequisites

Setup Steps

devenv shell

Load the development environment using devenv.

go mod tidy

Tidy and download Go module dependencies.

export ANTHROPIC_API_KEY="your-api-key-here"

Set the Anthropic API key environment variable.

go run chat.go

Run the basic chat agent.

Key Commands

go mod tidy

Synchronize Go module dependencies for the project.

go run chat.go

Run the basic chatbot application.

go run read.go

Run the agent with file reading capabilities.

go run list_files.go

Run the agent with directory listing capabilities.

go run bash_tool.go

Run the agent with shell command execution capabilities.

go run edit_tool.go

Run the agent with file editing capabilities.

go run code_search_tool.go

Run the agent with code search capabilities.

Ensure that the ANTHROPIC_API_KEY environment variable is properly set before running.

# Use via CDN

jsDelivr

jsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.

Command Glossary

Commands referenced in this DOCs, explained below.

🔍

devenv

View Details ▼

Fast, declarative, reproducible, and composable developer environments using Nix.

devenv init

Initialize the environment:

devenv shell --impure

Enter the Development Environment with relaxed hermeticity (state of being airtight):

devenv info --verbose

Get detailed information about the current environment:

🔍

go mod

View Details ▼

Module maintenance.

go mod init {{module_name}}

Initialize new module in current directory:

go mod download

Download modules to local cache:

go mod tidy

Add missing and remove unused modules:

🔍

go run

View Details ▼

Compile and run Go code without saving a binary.

go run {{path/to/file.go}}

Run a Go file:

go run {{path/to/package}}

Run a main Go package:

🔍

hello

View Details ▼

Print "Hello, world!", "hello, world", or a customizable text.

hello

Print "Hello, world!":

hello {{[-t|--traditional]}}

Print "hello, world", the traditional type:

hello {{[-g|--greeting]}} "{{greeting_text}}"

Print a text message:

// repository documentation