Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 179 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,208 @@
# Flagsmith CLI

The next-generation Flagsmith command-line interface (work in progress).
Manage Flagsmith from your terminal and your pipeline.

## Install

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI docs over at docs.flagsmith.com reference #install. we should keep the Install heading, or change that reference in Flagsmith/flagsmith#8045.

```bash
curl -sSL https://get.flagsmith.com | sh
flagsmith init

[![Release](https://img.shields.io/github/v/release/Flagsmith/flagsmith-cli)](https://github.com/Flagsmith/flagsmith-cli/releases) [![License](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ```bash fence opened above is never closed, so the badges line and the whole rest of the README get swallowed into the code block. Needs a closing fence before the badges.


---

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a heading here instead of a divider.


## Stop a release that depends on a flag that's off

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this section gains an H2 heading, these become H3 and don't read as noisy as they do now.

Ideally, they shouldn't be headings at all. Landing page layouts don't really work well in documentation.


```bash
flagsmith evaluate checkout-v2 --test
```

Exits non-zero when a flag your release needs isn't enabled. Drop it into any pipeline to block a bad deploy before it ships:

```sh
brew install Flagsmith/tap/flagsmith
```yaml
- name: Verify release flags
run: flagsmith evaluate checkout-v2 --test
env:
FLAGSMITH_API_KEY: ${{ secrets.FLAGSMITH_API_KEY }}
```

Or:
We use this on ourselves. A 78-line GitHub Actions workflow in the Flagsmith repo is now one command.
Comment thread
asaphko marked this conversation as resolved.

```sh
curl -fsSL https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/main/install.sh | sh
## Bind a repo once, and the whole team is in the right place

```bash
flagsmith init
```

Installs to `$HOME/.local/bin` and adds it to your `PATH`. Options:
Writes a `flagsmith.json` you commit with your code, recording which project and environment this repo maps to. New teammates can clone, log in, and they're pointed at the right project. Prevents complex setup docs and changes landing in the wrong environment.

If you work across several projects, this is even more uesful, both for you and for LLMs interacting on your behalf.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "uesful" -> "useful"


```sh
curl -fsSL https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/main/install.sh | sh -s -- --version v2.0.0 --bin-dir /usr/local/bin --no-modify-path
curl -fsSL https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/main/install.sh | sh -s -- --help
## Readable for you, parseable for machines

```bash
flagsmith flag list # a table
flagsmith flag list --json # JSON
flagsmith flag list --json --jq '.[] | select(.enabled) | .name'
```

`FLAGSMITH_CLI_VERSION`, `FLAGSMITH_INSTALL_DIR` and `FLAGSMITH_NO_MODIFY_PATH` do the same if exported first.
jq is compiled into the binary so your agent doesn't have to pipe the output anywhere.

To pin the installer itself, fetch it at a commit you trust: `raw.githubusercontent.com/Flagsmith/flagsmith-cli/<sha>/install.sh`.
---

Alternatively, `go install github.com/Flagsmith/flagsmith-cli/v2@v2.0.0-beta.3` (installs as `flagsmith-cli`), or grab an archive from [Releases](https://github.com/Flagsmith/flagsmith-cli/releases). <!-- x-release-please-version -->
## Install

On Windows:
**macOS and Linux**
```bash
curl -sSL https://get.flagsmith.com | sh
```

Installs to `~/.local/bin`. The installer takes options:

```bash
curl -sSL https://get.flagsmith.com | sh -s -- --version v2.0.0 --bin-dir /usr/local/bin --no-modify-path
curl -sSL https://get.flagsmith.com | sh -s -- --help
```

`FLAGSMITH_CLI_VERSION`, `FLAGSMITH_INSTALL_DIR` and `FLAGSMITH_NO_MODIFY_PATH` do the same if exported first. To pin the installer itself, fetch it at a commit you trust:

```bash
curl -sSL https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/<sha>/install.sh | sh
```

**Windows**
```powershell
irm https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/main/install.ps1 | iex
irm https://get.flagsmith.com/install.ps1 | iex
Comment thread
asaphko marked this conversation as resolved.
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homebrew instruction got swallowed in a merge conflict. we'll also have an npm instruction soon


## Build
**Docker**
```bash
docker run --rm -e FLAGSMITH_API_KEY ghcr.io/flagsmith/flagsmith-cli flag list
```

**Go**
```bash
go install github.com/Flagsmith/flagsmith-cli/v2@latest
```
Note this installs the binary as `flagsmith-cli`, not `flagsmith`.

Or download an archive from [Releases](https://github.com/Flagsmith/flagsmith-cli/releases).

## Authentication

```bash
flagsmith login # opens your browser, stores credentials in your OS keyring
flagsmith auth status # who am I, and against which instance
flagsmith auth token # print the current token, for scripts
```

Without a browser, use static credentials:

- `FLAGSMITH_API_KEY` — Admin API, for managing flags, features, projects and so on
- `FLAGSMITH_ENVIRONMENT_KEY` — SDK-side, for evaluation and environment documents

```sh
go build -o flagsmith .
Containers have no keyring, so `flagsmith login` can't persist there — pass one of the above instead.

Self-hosted? Point at your own instance with `--api-url` or `FLAGSMITH_API_URL`:

```bash
flagsmith --api-url https://flagsmith.internal/api/v1 flag list
```
Comment on lines +105 to 109

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add info on host-scoped static credentials here


## Docker
## Using it with a coding agent

The CLI is a smaller context cost than a full tool catalogue: your agent gets one binary with self-documenting help, and pays for it only when it runs something.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI is a smaller context cost than a full tool catalogue

context?


## Which Flagsmith CLI is this?

There are two, and they do different jobs.

| | `flagsmith-cli` (npm) | `flagsmith` (this one) |
|---|---|---|
| **What it's for** | Fetching flag state at build time and writing it to a file | Managing your Flagsmith account, and gating pipelines |
| **Reads / writes** | Read-only | Read and write |
| **Installed with** | npm | curl, PowerShell, Docker, `go install` |
| **Needs** | Node | Nothing |

**Already using the npm package?** Keep using it — it still works and we'll give notice before that changes. When you want to consolidate, this CLI covers the same ground:

```sh
docker run --rm -v "$PWD:/work" -e FLAGSMITH_API_KEY ghcr.io/flagsmith/flagsmith-cli flag list
```bash
flagsmith evaluate --js # the state a frontend SDK hydrates from
flagsmith environment document # the local-evaluation environment document
```

A container has no keyring, so `flagsmith login` cannot store credentials there — pass `FLAGSMITH_API_KEY` or `FLAGSMITH_ENVIRONMENT_KEY`.
This tool is version 2 because it shares a repository and a name with the older one. It is not an upgrade of it.
Comment on lines +115 to +133

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really should be a simple deprecation notice / migration guide. Instead, it confuses people, and their agents:

It is not an upgrade of it.

It very much is. It's a replacement!


## Quickstart
---

```sh
flagsmith init # log in, pick a project + environment, write flagsmith.json
flagsmith flag list # list the flags in the current environment
## Command reference

@khvn26 khvn26 Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI docs over at docs.flagsmith.com reference #commands, let's change this heading back:

Suggested change
## Command reference
## Commands


Every command carries worked examples in `--help`, which is always current:

```bash
flagsmith flag --help
```

## Commands

- `flagsmith init` — bind the current directory to a project (writes `flagsmith.json`).
- `flagsmith flag list` — list feature flags in the current environment.
- `flagsmith flag get <feature>` — show a single flag's state (`--segment <id>` or `--identifier <id>` for an override).
- `flagsmith flag update <feature>` — toggle (`--enable`/`--disable`) or set the value (`--value`, `--type`); `--segment <id>` or `--identifier <id>` targets an override.
- `flagsmith flag enable|disable <feature>` — shorthand for `flag update --enable`/`--disable` (same `--segment`/`--identifier` targeting).
- `flagsmith flag delete <feature> --segment <id>|--identifier <id>` — delete a segment or identity override.
- `flagsmith segment list` — list segments (`--include-feature-specific` to include feature-scoped ones).
- `flagsmith segment get <segment>` — show a segment and its rule tree.
- `flagsmith segment create <name> --rules @rule.json` — create a segment (`--description`, `--feature`).
- `flagsmith segment update <segment>` — replace the rules (`--rules`), description, or feature.
- `flagsmith segment delete <segment>` — delete a segment.
- `flagsmith feature list` — list project features (`--include-archived`).
- `flagsmith feature get <feature>` — show a feature and its variants.
- `flagsmith feature create <name>` — create a feature (`--value`, `--enabled`, `--description`, `--variants`).
- `flagsmith feature update <feature>` — update description or archive (`--description`, `--archive`/`--unarchive`).
- `flagsmith feature delete <feature>` — delete a feature.
- `flagsmith feature variant list|add|update|delete <feature>` — manage a multivariate feature's variants (by id or key).
- `flagsmith organisation list|get|create|update|delete` (alias `org`) — manage organisations.
- `flagsmith project list|get|create|update|delete` — manage projects (`create` uses `--organisation`).
- `flagsmith environment list|get|create|update|delete|clone` (alias `env`) — manage environments (by name or API key).
- `flagsmith environment key list|create|delete <environment>` — manage server-side SDK keys.
- `flagsmith environment document [environment]` — output the environment document (local-evaluation JSON).
- `flagsmith evaluate [feature]` (alias `eval`) — the flags an SDK resolves for the current environment (`--identity`, `--trait key=value`, `--persist`); `--js` writes the state a frontend SDK hydrates from, `--test` fails when a named flag is disabled.
- `flagsmith config` — show the resolved context and where each value comes from.
- `flagsmith login` / `logout` — browser OAuth (PKCE, loopback); also `auth login`/`auth logout`.
- `flagsmith auth status` — identity, organisations, credential source, token expiry.
- `flagsmith auth token` — print the active Admin API credential for curl/scripts.
- `flagsmith api <path>` — call any Flagsmith endpoint with the CLI's credentials applied (curl-like; `--sdk` for the SDK API, `-F`/`-f` fields).

## Conventions

- `--json` (or `FLAGSMITH_JSON_OUTPUT`) for machine-readable output; `--jq <expr>` to filter it.
- Static credentials: `FLAGSMITH_API_KEY` (Admin API), `FLAGSMITH_ENVIRONMENT_KEY` (SDK). When self-hosting Flagsmith, append the host and port, doubling `-` and writing `.` and `:` as `_`: `https://flagsmith-staging.com:8000` reads `FLAGSMITH_API_KEY_flagsmith__staging_com_8000`.
- Self-hosted: `--api-url` or `FLAGSMITH_API_URL`.
<details>
<summary><b>Full command list</b></summary>

### Setup

- `flagsmith init` — log in, pick a project and environment, write `flagsmith.json`
- `flagsmith config` — show every setting and where it came from
- `flagsmith login` / `logout`
- `flagsmith auth status` / `auth token`

### Flags

- `flagsmith flag list` — list flags in the current environment
- `flagsmith flag get <feature>` — show a flag's state
- `flagsmith flag enable|disable <feature>` — toggle in the current environment
- `flagsmith flag update <feature>` — change value or state, including `--segment` and `--identifier` overrides
- `flagsmith flag delete <feature> --segment <id>|--identifier <id>` — delete a segment or identity override

### Features

- `flagsmith feature list` — list project features (`--include-archived`)
- `flagsmith feature get <feature>` — show a feature and its variants
- `flagsmith feature create <name>` — `--value`, `--enabled`, `--description`, `--variants`
- `flagsmith feature update <feature>` — `--description`, `--archive` / `--unarchive`
- `flagsmith feature delete <feature>`
- `flagsmith feature variant list|add|update|delete <feature>` — manage a multivariate feature's variants

### Segments

- `flagsmith segment list` — `--include-feature-specific` to include feature-scoped segments
- `flagsmith segment get <segment>` — show a segment and its rule tree
- `flagsmith segment create <name> --rules @rule.json` — `--description`, `--feature`
- `flagsmith segment update <segment>` — replace rules, description, or feature
- `flagsmith segment delete <segment>`

### Environments, projects, organisations

- `flagsmith environment list|get|create|update|delete|clone` (alias `env`) — by name or API key
- `flagsmith environment key list|create|delete <environment>` — server-side SDK keys
- `flagsmith environment document [environment]` — the local-evaluation environment document
- `flagsmith project list|get|create|update|delete` — `create` takes `--organisation`
- `flagsmith organisation list|get|create|update|delete` (alias `org`)

### Evaluation

- `flagsmith evaluate [feature]` (alias `eval`) — the flags an SDK would resolve for the current environment
- `--identity <id>` and `--trait key=value` — evaluate as a specific identity
- `--test` — exit non-zero when a named flag is disabled
- `--js` — write the state a frontend SDK hydrates from
- `--persist` — write the result to disk

### Anything else

- `flagsmith api <path>` — call any Flagsmith endpoint with your credentials applied, e.g. `flagsmith api /projects/`

</details>

---

## Docs, and getting help

- Documentation: [docs.flagsmith.com](https://docs.flagsmith.com/integrating-with-flagsmith/CLI)
- Bugs and requests: [open an issue](https://github.com/Flagsmith/flagsmith-cli/issues)
- Include `flagsmith --version` and how you installed it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an issue template instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what that exactly means, can you show me an example?

@khvn26 khvn26 Aug 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.