Feature flag management: run every flag from creation to removal

Feature flag management is the work of running flags across their whole life: declaring each one with an owner and a purpose, rolling it out in steps, controlling who can change it in production, keeping a record of every change, and removing it once the feature is fully on. A flag tool handles the switching. Management is the inventory, permissions, history and cleanup around it, so a team with hundreds of flags still knows what each one does and who can touch it.

Updated

What feature flag management covers

A feature flag is one switch in your code. Managing flags is what keeps a few hundred of those switches understandable. It has five parts:

  • An inventory. Every flag has a key, a one-line summary, an owner and a description, in one place.
  • A lifecycle. Each flag goes from created, through a rollout, to fully on, and is then deleted from the code.
  • Permissions. It's clear who and what may change a flag in production, and how far.
  • History. Every change records who made it, when, from what to what, and why, and can be undone.
  • Cleanup. Flags that have done their job are removed, so the codebase doesn't fill with dead branches.

Teams usually feel the need for this at the point where nobody can say what half the flags in the dashboard are for. That point comes sooner when AI coding agents create flags, because they create them faster than people review them.

The lifecycle of a flag

  1. Declare. The change that adds the flag check also declares the flag: key, summary, owner and, if the work isn't finished, a reason it isn't ready.
  2. Ship dark. The code merges and deploys with the flag off, or on only for your own team.
  3. Target. Turn it on for named users or workspaces who agreed to try it.
  4. Roll out. Widen it by a sticky percentage (5%, 25%, 50%) while you watch errors and metrics. See percentage rollouts.
  5. Fully on. Everyone gets the new path. If anything goes wrong at any step, the kill switch turns it off at once.
  6. Remove the code. Delete the check and the old path in a small change, and deploy it.
  7. Archive. Only after the code is gone, archive the flag so it stops appearing in lists and rules.

Steps 6 and 7 are the ones teams skip, and skipped cleanup is where flag debt comes from. Flag cleanup covers how to find flags that are ready to go.

Keep an inventory that stays true

A list of flags in a dashboard drifts from the code: flags are created and never used, or deleted from code and left in the dashboard. The fix is to make the code the source of the inventory.

  • Declare flags in code. One registry file lists every flag with its summary, description and owner. See typed feature flags for a registry the compiler checks.
  • Let the app register them. Flagger.gg's Go and Node SDKs send that registry when the app starts. Missing flags are created and descriptions are updated, but registration never changes a flag's state or rules, so a deploy never undoes a change someone made.
  • Mark what's in code. A flag is "in code" when an SDK registered it in that environment in the last 30 days. flagger list marks flags that aren't with ?, and the Release console shows "Not in code yet" for a flag that exists in the service but in no registry, such as one an agent created through MCP.
  • Separate long-lived flags. Release flags should be short-lived. Kill switches for risky dependencies and per-customer permission flags may stay for years. Unleash builds this in: each flag has a type with an expected lifetime, and flags past it are marked potentially stale (Unleash docs, checked November 22, 2026).

Decide who can change production

Most flag incidents come from a change that was too wide, made too fast, by someone who didn't know the flag. Decide ahead of time:

  • Who can widen a rollout. Narrowing a flag or killing it should be easy for anyone. Turning it on for everyone deserves a second look.
  • Which flags are protected. Some flags, such as billing or auth paths, shouldn't be changed casually by anyone.
  • What automation may do. Scripts and AI agents need their own credentials, limited to the projects, environments and actions they need.

In Flagger.gg:

  • Agent tokens (flg_agent_…) are scoped to one project, a list of environments, and actions (read, create, target, rollout, kill, request). They expire after 90 days and can be revoked. See scoped agent tokens.
  • Protected flags refuse agents for everything except kill.
  • Approvals mode, per project, lets agents in production roll out up to a cap (10% by default) on their own. Anything wider becomes a request a person approves in the Release console. See human approval.
  • Kill always works for anyone who can write, on protected flags too, and is exempt from rate limits.
  • Agent rate limits: 30 writes a minute and 5 changes to one flag an hour, per token.

