claude-code: The clean room that rebuilt Claude Code

Claude Code Best turns a leaked terminal agent into a modular TypeScript system with feature flags, native hooks, and provider flexibility.

11 min read · claude-code-best/claude-code

A black-ink workshop scene shows a terminal agent machine being rebuilt from a blueprint on a clean workbench. It explains the article's core point: this project is less a wrapper around Claude Code and more a reconstruction of its machinery.
CCB treats the leaked CLI as a machine to be dissected, repaired, and reassembled.
Key Takeaways

Most AI coding CLIs start as thin shells around an API key. Claude Code Best is interesting because it tries to become the opposite: a system you can trace, swap, and ship. That makes it less a clone than a reconstruction of the control plane around an agent.

A reconstruction, not a wrapper

The repository presents itself as a runnable, buildable, debuggable version of Claude Code, with the original feel intact. That wording is doing real work. It says the project is not just imitating outputs, it is preserving the architecture shape so the internals stay inspectable.

原汁原昧 Claude Code 可运行,可构建, 可调试版; Typescript 类型全修复; 企业级可靠性; 安全无毒, lock 文件保真, 可直接 bun i; bun run dev 启动

claude-code-best/claude-code Repository, Project Description · claude-code-best README

The backstory is equally important. A public source-map exposure revealed a very large TypeScript tree, and the community used that map to reconstruct the CLI. CCB sits in that lineage, but the more durable story is maintenance work, not incident response.

What makes it different

The codebase behaves like a platform. Bun handles build and runtime, Ink renders the terminal UI, Zod validates tool inputs, and feature flags can hide or reveal entire modules at build time. That is a rare pattern in CLIs, and it is why the project can add voice, browser control, or computer use without turning the core loop into a mess of conditionals.

A close-up view shows removable modules, toggle switches, and sealed compartments inside a machine control panel. It explains how build-time feature flags can reveal or hide capabilities without changing the core loop.
Feature flags turn one CLI into a configurable product line.

How the agent loop works

The center of gravity is QueryEngine.ts. User input enters the query engine, history can be compacted, the system prompt is assembled, and the model may call tools through a structured context. Background work lives in Task.ts, which gives long-running operations a lifecycle, so the UI can show progress instead of pretending everything is instantaneous.

CCB's agent loop is not one big prompt. It is a routed system with feature gates, tool schemas, and task state.

That structure also explains the security posture. Tools are schema-validated, permissions can be set to always allow, always deny, or always ask, and task IDs are generated with care to reduce attack surface. The project wants agentic power, but it also wants the boring discipline that keeps a shell from becoming a footgun.

Where it sits in the landscape

DimensionClaude Code BestOfficial Claude CodeClean-room rewrite
LanguageTypeScriptTypeScriptPython and Rust
RuntimeBunBunVaries by implementation
Core stanceRestore and extend the original architectureClosed-source vendor productRebuild the agent from scratch
Notable extrasCustom login, OpenAI compatibility, Sentry, GrowthBook, computer and Chrome useOfficial product experience and toolingFresh implementation and fast community traction
Trade-offCarries original complexityNot open sourceLess tied to the original code shape

That comparison is the point. If you want a fresh rewrite, other projects are starting from a blank page. If you want the original TypeScript architecture plus new providers and observability, this repo is closer to a literal continuation of the same machine.