A tiny Go CLI code-editing agent that can chat with OpenAI or Anthropic models and use tools to read files, list directories, and edit files.
- Provider support: OpenAI or Anthropic
- Minimal tool loop with file system tools
- Single-file implementation (main.go)
- Go 1.25+
- An API key for at least one provider
- OpenAI: set OPENAI_API_KEY
- Anthropic: set ANTHROPIC_API_KEY
go mod tidyexport OPENAI_API_KEY="..."
go run main.goOptional model override:
export OPENAI_MODEL="gpt-4o"
go run main.goexport ANTHROPIC_API_KEY="..."
go run main.go -provider anthropicOptional model override:
export ANTHROPIC_MODEL="claude-3-7-sonnet-latest"
go run main.go -provider anthropicThe provider is chosen in this order:
- -provider flag
- AGENT_PROVIDER or PROVIDER env var
- If only one API key is set, use that
- If both are set, OpenAI is chosen by default
- read_file: read a file by relative path
- list_files: list files and directories under a path
- edit_file: replace a string in a file or create a file
- Tool calls are executed locally. Be cautious when running with access to sensitive files.
- This is a minimal example intended for experimentation.