Record every change, and make it undoable

When a metric drops, the first question is "what changed?". A flag history answers it only if every change carries the actor, the before and after, and a reason.

  • Flagger.gg records each change with who made it (a person, an agent token, an admin token, an SDK registration or an import), the run it came from, the note, from and to, the client and the IP.
  • A note is required on every agent write, so the reason is never blank.
  • The org audit log filters by project, environment, flag, agent, actor and run.
  • flagger revert rolls a flag back to its previous state, or to any event in its history.
flagger get new_checkout                 # state, rules, history, pending requests
flagger revert new_checkout --note "errors up after 25% step"
flagger eval new_checkout --user u_123   # would it be on for this user, and why

More in the audit trail for agent changes.

What to look for in a flag management tool

NeedWhat to checkFlagger.gg
InventoryOwner and description per flag; a sign of which flags are still in codeRegistry from code, inCode mark, "Not in code yet"
LifecycleStates from off to on, sticky percentages, archiveFive states (off, admins, targets, percent, on); people archive from the flag's drawer
Stale-flag detectionFlags fully on, unchanged or unevaluated for a set timeYou judge from state, history and the in-code mark; automated cleanup PRs In development
PermissionsRoles, scoped tokens, protected flags, approvalsScoped agent tokens, protected flags, approvals mode with an agent cap
HistoryActor, reason and before/after on every change; one-step undoAudit log with run and note; revert
AutomationAn API, a CLI with machine-readable output, MCP for agentsAPI, flagger CLI with --json, 11 MCP tools

Some tools go further on lifecycle automation today. Unleash moves flags through five lifecycle stages (Define, Develop, Production, Cleanup and Archived) from usage data (Unleash docs). LaunchDarkly's lifecycle settings mark flags ready for code removal or ready to archive from checks you choose, such as no targeting changes or no evaluations for a set time (LaunchDarkly docs). Both checked November 22, 2026. For a side-by-side of the main tools, see the best feature flag tools in 2026.

Managing flags that AI agents create

When agents write most of the code, they also create most of the flags. Three habits keep that manageable:

  • Agents declare, people decide how wide. An agent adds the flag to the registry and ships it dark or with a not-ready reason. In auto-live mode, Flagger.gg's default, new flags start on unless they carry a not-ready reason, so unfinished work must pass one (--not-ready in the CLI, notReady in the SDKs).
  • Every agent change says why. The required note and the run id tie a flag change back to the agent session that made it.
  • Review the not-live list. The Release console puts flags that aren't live first ("Not live yet: N"), with each flag's summary, so a person can see at a glance what's waiting.
flagger create pdf_export --summary "Users can export reports as PDF" \
  --owner reports --not-ready "Fonts not embedded yet" \
  --note "adds PDF export behind a flag" --run "$FLAGGER_RUN"
flagger list --not-live --json

For the full setup, see feature flags for AI coding agents.

FAQ

What is feature flag management?

It's running flags over their whole life: keeping an inventory with owners, rolling flags out in steps, limiting who can change production, recording every change, and removing flags once they're fully on.

How do you manage feature flags at scale?

Declare every flag in code with an owner and summary, let the app register them so the inventory matches the code, give automation scoped credentials, require a reason on each change, and make removing the code part of finishing the feature.

What's the difference between a feature flag tool and feature flag management?

The tool evaluates flags and stores their state. Management is the process around it: ownership, permissions, history and cleanup. Good tools build the process in, but a team still has to decide who owns each flag and when it goes.

How long should a feature flag live?

A release flag should be gone within weeks of reaching everyone. Kill switches and permission flags can stay as long as the code they guard. Unleash, for example, gives each flag type its own expected lifetime.

Who should be allowed to turn a flag on in production?

Anyone who can write should be able to turn a flag off. Widening it to everyone is worth limiting. In Flagger.gg's approvals mode, agents in production can roll out up to a cap and a person approves anything wider.

Ship your next change behind a flag.

Sign up, add an SDK key to your app and give your agent a token.

Sign up