Graphite Reviewer is now Diamond

What are feature flags?

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite

Feature flags—also known as feature toggles, switches, or flippers—are a software development technique that allows teams to enable or disable features at runtime without deploying new code. They are typically implemented as conditional statements in the codebase, controlled by configuration files or external services. This approach enables developers to manage feature rollouts dynamically, providing flexibility and control over the software's behavior in different environments.

Feature flags offer several advantages:

  • Decoupling deployment from release: Deploy code to production without immediately exposing new features to users.
  • Progressive delivery: Gradually roll out features to specific user segments or environments.
  • Risk mitigation: Quickly disable problematic features without rolling back the entire deployment.
  • Experimentation: Conduct A/B testing and gather user feedback before a full release.
  • Operational control: Manage features based on user roles, geographies, or other criteria.

These benefits make feature flags a valuable tool for continuous integration and continuous deployment (CI/CD) workflows, enabling faster and safer software delivery.

Feature flags can be categorized based on their purpose and lifespan:

  • Release flags: Control the visibility of new features during rollout.
  • Experiment flags: Facilitate A/B testing and experimentation.
  • Kill switches: Provide an immediate way to disable features in case of issues.
  • Operational flags: Manage infrastructure changes or performance optimizations.
  • Permission flags: Enable or disable features based on user permissions or roles.

Each type serves a specific function, and understanding their differences helps in implementing effective feature flag strategies.

Implementing feature flags involves:

  1. Adding conditional logic: Wrap new or risky code paths with conditional statements that check the status of a feature flag.
  2. Managing flag states: Use configuration files or feature flagging services to control the state (on/off) of each flag.
  3. Monitoring and analytics: Track the performance and impact of features controlled by flags.
  4. Cleaning up: Remove obsolete flags to prevent technical debt and maintain codebase clarity.

Proper management ensures that feature flags enhance flexibility without introducing complexity.

Several tools and services assist in managing feature flags effectively:

  • Statsig: A modern feature flagging and experimentation platform offering a generous free tier with no limits on flags, users, or environments. Statsig provides advanced targeting, real-time diagnostics, and integrates seamlessly with your data warehouse.
  • LaunchDarkly: A feature management platform that supports advanced targeting and analytics.
  • Flagsmith: An open-source feature flag service with options for self-hosting or cloud deployment.
  • Unleash: An open-source feature management solution designed for enterprise use.
  • ConfigCat: A feature flag service offering a forever free plan with unlimited seats.
  • PostHog: An all-in-one platform that includes feature flags, analytics, and session recording.
  • FeatBit: A scalable, open-source feature flag management service built with .NET.

These tools provide various features and integrations to suit different project needs and team sizes.

While Graphite does not manage feature flags directly, it facilitates best practices around them by enhancing pull request workflows. Graphite's support for stacked pull requests and streamlined code reviews enables teams to:​

  • Break down large features into smaller, manageable changes, each potentially guarded by its own feature flag.
  • Maintain a clear history of feature flag implementations and modifications within the pull request stack.
  • Ensure that feature flags are reviewed and approved alongside code changes, promoting transparency and accountability.​

By integrating Graphite into your development workflow, you can manage feature flags more effectively within your pull requests, ensuring smoother feature integration and team collaboration.​

Feature flags are a powerful tool for modern software development, enabling teams to release features safely, conduct experiments, and manage operational aspects without redeploying code. By understanding their types, benefits, and implementation strategies, and by leveraging appropriate tools, teams can enhance their development processes and deliver better software faster.

Built for the world's fastest engineering teams, now available for everyone