Skip to main content

GrowthBook Command Line Interface (CLI)

The GrowthBook command-line interface (CLI) is a tool for working with the GrowthBook A/B testing, feature flagging, and experimentation platform.

Requires Node.js version 16+.

New

The GrowthBook CLI is a brand new tool. If you experience any issues, let us know either on Slack or create an issue.

CLI Features

Generating Types

The GrowthBook CLI enables you to generate TypeScript types for working with the SDK.

Run growthbook features generate-types --help for more info.

See the JavaScript SDK documentation for more information on working with typed features.

Profile management

If you have multiple GrowthBook organizations or accounts, you can easily switch between profiles when running individual commands.

Run growthbook auth --help for more info.

Usage

Installing the CLI

You can install the CLI to your project with the following command:

npm install growthbook --save

Or if you use yarn you can do:

yarn add growthbook

You can also install it globally so you can use it with multiple projects and outside of projects:

npm install -g growthbook

The growthbook executable should now be available in your project. You should now be able to run commands, e.g.:

growthbook --help

Adding your API secret

Before using the GrowthBook CLI you will need to authenticate yourself. You will need to get an API key, which you can do here .

Next, use the growthbook auth login --apiKey XXX command to set your token for the default profile.

Run growthbook auth login --help for more info and options.

Generating Types

You can also add it to your package.json file of the project that will use the types, e.g.:

{
"scripts": {
"type-gen": "growthbook features generate-types --output ./types"
}
}

It should now be available for use when you run npm run type-gen or yarn type-gen.

Usage on CI/CD

If you'd like to use the CLI in continuous integration/continuous deployment environments, instead of running the growthbook auth login command, we recommend creating the following file at ~/.growthbook/config.toml with your secret and API base URL:

[default]
growthbook_secret = "secret_abc123"
api_base_url = "https://api.growthbook.io" # replace this with your API URL if self-hosted

You can also store multiple profiles and refer to them with the --profile flag in supported commands:

[default]
growthbook_secret = "secret_abc123"
api_base_url = "https://api.growthbook.io"

[acme_donuts]
growthbook_secret = "secret_xyz987"
api_base_url = "http://localhost:3100"

Detailed Command Usage

See the generated GrowthBook CLI command documentation on Github .

Examples