Feature flags with Claude Code: a practical workflow
Claude Code is good at writing feature flag code. It is less good at knowing what flags exist in your project, what the naming conventions are, or how to use your specific SDK. The fix is to give it context.
Flagify ships with a command that generates that context for you.
The one command
npx flagify ai-setup --tool claude
This generates a few things in your repo:
CLAUDE.mdat the project root, with Flagify SDK patterns, naming conventions, and rules for when to use flags.claude/commands/flagify-*.md— slash commands for common flag operations- Updates to your
.cursorignoreor equivalent so flag cache files don’t leak into prompts
If you have existing flags, pass --include-flags and the current list gets included in the context.
npx flagify ai-setup --tool claude --include-flags
What the slash commands do
The generator creates four slash commands:
/flagify-create — “Create a feature flag named X of type Y.” Claude runs the CLI, confirms the flag was created, and adds it to its context.
/flagify-toggle — “Toggle flag X in environment Y.” Claude runs the toggle and tells you what changed.
/flagify-list — Lists all flags in the current project. Useful when you want to know what already exists before creating a new one.
/flagify-wrap — “Wrap this code behind a flag.” Claude refactors the selected code to go behind a new flag, creates the flag via CLI, and leaves you with a working diff.
You can edit these commands after generation. They are just markdown files in .claude/commands/.
A real workflow
Here’s how I use this in practice. I’m about to add a new payment provider. I want it behind a flag.
- In Claude Code: “Add a Braintree payment path behind a feature flag. Keep the existing Stripe path as fallback.”
- Claude reads
CLAUDE.md, sees the naming convention iskebab-case, and proposesenable-braintree-payments. - It runs
flagify flags create enable-braintree-payments --type booleanvia the CLI. - It wraps the code in
if (flagify.isEnabled('enable-braintree-payments')) { ... }. - It adds a fallback value of
false(because this is a release flag, not a kill switch). - It suggests a test for both paths.
Total time: about 90 seconds of wall clock, most of which is Claude thinking.
What CLAUDE.md looks like
The generated file teaches Claude the patterns. Excerpt:
## Feature flag conventions
- Use kebab-case for flag names: `new-checkout-flow`, not `newCheckoutFlow`
- Always provide a fallback value: `flagify.isEnabled('key', false)`
- Release flags should have a planned removal date, written as a code comment
- Kill switches have fallback `true` (feature on if flag service fails)
- Use `getVariant()` for A/B tests, not nested booleans
## When to use a flag
- Rolling out a new feature gradually: yes
- Kill switch for risky code: yes
- Static config that rarely changes: no, use env vars
- Every if/else: no, flags have a carrying cost
You can edit these rules. Claude respects them.
Why this matters more than it sounds
Without this setup, Claude will still write flag code. But it will invent flag names that don’t match your convention. It will forget to add fallback values. It will create duplicate flags because it doesn’t know what exists. Each of these is a small friction that adds up.
With CLAUDE.md and the slash commands, the AI is operating inside your system, not next to it.
Cursor, Copilot, Windsurf
The same generator supports other AI coding tools. Pass --tool cursor, --tool copilot, or --tool windsurf. Each gets the appropriate config files for that tool. See the AI tools documentation for the full list.
Read our collection of Cursor prompts for feature flags if you use Cursor.
What we don’t support yet
A few things on our roadmap:
- MCP server for direct Claude Desktop integration (not Claude Code, which is handled by the slash commands)
- Automatic flag cleanup suggestions based on evaluation patterns
- Drift detection when Claude creates flags that don’t match your team’s naming rules
Flagify is the first feature flag platform built for AI-assisted development. Read more in the AI tools documentation or start with the quick start.
Start for free — no credit card required.