# claude-code-go **Repository Path**: hackerwjz/claude-code-go ## Basic Information - **Project Name**: claude-code-go - **Description**: https://github.com/tunsuy/claude-code-go.git - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-10-12 - **Last Updated**: 2026-10-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

Claude Code Go Logo

Claude Code Go

๐Ÿค– A Go reimplementation of Claude Code โ€” AI coding assistant in your terminal

Go Version Go Report Card codecov Go Reference CI Release License PRs Welcome

English โ€ข ็ฎ€ไฝ“ไธญๆ–‡ โ€ข ๆ—ฅๆœฌ่ชž โ€ข ํ•œ๊ตญ์–ด โ€ข Espaรฑol โ€ข Franรงais

---

Claude Code Go - Interactive Session
Interactive TUI with file reading and real-time thinking display

Claude Code Go - Project Analysis
Comprehensive project analysis with architecture breakdown

--- ## What is this? This project is a **complete Go reimplementation of [Claude Code](https://claude.ai/code)** โ€” Anthropic's official TypeScript CLI โ€” rewritten module-by-module in Go, covering all core features: TUI, tool use, permission system, multi-agent coordination, MCP protocol, session management, and more. It understands your codebase, runs tools, and helps you write, review, and refactor code through natural conversation. > **๐Ÿค– Built entirely by AI agents โ€” zero human-written production code.** The initial build (April 2026) was produced by 9 Claude AI agents collaborating in 9 days; since August 2026 a single main Claude session maintains the project against a behavior-parity ledger, with one human owner reviewing and merging. [Full story โ†“](#built-entirely-by-ai-agents) ## โค๏ธ Sponsors > [Want to be featured here?](https://github.com/tunsuy)
OrcaRouter OrcaRouter โ€” one gateway, every model. OrcaRouter routes each request to the best-fit model among 200+ (frontier and open-source) models at provider prices, with failover and request logs. It is OpenAI-compatible and plugs straight into Claude Code Go โ€” see API Providers for the exact configuration.
## Features - **Interactive TUI** โ€” Full-featured terminal UI built with [Bubble Tea](https://github.com/charmbracelet/bubbletea), with dark/light themes - **Agentic tool use** โ€” 34 built-in tools (file, shell, search, web, tasks, sub-agents, โ€ฆ), all mediated through a 9-layer permission pipeline - **CLI subcommands** โ€” `claude mcp โ€ฆ`, `claude plugin โ€ฆ`, `claude auth โ€ฆ`, `claude doctor`, `claude update`; the `mcp` and `plugin` groups produce byte-for-byte identical output to the TypeScript CLI - **Plugin management** โ€” Install/enable/disable plugins from local marketplaces, with full manifest validation (`claude plugin validate`) - **Multi-agent coordination** โ€” Spawn background sub-agents for parallel tasks - **MCP support** โ€” Connect external tools via the [Model Context Protocol](https://modelcontextprotocol.io) (stdio + HTTP transports), importable from Claude Desktop - **CLAUDE.md memory** โ€” Auto-loads project context from `CLAUDE.md` files up the directory tree - **Session management** โ€” Resume previous conversations; compact long histories automatically - **Vim mode** โ€” Optional Vim key bindings in the input area - **OAuth + API key auth** โ€” Sign in with Anthropic OAuth (`claude auth login`) or supply an `ANTHROPIC_API_KEY` - **Built-in slash commands** โ€” `/compact`, `/commit`, `/review`, `/model`, `/theme`, and more (see below) - **Streaming responses** โ€” Real-time token streaming with thinking-block display ## Architecture Claude Code Go is organized in six layers: ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ CLI (cmd/claude) โ”‚ cobra entry point โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ TUI (internal/tui) โ”‚ Bubble Tea MVU interface โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Tools (internal/tools/*) โ”‚ file, shell, search, MCP tools โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Core Engine (agtkeel/engine) โ”‚ streaming, tool dispatch, coordinator โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Services (agtkeel/api, oauth, โ”‚ Anthropic API, OAuth, MCP client โ”‚ agtkeel/mcp, compact) โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Infra (agtkeel/types, config, โ”‚ types, config, state, hooks, plugins โ”‚ state, session, hooks) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` See [`docs/project/architecture.md`](docs/project/architecture.md) for a detailed breakdown. ## Requirements - Go 1.21 or later - An [Anthropic API key](https://console.anthropic.com/) **or** Claude.ai account (OAuth) ## Installation ### From source ```bash git clone https://github.com/tunsuy/claude-code-go.git cd claude-code-go make build # Binary is placed at ./bin/claude ``` Add to your `PATH`: ```bash export PATH="$PATH:$(pwd)/bin" ``` ### Using `go install` ```bash go install github.com/tunsuy/claude-code-go/cmd/claude@latest ``` ## Quick Start ```bash # Set your API key (or use OAuth โ€” see Authentication below) export ANTHROPIC_API_KEY=sk-ant-... # Start an interactive session in the current directory claude # Ask a one-shot question and exit claude -p "Explain the main entry point of this project" # Resume the most recent session claude --resume ``` ## Authentication **API key (recommended for CI/scripts):** ```bash export ANTHROPIC_API_KEY=sk-ant-... # or store it persistently: claude auth login --api-key sk-ant-... ``` **OAuth (recommended for interactive use):** ```bash claude auth login # opens the OAuth flow in your browser claude auth status # check who you're signed in as ``` ## API Providers Claude Code Go supports multiple API providers, allowing you to use not just Anthropic's API, but also OpenAI-compatible APIs. ### Supported Providers | Provider | Description | Environment Variables | |----------|-------------|----------------------| | `direct` (default) | Anthropic Direct API | `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL` | | `openai` | OpenAI & compatible APIs | `OPENAI_API_KEY`, `OPENAI_BASE_URL` | | `bedrock` | AWS Bedrock | AWS credentials via environment | | `vertex` | Google Cloud Vertex AI | GCP credentials via environment | ### Using OpenAI-Compatible APIs To use OpenAI, DeepSeek, Qwen, Moonshot, or any OpenAI-compatible API: **Method 1: Environment Variables** ```bash # Set provider to openai export CLAUDE_PROVIDER=openai # Set your API key export OPENAI_API_KEY=sk-xxx # Optionally set a custom base URL (for OpenAI-compatible services) export OPENAI_BASE_URL=https://api.deepseek.com # DeepSeek # export OPENAI_BASE_URL=https://api.moonshot.cn/v1 # Moonshot # export OPENAI_BASE_URL=http://localhost:11434/v1 # Ollama # Set the model export OPENAI_MODEL=deepseek-chat # Run Claude Code claude ``` **Method 2: Configuration File** Create or edit `~/.config/claude-code/settings.json`: ```json { "provider": "openai", "apiKey": "sk-xxx", "baseUrl": "https://api.openai.com", "model": "gpt-4-turbo", "openaiOrganization": "org-xxx", "openaiProject": "proj-xxx" } ``` ### Provider-Specific Notes **OpenAI:** - Supports all GPT-4 and GPT-3.5 models - Full tool/function calling support - Streaming responses **DeepSeek:** ```bash export CLAUDE_PROVIDER=openai export OPENAI_API_KEY=sk-xxx export OPENAI_BASE_URL=https://api.deepseek.com export OPENAI_MODEL=deepseek-chat ``` **Ollama (local):** ```bash export CLAUDE_PROVIDER=openai export OPENAI_BASE_URL=http://localhost:11434/v1 export OPENAI_MODEL=llama3 ``` **Azure OpenAI:** ```bash export CLAUDE_PROVIDER=openai export OPENAI_API_KEY=your-azure-key export OPENAI_BASE_URL=https://your-resource.openai.azure.com export OPENAI_MODEL=your-deployment-name ``` **OrcaRouter (AI gateway):** [OrcaRouter](https://www.orcarouter.ai/ref/ref_49eee7ba2e9927450075) is an AI gateway that routes each request to the best-fit model among 200+ (frontier and open-source) models at provider prices, with failover and request logs. It is OpenAI-compatible, so it works directly through the `openai` provider: ```bash export CLAUDE_PROVIDER=openai export OPENAI_API_KEY= export OPENAI_BASE_URL=https://api.orcarouter.ai/v1 export OPENAI_MODEL=orcarouter/auto # let OrcaRouter pick the model per request ``` ## Usage ### Interactive mode ``` claude [flags] ``` | Flag | Description | |------|-------------| | `--resume` | Resume the most recent session | | `--session ` | Resume a specific session by ID | | `--model ` | Override the default Claude model | | `--dark` / `--light` | Force dark or light theme | | `--vim` | Enable Vim key bindings | | `-p, --print ` | Non-interactive: run a single prompt and exit | ### CLI subcommands Non-interactive management commands. The `mcp` and `plugin` groups are byte-for-byte output-compatible with the TypeScript CLI: | Command | Description | |---------|-------------| | `claude mcp add -- [argsโ€ฆ]` | Register a stdio MCP server (`--transport http ` for remote, `-e KEY=VAL` for env) | | `claude mcp list` / `claude mcp get ` | List configured servers / health-check one | | `claude mcp add-json ` | Register a server from raw JSON | | `claude mcp add-from-claude-desktop` | Import servers from Claude Desktop's config | | `claude mcp remove ` / `reset-project-choices` | Remove a server / reset project-local choices | | `claude plugin install ` | Install a plugin from a configured marketplace | | `claude plugin list` / `enable` / `disable` / `uninstall` / `update` | Manage installed plugins | | `claude plugin validate ` | Validate a plugin or marketplace manifest (`--strict`, `--json`) | | `claude plugin marketplace add/list/remove/update` | Manage plugin marketplaces (local paths) | | `claude auth login` / `logout` / `status` | OAuth or API-key authentication | | `claude doctor` | Environment health check | ### Slash commands Type `/` in the input to see all available commands: | Command | Description | |---------|-------------| | `/help` | Show all commands | | `/clear` | Clear conversation history | | `/compact` | Summarise history to reduce context usage | | `/exit` | Exit Claude Code | | `/model` | Show or set the active model | | `/theme` | Switch color theme | | `/vim` | Toggle Vim key bindings | | `/effort` | Set effort level (low / medium / high) | | `/status` | Show session status | | `/cost` | Show token usage for this session | | `/session` | Show current session ID | | `/memory` | Show loaded CLAUDE.md memory files | | `/dream` | Manually trigger memory consolidation | | `/review` | Review the current git diff with Claude | | `/commit` | Ask Claude to write and create a git commit | | `/diff` | Show the current git diff | | `/init` | Generate a CLAUDE.md for this project | `/config`, `/mcp`, `/resume`, and `/terminal-setup` are registered but not yet implemented โ€” use the CLI subcommands above for MCP management in the meantime. ## Built entirely by AI agents > **No human wrote a single line of production code in this repository.** The entire project โ€” architecture design, detailed design docs, parallel implementation, code review, QA, and integration testing โ€” was produced by **9 Claude AI agents** collaborating in a structured multi-agent workflow: ``` PM Agent โ†’ project plan, milestones, task scheduling Tech Lead Agent โ†’ architecture design, design-doc review, code review Agent-Infra โ†’ infrastructure layer (types, config, state, session) Agent-Services โ†’ services layer (API client, OAuth, MCP, compaction) Agent-Core โ†’ core engine (LLM loop, tool dispatch, coordinator) Agent-Tools โ†’ tools layer (file, shell, search, web โ€” 18 tools at build time) Agent-TUI โ†’ UI layer (Bubble Tea MVU, themes, Vim mode) Agent-CLI โ†’ entry layer (Cobra CLI, DI, bootstrap phases) QA Agent โ†’ test strategy, per-layer acceptance, integration tests ``` Each agent worked on an isolated Git Worktree branch in parallel, collaborating through the shared codebase, design docs, and QA reports. The result: ~**7,000 lines of production code + a full test suite in 9 days**, with `go test -race ./...` passing. This is a real-world demonstration that a non-trivial, multi-layer Go application can be fully designed, implemented, reviewed, and shipped by AI agents collaborating asynchronously. Since August 2026 the project is maintained in the same spirit โ€” a single main Claude session working through a behavior-parity gap ledger against the original TypeScript CLI, with one human owner reviewing and merging. Still zero human-written production code (~33,000 lines today). The complete decision trail lives in [`docs/project/`](docs/project/). ## Development ### Prerequisites - Go 1.21+ - `golangci-lint` (optional, for linting) ### Build & test ```bash # Build make build # Run all tests make test # Run tests with coverage report make test-cover # Vet make vet # Lint (requires golangci-lint) make lint # Build + test + vet make all ``` ### Project layout ``` claude-code-go/ โ”œโ”€โ”€ cmd/claude/ # CLI entry point โ”œโ”€โ”€ internal/ โ”‚ โ”œโ”€โ”€ api/ # Anthropic API client & streaming โ”‚ โ”œโ”€โ”€ bootstrap/ # App initialisation โ”‚ โ”œโ”€โ”€ commands/ # Slash command handlers โ”‚ โ”œโ”€โ”€ compact/ # Conversation compaction โ”‚ โ”œโ”€โ”€ config/ # Configuration (file + env) โ”‚ โ”œโ”€โ”€ coordinator/ # Multi-agent coordinator โ”‚ โ”œโ”€โ”€ engine/ # Query engine, tool dispatch โ”‚ โ”œโ”€โ”€ hooks/ # Pre/post-tool hooks โ”‚ โ”œโ”€โ”€ mcp/ # MCP server management โ”‚ โ”œโ”€โ”€ memdir/ # CLAUDE.md loader โ”‚ โ”œโ”€โ”€ oauth/ # OAuth2 flow โ”‚ โ”œโ”€โ”€ permissions/ # Tool permission layer โ”‚ โ”œโ”€โ”€ plugin/ # Plugin system โ”‚ โ”œโ”€โ”€ session/ # Session persistence โ”‚ โ”œโ”€โ”€ state/ # Application state โ”‚ โ”œโ”€โ”€ tools/ # Tool interface, registry & built-in implementations โ”‚ โ”‚ โ”œโ”€โ”€ agent/ # sub-agent & send-message tools โ”‚ โ”‚ โ”œโ”€โ”€ fileops/ # file read/write/edit/glob/grep tools โ”‚ โ”‚ โ”œโ”€โ”€ interact/ # user-interaction & worktree tools โ”‚ โ”‚ โ”œโ”€โ”€ mcp/ # MCP tool adapter โ”‚ โ”‚ โ”œโ”€โ”€ misc/ # miscellaneous tools โ”‚ โ”‚ โ”œโ”€โ”€ shell/ # Bash execution tool โ”‚ โ”‚ โ”œโ”€โ”€ tasks/ # task-list tools โ”‚ โ”‚ โ””โ”€โ”€ web/ # web fetch & search tools โ”‚ โ””โ”€โ”€ tui/ # Bubble Tea UI components โ”œโ”€โ”€ pkg/ โ”‚ โ””โ”€โ”€ types/ # Shared public types โ”œโ”€โ”€ docs/ # Design docs and QA reports โ”œโ”€โ”€ Makefile โ””โ”€โ”€ go.mod ``` ## Roadmap The initial build (April 2026) delivered the full six-layer architecture in 9 days. Since August 2026 the project is in **maintenance mode**: development is driven by a behavior-parity gap ledger ([`test/parity/cases.md`](test/parity/cases.md)) that compares this CLI against the original TypeScript version โ€” every closed gap is byte-pinned by tests, every deliberate divergence is recorded as `waived` with a reason. Recent milestones: - **2026-09-05** โ€” `mcp` (7 commands) and `plugin` (8 commands + `marketplace` subtree) CLI groups landed, output byte-identical to the TS CLI; user-visible stubs reduced 42 โ†’ 27 - **2026-08-30** โ€” `--version` format parity; full subcommand inventory against the TS CLI (ยงB11) - **2026-08-29** โ€” maintenance-mode process landed: CI-enforced debt red lines, parity test skeleton The original phased plan (v0.2.0 โ†’ v1.0.0) is preserved with per-phase completion status in [`docs/ROADMAP.md`](docs/ROADMAP.md). ### Current Status ``` โœ… Done: Core engine + streaming, TUI, 34 tools, 17 slash commands (4 stubs), mcp/plugin/auth/doctor CLI subcommands, 9-layer permission pipeline, context compaction (snip/micro/auto), OAuth, session persistence ๐Ÿ”ง Mode: Maintenance โ€” gap-ledger-driven parity work vs. the TypeScript CLI ๐Ÿ“‰ Debt: 56 TODO(dep) / 27 user-visible stubs, CI-enforced only-down red lines ๐Ÿš€ Release: v0.8.0, 5-platform binaries ``` ## Contributing We welcome contributions! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a pull request. Quick checklist: - Fork the repo and create a feature branch - Make sure `make test` and `make vet` pass - Write tests for new functionality - Follow existing code style (run `gofmt ./...`) - Open a pull request using the provided template ## Security To report a security vulnerability, please see [SECURITY.md](SECURITY.md). **Do not** open a public GitHub issue for security bugs. ## License This project is licensed under the MIT License โ€” see [LICENSE](LICENSE) for details. ## Related projects - [claude-code](https://github.com/anthropics/claude-code) โ€” the original TypeScript CLI - [anthropic-sdk-go](https://github.com/anthropics/anthropic-sdk-go) โ€” official Go SDK for the Anthropic API - [Model Context Protocol](https://modelcontextprotocol.io) โ€” open standard for connecting AI to tools