Entrypoints Architecture
Overview
Claude Code has multiple entry points depending on how it's launched. This is the front door of the application - where execution begins and branches.
Shared from "Claude-Code" on Inkdown
Claude Code has multiple entry points depending on how it's launched. This is the front door of the application - where execution begins and branches.
cli.tsxFile: src/entrypoints/cli.tsx
This is the main entry when you type claude in your terminal.
The CLI uses fast-path routing - special cases are handled before loading heavy modules:
| Branch | Trigger | Purpose |
|---|---|---|
--version | Version flag | Print version and exit |
--dump-system-prompt | Debug flag | Output system prompt |
--claude-in-chrome-mcp | Chrome mode | Run Chrome MCP server |
--daemon-worker | Internal | Spawn daemon worker |
remote-control | Bridge mode | Remote control session |
daemon | Background | Run supervisor daemon |
ps/logs/attach/kill | Sessions | Background session management |
--print | Headless | Non-interactive output |
| default | Interactive | Full TUI REPL |
main.tsxFile: src/main.tsx (~800KB - the largest file)
This is where the full application initializes. Think of it as the main() function.
Notice the pattern at the very top:
Why? These start async operations immediately so they run in parallel with module loading.
bootstrap/state.tsFile: src/bootstrap/state.ts
This module holds global bootstrap configuration that must be available before React/State init.
AppState is React-connected. bootstrap/state is pre-React - it needs to be available before the UI initializes.
File: src/bridge/bridgeMain.ts
Launched via: claude remote-control
| File | Purpose |
|---|---|
bridgeMain.ts | Entry point, initialization |
remoteBridgeCore.ts | Core polling and sync logic |
bridgeMessaging.ts | Message routing |
bridgeUI.ts | UI coordination |
initReplBridge.ts | Bridge-aware REPL init |
File: src/daemon/main.ts
Launched via: claude daemon
The daemon is a background supervisor that:
Flow: cli.tsx โ main.tsx โ askNonInteractive()
Used for:
No React/Ink UI. Uses direct stdout/stderr output.
File: src/entrypoints/sdk/
Exposes Claude Code as a programmatic API:
Understanding init order is crucial:
feature()feature() is a compile-time macro - not a runtime check!
Used to optimize startup performance.
Before full init, users must accept terms. Early exits if not trusted.
Shows profile checkpoints and init flow.
Prints detailed timing breakdown.
Enables debug logging throughout.
| Entry Point | File | When Used |
|---|---|---|
| CLI | cli.tsx | Primary entry |
| Main | main.tsx | Full initialization |
| Bridge | bridge/bridgeMain.ts | Remote control |
| Daemon | daemon/main.ts | Background supervisor |
| SDK | entrypoints/sdk/ | Programmatic API |
The key insight: cli.tsx is the router, main.tsx is the application, and specialized entrypoints handle specific modes (bridge, daemon, headless).