Skip to main content

Hosted boxes

The boxes provider creates microVMs on the hosted service at boxctl.io. You need no cloud account and no host of your own. onctl is the command-line tool for the service. The web at boxctl.io is its main interface.

A box is used like any other VM: onctl create, ls, ssh, pause, resume and destroy work with -p boxes. This page covers what only hosted boxes have.

onctl login
onctl create -p boxes -n my-box
onctl ssh -p boxes my-box

To leave out -p boxes, set ONCTL_CLOUD=boxes.

Log in​

onctl login

On a terminal this opens your browser. Sign in, click Approve, and this computer is logged in. The token is saved in ~/.onctl/boxes.json, readable only by you.

onctl loginopen the browser and wait for the approval
onctl login --no-browserprint a link to open on any computer, then wait for the approval. Over ssh this is the default
onctl login --pastepaste a token made in the dashboard at boxctl.io, at a hidden prompt
pbpaste | onctl loginread a token from stdin
onctl logoutforget the saved token

A pasted token is checked against the service before it is saved. In CI, set ONCTL_BOXES_TOKEN instead of logging in: it overrides the saved token.

Run one command in a new box​

onctl exec -p boxes "ls -la | grep foo"

onctl exec creates a new box, runs the command in it over ssh, and destroys the box, whether the command worked or not. The command is one shell string.

It prints exactly one JSON object to stdout:

{"exit_code":0,"stdout":"...","stderr":"...","error":""}
  • Progress goes to stderr, so stdout can be parsed as JSON.
  • onctl exits with the command's own exit code.
  • error is set only when onctl could not reach the box or the command timed out. Then onctl exits with 1.
Flag
-T, --timeouthow long the command may run: whole seconds, default 30s, at most 5m. A longer value is refused before any box is created
-s, --sizebox size: small (default), medium or large
-i, --imageboot image (default debian-slim); onctl images -p boxes lists them

For a command that needs longer than five minutes, create a box and run onctl ssh <box> -- command.

Copy files​

onctl cp -p boxes my-box:/root/evidence/shot.png .
onctl cp -p boxes -r my-box:/root/out ./out
onctl cp -p boxes -r ./site my-box:/srv/

onctl cp copies a file, or with -r a directory, from a box to this machine or the other way. It uses scp, so it needs scp on this machine. A paused box is resumed first.

  • Exactly one side is a box, written <box>:<path>.
  • A path with a / before its first : (./a:b) is local. So is a Windows path such as C:\out.
  • As with scp -r, a directory is copied into the target if the target exists. dir/. copies the directory's contents.

onctl cp is not limited to hosted boxes: it works with any provider onctl ssh reaches.

Give a port a public URL​

onctl expose -p boxes my-box 3000 # https://my-box-k7f2q9xd.boxctl.app -> my-box:3000
onctl expose -p boxes my-box # list my-box's public URLs
onctl expose -p boxes ls # list the public URLs of all your boxes
onctl unexpose -p boxes my-box 3000 # take one down
onctl unexpose -p boxes my-box all # take all of my-box's down

onctl expose puts a port of a box on the internet at an HTTPS URL. Anyone with the URL can open it. For something only you should see, use onctl port-forward instead.

  • The service chooses the URL. It stays the same while the port is exposed, across pause and resume. While the box is paused, the URL shows a "not available" page.
  • onctl unexpose retires the URL. Exposing the port again gives a new one.
  • An account can have up to five public URLs, across all its boxes.
  • HTTP, WebSocket and server-sent events work. Other TCP protocols do not.
  • Visitors count as use of the box, so it is not paused while people are on the URL.
  • onctl expose waits until the URL serves. --no-wait prints it at once.
  • -o json prints the URLs as JSON, on onctl expose and onctl expose ls.

The app inside the box has to do two things:

  • Listen on 0.0.0.0, not 127.0.0.1.
  • Accept the public hostname. Some dev servers (Vite, Rails, Django) refuse names they do not know. Either allow the hostname in the app, or pass --host-header localhost:3000 so requests arrive under that name.

A username and password on the URL​

onctl expose -p boxes my-box 3000 --basic-auth-user demo # asks for the password, hidden
echo "$PW" | onctl expose -p boxes my-box 3000 --basic-auth-user demo --basic-auth-password-stdin
ONCTL_EXPOSE_PASSWORD=... onctl expose -p boxes my-box 3000 --basic-auth-user demo
onctl expose -p boxes my-box 3000 --no-basic-auth # remove them

The password comes from --basic-auth-password-stdin if given, else from ONCTL_EXPOSE_PASSWORD, else from a hidden prompt. It is never a flag value, and the service never returns it. On a port that is already exposed, the same command changes the username and password and the URL stays.

The username is 1 to 64 characters from A-Z a-z 0-9 . _ @ + -. The password is 8 to 128 printable ASCII characters, with no spaces and no { or }.

List runs​

onctl runs
onctl runs -o json

onctl runs lists every run, one row each: the backlog's runs and every other run onctl claude started. Runs that are going come first, then the newest. Runs are on the hosted service, so this command needs no -p.

Column
ITEMthe backlog item, for a backlog run
REPOthe repository
KINDinteractive, code (a new branch that ends in a pull request), or a follow-up on a pull request's branch: ci_fix, conflict_fix or change
BOXthe run's box
STATEfor a run that is going, what its box reports; for one that ended, how it ended: done, failed, lost or killed
AGEthe run's age

A run outside the backlog is listed while its box exists.

To start runs, and to read one run's status and log, see Claude Code on a box.

The Claude Code plugin​

The onctl plugin makes Claude Code on your machine run its Bash commands on a box instead of on your machine. It needs onctl, logged in with onctl login, and jq on your PATH.

Install it inside Claude Code:

/plugin marketplace add cdalar/onctl
/plugin install onctl@onctl

Then:

/onctl:onrun Bash commands on a box from now on
/onctl:statussay whether Bash commands run here or on a box
/onctl:offrun Bash commands here again
/onctl:handoff [note]move the whole session to a box with onctl claude --handoff; Claude carries on there with this conversation

/onctl:on takes --mode and --workspace:

--mode
session (default)one box for this session, destroyed when the session ends
projectone box for the project, kept across sessions
execa new box for every command
--workspace
sync (default)copy the project to the box before every command and back after
copycopy the project to the box once
gitclone the project's origin on the box
nonestart with an empty box

Files that .gitignore names are never copied. A command that starts with onctl , or has a # local line, runs on your machine.

The plugin's settings (/plugin, then onctl, then configure) can turn it on at every session start, and set the workspace, size and image.

What the web does​

onctl has no command for these. Use the web at boxctl.io:

  • backups and restore
  • downloading a snapshot