Skip to content

Runtime lifecycle

This section reverse-engineers package/Bun startup, command-line routing, runtime mode selection, terminal rendering/input, accessibility rendering, conversation termination, and high-level session entry paths to show how Claude Code reaches and eventually leaves a live session.

Source-anchor policy

This page is a section guide. Linked implementation pages carry concrete cli.renamed.js or Bun-graph anchors.

Semantic aliasMinified anchorScope
Runtime lifecycle sectionN/A — navigation pageGroups package bootstrap, root command routing, flags, subcommands, headless mode, and interactive mode.
Runtime implementation pagesSee linked source-anchor tablesConcrete bundle anchors live in destination pages.

Runtime map

flowchart TD
Package[Package/native Bun executable] --> Bootstrap[Outer bootstrap]
Bootstrap --> Main[Top-level main]
Main --> Commander[Commander root]
Commander --> Headless[Headless runner and control loop]
Commander --> Interactive[Interactive session loop and picker]
Commander --> Commands[mcp / plugin / auth / agents / doctor / update]

Pages

CLI main paths owns routing and control flow; Command-line reference owns names, aliases, flags, gates, and surface lookup. The former commands-and-flags.md page was retired because it repeated both owners without adding a third reader contract.

OrderPageRuntime question answered
1Package and Bun bootstrapHow does the npm/native/Bun module graph reach cli.renamed.js, and what else is embedded?
2CLI main pathsHow do outer bootstrap, top-level main, Commander root, headless, interactive, resume, remote, and MCP paths connect?
3Daemon and background serviceWhat does claude daemon supervise, how do /background and /stop hand off/retain session state, and how do service install/transient startup, locks, roster, and reachability work?
4Command-line referenceWhich source-visible flags, root subcommands, all core/bundled interactive command names, aliases, gates, and mode-specific surfaces exist? Routing behavior remains in CLI main paths rather than being duplicated here.
5Terminal UI renderer and input lifecycleHow are classic/fullscreen renderers selected, how do raw terminal bytes become scoped UI events, and how are alternate-screen, resize, suspend, and cleanup state managed?
6Accessibility and screen-reader modeHow do flag/env/setting precedence, classic renderer selection, animation suppression, terminal cues, and child propagation compose?
7Conversation terminationHow does the gated EndConversation tool reflect twice, persist an ended-by-model marker, block resumed turns, and recover through /clear?
8Runtime lifecycle architectureHow is bootstrap → main → Commander composed, what is the public interface, and what design decisions drive mode dispatch and shutdown?

Handoffs

Created and maintained by Yingting Huang.