Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI overview

Castellan is a single binary (castellan) with subcommands for goal runs, evolution, multiplexer control, MCP, and diagnostics.

Precedence

Configuration resolves in this order (highest wins):

  1. CLI flags — e.g. --goal, --plugin, --json
  2. Environment variables — e.g. CASTELLAN_MUX_AUTO, CASTELLAN_SESSION_SPEND_CAP_USD
  3. Layered config files — see castellan.toml

Output modes

ModeFlag / entrypointConsumerReference
Human textdefaultInteractive terminalrun
NDJSON eventscastellan run --jsonCI, automation, log pipelinesrun
MCP stdiocastellan mcpCursor, Claude Desktop, other MCP clientsmcp, MCP tools
ACP stdiocastellan acpEditor-class agents (Zed, experimental)ACP integration
Socket NDJSONcastellan multiplexer serverDashboard, remote attach, HerdR paritySocket API

One runnable recipe per mode:

# text — human terminal
castellan run --goal "reach target" --plugin gridworld

# json — typed NDJSON events for CI (episode JSON also lands in .castellan/episodes/)
castellan run --goal "reach target" --plugin gridworld --json | grep episode_end

# mcp — stdio JSON-RPC (tools/list handshake)
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}\n' | castellan mcp

# socket — multiplexer NDJSON API
castellan multiplexer server &
castellan multiplexer status

# acp — agent client protocol over stdio
castellan acp doctor

Episode JSON is always written to .castellan/episodes/<goal-id>.json on successful runs (separate from --json stdout).

Top-level commands

CommandPage
runrun
evolveevolve
remoteremote
herdherd
pluginplugin
mcpmcp
telemetrytelemetry
doctordoctor
replayreplay
swarm-demo, rah-demodemos

Other commands: multiplexer, acp, skills, episodes, recipes, drift-check, memory, integration, vitals, genome, dashboard, completions, ipc (deprecated). Run castellan <cmd> --help for flags. Recipes are defined in castellan.toml [[recipes]].

Shell completions

Completions are generated from live clap metadata so they stay in sync with the CLI:

castellan completions bash   # bash completion script
castellan completions zsh    # zsh completion script
castellan completions fish   # fish completion script

Install examples:

# bash (user-local)
mkdir -p ~/.local/share/bash-completion/completions
castellan completions bash > ~/.local/share/bash-completion/completions/castellan

# zsh
castellan completions zsh > "${fpath[1]}/_castellan"

# fish
mkdir -p ~/.config/fish/completions
castellan completions fish > ~/.config/fish/completions/castellan.fish

Re-run after upgrading castellan when subcommands or flags change.

Help snapshots

CLI help is snapshot-tested in CI. After intentional CLI changes:

UPDATE_SNAPSHOTS=1 cargo test -p castellan-cli cli_help_snapshot

See Deployment.

Recipes

castellan run --goal "reach target" --plugin gridworld
castellan run --goal "reach target" --plugin gridworld --json | grep episode_end
castellan multiplexer server &
castellan dashboard &
castellan run --goal "reach target" --plugin gridworld --mux
castellan evolve --episodes 16 --workspace .castellan/episodes
castellan run --goal "reach target" --plugin gridworld --seed-archive