---
title: CLI reference
description: Install and use the Spacefolder CLI from a terminal or coding agent.
seo:
  description: "Install and configure the Spacefolder CLI. Manage Worlds, Fold events, Navigate predictions, and handle JSON input, output, and exit codes."
---

## Install

After the first CLI package release, install with Node.js 22 or newer:

```sh
npm install -g @spacefolder/cli
spacefolder --version
```

The npm package includes native binaries for Apple Silicon and Intel macOS, and arm64/x64 Linux with glibc (built on Ubuntu 24.04). Windows and Alpine/musl binaries are not currently provided. It does not download executable code during installation.

Before the first release, build from the repository:

```sh
cargo build --locked --release -p spacefolder-cli
./target/release/spacefolder --help
```

## Configure

```sh
export SPACEFOLDER_API_KEY='your-workspace-api-key'
spacefolder auth status
```

Alternatively set `SPACEFOLDER_API_KEY_FILE` to a file containing the key. A key file takes precedence over `SPACEFOLDER_API_KEY`.

```sh
spacefolder --api-key-file /path/to/key --timeout 30 world list
```

The CLI connects to the hosted API automatically. Global flags must come before the command. `--timeout` accepts 1–300 seconds and defaults to 30.

## Commands

| Command | Purpose |
| --- | --- |
| `auth status` | Check credentials against the API |
| `world create <id> [--name NAME]` | Create a World |
| `world list [--limit COUNT] [--cursor CURSOR]` | List Worlds |
| `world show <id>` | Read World metadata |
| `fold <request.json\|->` | Ingest observed events |
| `navigate <request.json\|->` | Request predictions |
| `fold list <world> [--limit COUNT]` | Read Fold history |
| `navigate list <world> [--nav-id ID] [--cursor CURSOR]` | Read Navigate history |
| `fold get <world> <run-id>` | Read Fold detail |
| `navigate get <run-id> [--trace]` | Read Navigate detail |
| `--help` / `--version` | Print help/version without connecting |

History list commands also accept API filter names as `--name value` pairs; hyphens become underscores. Each flag may occur once. Use the SDK or HTTP API for repeated array values. World rename/delete are available through the API and SDKs.

## JSON files and stdin

Request JSON has the same shape as the [API](/docs/reference/api). Every Navigate request must include a [`context` object](/docs/concepts/primitives#context) describing the situation at decision time; use `"context": {}` when none is available. See [Get started](/docs/get-started) for `fold.json` and `navigate.json`.

```sh
spacefolder world create my_app --name 'My application'
spacefolder fold fold.json
spacefolder navigate navigate.json
cat fold.json | spacefolder fold -
```

JSON input is limited to 8 MiB. Successful commands print JSON to stdout. Failures print JSON to stderr. Redirects are not followed and requests are not automatically retried.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Success |
| 1 | Transport, local, or other API error |
| 2 | Invalid command or configuration |
| 3 | HTTP 401 / 403 |
| 4 | HTTP 404 |
| 5 | HTTP 409 |

Keep credentials in environment variables or a key file; do not place them in request JSON. Use shell exit codes and JSON output to integrate with agents and scripts.
