dev-tools
Glossary ↗Feature Flag
A feature flag (also called a feature toggle) is a conditional switch in code that determines whether a piece of functionality is active, controlled by configuration rather than by which code is deployed. Instead of `if (newCheckoutFlow)` being decided at build time by which branch got merged, it's decided at runtime by looking up a flag's value — which can be flipped instantly for some, all, or a percentage of users without a new deployment. Tools like LaunchDarkly, Statsig, PostHog, and Unleash provide dedicated flag-management platforms; smaller teams often implement a simple version with a database table or environment variables. Why it matters for AI/SaaS builders: feature flags decouple deployment from release — you can merge and deploy a half-finished feature to production behind a flag that's off for everyone, continue working on it safely, and then release it later by flipping the flag, with zero additional deployment risk at release time. They also enable gradual rollouts (release to 5% of users, watch error rates and metrics, ramp to 100% if healthy, instantly roll back to 0% if not — far faster than a code revert and redeploy) and A/B testing (show variant A to half of users and variant B to the other half, measuring which performs better). This is especially valuable for AI features specifically, since a new AI-powered flow (say, an AI-generated onboarding checklist) often needs careful, gradual exposure while you monitor quality and cost before a full rollout. How it works: application code checks a flag's value at the relevant decision point (`if (flags.isEnabled("new-ai-onboarding", userId)) { ... }`), where the flag service resolves the value based on rules — a fixed on/off state, a percentage rollout, targeting specific user segments or individual users, all typically configurable from a dashboard without a deploy. Flag values are usually fetched at request time from a fast, cached source (an SDK with a local cache updated via streaming/polling, so the check adds negligible latency) rather than a slow database round trip on every check. Worked example: a SaaS company builds a new AI-powered "smart search" feature. They wrap it in a feature flag `ai-smart-search`, deploy the code to production with the flag off for everyone, and use their internal admin panel to turn it on just for their own team's accounts to test with real data. Satisfied it works, they set the flag to a 10% rollout; after 48 hours of clean error rates and positive engagement metrics, they ramp it to 100%. When a bug report comes in three days later showing the AI occasionally returns irrelevant results for a specific query pattern, they flip the flag back to 0% instantly from the dashboard — reverting the feature for all users in seconds, with no emergency deploy or rollback required.
Related terms