Feature flag best practices: types, lifecycle, and cleanup
Feature flag best practices from Pete Hodgson's Feature Toggles guide: the four flag types, how to manage each, keeping flag debt low, and flags with AI agents.
A codebase has 340 feature flags. Nobody knows which are still used. A two-year-old flag for a "new checkout" is still checked on every request, both code paths still exist, and an engineer spends a day fixing a bug in the path no customer has seen since 2024.
Flags are cheap to add and easy to forget. This guide follows Pete Hodgson's Feature Toggles article on martinfowler.com, checked on 16 November 2026.
Four kinds of flags
Hodgson's key point is that flags fall into categories with different lifetimes and owners, and should be managed differently.
| Type | Purpose | Lifetime | Typical owner |
|---|---|---|---|
| Release | Ship unfinished code turned off, for trunk-based development | Days to weeks | Engineering |
| Experiment | A/B and multivariate tests | Long enough for significant results | Product, data |
| Ops | Control operational behavior, such as a kill switch | Short, or long-lived for kill switches | Operations, SRE |
| Permissioning | Turn features on for certain users | Often long-lived | Product |
Release flags let in-progress work merge to the main branch while the branch stays deployable. The code ships as latent code that may never be turned on.
Experiment flags put each user in a cohort and consistently route them to one code path, so you can compare outcomes. They need to stay unchanged long enough for statistically significant results.
Ops flags control production behavior: disabling an expensive feature under load, for example.
Permissioning flags give features to specific users: beta testers, internal staff, premium customers.
Best practices
Manage each type differently
Hodgson's example: a recommendations section might start behind a release flag, then move to an experiment flag, then stay behind an ops flag. Same machinery, different rules for each phase. Label every flag with its type.
Keep release flags short-lived
Release flags exist to get code to production safely. Once the feature is fully on, remove the flag and the old path.
Plan removal when you add the flag
From the article, teams that do this well:
- Add a removal task to the backlog when they add a release flag
- Put expiration dates on short-lived flags
- Add "time bombs": tests that fail, or apps that won't start, if a flag outlives its expiry
- Cap the number of flags; to add one past the limit, remove another
Hodgson's framing: savvy teams treat flags as inventory with a carrying cost and keep that inventory low.
Make flag state visible
Expose the current configuration so anyone can see which flags are on where. Most incidents involving flags start with "I didn't know that was on."
Test both paths while both exist
Each flag doubles some code paths. Test the combinations that matter, and remember that every extra flag adds validation work.
Kill switch vs feature flag
A kill switch is an ops flag. Keep it long term for risky dependencies, document it in the runbook, and test that it works before you need it.
Flags and AI coding agents
Agents read code, and flags hide intent in it. An agent sees if (flags.newCheckout) and both branches, with no sign that one branch is dead or that the team decided to remove it this sprint. It may extend the old path, or add features behind a flag that's about to be deleted. Note flag ownership and planned removals in the flag's definition, and keep the list of flags small.
Flags are decisions
Turning a flag fully on, keeping an experiment running, removing a kill switch: each is a decision with an owner and a reason. Written down, they keep flags from piling up. Left in a Slack thread, they become the 340-flag codebase.
Where Lockstep fits
Lockstep captures decisions like "new checkout is permanent; remove the flag by Friday" from Slack, documents, and pull requests, routes each to its owner for approval, and briefs Claude Code sessions on the ones that apply to the code being changed.
See how it works.
Sources checked 16 November 2026
Related reading
For delivery metrics flags affect, see DORA metrics. For technical debt more broadly, see technical debt from AI coding. For the branching model flags support, see trunk-based development. For telling users what changed, see the release notes template. For a full launch checklist, see the launch checklist.
Frequently asked questions
- What are feature flags?
- A technique for changing a system's behavior without changing code. Pete Hodgson's article on martinfowler.com calls them feature toggles and notes they're also called feature flags, feature bits, or feature flippers.
- What are the types of feature flags?
- Hodgson describes four categories: release toggles, which let unfinished code ship turned off; experiment toggles, for A/B and multivariate tests; ops toggles, for controlling operational behavior such as a kill switch; and permissioning toggles, which turn features on for specific users or groups.
- What is the difference between a feature flag and a kill switch?
- A kill switch is one use of a feature flag: an ops toggle that turns off a feature or dependency under load or failure. Release and experiment flags are usually temporary; kill switches are often kept long term.
- What is the difference between feature flags and A/B testing?
- A/B testing is one use of flags. Experiment toggles put each user in a cohort and consistently route them to one code path, so you can compare cohorts. They must stay in place long enough to reach statistically significant results.
- How do I avoid feature flag debt?
- Hodgson suggests treating flags as inventory with a carrying cost: add a removal task to the backlog when you create a release flag, put expiration dates on short-lived flags, use tests that fail if a flag outlives its expiry, or cap how many flags exist at once.
Keep reading