GrowthBook A/B Testing

Feature flagging and experiment management using GrowthBook for gradual rollouts, A/B tests, and targeted feature releases.

Internal Infrastructure GrowthBook integration is used for Claude Code's own product development telemetry and experiment tracking. It is not a user-facing feature — this documentation is for contributors and integrators.

Overview

GrowthBook provides feature flagging and A/B testing within Claude Code. It enables controlled rollouts of new features, experiment tracking, and targeted feature releases based on user segments. The SDK is initialized at startup and evaluates flags locally with caching for minimal latency.

Architecture

Usage in Code

Feature flags are accessed through a cached evaluation function. The cache may return slightly stale values within a session, which is acceptable for product experimentation:

// Check if a feature is enabled (cached evaluation)
const isEnabled = getFeatureValue_CACHED_MAY_BE_STALE(
  'tengu_plum_vx3',  // Feature key
  false                  // Default value
);

// Use the feature value
if (isEnabled) {
  // New behavior path
} else {
  // Control behavior path
}

Configuration

GrowthBook is configured via environment variables. The SDK connects to the GrowthBook API at startup to fetch the latest feature definitions, then caches them locally for offline operation:

VariablePurpose
GROWTHBOOK_API_HOSTGrowthBook API endpoint (self-hosted or cloud)
GROWTHBOOK_CLIENT_KEYClient-side SDK key for feature flag access
GROWTHBOOK_FORCE_VARIATIONForce a specific variation for testing

How It Works

  1. On startup, Claude Code initializes the GrowthBook SDK with the configured API host and client key
  2. Feature definitions are fetched from the GrowthBook server and cached locally
  3. Throughout the session, code checks feature flags using the cached evaluation function
  4. Flag values are re-evaluated periodically or on explicit refresh
  5. Experiment results are tracked and sent back to GrowthBook for statistical analysis
  6. Forced variations can override normal bucket assignment for testing

Best Practices