Feature Flags for AI Coders
A simple switch that lets you turn features on or off for specific users. No redeploy needed.
In this chapter
- What a feature flag is, in one sentence
- Three real reasons you'll want one (and they're not what you think)
- How to ask AI to add a flag for you
- When to upgrade to a real flag tool (and when not to)
A Switch for Your App
Imagine your app has a new feature (say, a fancy new dashboard). You've built it, but you're not sure if it's ready to show to everyone. What do you do?
With a feature flag, you flip a switch. On → people see the new dashboard. Off → they see the old one. You can change the switch any time, without rewriting code, without redeploying, without anyone waiting.
Three Reasons You'll Want a Flag
How to Ask AI to Add a Flag
You don't need any special tool to start. Just describe what you want and AI handles the rest. The trick is to tell AI three things:
The 3 things to tell AI
- What feature you want to flag: "the new dashboard", "the AI chat sidebar"
- Who should see it: "just me", "these 5 emails", "Pro users"
- Where to flip it: "a setting I can change without redeploying"
“Add a feature flag to my app called "new-dashboard". When it's ON, users see my new dashboard component. When it's OFF, they see the old one. For now, only show it to my own account (my email is [[email protected]]). Make it easy to flip on or off without redeploying: pick the simplest setup you can, no fancy services required.”
Three Real Examples
Here are the most common ways people actually use feature flags. Pick whichever matches what you're building.
“Add a feature flag called "new-homepage". When ON, I see the new homepage I just built. When OFF, everyone sees the old one. Only my account ([[email protected]]) should ever see the new one for now: even when the flag is ON, hide it from everyone else.”
“Add a feature flag called "beta-comments" for my new commenting feature. Show the comments section ONLY to users whose email is in this list: [email1, email2, email3]. Everyone else should see no comments at all. When I'm ready to launch to everyone, I want to be able to flip it on without redeploying.”
“Add a feature flag called "export-pdf" for my PDF export feature. Show the Export PDF button only to users on the Pro plan. Free users should not see the button at all, and if they somehow find the URL, redirect them to my pricing page.”
When to Upgrade to a Real Flag Tool
For your first flags, the simple version works great. AI puts the on/off setting somewhere in your code or your hosting environment, and you flip it by changing one line.
But once you have 5+ flags and want to flip them from a dashboard without touching code, it's worth using a real flag tool. The most popular free option is PostHog. It gives you a web dashboard where you can flip any flag with a click.
✅ Stay simple if
- You have 1-5 flags
- Only you change them
- You don't need to flip them daily
⬆️ Upgrade to PostHog if
- You have 5+ flags
- You want a dashboard to flip them
- You want to enable for % of users
Common Mistakes
Forgetting to remove a flag once the feature is launched to everyone
Once your feature is on for 100% of users, the flag is just clutter. Tell AI: "remove the new-homepage flag, the feature is permanent now."
Adding a flag for things you'll never turn off
Don't flag every little change. Flags are for things you're unsure about, not for permanent features. If you'd never turn it off, just ship it directly.
Flag is on for me locally but off in production
Different environments have different settings. Tell AI: "make sure the flag value is the same on localhost and on Vercel, or show me where to set it for production."
Hiding a button is not the same as protecting a feature
If a feature uses paid data (like an AI call), hide the button AND block the underlying call on the server. Otherwise users could still trigger it directly.
Real World Example: Showing a half-finished feature to your team only
You built a new dashboard but it's not quite ready. You want your two co-founders to be able to use it on the real site (so they can give feedback), but everyone else should still see the old dashboard. With one prompt, AI adds a flag that uses your team's email addresses to decide who sees what.
“Add a feature flag called "new-dashboard" to my app. Show the new dashboard ONLY to users whose email is in this list: [[email protected], [email protected], [email protected]]. Everyone else should still see the old dashboard. Make the email list easy for me to update later: keep it in one obvious place.”
Prompt This
“Something's broken with my [feature name]. Add a feature flag so I can hide that feature from everyone immediately. Don't delete the code: just hide the feature from users until I flip the flag back on after the fix.”
“I want to roll out my new search bar slowly. Add a feature flag that shows it to about 10% of users (random but consistent: the same user should always see the same version). Make it easy for me to bump that number up later.”
“I want to announce my new pricing on January 15th. Set up a feature flag that automatically turns on the new pricing page on that date. Until then, everyone sees the old pricing.”
Frequently Asked Questions
What's a feature flag in plain English?
It's a switch in your app. You can flip a feature on or off without changing the code or redeploying. Like a light switch, but for parts of your app.
Why not just delete a feature when I don't want it?
Because you might want it back. Or you only want SOME people to see it. Flags let you keep the code in place but choose who sees it. Easier than deleting and rebuilding later.
Do I need a fancy tool for this?
Not at first. For your first flags, AI can wire one up using a simple list in your code or your settings (no extra service needed). If you want to flip flags from a dashboard without touching code, you can upgrade to a free tool like PostHog later.
Is this the same as a paid plan check?
Similar idea, slightly different. A paid plan check asks 'is this user paying?' A feature flag is more general: you can flip it on for testers, beta users, certain emails, or any group you want, regardless of whether they pay.