What is the extracted cli.js?
This page defines the artifact boundary for the Claude Code internals wiki.
cli.js is the readable JavaScript entrypoint extracted from the Linux x64 Bun standalone package for @anthropic-ai/claude-code@2.1.143. It is not the original TypeScript source tree: it is bundled, minified, and paired with JavaScriptCore bytecode in the same Bun module graph.
Source anchors
| Semantic alias | Source file | Approximate location | Anchor | Meaning |
|---|---|---|---|---|
| FinalArtifactExtractor | scripts/extract-claude-code-final-artifacts.mjs | repository script | TRAILER, MODULE_RECORD_SIZE, FINAL_ROOT_FILES | Parses the Bun graph in memory and keeps only selected JS files. |
| BunEntrypointWrapper | cli.js | line ~1, byte 0x3 | // @bun @bytecode @bun-cjs | Bun CommonJS wrapper emitted for the entrypoint. |
| EmbeddedProductVersion | cli.js | line ~11, byte 0xdc5 | VERSION:"2.1.143" | Embedded product version used by version output and runtime metadata. |
| OuterBootstrap | cli.js | line ~19590, byte 0xddd998 | async function J9A | Outer bootstrap function reached by the Bun standalone executable. |
| ImageProcessorShim | image-processor.js | line ~11 | require("/$bunfs/root/image-processor.node") | Thin wrapper around an embedded N-API image module. |
| AudioCaptureShim | audio-capture.js | line ~11 | require("/$bunfs/root/audio-capture.node") | Thin wrapper around an embedded N-API audio module. |
Artifact stack
flowchart TD Npm[wrapper npm package] --> Native[platform native package] Native --> Elf[Linux x64 Bun standalone ELF] Elf --> BunSection[.bun section] BunSection --> Graph[StandaloneModuleGraph] Graph --> Cli[src/entrypoints/cli.js] Graph --> Image[image-processor.js] Graph --> Audio[audio-capture.js] Graph -. pruned .-> NativeAddons[embedded .node addons] Graph -. not retained .-> Jsc[JavaScriptCore bytecode]The Bun payload contains five modules, but the final retained package keeps only the readable JavaScript files:
| Module | Role |
|---|---|
claude-code-pkg/src/entrypoints/cli.js | The main bundled runtime: command parsing, TUI, headless runner, tools, sessions, MCP, plugins, agents, auth, models, telemetry, and updates. |
claude-code-pkg/image-processor.js | CommonJS shim that refers to /$bunfs/root/image-processor.node; the native addon is not retained in this repo layout. |
claude-code-pkg/audio-capture.js | CommonJS shim that refers to /$bunfs/root/audio-capture.node; the native addon is not retained in this repo layout. |
What cli.js owns
The extracted cli.js is the central agent runtime rather than a thin argument parser. Confirmed top-level ownership includes:
- Bun/bootstrap and product-version fast paths.
- Commander root command, root flags, and utility subcommands.
- Interactive TUI/session loop and resume picker.
- Print/headless runner, stream-JSON I/O, SDK transport, and control frames.
- Prompt/context inputs such as
CLAUDE.md, settings, system-prompt flags, output styles, agents, skills, and MCP. - Model/provider/auth selection across first-party, Bedrock, Vertex, Foundry, Anthropic AWS, Mantle, and API-key/OAuth paths.
- Built-in tools, permissions, hooks, MCP, plugins, IDE/Chrome integration, and settings policy.
- Local JSONL transcripts, resume/continue/fork/rewind, remote sessions, teleport, and Remote Control.
- Agents, subagents, task tools, background agents,
ultrareview, andauto-mode. - Diagnostics, debug logs, telemetry/traffic gates, native updater, and media native modules.
What it is not
- It is not clean source with original module names.
- It is not sourcemap-backed; temporary Bun graph inspection found no serialized sourcemap payload for this build.
- JavaScriptCore cached bytecode can be dumped for instruction-level research, but bytecode dumps are no longer retained as final artifacts and do not recover the original JavaScript/TypeScript.
- Minified anchors behind aliases such as
TopLevelMain,CommanderRoot,HeadlessRunner, andInteractiveSessionLoopare version-specific. Use them only with exact string/offset anchors.
Related docs
Created and maintained by Yingting Huang.