Kill switches: roll back a bad release in seconds

A kill switch is a flag you can turn off at once, without a deploy. In Flagger.gg, flagger kill <key>, the flag_kill tool or the console turns a flag off for everyone, on protected flags too. The change reaches your SDKs within a second, and kill is exempt from agent rate limits.

Updated

Kill a feature, step by step

  1. Ship the change behind a flag. A kill switch only exists if the code path is wrapped in a flag check. Unknown or errored flags are off, so the fallback path is the safe one.
  2. Kill it. Run flagger kill <key> --note "why", call flag_kill over MCP, or switch it off in the Release console. The flag goes off for everyone and keeps its rules.
  3. Confirm it's off. flagger eval <key> --user <id> explains the answer for one user; it should say off.
  4. Fix, then bring it back. When the fix is deployed, flagger revert <key> restores the state before the kill, rules included, or walk it up again from admins.
flagger kill checkout_v2 --note "500s on /checkout since 3:02 PM" --json
flagger eval checkout_v2 --user usr_123 --json
flagger revert checkout_v2 --note "fix deployed in #881" --json

How fast it takes effect

Flagger.gg's SDKs hold the ruleset in memory and follow a server-sent event stream. After every change the service pushes the new ruleset within a second; if the stream is down, the SDK polls every 5 seconds. There's no build, no deploy and no cache to purge.

Kill always works

  • Anyone who can write, a person or a token with the kill action, can kill any flag, including protected flags that otherwise refuse agents.
  • Kill is exempt from agent rate limits and never needs approval, in auto-live or approvals mode.
  • It writes an audit row with who, which run, the state before and the note, so the post-mortem starts with the facts.

Give the agents that ship your code the kill action, and tell them to kill their own flag the moment a check fails after a change.

Kill switch vs rolling back a deploy

Both undo a bad release. They differ in what they undo and how long it takes.

Kill switchRolling back a deploy
What it turns offOne feature, everything else staysEvery change in the release
How long it takesSeconds: apps pick up the change within a secondA build and a deploy
Needs the code to be flaggedYesNo
Fixes a bad migration or a crash at startNoSometimes
Undoflagger revert <key>Deploy again

Use the kill switch first when the broken thing is behind a flag. Roll back the deploy when it isn't, or when the problem is outside any flag, such as a schema change or a process that won't start. Teams that ship to production behind flags instead of a staging environment rely on both; see feature flags vs staging.

What to put behind a kill switch

Every new feature gets a release flag, which doubles as its kill switch until the flag is removed. Some switches are worth keeping for good, as operational flags:

  • Third-party calls, such as a payment, email or AI provider, so you can stop calling it while it's down.
  • Expensive work, such as a heavy report, a recommendation query or a background job, so you can shed load.
  • Risky write paths, such as a new sync or import, so you can stop them before they touch more data.

Write the check so that off is the safe answer. Flagger.gg's SDKs treat an unknown, not-loaded or errored flag as off, and start from a disk cache of the last ruleset they saw, so a restart during an outage keeps the last known state. Say in the flag's summary that it's a permanent switch, and have a person mark it protected: agents can then kill it but can't turn it back on alone. More in feature flag best practices.

A kill switch for an AI agent's deploys

When an AI agent ships code, the kill switch is the flag around each change it made, not the agent process. Give every agent change its own flag and a run id, and you can turn off one change, or everything one run shipped, without touching the rest.

  1. Tag the agent's writes with its run. Set FLAGGER_RUN (or pass --run) in the agent's environment, so every flag it creates or changes records which run did it. Over MCP, the run is the tool's run input, else FLAGGER_RUN on stdio or the X-Flagger-Run header on the hosted server.
  2. Find what the run changed. The console's audit log filters by run, agent, flag and actor (/audit?run=<id>), and so does GET /v1/audit?run=<id>. Each row shows the flag, the state before and after, and the agent's note.
  3. Kill those flags. Run flagger kill <key> for each one. Kill works on protected flags, skips approvals and agent rate limits, and reaches your apps within a second.
  4. Stop the agent's flag access if you need to. Revoke its agent token on the console's Tokens page. From then on, every call with that token gets 401 unauthorized. Revoking doesn't undo what the agent already changed, so kill first, then revoke.
export FLAGGER_RUN="run_8812 https://ci.example.com/runs/8812"
flagger set search_v3 percent --percent 10 --note "roll out PR #912 to 10%" --json
# later, if the run's changes misbehave:
flagger kill search_v3 --note "p95 latency doubled after run_8812" --json

Flagger.gg turns off features, not agents. Stopping an agent's other actions, like its access to your repo or cloud, is a job for the tools that granted that access.

For the whole checklist, from turning off what the agent shipped and stopping the machines it started to cutting off its access, see North Bay Ventures' guide to stopping a misbehaving AI agent.

Automatic rollback

In development Rolling a flag back automatically when error rates or other metrics regress is in development. Today a kill is a person's or an agent's call, made with one command.

FAQ

How do I turn off a broken feature instantly without redeploying?

Put the feature behind a flag, then turn the flag off. With Flagger.gg, flagger kill <key> turns it off for everyone and your apps see the change within a second.

What's the difference between kill and setting a flag off?

Both end in off and keep the rules. Kill is always allowed for anyone who can write, works on protected flags and skips agent rate limits and approvals.

What's the difference between a kill switch and a feature flag?

A kill switch is a feature flag used to turn something off fast. Every release flag can act as one while it's in code; an operational kill switch is a flag you keep for good around a risky dependency or expensive job.

Should I kill the feature or roll back the deploy?

Kill the feature when the broken code is behind a flag: it takes seconds and leaves the rest of the release running. Roll back the deploy when the problem isn't behind a flag, such as a bad migration.

What's a kill switch for AI agent deploys?

It's a flag around each change an agent ships, so a person or the agent can turn that change off in seconds without a redeploy. In Flagger.gg, give the agent's token the kill action and tag its writes with a run, so you can find and kill everything one run changed.

How do I undo a kill?

flagger revert <key> (or flag_revert) rolls back to the state before the latest change. With approvals on, a revert that widens the flag past the agent's cap becomes a request.

Ship your next change behind a flag.

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

Sign up