Skip to content

CLI Overview

The Featsync CLI helps you manage feature flags from the command line. Scan your codebase for flag usage, list flags, and automatically clean up stale feature flag code.

Installation

Install the CLI globally:

Terminal window
npm install -g @featsync/cli

Or use with npx (no install required):

Terminal window
npx @featsync/cli <command>

Verify the installation:

Terminal window
featsync --help

Authentication

  1. Get your CLI API key

    Go to your project in the dashboard, click API Keys, and create a CLI key (starts with fs_cli_).

  2. Log in

    Terminal window
    featsync login

    Paste your CLI API key when prompted.

  3. Verify authentication

    Terminal window
    featsync list

    If successful, you’ll see your project’s flags.

Project Setup

Initialize Featsync in your project directory:

Terminal window
cd your-project
featsync init

This creates a .featsync.json config file:

.featsync.json
{
"projectId": "your-project-uuid",
"environment": "production"
}

Quick Start

Once authenticated and initialized:

Terminal window
# List all flags in your project
featsync list
# Show only stale flags (enabled 100% for 14+ days)
featsync list --stale
# Scan codebase for flag usage
featsync scan
# Preview cleanup for a stale flag
featsync cleanup my-old-flag --dry-run

Configuration Files

Auth Config

Stored at ~/.config/featsync/config.json:

{
"apiKey": "fs_cli_...",
"baseUrl": "https://featsync.dev"
}

Project Config

Stored at .featsync.json in your project root:

{
"projectId": "uuid",
"environment": "production"
}

Cleanup Config (Optional)

Create .featsyncrc to customize cleanup behavior:

.featsyncrc
{
"cleanup": {
"exclude": ["**/legacy/**", "**/migrations/**"],
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
}

Default Excluded Paths

The scanner automatically excludes:

  • node_modules/**
  • dist/**, build/**, .next/**
  • coverage/**
  • *.test.ts, *.spec.ts, __tests__/**
  • *.d.ts, generated/**

Resetting Configuration

Terminal window
# Clear authentication
rm -rf ~/.config/featsync
# Clear project config
rm .featsync.json

Next Steps