Skip to content

Feature flags: a safety net for changes written by coding agents

A flag lets you merge code that is switched off, release it gradually and turn it off without a deploy. How to use them, and how to avoid flag debt.

Published by Contextingo.

A feature flag is a switch in the code or configuration that turns a feature on or off without a new deploy. It separates merging code from releasing it.

Why flags suit agent changes

  • You can merge small steps behind a flag, with the feature still off.
  • You can enable it for yourself first, then for a few users, then for all.
  • If something goes wrong you turn it off in seconds.

Rules

  1. Name the flag after the feature and give it an owner.
  2. Default to off. A missing flag must not turn the feature on.
  3. Test both states.
  4. Put an expiry date on the flag and an issue to remove it.
  5. Remove the flag and the old code path once the feature is on for everyone.

Watch for flag debt

Old flags multiply the paths through the code. A flag that stays for a year is a decision nobody made. Ask the agent to find flags past their date, and have a person decide.

Not for everything

A flag does not replace review. A flagged change still gets reviewed, and flags for security-sensitive code need extra care.

Questions

Good to know.

Should every change have a flag?

No. Use them for changes that are risky or need gradual release.

Where should flags live?

In configuration or a flag service, not scattered as constants.

Nothing learned is lost. Nothing unchecked is done.