Detect Duplicate or Outdated Feature Flag Usage
Flags deprecated or fully launched feature flags in new code, raw flag keys outside the central registry, and repeated checks of the same flag.
What it flags
import { flags } from '@/lib/flags';
export async function submitOrder(order: Order, user: User) {
// Raw key strings, spelled two ways, for the same flag
if (await flags.isEnabled('new-checkout-v2', user)) {
await chargeV2(order);
} else {
await chargeLegacy(order);
}
if (await flags.isEnabled('new_checkout_v2', user)) {
await sendReceiptV2(order);
} else {
await sendReceipt(order);
}
}import { FLAGS, flags } from '@/lib/flags';
export async function submitOrder(order: Order, user: User) {
const useNewCheckout = await flags.isEnabled(FLAGS.newCheckoutV2, user);
if (useNewCheckout) {
await chargeV2(order);
await sendReceiptV2(order);
} else {
await chargeLegacy(order);
await sendReceipt(order);
}
}Why it matters
Each flag doubles the paths through the code it guards, and a flag that outlives its rollout becomes a permanent branch that nobody tests. Flag keys typed as raw strings drift: in most flag SDKs a misspelled key evaluates to the default value without an error, so part of the product never sees the feature. When several places check the same flag they can disagree mid-rollout, and removing the flag later means finding every copy.
Agent instructions
cubic checks every pull request against these instructions. Paste them into AGENTS.md or Cursor rules and your AI coding tool follows them while it writes code.
AGENTS.md
Add this section to AGENTS.md at the repository root. Codex, Cursor, and other AI coding tools read it.
## Detect Duplicate or Outdated Feature Flag Usage Feature flags must be centrally defined and consistently referenced. Flags marked as deprecated must not be used in new code. Multiple branches checking the same feature flag should be consolidated. Remove feature flag logic once features are fully launched or deprecated.
Checks every changed file.
Related agents
Run this agent on every pull request
cubic reviews every pull request against the agents you turn on and comments on the lines that break them.