Group
  • Deployment

    Add feature flags so risky changes can ship dark

    Ship code behind a switch so you can release, roll out gradually, and kill features without redeploying.

    • Ship faster
    • Plan & validate
    • Intermediate
    • General

Free Prompt

Add a lightweight feature flag system to my app. I don't need a fancy vendor; I need to be able to ship risky code turned off, flip it on for me first, roll out to a percentage of users, and kill it fast if it misbehaves. Implement this: 1. A flag store: environment variables for simple boolean flags is fine for a small app; use a database table (or a hosted flag service like LaunchDarkly/PostHog if I already use one) once flags need per-user or percentage rollouts. Ask which fits before choosing. 2. A single check function: is_flag_enabled(flag_name, user) that returns a boolean and handles the 'flag missing' case by defaulting to off (fail closed for anything risky). 3. Support three rollout modes: off, on for specific users (me and a test list), and on for a percentage of users (hashed on user id so a given user's answer is stable). 4. Use flags for the right things: new features that are risky, migrations between old and new code paths, and kill switches for third-party integrations. Don't wrap every trivial change; flags are debt if left in the code forever. 5. Add a small admin UI or documented process for flipping flags without a deploy. That's the whole point; if changing a flag requires a redeploy, it's not solving the problem. 6. Log every flag evaluation with the flag name, user, and result (sampled if volume is high) so I can debug 'why did this user see the new thing'. Don't ship a huge flag framework; keep it small. The deliverable is the flag check function, the store (env or table), the rollout modes working, one real feature migrated behind a flag as a proof of concept, and a note in the docs about cleaning up flags after full rollout.

What This Does / How This Helps

This gives you a switch for risky changes: ship code behind a flag, turn it on for yourself first, roll out to a percentage, and kill it in seconds if it breaks. Without flags, every risky change is a bet-the-launch deploy. You can't test the new checkout against real users without shipping it to all of them, and you can't turn it off without a rollback. Flags decouple deploy from release, which is what lets you ship confidently to a fraction of users and back out cleanly when something's off, instead of arguing with your rollback plan at 2am.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts