# CLI reference The main `fdtn` commands and options. `fdtn --help` lists all commands. `fdtn --help` shows the options of one command. ## Install and update Needs Node.js 22.19 or newer. The install line checks Node.js and the file checksum. ```bash $ curl -fsSL https://compute.fdtn.dev/install | sh $ fdtn auth ``` The CLI updates itself once a day. `fdtn` with no arguments shows a home screen. ## Rules for all commands | Names | Where a command takes a sandbox ID, you can give `@name` (from `fdtn create --name`). A name has 1 to 64 letters, digits, `-` or `_`. A new name can take a few seconds to appear. | |---|---| | Output | Commands that print data take `--json`. Commands marked **[format]** also take `-f, --format `. JSON keeps every API field; times are ISO 8601 UTC. | | Lifetime | `exec`, `cp`, `files`, `process`, `each` and `connect` make the time left at least 5 minutes. | | Key | From `FDTN_API_KEY`, then `~/.fdtn/key`. A key file that other users can read is refused (fix: `chmod 600 ~/.fdtn/key`). | | Exit codes | `0` worked. `1` failed or bad input. `128`+N: signal N (Ctrl-C gives 130). `exec`, `create`, `connect` and `claude` return the command's or shell's own code. | | Environment | `FDTN_API_KEY` (wins over the key file), `FDTN_DEBUG=1` (full error text), `NO_COLOR=1`. | ## Setup | Command | What it does | |---|---| | `fdtn auth` | Asks for the key, saves it in `~/.fdtn/key` (mode 600) and checks it. `--replace` saves a new key over a working one. From a pipe (`fdtn auth < key.txt`) it saves with no check. | | `fdtn doctor` | Checks key, DNS, TLS and API access, and shows the fix for the first failure. `--create` also runs `echo ok` in a new sandbox. `--json`. [Troubleshooting](https://fdtn.dev/docs/troubleshooting.md#doctor) | | `fdtn env` | Prints shell lines that point other tools at your workspace. The output never contains the key. `--shell bash\|zsh\|fish\|powershell` (default from `$SHELL`), `--json`. | | `fdtn update` | Installs the newest `fdtn` now. | | `fdtn version` | Prints the version. Same as `fdtn -V`. | ```bash $ fdtn auth $ fdtn doctor --create $ eval "$(fdtn env)" # or: fdtn env --shell fish | source ``` ## Sandboxes These commands also exist under `fdtn sandbox` (short `fdtn sbx`), with `info`, `logs`, `metrics`, `timeout`, `refresh` and `network`. ### `fdtn create [template]` Starts a sandbox (default `base`) and opens a terminal in it. On `exit` the sandbox stops, unless you set `--timeout`. Alias: `cr`. | Option | Default | What it does | |---|---|---| | `-d, --detach` | off | Print the ID and return. No terminal. Use this in scripts. | | `--name ` | none | Name for `@name`. With `--count 3`: `name-1` to `name-3`. | | `-m, --metadata ` | none | Such as `project=demo,run=eval-1`. | | `--count ` | 1 | Start several, five at a time. Needs `--detach`. Maximum 100. | | `--json` | off | With `--detach`: one JSON result per line. | | `--timeout ` | none | Lifetime after you leave. 30 to 86400. | | `--lifecycle.ontimeout ` | `kill` | `pause` or `kill` when the lifetime ends. | | `--public` | off | Open ports without a token. | | `--trusted` | off | Run only on machines that Foundational Compute owns. | | `-e, --env ` | none | Environment variable. Repeatable. | | `-u, --user`, `-c, --cwd` | sandbox user, home | Terminal user and folder. Not with `--detach`. | ```bash $ fdtn create # a terminal in a base sandbox $ fdtn create base -d --name worker --timeout 3600 # start only, print the ID $ fdtn create base -d --count 10 --metadata run=eval-1 --json ``` ### `fdtn claude` Opens Claude Code in a `claude` sandbox on a machine that Foundational Compute owns. A local `ANTHROPIC_API_KEY` goes into the sandbox environment only. `--keep` keeps the sandbox after you leave, for `--timeout` seconds (default 3600). `--secret ` uses a saved [secret](https://fdtn.dev/docs/secrets.md): the sandbox gets a placeholder, never the key. ```bash $ fdtn claude --keep --timeout 7200 $ fdtn claude --secret anthropic ``` ### `fdtn ls` [format] | Option | Default | What it does | |---|---|---| | `-s, --state` | `running` | `running`, `paused` or `running,paused`. | | `-m, --metadata` | none | Filter by metadata. | | `-t, --template` | none | Filter by template name or ID. | | `--started-after ` | none | ISO 8601 time, such as `2026-01-01T00:00:00Z`. | | `-o, --order` | `asc` | By start time: `asc` or `desc`. | | `-l, --limit` | 1000 | `0` shows all. | | `--watch`, `--interval ` | off, 3 | Refresh every 1 to 3600 seconds until Ctrl-C. | ```bash $ fdtn ls -s running,paused -m run=eval-1 --watch ``` ### `fdtn connect ` Opens a terminal in a sandbox. A paused sandbox resumes. Options: `-u`, `-c`, `-e` (as for `create`). Alias: `cn`. ```bash $ fdtn connect @worker ``` ### `fdtn exec ` Runs a command and returns its output and exit code. Put `fdtn` options before the ID. Standard input goes to the command. Use `fdtn cp` for binary data. Alias: `ex`. | Option | What it does | |---|---| | `-b, --background` | Print the process ID and return at once. `--json` prints both IDs. | | `-c, --cwd`, `-u, --user` | Folder and user. Default: home folder, sandbox user. | | `-e, --env ` | Environment variable. Repeatable. | ```bash $ fdtn exec -c /app -e DEBUG=1 @worker npm test $ echo hello | fdtn exec @worker cat $ fdtn exec -b @worker node server.js # prints the process ID ``` A command that starts with a dash cannot run directly. Run it with `sh -c`. ### `fdtn each -m -- ` Runs one command in each running or paused sandbox with the metadata. One failure does not stop the others; exit 1 if any failed. `--concurrency` (default 5, maximum 20), `-c, --cwd`, `--json`. ```bash $ fdtn each --metadata run=eval-1 --json -- python /app/eval.py ``` ### `fdtn pause`, `fdtn resume`, `fdtn kill` | Command | What it does | |---|---| | `fdtn pause [id]` | Keeps memory and files; stops the vCPU and memory charge. Give an ID, `@name` or `-m `. Alias: `ps`. [Paused limits](https://fdtn.dev/docs/limits.md#paused) | | `fdtn resume [id]` | Starts a paused sandbox again. Give an ID, `@name` or `-m `. Alias: `rs`. | | `fdtn kill [ids...]` | Stops sandboxes and deletes their files. `-a, --all` with optional `-s ` and `-m `. | All three take `--json`: one result per sandbox per line. ```bash $ fdtn pause @worker $ fdtn resume --metadata run=eval-1 --json $ fdtn kill --all --state running,paused --metadata run=eval-1 ``` ### `fdtn sandbox` subcommands | Command | What it does | |---|---| | `info ` [format] | State, size, times, lifecycle, network, metadata. Alias: `in`. | | `logs ` [format] | What started, ran and failed. Kept some days after the end. `--level` (default `info`), `-f, --follow`, `--loggers`. Alias: `lg`. | | `metrics ` [format] | CPU, memory and disk, a sample about every 5 seconds. `-f, --follow`. Alias: `mt`. | | `timeout ` | Sets the time left from now, shorter or longer. Maximum 86400. | | `refresh ` | Makes the time left at least this long. Never shortens it. 1 to 3600. | | `network --input ` | Replaces outbound rules from JSON: `allow_internet_access`, `allowOut`, `denyOut`. | ```bash $ fdtn sandbox logs @worker --follow --level debug $ fdtn sandbox timeout @worker 1800 $ echo '{"allow_internet_access":false}' | fdtn sandbox network @worker --input - ``` ### `fdtn process ls|wait|kill` | Subcommand | What it does | |---|---| | `process ls ` [format] | Running commands with PID, command and folder. | | `process wait ` | Follows the output of an `exec -b` command and returns its exit code. | | `process kill ` | Stops one command. | ```bash $ pid=$(fdtn exec -b @worker python train.py) $ fdtn process wait @worker "$pid" ``` ## Files ### `fdtn cp ` [format] Copies between this computer and a sandbox. Write the sandbox side as `ID:path` or `@name:path`. `-r` copies a folder; `--force` replaces files. ```bash $ fdtn cp ./input.json @worker:/app/input.json $ fdtn cp -r @worker:/app/results ./results ``` A local path through a symbolic link fails. On macOS, write `/private/tmp`, not `/tmp`. For a local path with a colon, use `fdtn files push` or `pull`. ### `fdtn files ...` [format] Each subcommand takes the sandbox ID or `@name` first. | Subcommand | What it does | |---|---| | `ls [path]` | Lists a folder (default `.`). | | `pull `, `push ` | Download or upload. Take `-r` and `--force`. | | `info`, `mkdir`, `remove` `` | Details, new folder, delete. | | `move ` | Moves or renames. | ```bash $ fdtn files push @worker ./data /app/data -r ``` ### `fdtn collect` [format] Downloads one result folder from each sandbox in a group into `--destination`, with a `manifest.json` of SHA-256 checksums. | Option | What it does | |---|---| | `--destination ` | Required. Folder for results and the manifest. | | `-m, --metadata`, `--path ` | New collection: which sandboxes, and which folder in each. | | `--retry-failed` | Retry failed downloads and keep finished ones. | ```bash $ fdtn collect --metadata run=eval-1 --path /app/results --destination ./results-1 $ fdtn collect --retry-failed --destination ./results-1 ``` ## Templates Short form: `fdtn tpl`. Guide: [Templates](https://fdtn.dev/docs/templates.md). ### `fdtn template create ` Builds a template from a Dockerfile, new or again, and prints the log. A build is free. At a spending limit, new builds stop. Alias: `ct`. | Option | Default | What it does | |---|---|---| | `-p, --path` | current folder | Build context folder. | | `-d, --dockerfile` | `fdtn.Dockerfile`, then `Dockerfile` | Dockerfile to build. | | `--cpu-count` | 2 | vCPUs per sandbox, up to 16. | | `--memory-mb` | 1024 | MiB per sandbox, an even number up to 32768. Rounded up to 512 MiB blocks. | | `--min-free-disk-mb` | service | Free disk after the build. At most 5120, 10240 or 20480, by memory size. | | `-c, --cmd`, `--ready-cmd` | none | Start command, and a command that exits 0 when ready. `--cmd` needs `--ready-cmd`. | | `--no-cache` | cache on | Build every step again. | ```bash $ fdtn template create my-env --cpu-count 4 --memory-mb 4096 $ fdtn create my-env ``` ### Other template commands | Command | What it does | |---|---| | `template list` [format] | Name, ID, status, size, age. Alias: `ls`. | | `template delete [names...]` | Deletes templates. `-y` skips the question; `-s` picks from a list. Alias: `dl`. | | `template init` | Writes starter build files. `-n `, `-l typescript\|python-sync\|python-async`, `-p `. Alias: `it`. | | `template resolve ` | Shows a template name if it exists. | | `template tags ls\|add\|remove` | `ls `; `add `; `remove `. | | `template build status\|logs ` | Build status or log. Give the template ID, not the name. | ```bash $ fdtn template delete old-env other-env --yes $ fdtn template tags add my-env:default stable ``` ## Snapshots `fdtn snapshot create --name ` saves a sandbox as a template that new sandboxes start from. Always give `--name`: you start from it and delete by it. `--trusted` and `claude` sandboxes cannot make one. [Snapshots](https://fdtn.dev/docs/lifecycle.md#snapshots) ```bash $ fdtn snapshot create @worker --name worker-ready $ fdtn create worker-ready -d $ fdtn snapshot delete worker-ready ``` ## Secrets Values come from a JSON file or stdin, never from a command-line argument. [Secrets](https://fdtn.dev/docs/secrets.md) ```bash $ fdtn secrets create --input anthropic.json $ fdtn secrets ls $ fdtn secrets info $ fdtn secrets rotate --input new.json $ fdtn secrets delete ``` ## Utilities ### `fdtn api ` Calls an [HTTP API](https://fdtn.dev/docs/api.md) path with your saved key and prints the JSON. `-X ` (default `GET`), `--input ` for a JSON body, `--include` for the next page token. ```bash $ echo '{"timeout":600}' | fdtn api /sandboxes/i3k9.../timeout -X POST --input - ``` ### `fdtn harbor [arguments...]` Runs Harbor with your key and Foundational Compute as the sandbox service. Do not give Harbor an environment option. [Evals with Harbor](https://fdtn.dev/docs/harbor.md) ```bash $ fdtn harbor run -d terminal-bench@2.0 -a oracle -n 2 ``` ## Next - [**Python SDK**: Sandboxes from Python.](https://fdtn.dev/docs/python.md) - [**TypeScript SDK**: Sandboxes from Node.js.](https://fdtn.dev/docs/typescript.md) - [**HTTP API**: Calls with curl.](https://fdtn.dev/docs/api.md) Source: https://fdtn.dev/docs/cli/