CLI
Reference for the appstrate command-line tool. Install and operate an instance, sign in, call the API, run agents, edit packages locally.
The appstrate CLI installs and operates an instance, signs you in to any instance, and drives its API from a terminal or a script. It is a single self-contained binary: no Node.js or other runtime is required on the host (except Bun for a Tier 0 install). This page covers the common cases. The full flag tables are in the CLI README.
Global flags work on every command: -p, --profile <name> selects a profile, --insecure allows an instance without HTTPS (tokens then travel in plaintext, so use it on a trusted network only), and --version prints the version.
Get the CLI
curl -fsSL https://get.appstrate.dev | bashDownloads the signed binary for macOS or Linux (x64 and arm64) into ~/.local/bin, and verifies it. In an interactive terminal it then stops and tells you to run appstrate install. Unattended (bash -s -- --yes, CI=true, or stdout not a terminal), it runs appstrate install --yes itself. To install only the CLI in every case, pipe into APPSTRATE_NO_LAUNCH=1 bash. On Windows, run it inside WSL2. Update with appstrate self-update.
bun install -g appstrate # needs Bun 1.3.9 or later
bunx appstrate <command> # or run it once without installingThe npm package is appstrate. Update with bun update -g appstrate. This is the route on native Windows.
The two channels are independent. If both are installed, appstrate doctor lists every appstrate on your PATH and which one wins. See Upgrading the CLI.
Driving the CLI from a coding agent
The repository ships an operating manual written for a coding agent: apps/cli/AGENTS.md. It covers the zero-to-first-run recipe, the rules of engagement and a curl to appstrate api cheat sheet. With a logged-in profile the CLI injects the bearer token itself, so the agent never sees it. An API key passed through the environment or --api-key is readable by the process that sets it, so give an agent a key scoped to what it may do. See also Skills and coding agents.
Commands
| Command | Purpose |
|---|---|
install, start, stop, restart, logs, status, uninstall | Install an instance and manage its Docker stack |
login, logout, whoami, token | Sessions |
org, space | Pin the organization and the default space of REST commands |
api, openapi | Call the REST API, explore its schema |
run | Run an agent, on the instance or locally |
models | List the model presets an instance exposes |
packages | Edit a package in a local folder, push it, publish it |
code | Sync skills and agents into Claude Code and Codex |
self-update, doctor | Maintain the CLI itself |
runner | Install the Firecracker runner daemon on a KVM host |
Headless and CI runs
appstrate run can authenticate without appstrate login: give it an API key and the instance, and it works on a CI runner or any machine with no profile. appstrate api reads the same key and instance (see Call the API with an API key). The other commands (openapi, whoami) still need a profile.
| Variable | Meaning |
|---|---|
APPSTRATE_API_KEY | An apst_ API key. Same as --api-key, and the flag wins when both are set. It replaces the profile's session entirely, so the run is made as the key. |
APPSTRATE_INSTANCE | Base URL of the instance. When unset, the active profile's instance is used. |
APPSTRATE_SPACE_ID | Id of the space (spc_...). Not needed for a platform run. A remote run with remote integrations (the default, see below) requires it, and the command stops without it. |
APPSTRATE_ORG_ID | Organization id. Not needed for a platform run. Required by --model-source preset, which refuses to start without it. |
With an API key, the organization and the space come only from APPSTRATE_ORG_ID and APPSTRATE_SPACE_ID, never from the active profile, and only the instance falls back to the profile. A key is pinned to one organization and one space: leave both unset for a platform run, and when you set them, use the ones the key is pinned to (a space that disagrees with the key is a 403). An empty value counts as unset.
The key needs a few scopes, depending on what you run:
| You run | Scopes the key needs |
|---|---|
| A platform run | agents:run to launch, runs:read to follow the run |
A remote run of a package id (--local) | agents:read to download the bundle and read the space's run configuration, skills:read when the agent depends on a skill (the bundle carries it), agents:run to register the run |
| A remote run of a bundle path | agents:run, and agents:write too, because the run is registered with its manifest and prompt |
| A remote run with integrations (the default) | credential-proxy:call |
A remote run with --model-source preset | llm-proxy:call |
The last two are explained in LLM proxy and credential proxy. Mint the key with the narrowest list that covers your case.
Call the API with an API key
For a CI job or a script on a machine with no login, pass an apst_ API key instead of a session:
export APPSTRATE_API_KEY=apst_...
export APPSTRATE_INSTANCE=https://appstrate.example.com # optional when a profile exists
appstrate api GET /api/agents- The key replaces the profile credential entirely. The keyring is not read and no profile is needed.
--api-key <key>does the same as the variable and wins over it, but a command-line argument is visible to other local users, so prefer the variable. - The instance is
APPSTRATE_INSTANCE, else the profile's. With neither, the command stops. - No
X-Org-IdorX-Space-Idis sent: a key is pinned to one organization and one space, and those apply. Your own-Hheaders still pass through. - An exported
APPSTRATE_API_KEYswitches everyappstrate apicall to the key. If that variable is already set forappstrate run,apiin the same shell stops using your login: another principal, no org or space headers, and the instanceAPPSTRATE_INSTANCEnames. Unset it to go back to your profile. - Only
apiandrunread the key.openapi,whoamiand the other commands still use the profile.
Platform run or remote run
A platform run executes on the instance, in its sandbox, as if you had clicked Run in the dashboard. It is the default for a package id, and --remote selects it explicitly. A remote run (runOrigin: "remote") executes on your own host, in the appstrate process, with your shell, filesystem and environment: you get one with --local or with a bundle path. When the CLI has credentials for an instance, it registers the run and streams signed events back, so the run shows up in the dashboard with a Remote badge.
| Platform run | Remote run | |
|---|---|---|
| Command | appstrate run @scope/agent | appstrate run @scope/agent --local, or appstrate run ./bundle.afps-bundle |
| Where the agent runs | The instance's sandbox | Your host |
| Model | The instance's. Only --model <preset id> and --proxy <id> are accepted | Your own provider key (env), or the instance's models through the LLM proxy (preset) |
| Integrations | The platform's connections | --integrations remote (default, through the credential proxy), local (a creds file) or none |
| Reporting | Native. --report, --report-fallback and --sink-ttl are refused | --report auto by default: on when the run has credentials for an instance |
| Exit code | 0 on success, 1 for failed, timeout or cancelled | The CLI does not turn the final status into an exit code. Read status in the --output file |
Use a platform run when the agent should behave exactly as it does in the dashboard: same sandbox, model, connections and stored run configuration. A CI step that triggers a production agent and waits for its result is the typical case. Use a remote run when the agent has to act on the machine that runs the CLI (the files of a checkout, local tools), when it must use your own LLM key, or while you iterate on a bundle with --snapshot.
One limit of a remote run: only serverless apiCall integrations are available in-process, since MCP-server integrations are skipped.
Flags of a remote run
The flags that matter most:
--model-source env|preset: your own provider key, or the instance's model presets through the LLM proxy. The automatic choice ispresetfor a package id with--integrations remote, andenvotherwise. Withenv,--modeland--model-apiname the model and its protocol, and the key comes from--llm-api-keyor fromANTHROPIC_API_KEY,OPENAI_API_KEYorMISTRAL_API_KEY.--integrations remote|local|none: through the credential proxy (the default), from a--creds-file, or none.--report auto|true|false: whether the run is registered on the instance.autoregisters it when the CLI has credentials for an instance.--sink-ttl <seconds>: how long the run may keep reporting, for a run that outlives the default (see Run liveness).--run-id <id>: a platform run sends it as itsIdempotency-Key, so repeating the command replays the first launch instead of starting a second run.
appstrate run --help lists every flag, and the CLI README covers the rest of the command.
--model-source preset reads the list of presets with the session of a CLI profile, not with the API key, so it needs appstrate login on that machine. A job that has only an API key must pass --model-source env.
When you run a package id with --local, the CLI also reads the space's run configuration for that agent (model, generation settings, stored input values) and applies it under your flags. Pass --no-inherit in CI so that a change made in the dashboard cannot alter a pipeline.
LLM proxy and credential proxy
A remote run has no sidecar on the platform, so the CLI reaches the organization's models and the space's connections through two routes of the instance, the same ones the GitHub Action uses. They are the plumbing of remote runs, not an API to build on.
- With
--integrations remote, everyapi_callof an integration goes through the credential proxy, which injects the connection's credential on the platform and checks the target against the integration'sauthorized_uris. A remote runner addresses one connection per integration: when the space binds several connections to one integration, the run is refused withremote_binds_one_connection. Name one with--connection, or run the agent on the platform. - With
--model-source preset, model calls go through the LLM proxy, which resolves the organization's model preset, adds the provider key and meters the usage. With--model-source env, the CLI calls your provider directly.
The CLI never holds a provider key or an integration credential. A key with llm-proxy:call spends the organization's model budget, and one with credential-proxy:call uses the space's connected accounts, so give these scopes only to keys that run agents remotely. A key created without an explicit scopes list carries both when its creator holds them. Both proxies are rate-limited (see Rate limits).
CI examples
A GitHub Actions job that triggers an agent on the instance and fails when the run does:
jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Install the CLI
run: |
curl -fsSL https://get.appstrate.dev | APPSTRATE_NO_LAUNCH=1 bash
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run the agent on the instance
env:
APPSTRATE_API_KEY: ${{ secrets.APPSTRATE_API_KEY }}
APPSTRATE_INSTANCE: https://appstrate.example.com
run: |
appstrate run @acme/triage \
--input-file ./input.json \
--run-id "ci-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
--json --output result.jsonThe key needs agents:run and runs:read. It names its own organization and space, so no APPSTRATE_SPACE_ID is set. With --json the CLI prints events as JSON lines, starting with an appstrate.remote.triggered line that carries the run id, and the step ends with exit code 1 when the run did not succeed. If the CLI receives SIGINT, SIGTERM or SIGHUP while the run is in flight, it detaches and the run carries on on the instance.
The same job as a remote run on the runner itself, with your own model key:
- name: Run the agent on this runner
env:
APPSTRATE_API_KEY: ${{ secrets.APPSTRATE_API_KEY }}
APPSTRATE_INSTANCE: https://appstrate.example.com
APPSTRATE_SPACE_ID: spc_xxx
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
appstrate run @acme/triage --local \
--model-source env --no-inherit \
--input-file ./input.json \
--output result.jsonThis one needs APPSTRATE_SPACE_ID, set to the space the key is pinned to, because a run on your host names the space when it registers itself and calls the credential proxy. The key needs agents:read and agents:run, plus skills:read if the agent depends on a skill and credential-proxy:call if it uses integrations. The run is reported to the instance and appears there as a remote run. Do not rely on the exit code to detect a failed agent: read status in result.json.
Profiles
A profile ties a name to an instance URL, your identity and the pinned organization and space. The active profile is the first of: the --profile flag, the APPSTRATE_PROFILE environment variable, defaultProfile in the config file, then default.
appstrate login --profile prod --instance https://appstrate.acme.com
appstrate --profile prod whoami
APPSTRATE_PROFILE=prod appstrate api GET /api/agentsProfiles live in ~/.config/appstrate/config.toml (or under $XDG_CONFIG_HOME). Tokens are stored in the OS keyring (macOS Keychain, libsecret, Windows Credential Manager) under the profile's name. If no keyring backend exists at all, for example in a headless Linux container, the CLI falls back to a 0600 file ~/.config/appstrate/credentials.json. If a keyring exists but refuses access (locked), the CLI stops unless you set APPSTRATE_ALLOW_PLAINTEXT_TOKENS=1. On Windows there is no file fallback.
Troubleshooting
| Message | Fix |
|---|---|
your session may have been revoked | Run appstrate login again |
Space context required | No space is pinned. Run appstrate space switch |
Space '<id>' not found in this organization | The pinned space belongs to another organization. Run appstrate space switch |
Docker is required for this tier | Tiers 1 to 3 need Docker. Install it, or use Tier 0 |
No space id for a local run | An API key run on your host needs APPSTRATE_SPACE_ID, the space the key is pinned to. A platform run does not |
More entries are in the CLI README.
Reference
- CLI README: every flag, exit code and edge case.
- REST API.