Ship behind flags when agents move fast

Agents can implement a feature quickly enough that the rollout plan becomes the risky part.

Published 2026-11-09 · Translation: VI

Agents can implement a feature quickly enough that the rollout plan becomes the risky part. Feature flags let you merge the code while keeping user impact off by default, then turn it on deliberately.

The trap is also simple. Flags that never get removed become permanent branching. Over time you end up with behavior nobody can reason about, and “toggle it off” stops being a real kill switch.

Decide: add a flag, or do something else

Use a flag when at least one of these is true:

  • You must merge before the feature is safe to expose. Backend or data work needs to land first, but the UI path cannot be shown yet.
  • You need a gradual rollout. You want to ramp from internal users to a small percentage to full traffic.
  • You need an incident switch. Turning the flag OFF must stop the bad behavior in one step.

Do not use a flag when a cheaper tool solves the job:

  • Low risk change. Copy edits and pure refactors with good tests usually do not need a flag.
  • A revert is cleaner. If the risky part is a small commit and rollbacks are fast, ship normally and revert if needed.
  • You cannot own the lifecycle. No owner, no removal date, no metric, no flag.

The minimum flag contract (what the PR must contain)

When an agent proposes a new flag, treat it like a small rollout project. Put this contract in the PR description (or your template) every time:

  • Flag name: stable, searchable, and scoped (checkout.new_tax_calc not tempFlag123).
  • Default state: usually OFF for new behavior.
  • Owner: a person or on-call rotation, not “the team”.
  • Removal date: a real date, not “soon”.
  • Cleanup ticket: link to the issue that deletes the flag and the dead path.
  • Kill switch: the exact operation to disable, and the blast radius (global, org, user).
  • Metric and alert: what you will watch during ramp (error rate, latency, conversion, queue depth).
  • Rollback plan: what you do if OFF does not stop impact (revert commit, disable job, block endpoint).

If you want one high leverage guardrail, make a CI check that fails when a new flag is added without an owner and a removal date. Agents are consistent when the gate is consistent.

Implementation patterns that survive cleanup

Flags rot fastest when the conditional leaks everywhere. Keep the decision close to the edge and pass a plain value inward.

Practical patterns:

  • One decision point. Evaluate the flag once per request and store the result in a request context or a feature snapshot.
  • Keep the flag out of deep business logic. Instead of if (flag) sprinkled across layers, route into NewPath() vs OldPath() in one place.
  • Prefer “replace a module” over “wrap every line”. It is easier to delete later.
  • Test the OFF path. OFF is your incident mode. It should have an explicit test.

If the feature changes data shape or writes, add a second guardrail:

  • Read and write flags are separate. A common safe rollout is “write both, read old” first, then “read new”, then remove the old write.

Three failure modes to catch early

Failure modes to catch early

Failure modes to catch early

  • Orphan flags. Nobody owns it, nobody remembers why it exists. Fix: registry + owner + removal date, then schedule deletion work.
  • Flag spaghetti. Flags nested inside flags, behavior depends on the order of conditionals. Fix: one decision point and a single routing switch.
  • Fake kill switches. Flag OFF hides UI but background jobs still write, or the API still triggers side effects. Fix: make OFF disable the side effect, not only the button.

A 30-minute weekly flag debt loop

Flag Gate

Flag Gate

Once a week, run a short cleanup pass. It prevents “flag archaeology” later.

  • List flags added this month. Confirm each has an owner and a removal date.
  • Expire old release flags. If rollout is done, schedule the deletion PR first, not “later”.
  • Search for dead paths. Look for if (flag) branches that have been ON in production for weeks and delete the OFF path with tests.
  • Rehearse a kill switch. Pick one flag and practice disabling it in staging. If nobody knows how, the kill switch is imaginary.

Bottom line

When this fits vs when it does not

When this fits vs when it does not

Feature flags are safe when they are temporary, owned, and tied to a real gate. When agents are moving fast, the right default is not “add flags everywhere”. The right default is “add a flag only when the PR also contains its ending”.

If you are in incident mode, pair this guide with the hotfix playbook for agents so “turn it off” and “ship a fix” do not fight each other.

Share

X Facebook LinkedIn
Educational content only. Rankings reflect stated criteria at the update date—not investment advice or permanent performance guarantees.