Flags guides
12 · Flag cleanup

Remove flags you’re done with.

Every release flag is temporary. A short routine keeps your code and your config free of switches nobody flips.


1

Temporary, permanent, released

Give each setting a lifecycle. temporary is for release flags and experiments that should go once they are at 100% or 0%. permanent is for kill switches, plan entitlements and remote settings that stay; they are never reported. Mark a flag released or deprecated when you know it is done. Set an owner too, so someone gets asked.


2

Find the ones that are done

Flags › Stale flags lists every flag that has not changed for 30 days (you choose the number per project), serves one value to everyone in every environment, or is marked released or deprecated. For each one it shows the value to put in its place in your code. Every Monday, each owner gets their list by email, and flags without an owner go to the workspace owners.

Flags collects no evaluation data (your app decides flags locally and reports nothing), so search your code before you delete a flag. AI agents get the same list through the MCP tool flags_list_stale_flags: ask one to remove the dead flags from your repository and open a pull request.

stale-flags.ts
import { Flags } from "@productcraft/flags";
const flags = new Flags(); // PRODUCTCRAFT_API_KEY + PRODUCTCRAFT_WORKSPACE_ID

declare const projectId: string;

// Flags unchanged for 30 days, serving one value everywhere, or marked
// released / deprecated. Permanent flags are never listed.
for await (const flag of flags.projects.staleFlags.list(projectId, { days: 30 })) {
  if (flag.prerequisite_of > 0) continue; // other flags still depend on it
  console.log(flag.key, flag.reasons.join(", "), "inline:", JSON.stringify(flag.suggested_value));
}

3

Code first, then Flags

  1. Remove every read of the flag from your code, keeping the branch it serves, and deploy.
  2. Delete the flag in Flags. Do it in this order: an app still reading a deleted flag gets its default (reason ERROR, FLAG_NOT_FOUND), which may be the old behaviour.

Prerequisites and segments that point at the flag block the delete (409 SETTING_IN_USE); the flag page lists them. The delete is kept in History with your note.

delete.ts
import { Flags } from "@productcraft/flags";
const flags = new Flags(); // PRODUCTCRAFT_API_KEY + PRODUCTCRAFT_WORKSPACE_ID

declare const settingId: string;

const setting = await flags.settings.retrieve(settingId);
// Prerequisites and segments that point at it block the delete (409).
console.log(setting.dependents);
await flags.settings.delete(settingId, { note: "new_checkout shipped to 100%; code path removed in #812" });