CLI reference
Every command and flag of the gitterm CLI (@gitterm/cli), grouped by what it manages.
The gitterm CLI (@gitterm/cli) signs you in, manages your cloud workspaces, and runs commands in remote sandboxes. Inside a cloud workspace it offers a smaller set of commands for that workspace's ports. Use this page to look up a command or flag.
Install
npm install -g @gitterm/cli
# or run it without installing
npx @gitterm/cli --helpGlobal flags
Account
gitterm login saves the login in ~/.config/gitterm/cli.json. The SDK and the OpenCode plugins use the same file. The login is a revocable gt_... API token, listed under API tokens in the dashboard.
For a self-hosted deployment, pass its API URL. Behind the bundled path-routing proxy, that is the /api path:
gitterm login --server https://gitterm.example.com/apiWorkspaces
ws is an alias for workspace. Every command accepts --json. <workspaceId> is the id that gitterm workspace list prints.
The CLI does not create workspaces. Use the dashboard, the SDK, or /cloud. See Cloud workspaces.
Sandboxes
sb is an alias for sandbox. Every command accepts --json, and --account <name> to use an account other than the selected one. For what sandboxes are and how to set up accounts, see Sandbox setup.
The --lifetime and --timeout defaults are the built-in sandbox limits; limits set in the accounts file change them.
exec and job exit with the job's exit code when it fails, or 1 when it timed out or was cancelled, so scripts and CI see the failure.
create, sync and apply ask for approval. Pass --yes to approve without a prompt; with --json you must.
The CLI reads accounts from ~/.config/gitterm/sandbox.json, or from the file in GITTERM_SANDBOX_CONFIG. The file holds account names and the names of environment variables, never keys:
{
"account": "e2b",
"accounts": {
"e2b": { "provider": "e2b", "apiKeyEnv": "E2B_API_KEY" },
"gitterm": { "size": "medium" }
}
}The file takes the same limits, exclude, and publicPreviews settings as the sandbox plugin. With "publicPreviews": true, create makes public previews without asking. Whether a provider can make a preview public: Previews by provider.
An account with apiKeyEnv uses your own provider key and needs no Gitterm login. One without goes through GitTerm. A single account can also sit at the top level: { "provider": "e2b", "apiKeyEnv": "E2B_API_KEY" }.
Inside a workspace
Gitterm installs the CLI in supported workspace images and gives it the workspace's own identity. When that identity is present, the CLI offers only these commands and never uses a saved user login. It can see only its own workspace.
port is an alias for ports. See Previews.
Environment variables
Environment variables win over the saved login.