Skip to Content
ArchitectureFeature Flags

Feature Flags

Source: src/main.tsx (feature flag initialization) and various conditional imports

Overview

Claude Code uses build-time feature flags for dead-code elimination. When a feature is disabled at build time, all code paths for that feature are completely removed from the bundle by the Bun bundler.

Mechanism

Feature flags are evaluated via a feature() function call pattern:

if (feature("COORDINATOR_MODE")) { // This entire block is removed from the bundle // when COORDINATOR_MODE is disabled import("./coordinator/coordinatorMode"); }

The Bun bundler treats feature() calls as compile-time constants, enabling tree-shaking of disabled feature branches.

Known Feature Flags

FlagDescription
KAIROSAssistant mode — alternative interaction pattern
COORDINATOR_MODEMulti-agent coordinator for parallel task execution
BRIDGE_MODERemote session bridge for cloud execution
VOICE_MODEVoice input/output capabilities
Chicago_MCPComputer use via MCP
DAEMONBackground daemon worker processes
WORKFLOW_SCRIPTSWorkflow scripting system
PROACTIVEProactive suggestions and actions

Impact on Architecture

Feature flags affect:

  1. Entry points — Conditional imports in main.tsx and cli.tsx
  2. Commands — Feature-gated commands only registered when their flag is active
  3. Components — UI elements conditionally rendered
  4. Services — Service modules loaded only when needed

Build Variants

Different builds can enable different flag combinations, producing separate bundles optimized for each deployment target. This keeps the base bundle small while supporting advanced features in specialized builds.

Runtime vs Build-Time

Most feature flags are evaluated at build time for optimal bundle size. However, some flags can also be evaluated at runtime via:

  • Environment variables
  • Configuration files
  • GrowthBook (A/B testing service) integration in src/services/analytics/
Last updated on