Feature flags
Turning features on and off without deploying.
Feature flags separate deploying from releasing. They enable gradual rollouts, experiments, beta access and kill switches. Old flags need removing, or they become technical debt.
Why it matters for a product engineer
Flags let a small team merge and deploy every day, and decide separately when users see the change. The engineer decides where the check lives in the code. That choice decides whether turning the flag off is safe, and whether the flag is easy to remove later.
How to do it
- Decide what kind of flag it is before you add it. A release flag should live days or weeks. A kill switch for operations can stay longer. An experiment flag lives as long as the test. A permission flag can be permanent. Put the type in the name.
- Check the flag in one place, inside one function, as high in the code as you can: the route or
the component that changes, not ten scattered
ifstatements. - Identify the user before you evaluate the flag, so the same person gets the same answer on every request and every device.
- Decide what the code does when the flag service does not answer. “Not evaluated yet” is not the same as “off”.
- Start with your own team, then a small share of users, and widen it while you watch errors and the one metric that matters.
- When the flag reaches 100%, delete the flag and the old code path in the same week.
Common mistakes
- One flag checked in many files, so nobody is sure what turning it off does.
- Flags evaluated in the browser before the user is known, so a user sees the new version, then the old one.
- Release flags that stay for months. Ten on-off flags give 1,024 possible combinations, and nobody tests most of them.
- Using a flag for settings that need a restart. That is configuration, not a feature flag.
Example
Mamitsu is built by one person with a team of coding agents. After a merge, the agent turns on a feature flag if the change needs one, watches the logs until about ten requests have gone through the new code, and rolls back if something breaks. That has happened once. Otherwise Unai Esteibar, its maker, gets a Slack message that all is well. (Mamitsu in In practice)
What Mamitsu's agent does after a merge
- 04This has happened once.
The flag and the logs give the agent a small, fast check. A person hears about it only when something needs them.
Sources: Feature toggles (Pete Hodgson, martinfowler.com) ↗ · Best practices for production-ready flags (PostHog docs) ↗ · 11 feature flag best practices for scale (Unleash docs) ↗
AI leverage
Use AI in your workUse AI to support this skill. Your judgment and verification remain part of the work.
- Workflow
- Draft rollout rules and a test matrix for flag combinations, including both enabled and disabled behavior.
- Limitations
- Generated conditions can expose the wrong cohort or leave an untested fallback.
- Verification
- Check targeting with representative identities and exercise disablement before widening exposure.
Technical leverage
Decouple release from deployment, compare cohorts and turn a failing change off without a full redeploy.
Evidence of mastery
Put it into practice- Practice
- Release one improvement to a bounded cohort with explicit expansion criteria.
- Artifact
- A rollout record with exposure data, outcome metrics and a tested disable switch.
What good looks like
- Both flag states work.
- The flag has an owner and a removal condition.
Use this evidence to assess your work. Your map status is a self-assessment, not a certification.
In practice
Real productsResources
2- articleGo deeper
Feature toggles (aka feature flags) ↗
Pete Hodgson (martinfowler.com) · 2017 · 35 minThe four kinds of feature flags, how long each should live, and how to stop them turning into debt.
- docsGo deeper
Best practices for production-ready flags ↗
PostHog docs · 12 minA checklist from a flag vendor on where to evaluate flags, how to keep results stable for each user, and when to remove a flag.
Tools
3- ToolOpen source
Unleash
Open-source feature flag platform for gradual rollouts, kill switches and experiments.
- ToolOpen source
- ToolPaid
LaunchDarkly
Feature management platform for targeted rollouts, release monitoring and experiments.