Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7d55270
feat!: rewrite as a Go CLI — browser OAuth login PoC
khvn26 Jul 16, 2026
adc0121
feat: rename OAuth scope management-api -> admin-api
khvn26 Jul 16, 2026
66b0bdb
test: cover the OAuth flow, credential store, API client and commands
khvn26 Jul 17, 2026
445ae8b
test: structure tests with Given/When/Then markers
khvn26 Jul 17, 2026
42823f3
docs: split installation and authentication into separate design docs
khvn26 Jul 17, 2026
d0715fe
docs: number installation design doc before authentication
khvn26 Jul 17, 2026
a645954
feat: FLAGSMITH_API_KEY, master-key login, per-instance credential store
khvn26 Jul 17, 2026
d1a9b10
feat: support login/logout under the auth subcommand
khvn26 Jul 17, 2026
6057834
docs: environment as client-side key, name cache, output/interactivit…
khvn26 Jul 20, 2026
e386cbd
feat: fail closed without a keychain; --insecure-storage opt-in
khvn26 Jul 20, 2026
03c9d45
feat: rename --api to --api-url, keep --api as hidden alias
khvn26 Jul 20, 2026
758e80f
docs: split FLAGSMITH_ENVIRONMENT_KEY (SDK auth) from FLAGSMITH_ENVIR…
khvn26 Jul 20, 2026
583a128
feat: flagsmith.json discovery and parsing
khvn26 Jul 20, 2026
6177bc0
feat: context resolution, name cache, and flagsmith config
khvn26 Jul 20, 2026
468d914
feat: flagsmith init, bare-command nudge, exit-code conventions
khvn26 Jul 20, 2026
1c9bfca
feat: implement the 02 output & interactivity conventions
khvn26 Jul 20, 2026
78cd925
feat: build prompts on charmbracelet/huh
khvn26 Jul 20, 2026
aeb1a23
fix: init organisation handling on re-init
khvn26 Jul 20, 2026
ed91631
feat: init offers to create an environment for empty projects
khvn26 Jul 21, 2026
75ef0b3
feat: centralise result output; add --jq; adopt the result model
khvn26 Jul 21, 2026
4c248a9
feat: flag-drivable resource creation in init; structural prompt gating
khvn26 Jul 21, 2026
1ee0d46
docs: extract CRUD conventions into 05-crud.md
khvn26 Jul 21, 2026
20221f7
docs: add 06-flags.md (flags = per-environment feature states)
khvn26 Jul 21, 2026
2c03697
feat: flags list
khvn26 Jul 21, 2026
49e198a
fix: bold header / coloured labels without breaking alignment
khvn26 Jul 21, 2026
7a43aff
docs: refresh README for current commands and design docs
khvn26 Jul 21, 2026
017d1f5
chore: point init $schema at the feat/cli-v2 ref
khvn26 Jul 21, 2026
adec899
chore: update repo flagsmith.json (schema ref + project)
khvn26 Jul 21, 2026
93e3742
refactor: singular resource command names (flags -> flag)
khvn26 Jul 21, 2026
3182cde
docs: remove stray duplicate 03-project-config.md
khvn26 Jul 21, 2026
bba9a05
chore: point schema $id at the feat/cli-v2 ref
khvn26 Jul 21, 2026
c90d38b
fix: colour config output consistently with auth status
khvn26 Jul 21, 2026
3b97f01
docs: expand 06-flags.md (get with overrides, mutation, list views)
khvn26 Jul 21, 2026
3cdebe0
refactor: browser-only login; keychain-only session store
khvn26 Jul 21, 2026
e1c1796
docs: named references in 04
khvn26 Jul 21, 2026
55c7b80
feat: resolve environment names to keys for flag list
khvn26 Jul 21, 2026
4066fc5
feat: accept project and organisation by name
khvn26 Jul 21, 2026
673305d
fix: serialise credential resolution to refresh once under concurrency
khvn26 Jul 21, 2026
d3fcac6
feat: flag list and flag get on the Admin features endpoint
khvn26 Jul 21, 2026
3ac1f0a
feat: flag update via update-flag-v2, and a flag create nudge
khvn26 Jul 21, 2026
aa01e4c
fix: hide flag create so it is not advertised as a command
khvn26 Jul 21, 2026
67ec00b
feat: flag segment overrides — get, update, and delete
khvn26 Jul 21, 2026
36c7d5b
fix: flag list display polish
khvn26 Jul 21, 2026
66b8fcf
fix: flatten multi-line flag values in the list table
khvn26 Jul 21, 2026
0e39b44
feat: curated JSON shape for flag get and flag list
khvn26 Jul 22, 2026
ba492b2
docs: add api design doc as 06, renumber flags to 07
khvn26 Jul 22, 2026
2fcf7f8
feat: flagsmith api — curl-like access with the CLI's credentials
khvn26 Jul 22, 2026
19d4a1b
feat: flag identity overrides (--identifier), core and edge
khvn26 Jul 22, 2026
ee0b971
fix: collapse the usage string to a single line
khvn26 Jul 22, 2026
7abaefa
installation priorities
khvn26 Jul 22, 2026
295ae60
docs: add segments design (08) and flag list --segment
khvn26 Jul 22, 2026
cf68751
feat: flag list --segment lists a segment's overrides
khvn26 Jul 22, 2026
034ae0a
feat: segment CRUD
khvn26 Jul 22, 2026
3872c00
docs: add features design (09)
khvn26 Jul 22, 2026
ec74e13
feat: feature list and get
khvn26 Jul 22, 2026
3ccef0b
feat: feature create, update, delete
khvn26 Jul 22, 2026
3b524ba
feat: feature variant subcommand (multivariate options)
khvn26 Jul 22, 2026
130a268
fix: truncate the value column in feature list
khvn26 Jul 22, 2026
b1b0f88
feat: feature default value naming — DEFAULT VALUE / default_value
khvn26 Jul 22, 2026
33e5034
fix: send project/feature in segment and mv-option writes
khvn26 Jul 22, 2026
f77e350
docs: replace mocked feature/segment/flag examples with real output
khvn26 Jul 22, 2026
397fe81
docs: add projects & organisations design (10)
khvn26 Jul 22, 2026
5a72711
feat: organisation CRUD
khvn26 Jul 22, 2026
570c658
feat: project CRUD
khvn26 Jul 22, 2026
74ec424
docs: real output for project & organisation examples (10)
khvn26 Jul 22, 2026
58a6c1d
docs: add environments design (11)
khvn26 Jul 22, 2026
b5ec797
feat: environment CRUD and clone
khvn26 Jul 22, 2026
3054a00
feat: environment key — server-side SDK keys
khvn26 Jul 22, 2026
4869b9e
docs: add environment document command (11)
khvn26 Jul 22, 2026
5787c55
feat: environment document
khvn26 Jul 22, 2026
bacbdef
docs: add Help and errors to 02
khvn26 Jul 22, 2026
84e28e9
feat: error hints, plan-gating detection, usage on incorrect input
khvn26 Jul 22, 2026
1b93154
feat: examples on every command usage page
khvn26 Jul 22, 2026
e89a864
fix: follow pagination in getList across all pages
khvn26 Jul 22, 2026
04a07f9
fix: route interactive prompts to stderr, not stdout
khvn26 Jul 22, 2026
5ce6112
feat: centralise HTTP in an api.Client with timeouts and retries
khvn26 Jul 23, 2026
7462d29
fix: make init preserve sdkApiUrl and never clobber a config it can't…
khvn26 Jul 23, 2026
4294ecb
feat: decouple --no-input (liveness) from --yes (authorization)
khvn26 Jul 23, 2026
1645a66
feat: split Admin API env creds into FLAGSMITH_API_KEY and FLAGSMITH_…
khvn26 Jul 23, 2026
37cf3fe
fix: guard segment update against no-op full PUT
khvn26 Jul 23, 2026
83bbc61
init long-running as well
khvn26 Jul 23, 2026
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
11 changes: 0 additions & 11 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/package-lock.json
/tmp
/yarn.lock
node_modules
oclif.manifest.json
.idea
flagsmith.json
/flagsmith
/dist/
*.test
12 changes: 0 additions & 12 deletions .mocharc.json

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

1 change: 0 additions & 1 deletion .release-please-manifest.json

This file was deleted.

80 changes: 0 additions & 80 deletions CHANGELOG.md

This file was deleted.

186 changes: 57 additions & 129 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,137 +1,65 @@
<img width="100%" src="https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png"/>
# Flagsmith CLI

@flagsmith/cli
=================
The next-generation Flagsmith command-line interface (work in progress).

Retrieve Flagsmith state from an API and store it in a file.
## Build

This CLI can be used to bake default flags into your application as part of CI/CD, this provides support for offline applications and is also advised as part of our [Defensive Coding and Default Flags Documentation](https://docs.flagsmith.com/guides-and-examples/defensive-coding). An example of this can be seen [here](./example).


# Populating defaultFlags in your Project

The steps to using this to provide default flags are as follows. An example of this can be found [here](./example). The main steps to achieving this are as follows:


1. Install the cli ``npm i @flagsmith/cli --save-dev``
2. Call the cli as part of postinstall to create a ``flagsmith.json`` file:

```export FLAGSMITH_ENVIRONMENT=API_KEY```

```
"postinstall": "flagsmith get"
```
An example of this can be seen [here](./example/src/index.tsx).
3. In your application, import the outputted JSON and initialise the client with the json ``flagsmith.init({state:json, environmentID: json.environmentID})``

**Example:**

```typescript
import flagsmith from '@flagsmith/flagsmith'
import state from './flagsmith.json'

flagsmith.init({state, environmentID: state.environmentID})
```

**Example with React:**

```jsx
import state from './flagsmith.json'
ReactDOM.render(
<FlagsmithProvider options={{environmentID: state.environmentID, state}} flagsmith={flagsmith}>
<App />
</FlagsmithProvider>,
document.getElementById('root')
);
```sh
go build -o flagsmith .
```

<!-- tocstop -->
# Usage - Global
<!-- usage -->
```sh-session
$ npm install -g @flagsmith/cli
$ flagsmith COMMAND
running command...
$ flagsmith (--version)
flagsmith-cli/0.1.2 darwin-arm64 node-v18.13.0
$ flagsmith --help [COMMAND]
USAGE
$ flagsmith COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`flagsmith get [ENVIRONMENT]`](#flagsmith-get-environment)
* [`flagsmith help [COMMANDS]`](#flagsmith-help-commands)

## `flagsmith get [ENVIRONMENT]`

Retrieve flagsmith features from the Flagsmith API and output them to a file.
## Quickstart

```sh
flagsmith init # log in, pick a project + environment, write flagsmith.json
flagsmith flag list # list the flags in the current environment
```
USAGE
$ flagsmith get [ENVIRONMENT] [-o <value>] [-a <value>] [-t
<value> -i <value>] [-p] [-e flags|environment]

ARGUMENTS
ENVIRONMENT The flagsmith environment key to use, defaults to the environment
variable FLAGSMITH_ENVIRONMENT

FLAGS
-a, --api=<value> [default: https://edge.api.flagsmith.com/api/v1/] The
API URL to fetch the feature flags from
-e, --entity=<option> [default: flags] The entity to fetch, this will either
be the flags or an environment document used for [local
evaluation](https://docs.flagsmith.com/clients/server-s
ide#local-evaluation-mode-network-behaviour).
<options: flags|environment>
-o, --output=<value> [default: ./flagsmith.json] The file path output
-p, --pretty Prettify the output JSON

IDENTITY FLAGS
-i, --identity=<value> The identity for which to fetch
feature flags
-t, --trait=<trait_key>=<trait_value>... Trait key-value pair, separated by
an equals sign (=)

DESCRIPTION
Retrieve flagsmith features from the Flagsmith API and output them to a file.

EXAMPLES
$ flagsmith get <ENVIRONMENT_API_KEY>

$ FLAGSMITH_ENVIRONMENT=abc123... flagsmith get

$ FLAGSMITH_ENVIRONMENT=ser.abc123... flagsmith get -e environment

$ flagsmith get -o ./my-file.json

$ flagsmith get -a https://flagsmith.example.com/api/v1/

$ flagsmith get -i flagsmith_identity

$ flagsmith get -i flagsmith_identity -t my_trait_key=some_trait_value -t other_trait=other_value

$ flagsmith get -p
```

_See code: [dist/commands/get/index.ts](https://github.com/Flagsmith/flagsmith-cli/blob/v0.1.4/dist/commands/get/index.ts)_

## `flagsmith help [COMMANDS]`

Display help for flagsmith.

```
USAGE
$ flagsmith help [COMMANDS] [-n]

ARGUMENTS
COMMANDS Command to show help for.

FLAGS
-n, --nested-commands Include all nested commands in the output.

DESCRIPTION
Display help for flagsmith.
```
## 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 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 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).
- Self-hosted: `--api-url` or `FLAGSMITH_API_URL`.

## Design

[Installation](docs/design/01-installation.md) ·
[Output & interactivity](docs/design/02-output-and-interactivity.md) ·
[Authentication](docs/design/03-authentication.md) ·
[Project config](docs/design/04-project-config.md) ·
[CRUD conventions](docs/design/05-crud.md) ·
[API](docs/design/06-api.md) ·
[Flags](docs/design/07-flags.md) ·
[Segments](docs/design/08-segments.md) ·
[Features](docs/design/09-features.md) ·
[Projects & organisations](docs/design/10-projects-organisations.md) ·
[Environments](docs/design/11-environments.md)
17 changes: 0 additions & 17 deletions bin/dev

This file was deleted.

3 changes: 0 additions & 3 deletions bin/dev.cmd

This file was deleted.

5 changes: 0 additions & 5 deletions bin/run

This file was deleted.

3 changes: 0 additions & 3 deletions bin/run.cmd

This file was deleted.

24 changes: 24 additions & 0 deletions docs/design/01-installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Flagsmith CLI v2: Installation

Status: draft

## 1. Distribution channels

Single static binary via goreleaser, from GitHub Releases:

- `curl -fsSL https://get.flagsmith.com | sh` (CI-friendly, pinnable version via FLAGSMITH_CLI_VERSION)
- `Flagsmith/setup-cli@v1` GitHub Action installs + performs the OIDC exchange
- Docker image
- `go install` for free
- Optional: publish a thin npm wrapper under the existing `@flagsmith` scope that downloads the binary — migration bridge for current npm installers

## 2. `get.flagsmith.com`

`get.flagsmith.com` redirects to https://raw.githubusercontent.com/Flagsmith/flagsmith-cli/main/install.sh. Security-conscious users are able to use the github CDN url directly, pinning a SHA they trust.

Upon successfull installation, `install.sh` prompts the user to run `flagsmith init`.

## 3. Later / deprioritised

- `brew install flagsmith/tap/flagsmith` (primary mac/linux path)
- winget / scoop, deb/rpm
Loading
Loading