Skip to main content
The Barekey CLI is the fastest way to work with Barekey day to day. Use it to:
  • log in on a machine
  • create, update, list, and delete variables
  • pull resolved values into files
  • generate SDK types

Install

Authentication

barekey auth login

Starts the browser-based device flow:
Optional:
What it does:
  • starts a device authorization request
  • prints the verification URL and code
  • opens the browser when possible
  • stores the session locally after approval

barekey auth whoami

barekey auth logout

Top-level aliases also exist:
  • barekey login
  • barekey whoami
  • barekey logout

How target resolution works

Every environment command needs a target:
  • organization
  • project
  • stage
The CLI resolves those from:
  1. command flags
  2. barekey.json
  3. stored CLI session org for organization only

Target flags

Most env and typegen commands accept:

barekey.json

Recommended project file:
Supported aliases:
  • org for organization
  • stage for environment

Missing target errors

If the CLI cannot resolve project and environment, it fails and tells you to either:
  • pass --project and --stage
  • or create a barekey.json

Command reference

barekey env list

List variables in the resolved stage:
The non-JSON output includes:
  • name
  • visibility
  • kind
  • declared type

barekey env get

Read one resolved variable:
Options:
Flags:

barekey env get-many

Read multiple values in one command:
Flags:

barekey env new

Create a variable with its first value:
Flags: Example:

barekey env set

Upsert a variable:
This creates the variable if it does not exist and updates it if it does. It accepts the same flags as env new. Examples:

barekey env delete

Delete a variable:
Flags: Examples:

barekey env pull

Resolve the whole stage and either print or write the result.
Flags: Examples:

Output formats

dotenv:
json:

barekey typegen

Generate SDK types into your installed @barekey/sdk package:
Watch mode:
Flags:

Day-to-day recipes

Create a variable and verify it

Update a public variable

Pull local dev values

Pull JSON for scripts

Regenerate SDK types after variable changes

Notes and gotchas

  • env new requires an initial <value>.
  • env set is the upsert command.
  • get-many expects a comma-separated --names value.
  • The CLI can reuse your saved login automatically.
  • barekey.json is safe to commit because it contains configuration, not secrets.
  • Pulled .env files are not safe to commit.
For SDK usage details, read JavaScript SDK.