Reflag CLI is a powerful command-line tool for managing feature flags in your applications. It allows you to create and manage flags, generate TypeScript type definitions, and integrate with AI development tools through the Model Context Protocol (MCP).
Get started by installing the CLI locally in your project:
# npm
npm install --save-dev @reflag/cli
# yarn
yarn add --dev @reflag/cli
Then initialize your project with the new
command from your project's root directory:
# npm
npx reflag new
# yarn
yarn reflag new
The CLI creates a reflag.config.json
file in your project directory during initialization. This file contains all necessary settings for your Reflag integration.
{
"$schema": "https://unpkg.com/@reflag/cli@latest/schema.json",
"baseUrl": "https://app.reflag.com",
"apiUrl": "https://app.reflag.com/api",
"appId": "ap123456789",
"typesOutput": [
{
"path": "gen/flags.d.ts",
"format": "react"
}
]
}
Option | Description | Default |
---|---|---|
$schema |
Autocompletion for the config. latest can be replaced with a specific version. |
"https://unpkg.com/@reflag/cli@latest/schema.json" |
baseUrl |
Base URL for Reflag services. | "https://app.reflag.com" |
apiUrl |
API URL for Reflag services (overrides baseUrl for API calls). | "https://app.reflag.com/api" |
appId |
Your Reflag application ID. | Required |
typesOutput |
Path(s) where TypeScript types will be generated. Can be a string or an array of objects with path and format properties. Available formats: react and node . |
"gen/flags.ts" with format "react" |
reflag new [flagName]
All-in-one command to get started quickly, combining initialization, flag creation, and type generation:
npx reflag new "My Flag" [--app-id ap123456789] [--key my-flag] [--key-format custom] [--out gen/flags.ts] [--format react]
reflag init
Initialize a new Reflag configuration in your project:
npx reflag init [--overwrite]
Options:
--overwrite
: Overwrite existing configuration file if one exists--app-id <id>
: Set the application ID--key-format <format>
: Set the key format for flagsreflag login
Log in to your Reflag account:
npx reflag login
reflag logout
Log out from your Reflag account:
npx reflag logout
reflag flags create [flagName]
Create a new flag in your Reflag app:
npx reflag flags create "My Flag" [--app-id ap123456789] [--key my-flag] [--key-format custom]
reflag flags list
List all flags for the current app:
npx reflag flags list [--app-id ap123456789]
reflag flags types
Generate TypeScript types for your flags:
npx reflag flags types [--app-id ap123456789] [--out gen/flags.ts] [--format react]
The rules
command helps you set up AI-specific rules for your project:
npx reflag rules [--format <cursor|copilot>] [--yes]
The mcp
command configures your editor or AI client to connect with Reflag's remote MCP server:
npx reflag mcp [--app-id <id>] [--editor <editor>] [--scope <local|global>]
Supported editors/clients:
cursor
: Cursor IDEvscode
: Visual Studio Codeclaude
: Claude Desktopwindsurf
: WindsurfFor automated environments, use the --api-key
option or the REFLAG_API_KEY
environment variable:
# Generate types in CI/CD
npx reflag flags types --api-key $REFLAG_API_KEY
Example GitHub Actions workflow:
# Using command option
- name: Generate types
run: npx reflag flags types --api-key ${{ secrets.REFLAG_API_KEY }}
# Using environment variable
- name: Generate types
run: npx reflag flags types
env:
REFLAG_API_KEY: ${{ secrets.REFLAG_CI_API_KEY }}
If you're migrating from the Bucket CLI:
bucket
to reflag
flags.d.ts
from features.d.ts
.reflag-auth
from .bucket-auth
reflag.config.json
from bucket.config.json
features
command renamed to flags
REFLAG_API_KEY
instead of BUCKET_API_KEY
Remember to update your scripts, build steps, and .gitignore
patterns.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "bucket" '{"command":"npx","args":["@bucketco/cli","mcp"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"bucket": {
"command": "npx",
"args": [
"@bucketco/cli",
"mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"bucket": {
"command": "npx",
"args": [
"@bucketco/cli",
"mcp"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect