docs/cli-reference.md

CLI reference

Command-line usage and operational commands.

๐Ÿ’ป CLI Reference

๐Ÿค  randal โ€” agent harness v0.2

๐ŸŽฌ Two Modes

Randal operates in two modes with different execution models:

๐ŸŽฏ randal run โ€” Local one-shot. Creates a Runner directly, prints to stdout, blocks until done, exits. No server, no persistence, no dashboard.

๐Ÿ—๏ธ randal serve โ€” Daemon. Starts an HTTP server with REST API, SSE event stream, job persistence (~/.randal/jobs/), memory integration, and a web dashboard. Jobs run in the background.

All other commands (send, status, jobs, stop, context, resume, memory) communicate with a running daemon via HTTP.


๐ŸŒ Global Options

FlagTypeDescription
--config <path>stringPath to config file. If omitted, searches for randal.config.yaml, randal.config.yml, or randal.yaml in the current directory.
--url <url>stringRemote server URL. Default: http://localhost:7600. Used by remote commands (send, status, etc.).
--version, -vflagPrint version and exit.
--help, -hflagPrint help and exit.

๐Ÿ“‹ Commands

๐Ÿ”ง randal init

Scaffold a randal.config.yaml in the current directory. Features an interactive onboarding wizard with environment auto-detection.

randal init              # Interactive โ€” QuickStart or Advanced
randal init --wizard     # Jump straight to Advanced wizard
randal init --persona    # Legacy persona-artifact helper; prefer the standalone script below
randal init --yes        # Non-interactive โ€” auto-detect + defaults
randal init --from <path> # Bootstrap from existing config

See Init Modes for details on each mode.

Primary persona authoring for source-machine -> Mac mini provisioning now lives outside randal init:

bun run scripts/persona-preseed.ts

That standalone Bun script launches a real OpenCode interview session from the repo checkout, writes the reviewed local artifacts into an output directory, and emits the trusted local preseed bundle you hand to the Mac mini.

randal init --persona remains available as a secondary local artifact writer when you only want the identity files without the standalone preseed handoff flow:

  • .randal/identity/persona.identity.yaml as the machine-readable source of truth
  • .randal/identity/PERSONA.md for human review and editing
  • IDENTITY.md as the rendered compatibility artifact used by current config flows

Generated persona artifacts are also recorded in .randal/managed-artifacts.yaml so later reset flows can remove only Randal-managed files.


๐Ÿงน randal reset

Clear all Randal config and state. Returns to a fresh state ready for randal init.

randal reset          # Remove config + job/cron state (preserves .env and memory data)
randal reset --all    # Aggressive reprovisioning wipe for the same machine/preseed flow
randal reset --yes    # Skip confirmation prompts
FlagDescription
--allAggressive reprovisioning wipe for the current macOS user: removes .env, manifest-tracked generated project artifacts, ~/.config/opencode, ~/.randal, and the randal-meilisearch Docker container/state. The interactive flow requires explicit machine-wide confirmation.
--yesSkip all confirmation prompts (for scripting). Combinable with --all.

Default reset removes:

  • randal.config.yaml in current directory
  • ~/.randal/jobs/ (all persisted job files)
  • ~/.randal/cron.yaml (cron scheduler state)

Default reset preserves:

  • .env (contains your API keys)
  • ~/.randal/meili-data/ (Meilisearch indexes and memory data)
  • ~/.config/opencode/

randal reset --all additionally removes:

  • .env
  • .randal/managed-artifacts.yaml and the generated project/home artifacts recorded there
  • ~/.config/opencode/ for the current macOS user
  • ~/.randal/ for the current macOS user
  • Interactive use asks for an explicit machine-wide confirmation before deleting those user-level runtime directories
  • randal-meilisearch Docker container (if present)

๐ŸŽฏ randal run <prompt|file>

Run an agent locally in one-shot mode. If the argument is a path to an existing .md file, its contents are used as the prompt.

randal run "refactor the auth module"
randal run spec.md
randal run "fix tests" --max-iterations 10
FlagTypeDefaultDescription
--agentstringConfig runner.defaultAgent (opencode)Agent adapter name.
--modelstringConfig runner.defaultModel (anthropic/claude-sonnet-4)Model identifier.
--max-iterationsnumberConfig runner.defaultMaxIterations (20)Maximum iteration count.
--workdirstringConfig runner.workdirWorking directory for the agent process.
--verbose, -vflagfalseShow iteration summaries during execution.

Exits with code 1 if the job fails.


๐Ÿ—๏ธ randal serve

Start the daemon: gateway + runner + dashboard.

randal serve
randal serve --port 8080
FlagTypeDefaultDescription
--portnumberConfig HTTP channel port (7600)Override the HTTP server port.

The server runs until terminated. Dashboard available at the root URL.

Published-artifact bootstrap is optional. The normal default is still local randal.config.yaml startup. If you want a runtime to start directly from a published artifact instead, set these environment variables before randal serve:

export RANDAL_MANAGED_CONTROL_PLANE_URL=https://control-plane.example
export RANDAL_MANAGED_WORKSPACE_ID=workspace-123
export RANDAL_MANAGED_VERSION_ID=version-7   # optional; omit to use the active published version

Optional override:

export RANDAL_MANAGED_ARTIFACT_URL=https://control-plane.example/api/workspaces/workspace-123/setup-versions/version-7/config-export

Notes:

  • Managed bootstrap fetches only published artifacts.
  • Config Studio draft state is never consumed by runtime startup.
  • GET /instance reports runtime mode as local or managed so the dashboard can surface which path is active.
  • See docs/config-studio.md for the current file-authoring model and source-of-truth rules.

๐Ÿ“จ randal send <prompt|file>

Submit a job to a running Randal instance via HTTP. If the argument is a path to an existing .md file, its contents are used as the prompt.

randal send "build the new API endpoint"
randal send spec.md --agent opencode
randal send "fix bug" --url http://remote:7600
FlagTypeDefaultDescription
--agentstringโ€”Agent override.
--modelstringโ€”Model override.
--max-iterationsnumberโ€”Max iterations override.
--workdirstringโ€”Working directory override.

Uses RANDAL_API_TOKEN environment variable for Bearer authentication.


๐Ÿ“Š randal status [job-id]

Get the status of a specific job, or list all running jobs if no ID is given.

randal status             # List all running jobs
randal status abc12345    # Get details for a specific job

๐Ÿ“‹ randal jobs

List all jobs from the gateway.

randal jobs
randal jobs --status failed
randal jobs --status complete
FlagTypeDefaultDescription
--statusstringโ€”Filter by status: queued, running, complete, failed, stopped.

๐Ÿ›‘ randal stop <job-id>

Stop a running job.

randal stop abc12345

๐Ÿ’‰ randal context [job-id] <text>

Inject context into a running job. Human text still lands in context.md, and the runner also supports structured context.packet.json and context.updates.jsonl files for machine-readable worker context without breaking the existing CLI flow.

If no job-id is given and exactly one job is running, it targets that job. If multiple jobs are running, an explicit ID is required.

randal context "focus on the payment module first"    # Single running job
randal context abc12345 "skip the tests for now"      # Explicit job ID

๐Ÿ”„ randal resume <job-id>

Resume a failed job. Fetches the job's history, builds a prompt containing prior iteration summaries as context, and submits a new job.

randal resume abc12345

๐Ÿง  randal memory <subcommand>

Memory operations. Requires a running daemon (for search and list) or local config (for add).

randal memory search <query>

Search memory by query.

randal memory search "database migrations"
randal memory search "auth" --agent my-agent --limit 10
FlagTypeDefaultDescription
--agentstringโ€”Filter by agent name.
--categorystringโ€”Filter by category.
--limitnumberโ€”Maximum results.

randal memory list

List recent memories.

randal memory list
randal memory list --limit 20 --category lesson
FlagTypeDefaultDescription
--agentstringโ€”Filter by agent name.
--categorystringโ€”Filter by category.
--limitnumberโ€”Maximum results.

randal memory add <content>

Add a memory entry.

randal memory add "The deploy script requires Node 20" --category fact
randal memory add "User prefers tabs over spaces" --category preference
FlagTypeDefaultDescription
--categorystring"fact"Memory category: preference, pattern, fact, lesson, escalation.
--agentstringโ€”Agent name to associate with the memory.

๐Ÿ” randal audit

Detect and report ambient host authentication. Scans for SSH keys, GitHub CLI auth, git credential stores, Google Cloud auth, AWS credentials, Docker registry auth, and npm/bun auth tokens.

randal audit              # Human-readable report
randal audit --json       # Machine-readable JSON output
FlagTypeDescription
--jsonflagOutput JSON format instead of human-readable text.

Does not require a config file. Probes run in subprocesses with short timeouts and are non-destructive (read-only).


๐Ÿ”ฉ randal setup

Generate opencode.json and configure the OpenCode runtime. This command replaces agent/setup.sh and is the recommended way to set up a Randal deployment.

randal setup                  # Generate config, symlink dirs, install plugins
randal setup --preseed ./source-machine-to-mac-mini.preseed.yaml
randal setup --dry-run        # Preview what would be generated (no writes)
randal setup --json           # Output raw JSON to stdout (for piping)
randal setup --verbose        # Show detailed MCP wiring and resolution steps
FlagTypeDescription
--config <path>stringPath to randal.config.yaml.
--preseed <path>stringTrusted local wrapper bundle authored on a source machine, then copied to the target Mac mini. Materializes files first, then runs the normal setup pipeline.
--output <dir>stringOutput directory. Default: ~/.config/opencode/.
--dry-runflagPrint generated opencode.json and planned symlinks without writing anything.
--jsonflagOutput raw JSON to stdout for piping to other tools.
--verboseflagShow which MCP servers are included, why, which capabilities were detected, and identity resolution details.

What it does:

  1. Reads randal.config.yaml (or the file given by --config)
  2. Compiles opencode.json from opencode.base.json + config values (MCP servers, tool permissions, capabilities)
  3. Writes the generated opencode.json to ~/.config/opencode/opencode.json
  4. Symlinks static content (agents/, skills/, lenses/, tools/, rules/, plugins/, package.json, tui.json) from agent/opencode-config/ into the output directory
  5. Runs bun install for plugin dependencies

The command is idempotent โ€” safe to run repeatedly. Existing non-symlink entries are backed up before replacement.

Source-machine -> Mac mini handoff

  1. On your source machine, from the repo checkout, run bun run scripts/persona-preseed.ts.
  2. Review the generated output directory and copy the emitted source-machine-to-mac-mini.preseed.yaml bundle to the Mac mini.
  3. On the Mac mini, run randal setup --preseed ./source-machine-to-mac-mini.preseed.yaml.
  4. If you need to reprovision the Mac mini, run randal reset --all --yes first, then re-run the same preseed bundle.

The preseed format is intentionally local and trusted for v1. Plaintext secrets in the bundle are supported, but the file should stay on machines you control.

Migration from agent/setup.sh: If you previously used bash agent/setup.sh, switch to randal setup. The old script still works but prints a deprecation warning. See Deprecation: agent/setup.sh below.


๐Ÿฉบ randal doctor

Validate the current deployment. Runs a series of diagnostic checks and reports pass/fail/warn for each.

randal doctor                 # Run all checks
randal doctor --config ./my-config.yaml   # Check a specific config
FlagTypeDescription
--config <path>stringPath to randal.config.yaml.
--output <dir>stringOpenCode config directory to check. Default: ~/.config/opencode/.

Checks performed:

CheckWhat it validates
Configrandal.config.yaml parses correctly
opencode.jsonFile exists at ~/.config/opencode/opencode.json
Config freshnessGenerated config matches current randal.config.yaml (detects stale configs)
Identity filesAll referenced persona, rules, and knowledge files resolve
MCP serversAll MCP server binaries/scripts referenced in opencode.json exist on disk
MeilisearchHealth check passes (if memory is configured)
OpenCode CLIopencode binary is available on PATH
SymlinksSymlinks in ~/.config/opencode/ point to valid targets

Exit codes: 0 if all checks pass, 1 if any check fails.

Example output:

  Randal Doctor โ€” deployment validation

  [PASS] Config: randal.config.yaml parses correctly
  [PASS] opencode.json: opencode.json exists at ~/.config/opencode/opencode.json
  [PASS] Config freshness: opencode.json is consistent with current config
  [PASS] Identity files: All identity files resolve (persona, 3 rules)
  [PASS] MCP servers: All MCP server scripts exist (memory, scheduler, tavily)
  [PASS] Meilisearch: Meilisearch is healthy at http://localhost:7701
  [PASS] OpenCode CLI: `opencode` is available on PATH
  [PASS] Symlinks: 8 symlinks OK (agents, skills, lenses, ...)

  Summary: 8 passed, 0 warned, 0 failed

โฌ†๏ธ randal update

Self-update for git-based installs. Fetches latest tags, compares versions, and optionally applies the update.

randal update              # Fetch, compare, pull if available, reinstall
randal update --check      # Just report if an update is available (exit 0/1)
randal update --pin v0.3.0 # Checkout a specific tag
randal update --dry-run    # Show what would change without applying
FlagTypeDescription
--checkflagReport availability and exit with code 0 (available) or 1 (up to date).
--pin <version>stringCheckout a specific tag version.
--dry-runflagShow commits that would be applied without making changes.

In container mode, reports the available update and suggests rebuilding the image. Does not modify the container filesystem.

Does not require a config file.


๐Ÿš€ randal deploy

Deploy to Railway. Wraps the Railway deployment scripts with a consistent CLI interface.

randal deploy agent                                    # Deploy single agent
randal deploy agent --dry-run                          # Preview without deploying
randal deploy posse --name my-team                     # Deploy multi-agent posse
randal deploy posse --name my-team --config posse.yaml # Deploy with custom config
randal deploy env                                      # Set Railway env vars only
randal deploy list                                     # List deployed posses
randal deploy delete my-team                           # Delete a posse

Subcommands

SubcommandDescription
agentDeploy a single Randal agent to Railway. Reads .env, sets Railway variables, deploys.
posse --name <name>Deploy a multi-agent posse with shared Meilisearch. Requires --name.
envSet environment variables on Railway from .env without deploying.
listList all deployed posses (local deployment summaries).
delete <name>Delete a deployed posse. Use --force to skip confirmation.

Agent Options

FlagDescription
--dry-runPreview what would be set and deployed without making changes.

Posse Options

FlagDescription
--name <name>Posse name (required). Used as the Railway project name prefix.
--config <file>Path to posse config YAML. Default: examples/railway-posse/full-company.yaml.
--dry-runPreview without deploying.

Prerequisites

  • Railway CLI: curl -fsSL https://railway.com/install.sh | sh
  • Railway auth: railway login
  • .env file: Must exist in project root with API keys
  • Posse only: yq and jq must be installed (brew install yq jq)

Examples

# First-time single agent deploy
railway login
randal deploy agent

# Deploy a 10-agent company
randal deploy posse --name acme-corp --config examples/railway-posse/full-company.yaml

# Update env vars without redeploying
randal deploy env

# Clean up
randal deploy delete acme-corp

๐Ÿ“š Skills Commands

randal skills list

List all available skills (bundled + workspace).

randal skills search <query>

Search skills by name or content.

randal skills show <name>

Display a skill's full documentation.


๐Ÿ“ก HTTP API Endpoints

When running in daemon mode (randal serve), the following REST endpoints are available. All endpoints except GET / require Bearer token authentication.

MethodPathDescription
GET/๐Ÿ“ก Dashboard (HTML)
GET/health๐Ÿ’š Health check: { status, uptime, version, updateChannel }
GET/audit๐Ÿ” Ambient auth audit report (JSON)
GET/instance๐Ÿชช Instance info: name, posse, status, version, capabilities
POST/job๐Ÿ“จ Submit job: { prompt, specFile?, agent?, model?, maxIterations?, workdir? }
GET/job/:id๐Ÿ“Š Get job details
GET/jobs๐Ÿ“‹ List jobs. Optional ?status= filter.
DELETE/job/:id๐Ÿ›‘ Stop a running job
POST/job/:id/context๐Ÿ’‰ Inject context: { text }
GET/events๐Ÿ“ก SSE event stream
GET/memory/search๐Ÿ” Search memory: ?q=&limit=
GET/memory/recent๐Ÿง  Recent memories: ?limit=
GET/configโš™๏ธ Sanitized config (credentials redacted)
GET/schedulerโฐ Scheduler status: heartbeat, cron, hooks
POST/heartbeat/trigger๐Ÿ’“ Force an immediate heartbeat tick
GET/cron๐Ÿ“… List all cron jobs
POST/cronโž• Add a runtime cron job: { name, schedule, prompt, execution? }
DELETE/cron/:nameโž– Remove a cron job
POST/hooks/wake๐Ÿช Wake hook: { text, mode } (requires hook token)
POST/hooks/agent๐Ÿค– Agent hook: { message, wakeMode?, model? } (requires hook token)

๐Ÿ“… Cron Commands

randal cron list

List all registered cron jobs on a running instance.

randal cron list
randal cron list --url http://remote:7600

randal cron add

Add a runtime cron job.

randal cron add my-job --schedule "0 8 * * *" --prompt "Morning briefing" --isolated
randal cron add check --schedule 30m --prompt "Check health"
FlagTypeDescription
--schedulestringCron expression, duration (30m), or ISO datetime
--promptstringThe prompt to execute
--isolatedflagUse isolated execution (default: main/heartbeat)
--modelstringOverride model

randal cron remove

Remove a cron job by name.

randal cron remove my-job

๐Ÿ’“ Heartbeat Commands

randal heartbeat status

Show heartbeat state: last tick, next tick, tick count, pending wake items.

randal heartbeat status

randal heartbeat trigger

Force an immediate heartbeat tick (bypasses active hours).

randal heartbeat trigger

๐Ÿ”ง Init Modes

randal init (default)

Interactive onboarding with environment auto-detection. Presents a choice between โšก QuickStart (3 questions, smart defaults) and ๐Ÿ”ง Advanced (full wizard walking through every config section).

Auto-detects:

  • ๐Ÿ–ฅ๏ธ Platform (macOS / Linux)
  • ๐Ÿ”Œ Installed agent CLI (opencode)
  • ๐Ÿ” Running Meilisearch instance

randal init --wizard

Jump straight to the Advanced wizard flow (bypasses QuickStart/Advanced selection).

randal init --from <path>

Bootstrap from an existing config file. Validates, fills gaps with defaults, and writes a merged result.

randal init --from ~/backups/randal.config.yaml

randal init --yes

Non-interactive mode. Uses auto-detected values and all defaults. Useful for Docker builds and CI.


๐ŸŒ Mesh Commands

randal mesh status

Show all instances in the mesh with health, load, specialization, and reliability scores.

randal mesh status
randal mesh status --url http://remote:7600

randal mesh route <prompt>

Dry-run the routing algorithm and show which instance would handle the task and why.

randal mesh route "build a React component"

๐Ÿ“Š Analytics Commands

randal analytics scores

Show reliability scores broken down by agent, model, and domain.

randal analytics scores
randal analytics scores --url http://remote:7600

randal analytics recommendations

Show current actionable recommendations based on annotation patterns.

randal analytics recommendations

๐ŸŽ™๏ธ Voice Commands

randal voice status

Show active voice sessions with duration and transcript length.

randal voice status

โš ๏ธ Deprecation: agent/setup.sh

The agent/setup.sh script is deprecated and will be removed in a future version. Use randal setup instead.

Migration:

# Old way (deprecated)
bash agent/setup.sh

# New way
randal setup

randal setup is a superset of agent/setup.sh with several improvements:

  • Config-driven: Generates opencode.json from randal.config.yaml instead of using hardcoded paths
  • Dynamic MCP wiring: MCP servers are included based on your capabilities and config, not hardcoded
  • Cross-platform: TypeScript-based, not bash-only
  • Dry-run support: Preview changes before applying with --dry-run
  • Validation companion: Pair with randal doctor to verify your deployment

The old script continues to work but prints a deprecation warning. If the randal CLI is available on PATH, it will suggest using randal setup instead.