Gopher Code
Claude Code, rewritten from scratch in Go. Zero Node.js. Zero Electron. One binary.
Ask AI about Gopher Code
Powered by Claude Β· Grounded in docs
I know everything about Gopher Code. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Gopher Code
Gopher Code, rewritten from scratch in Go. Zero Node.js. Zero Electron. One binary.
513K lines of TypeScript β clean, idiomatic Go.
Starts in 12ms. No runtime dependencies. Cross-compiles everywhere Go does.
[!IMPORTANT] This is an active ground-up rewrite. Gopher Code is not a wrapper, binding, or transpilation. Every subsystem of Claude Code v2.1.88 has been analyzed and rebuilt natively in Go using modern 2026 packages. See Porting Status for current progress.
Why This Exists
An incredible tool trapped inside a 500K-line TypeScript monolith that ships
with Node.js, a bundled Ink/React renderer, native addons for every platform, and a node_modules
tree deeper than the Mariana Trench.
Gopher Code asks: what if it was just a binary?
- 12ms cold start vs multi-second Node.js bootstrap
- Single static binary β
go buildand ship, nonpm install, no native addons - Native concurrency β goroutines for parallel tool execution, not Promise.all
- Cross-compile in seconds β
GOOS=linux GOARCH=arm64 go buildand done - Memory efficient β no V8 heap, no garbage collector pauses from React re-renders
- Hackable β read the source in an afternoon, not a week
Repository Layout
gopher/
βββ cmd/gopher/ # CLI entry point & REPL
β βββ main.go
βββ pkg/ # Core packages
β βββ compact/ # Token budget & context compaction
β βββ message/ # Message types & normalization
β βββ mcp/ # Model Context Protocol client
β βββ permissions/ # Tool permission evaluation
β βββ prompt/ # System prompt assembly
β βββ provider/ # Anthropic API provider (SSE streaming)
β βββ query/ # Query loop orchestration
β βββ session/ # Session state & persistence
β βββ tools/ # 33 built-in tools
βββ internal/
β βββ cli/ # Bubble Tea TUI renderer
β βββ testharness/ # Golden file test framework
βββ testdata/ # Parity test fixtures
βββ notes/ # Architecture & dependency docs
Porting Status
Full parity audit of 1,885 TypeScript source files against the Go port. 594 tasks identified across 24 subsystems. Every behavior, string, flag, keybinding, and error message has been classified.
| Subsystem | Parity | Tasks | Notes |
|---|---|---|---|
| API & Streaming | 8% | 25 | Core SSE streaming works; billing, analytics, retry gaps |
| CLI & Headless Mode | 0% | 21 | Auth, --print mode, subcommands not started |
| Commands (60+ slash) | 1% | 89 | Descriptors registered, handlers mostly stubs |
| Compaction & Context | 22% | 10 | Auto-compact works; reactive/collapse pipelines missing |
| Configuration & Constants | 13% | 22 | Beta headers ~80% done; OAuth config, prompt builders gap |
| Context & Overlays | 0% | 10 | Notification queue, modal system, voice state |
| Hook System | 1% | 25 | Execution exists; 100+ React hooks need bubbletea equivalents |
| IDE & Desktop | 0% | β | Entirely new subsystem |
| Keybindings | 0% | 15 | 13 of ~100 bindings across 17 contexts |
| Memory & CLAUDE.md | 5% | 8 | Type enum exists; scanning, relevance, paths missing |
| MCP Protocol | 0% | β | Client exists; service layer + 18 util files absent |
| Migrations | 0% | 12 | Startup migration registry not started |
| Model & Provider | 57% | β | Best coverage area; edge cases + allowlists remain |
| Permissions | 13% | β | Rule engine works; UI, classifiers, auto-mode missing |
| Plugins | 0% | 10 | Entirely new subsystem |
| Remote / Bridge (CCR) | 0% | 32 | 31-file subsystem, 100% absent |
| Session & Storage | 18% | 61 | Core state exists; 195 of 215 fields missing |
| Terminal UI (Ink β Bubbletea) | 1% | 17 | Architecture replaced; behavioral parity gaps |
| Tools (33 built-in) | 9% | 63 | Skeletons exist; validation, permissions, UI missing |
| UI Components (390 files) | 0% | 56 | Largest gap β design system, messages, permissions |
| Utilities (564 files) | 5% | 31 | Sprawling helper layer across 50+ subdirs |
| Vim Mode | 0% | 5 | 1,513 LOC absent |
| Voice | 0% | β | Entirely new subsystem |
| Overall | ~3% | 594 | ~301 impl / ~9,100 missing / ~124 fix |
Parity % = implemented items / (implemented + missing + fix). Tasks = numbered work items in the full porting plan (
notes/plan-v2/02-tasks.md).
Built With
Gopher Code is built on the modern 2026 Go ecosystem. No legacy. No baggage.
| Concern | Package | Why |
|---|---|---|
| Terminal UI | charm.land/bubbletea/v2 | Elm-architecture TUI |
| Styling | charm.land/lipgloss/v2 | ANSI styling & layout |
| Markdown | charm.land/glamour/v2 | Terminal markdown rendering |
| Components | charm.land/bubbles/v2 | Spinner, viewport, text input, progress bar |
| Prompts | charm.land/huh/v2 | Permission dialogs & interactive forms |
| Syntax HL | github.com/alecthomas/chroma/v2 | Code highlighting in terminal output |
| API streaming | github.com/tmaxmax/go-sse | Server-Sent Events for LLM API |
| HTTP | github.com/hashicorp/go-retryablehttp | Resilient HTTP with exponential backoff |
| MCP | github.com/mark3labs/mcp-go | Model Context Protocol client SDK |
| Shell parsing | mvdan.cc/sh/v3 | Bash AST for security analysis |
| Glob | github.com/bmatcuk/doublestar/v4 | ** pattern support |
| Git | github.com/go-git/go-git/v5 | Pure Go git operations |
| GitHub | github.com/google/go-github/v84 | GitHub API v84 |
| Config | github.com/knadh/koanf/v2 | Multi-source configuration |
| Schema | github.com/santhosh-tekuri/jsonschema/v6 | Tool input validation |
| Concurrency | golang.org/x/sync | errgroup + semaphore for parallel tools |
| Caching | github.com/hashicorp/golang-lru/v2 | File state LRU cache |
| Keyring | github.com/zalando/go-keyring | OS-native credential storage |
| Observability | go.opentelemetry.io/otel | Traces, metrics, spans |
Quickstart
# Clone
git clone https://github.com/projectbarks/gopher.git
cd gopher
# Build
go build -o gopher ./cmd/gopher
# Run interactive REPL
./gopher
# Run headless
./gopher -p "explain this codebase"
# Cross-compile for Linux ARM64
GOOS=linux GOARCH=arm64 go build -o gopher-linux-arm64 ./cmd/gopher
CLI Flags
Usage: gopher-code [flags]
Flags:
-p, --print string Run a single query in headless mode
-m, --model string Model to use (default: claude-sonnet-4-20250514)
-c, --cwd string Working directory
-r, --resume string Resume a previous session by ID
-o, --output string Output format: text, json, stream-json
-v, --verbose Enable verbose logging
Architecture
Gopher Code mirrors the subsystem architecture of Claude Code while leveraging Go's strengths:
βββββββββββββββββββββββββββ
β CLI / Bubble Tea β
β (cmd/gopher-code) β
ββββββββββββββ¬βββββββββββββ
β
ββββββββββββββΌβββββββββββββ
β Query Engine β
β (pkg/query) β
ββββ¬βββββββββββ¬βββββββββββ¬β
β β β
ββββββββββΌββββ βββββΌβββββ βββββΌβββββββββ
β Provider β β Tools β β Session β
β (Anthropic) β β (x33) β β (persist) β
ββββββββ¬ββββββ βββββ¬βββββ ββββββββββββββ
β β
ββββββββΌββββββ βββββΌβββββββββββββ
β SSE Stream β β Permissions β
ββββββββββββββ β Shell Parse β
β MCP Client β
ββββββββββββββββββ
Key design decisions:
- No global state β all state flows through explicit function parameters and the session store
- Context-first cancellation β every goroutine respects
context.Context - Interfaces at boundaries β provider, tools, and transport are all interface-based for testing
- Golden file tests β parity tests run against captured Claude Code v2 transcripts
Current Parity Checkpoint
Gopher Code passes L1-L4 parity tests against Claude Code v2.1.88:
- L1 β Message normalization round-trips match TypeScript output
- L2 β System prompt assembly produces identical prompts
- L3 β Tool input/output schemas match the API contract
- L4 β Multi-turn query loops produce equivalent tool call sequences
The parity test suite uses golden files captured from the TypeScript implementation to ensure behavioral equivalence, not just structural similarity.
Contributing
This is a research project exploring what a native Go implementation of an agentic coding assistant looks like. Contributions, ideas, and feedback are welcome.
# Run tests
go test ./...
# Run with race detector
go test -race ./...
# Update golden files
go test ./... -update
Built by @projectbarks
Gopher Code is an independent project. Not affiliated with Anthropic.
