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.
- Claude Code Best matters because it turns a leaked terminal agent into an inspectable product instead of a black box.
- Its center of gravity is the agent loop, where QueryEngine, tool schemas, permissions, and task state work together.
- Bun and feature flags make the codebase feel like a platform for assembling capabilities, not just a chat shell.
- The real comparison is not open source versus closed source, but a configurable control plane versus a fixed vendor boundary.
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 启动
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.
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.
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
| Dimension | Claude Code Best | Official Claude Code | Clean-room rewrite |
|---|---|---|---|
| Language | TypeScript | TypeScript | Python and Rust |
| Runtime | Bun | Bun | Varies by implementation |
| Core stance | Restore and extend the original architecture | Closed-source vendor product | Rebuild the agent from scratch |
| Notable extras | Custom login, OpenAI compatibility, Sentry, GrowthBook, computer and Chrome use | Official product experience and tooling | Fresh implementation and fast community traction |
| Trade-off | Carries original complexity | Not open source | Less 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.