A faithful Go recreation of the Claude Code CLI — reconstructed from the TypeScript source maps of the public npm release.
Overall Progress: ████████████████░░░░░░░░░░░░░░░░░░░░ 35%
Core Engine: ████████████████████░░░░░░░░░░░░░░░░ 40% API loop, streaming, compaction
Tools (8/53): ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 15% Bash, Read, Write, Edit, Glob, Grep, LS, WebFetch
Commands (18/87): ████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 21% /help, /compact, /memory, /settings, etc.
TUI: ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 20% Messages, input, spinner, suggestions, completion
Services: ████████████████░░░░░░░░░░░░░░░░░░░░ 40% API, auth, config, MCP, analytics
Completion: ████████████░░░░░░░░░░░░░░░░░░░░░░░░ 30% Tab completion, @files, ghost text, shell history
Settings: ██████████████████████████░░░░░░░░░░ 65% .env, settings.json, 25+ env vars
Agent/Coordinator:░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Multi-agent orchestration
Memory System: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% 5-tier memory architecture
Key Bindings: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Full keybinding engine (15 files in original)
Vim Mode: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Motions, operators, text objects
Voice: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Streaming STT
Bridge/Remote: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Remote session teleportation (37 files)
Plugins/Skills: ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0% Plugin & skill system
Warning
This repository is an unofficial Go recreation, built by studying the reconstructed TypeScript source of the public npm release. It is for research and learning purposes only and does not represent the internal development repository of Anthropic.
This project was fully vibe-coded using opencode and Qwen 3.6 Plus.
- Go ≥ 1.24.0
- Bubble Tea v2 ecosystem (Bubble Tea, Lip Gloss, Bubbles)
$ go build -o claude-gode ./cmd/claude-gode # Build the binary
$ ./claude-gode # Start CLI (Interactive)
$ ./claude-gode --version # Verify version.
├── cmd/claude-gode/ # CLI entry point
├── internal/
│ ├── bootstrap/ # Startup sequence, init, profiling
│ ├── cli/ # CLI transports & command handlers
│ ├── engine/ # Core LLM API loop (QueryEngine)
│ ├── tools/ # 53 tool implementations
│ │ ├── bash/ # Bash tool
│ │ ├── read/ # Read file tool
│ │ ├── edit/ # Edit file tool
│ │ ├── webfetch/ # Web fetch tool
│ │ ├── agent/ # Agent/sub-agent tool
│ │ └── ... # (remaining tools)
│ ├── commands/ # 87 slash commands
│ ├── services/ # Backend services (API, MCP, auth)
│ ├── tui/ # Terminal UI components (406 components)
│ │ ├── components/ # Messages, inputs, diffs, dialogs
│ │ ├── layout/ # Screen layouts & virtual scrolling
│ │ └── styles/ # Lip Gloss theme definitions
│ ├── coordinator/ # Multi-agent orchestration
│ ├── tasks/ # Task types (local, remote, agent, dream)
│ ├── memdir/ # Persistent memory system (5-tier)
│ ├── vim/ # Vim keybinding engine
│ ├── skills/ # Skill system & bundled skills
│ ├── plugins/ # Plugin system
│ ├── bridge/ # IDE bidirectional communication
│ ├── remote/ # Remote session teleportation
│ ├── voice/ # Voice interaction (streaming STT)
│ ├── buddy/ # Gacha companion sprite (Easter egg)
│ └── assistant/ # KAIROS daemon mode
├── pkg/ # Public packages
│ ├── types/ # Shared types & interfaces
│ ├── schemas/ # API schemas (JSON Schema / Zod equiv)
│ └── utils/ # Shared utilities
├── shims/ # Compatibility shims (if needed)
├── vendor/ # Vendored native binding sources
├── go.mod
├── go.sum
├── README.md
└── CONTRIBUTING.md
Claude Code is built on top of a highly optimized and robust architecture designed for LLM API interaction, token efficiency, and advanced execution boundaries.
cmd/claude-gode/main.go → bootstrap/ → cli/ → REPL (Bubble Tea)
│ │ │
│ │ └─ Full Init: Auth → Feature Flags → MCP → Settings → Commands
│ └─ Fast Path: --version / daemon / ps / logs
└─ Startup Gate: validates all dependencies; blocks boot until resolved
Token efficiency is critical. The architecture employs industry-leading token saving techniques:
engine/QueryEngine: The central engine managing the LLM API loop, session lifecycle, and automatic tool execution.- 3-Tier Compaction System:
- Microcompact: Removes messages from the server cache without invalidating the prompt cache context (zero API cost).
- Session Memory: Uses pre-extracted session memory as a summary to avoid LLM calls during mid-level compaction.
- Full Compact: Instructs a sub-agent to summarize the conversation into a structured 9-section format, employing
<analysis>tag stripping to reduce token usage while maintaining quality.
- Advanced Optimizations:
FILE_UNCHANGED_STUB: Returns a brief 30-word stub for re-read files.- Dynamic max output caps (8K default with 64K retry) preventing slot-reservation waste.
- Caching latches to prevent UI toggles from busting 70K context.
- Circuit breakers preventing wasted API calls on consecutive compaction failures.
The "Harness" safely controls LLM operations within the local environment:
- Permission Modes: 6 primary modes (
acceptEdits,bypassPermissions,default,dontAsk,plan) plus internal designations likeauto(yoloClassifier) andbubble(sub-agent propagation). - Security Checkers: PowerShell-specific security analysis to detect command injection, download cradles, and privilege escalation, plus redundant path validations.
- Agents: Orchestrated via
AgentTool, created with three distinct paths: Teammate (tmux or in-process), Fork (inheriting context), and Normal (fresh context). - Coordinator Mode: A designated coordinator delegates exact coding tasks to worker agents (
Agent,SendMessage,TaskStop), effectively isolating high-level reasoning from raw file execution.
Designed to persist AI knowledge across sessions and agents:
- Memdir: Project-level indices and topic files (
MEMORY.md). - Auto Extract: Fire-and-forget forked agent that consolidates memory post-session.
- Session Memory: Real-time context tracking without extra LLM overhead.
- Team Memory: Shared remote state leveraging SHA-256 delta uploads and git-leaks-based secret extraction guards.
- Agent Memory: Agent-specific knowledge scoped to local, project, or user levels.
Terminal UI based on Bubble Tea v2 + Lip Gloss + Bubbles:
tui/components/(~406 components) — Messages, inputs, diffs, permission dialogs, status bartui/layout/— Screen layouts, virtual scrolling, focus managementtui/styles/— Lip Gloss theme definitions and styling utilities
This is a ground-up Go recreation, not a direct translation. The following may differ:
| Type | Description |
|---|---|
| UI Framework | React/Ink replaced with Bubble Tea v2 + Lip Gloss + Bubbles |
| Type System | TypeScript interfaces replaced with Go structs and interfaces |
| Concurrency | Promise/async replaced with goroutines and channels |
| Native bindings | Replaced with Go equivalents or CGO where needed |
| Dynamic resources | Embedded via Go embed package |
- The original source code copyright belongs to Anthropic.
- This is for technical research and learning purposes only. Please do not use it for commercial purposes.