Skip to main content
Forge CLI is a JSON-first client for the public Forge API. It supports interactive OAuth, service-account tokens, named profiles, registry installation, bounded reads, and guarded administrative writes.

Install

The installer selects the build for the current operating system and CPU, verifies its published SHA-256 checksum, and installs forge on the command path. macOS and Linux use /usr/local/bin when writable and otherwise use ~/.local/bin. Run the stable-channel installer again to update to its current release. forge version verifies the installed version after installation or an update.

Authenticate

Interactive login uses OAuth device authorization and discovers the organization bound to the resulting token:
Use a service-account token for CI or another non-interactive environment:
You can save that credential to the active profile with forge auth login --token "$FORGE_TOKEN". Avoid doing so on ephemeral CI runners; environment injection keeps the credential out of a persisted profile.

Configuration

Values resolve in this order, from highest to lowest precedence:
  1. Global command flags.
  2. Environment variables.
  3. The selected saved profile.
  4. Built-in defaults.
Only JSON output is currently supported. --output json is accepted explicitly and is the default. Profiles isolate organizations or environments:
On supported systems, access tokens, refresh tokens, and MCP gateway tokens are stored in the operating-system keychain. The profile stores a keychain reference. Credential files use user-only permissions and are replaced atomically.

Global flags

Global flags must appear before the command group:
Command-local safety flags override neither authorization nor policy. Forge still validates the actor’s role, token scopes, organization settings, and the operation contract.

Exit behavior

Successful commands write JSON to stdout. Errors and usage text are written to stderr. The CLI does not retry API requests automatically; automation should apply the retry rules described in the API guide.

Guarded execution

Preview a supported write, review the JSON response, then execute with the same reason and idempotency key:
One-time service-account secrets are returned only when created or rotated. Capture them directly into a secret manager and do not persist the command output in build artifacts.

CI

Use a dedicated service account whose role and scopes cover only these commands. See Commands for the complete command surface.

Uninstall

Add --purge only when the local Forge credential store should also be removed.

Commands

Review command syntax, filters, and mutation safeguards.

API

Implement retries and inspect the underlying REST contracts.

MCP

Install governed MCP servers and manage MCP sessions.

Roles

Configure permissions for operators and service accounts.