Skip to main content
Use the Ona CLI to create, manage, and run commands in environments from external AI agents such as Claude Code, Cursor, or custom scripts. This guide covers the full lifecycle: discover resources, create an environment, execute commands, and clean up.

Prerequisites

Discover projects

List projects to find one to create an environment from:
Use -o json for machine-readable output:

Discover environment classes

Environment classes define the compute resources (CPU, memory) for your environment. List available classes:
Filter by runner:

Create an environment

From a project

The simplest way. The project already has a repository URL, environment class, and configuration:

From a context URL

Create directly from a repository URL. Requires an environment class:
Both creation methods support --inactivity-timeout to set a custom auto-stop timeout. See auto-stop timeout for details and examples.

Non-blocking creation

Use --dont-wait to return the environment ID immediately without waiting for it to start:
Then poll for readiness:

List environments

Filter to JSON for parsing:

Run commands

Execute commands inside a running environment using exec:
The command runs inside the environment’s dev container via the EnvironmentOps API (not SSH). The CLI waits for the command to complete and prints stdout/stderr.

Examples

Exit codes

The CLI exits with the same exit code as the remote command. A non-zero exit code means the command failed.

Flags

SSH access

For interactive sessions or when you need a persistent shell:
Run a single command over SSH:
See the CLI reference for SSH setup details.

Clean up

Stop an environment to preserve its state:
Delete an environment permanently:

Full workflow example

End-to-end script that creates an environment, runs a command, and cleans up:

JSON workflow for agents

Agents that parse structured output can use -o json throughout: