Skip to main content

CLI Client

The craft-cli is a terminal client for the Craft Agent headless server. It connects over WebSocket and lets you manage sessions, send messages with real-time streaming, and validate server health — all from the command line.

Installation

From the monorepo root:
After linking, craft-cli is available anywhere in your terminal.

Quick Start

1. Start the server

2. Set connection details

3. Verify the connection

4. Start working

Common Workflows

Run a One-Off Task (Self-Contained)

The run command spawns a headless server, creates a session, sends your prompt, streams the response, and exits — no separate server setup needed:
An API key is resolved from --api-key, $LLM_API_KEY, or a provider-specific env var (e.g., $ANTHROPIC_API_KEY, $OPENAI_API_KEY). See the CLI Reference for all run and LLM configuration flags.

Validate a Server Deployment

After deploying or updating the server, run the built-in validation:
When no --url is provided, --validate-server automatically spawns a local headless server, runs the validation, and shuts it down. This exercises 21 steps covering connectivity, credential health, workspace listing, session lifecycle, source/skill creation and cleanup. Note: it mutates workspace state (creates and deletes temporary resources). Use --json for CI-friendly output:

Manage Sessions

Stream AI Responses

The send command connects to the session event stream and writes the AI response to stdout in real time:
You can also pipe input:

Scripting with JSON Output

Every command supports --json for machine-readable output:

CI/CD Integration

Use the CLI to automate tasks in your pipeline:

Raw RPC Access

For channels not wrapped as named commands, use the invoke escape hatch:

Connection Options

See the full CLI Reference for all flags, environment variables, and troubleshooting.