Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.08 KB

File metadata and controls

48 lines (37 loc) · 1.08 KB

Build a CLI AI Assistant in Go

Video #09 — Claude API in Go Series
Publish date: 2026-07-27
Type: Heavy (Capstone)
Est. duration: ~35 min

What we cover

  • Building a fully interactive terminal AI assistant from scratch
  • Streaming output so responses appear token-by-token in the CLI
  • Persistent conversation history within a session (with reset command)
  • Loading system prompt and model from a config.json file
  • Graceful exit and error handling for production use

Prerequisites

  • Go 1.23+
  • An Anthropic API key
  • Episodes 01–04 (completions, system prompts, streaming, structured output)

Running the example

cd 09-cli-assistant
export ANTHROPIC_API_KEY=your_key_here
go run main.go

Optionally create config.json to customise the assistant:

{
  "system_prompt": "You are a Go expert. Answer with runnable code examples.",
  "model": "claude-opus-4-7-20250514",
  "max_tokens": 2048
}

Project structure

.
├── README.md
├── go.mod
├── go.sum
└── main.go