Skip to main content
Claude Code uses Bun’s bun:bundle feature flag system for dead code elimination at build time. Code inside an inactive feature flag is completely removed from the compiled binary — it is never shipped to users and does not increase bundle size.

How it works

import { feature } from 'bun:bundle'

if (feature('VOICE_MODE')) {
  const voiceCommand = require('./commands/voice/index.js').default
}
When VOICE_MODE is disabled at build time, the entire if block — including the require() — is stripped before the binary is produced. The feature simply does not exist in that build.
This is distinct from runtime feature flags (e.g., GrowthBook A/B experiments). bun:bundle flags are resolved at compile time and cannot be toggled at runtime.

Flag reference

FlagFeature
PROACTIVEProactive agent mode — enables autonomous, unprompted agent actions
KAIROSKairos subsystem
BRIDGE_MODEIDE bridge integration (VS Code, JetBrains)
DAEMONBackground daemon mode
VOICE_MODEVoice input/output
AGENT_TRIGGERSTriggered agent actions (event-driven execution)
MONITOR_TOOLMonitoring tool
COORDINATOR_MODEMulti-agent coordinator for parallel workloads
WORKFLOW_SCRIPTSWorkflow automation scripts

Anthropic-internal gates

Some features are gated at runtime for Anthropic employees only:
if (process.env.USER_TYPE === 'ant') {
  // Anthropic-internal feature
}
These are runtime checks rather than build-time flags, so the code is present in all binaries but only activated for internal users.

Effect on binary size

Stripping inactive features via bun:bundle flags results in meaningfully smaller binaries for standard distributions. For example:
  • A build without BRIDGE_MODE excludes all bridge protocol code, JWT utilities, and IDE session management.
  • A build without VOICE_MODE excludes the voice service, speech-to-text streaming, and voice hooks.
When adding a new optional subsystem, gate it behind a bun:bundle feature flag from the start. This keeps non-target builds lean and ensures the feature cannot accidentally activate in unsupported environments.

Build docs developers (and LLMs) love