A Go port of Claude Code — Anthropic's agentic CLI coding assistant
Fast. Extensible. Built for terminals.
claw-code-go is a full Go reimplementation of Claude Code — Anthropic's agentic coding assistant. It runs in your terminal, understands your codebase, calls tools, writes and edits files, searches the web, and works autonomously until the job is done.
Why Go?
- Single static binary — no Node.js runtime required
- Faster startup, lower memory footprint
- Easier to embed, cross-compile, and distribute
Full tool-use conversation loop: Claude reasons, calls tools, reads the results, and keeps going until the task is complete or it hits an end_turn.
Rich terminal UI built with Bubble Tea — streaming output with a spinner, styled message history, syntax-aware theming, and a clean session view.
| Tool | Description |
|---|---|
bash |
Execute shell commands (30s timeout, sandboxed) |
read_file |
Read files from disk |
write_file |
Write/create files |
file_edit |
Surgical text replacements in existing files |
glob |
Find files matching a glob pattern |
grep |
Search across files with regex |
web_fetch |
Fetch and parse a URL |
web_search |
Search the web (Brave API) |
todo_write |
Track and persist task lists |
Native OAuth flow for Anthropic accounts. Credentials are stored securely and refreshed automatically. OpenAI is scaffolded alongside Anthropic — swap providers via config.
Full MCP integration: connect external tool servers over stdio or SSE, register their tools, and let Claude call them seamlessly alongside built-in tools.
Fine-grained permission system controls what Claude can do — bash execution, file writes, network access — with configurable modes (auto, ask, deny) and rule-based overrides.
On every turn, claw-code-go automatically injects:
- Git repo state (branch, diff summary, recent commits)
- Memory directory files (
.claw-code/memory/) - System info (OS, hostname, working directory)
Sessions are saved as JSON files in ~/.claw-code/sessions/. Resume any previous session by ID. The TUI includes a built-in session history browser.
Every session tracks input/output tokens per turn. Estimated USD cost is shown at the end of each session for all known models (Claude 3/4 + GPT-4o family).
Automatic conversation compaction keeps context windows manageable on long sessions — summarising older turns without losing important state.
Drop markdown files into .claw-code/memory/ and they're injected into every conversation automatically — persistent instructions, project context, preferences.
- Go 1.24+
ANTHROPIC_API_KEYenvironment variable (or log in via--login)
git clone https://github.com/daolmedo/claw-code-go
cd claw-code-go
go build -o claw-code-go ./cmd/claw-code-goOr install directly:
go install github.com/daolmedo/claw-code-go/cmd/claw-code-go@latest./claw-code-goexport ANTHROPIC_API_KEY=sk-ant-...
./claw-code-go --prompt "Refactor the auth package to use interfaces"./claw-code-go --login
# or explicitly:
./claw-code-go --login --provider anthropic./claw-code-go --login --provider openai
# Prompts for your OpenAI API key and stores it securelyCredentials are saved to ~/.claw-code/credentials/ and reused automatically on the next run. Switch providers at any time with --provider.
./claw-code-go --session <session-id>| Flag | Default | Description |
|---|---|---|
--prompt |
— | Single prompt (one-shot mode) |
--model |
claude-sonnet-4-20250514 |
Model to use |
--provider |
anthropic |
AI provider: anthropic, openai |
--repl |
false | Force interactive REPL mode |
--login |
false | Authenticate for the selected provider |
--session |
— | Resume a saved session by ID |
--session-dir |
~/.claw-code/sessions |
Directory for session files |
--permission-mode |
ask |
Permission mode: auto, ask, deny |
| Command | Description |
|---|---|
/help |
Show available commands |
/clear |
Clear the current session |
/session-list |
Browse saved sessions |
/model <name> |
Switch model mid-session |
/compact |
Manually trigger context compaction |
/cost |
Show current session token usage and estimated cost |
/exit or /quit |
Exit the REPL |
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY |
Your Anthropic API key |
ANTHROPIC_MODEL |
Override the default model |
ANTHROPIC_BASE_URL |
Override the Anthropic API base URL |
OPENAI_API_KEY |
OpenAI API key (if using OpenAI provider) |
claw-code-go/
├── cmd/claw-code-go/ # CLI entry point
└── internal/
├── api/ # Anthropic API client (SSE streaming, types)
├── auth/ # OAuth flow, credential storage, token refresh
├── commands/ # Slash command registry
├── compat/ # Upstream TS source parity manifest
├── config/ # Config loading, permission modes, rules
├── context/ # Context assembly (git, memory, sysinfo)
├── mcp/ # Model Context Protocol client (stdio + SSE)
├── permissions/ # Permission enforcement & rule engine
├── runtime/ # Agentic conversation loop, session persistence
├── tools/ # Built-in tool implementations
├── tui/ # Bubble Tea TUI (model, styles, theme, history)
└── usage/ # Token tracking and cost estimation
- Phase 1 — Foundation: API client, basic conversation loop, core tools
- Phase 2 — TUI: Bubble Tea UI, streaming, spinner, slash commands
- Phase 3 — OAuth + multi-provider scaffolding
- Phase 4 — MCP (Model Context Protocol) integration
- Phase 5 — Permissions & Safety
- Phase 6 — Context compaction
- Phase 7 — Multi-provider login UX
- Phase 8 — Compat harness modes
- Phase 9 — Full TUI foundation (themes, history view)
- Phase 10 — Core tool expansion (file_edit, web_fetch, web_search, todo_write)
- Phase 11 — Permissions + config system
- Phase 12 — Context assembly + memory directory
- Phase 13 — Cost tracking + session history UI
- Phase 14 — LSP integration
- Phase 15 — Plugin/extension system
PRs welcome. Run go build ./... and go vet ./... before submitting.
MIT

