Skip to main content

CLI Reference

The craft-cli is a terminal client that connects to a running Craft Agent headless server over WebSocket. It provides commands for listing resources, managing sessions, sending messages with real-time streaming, and validating server health.

Installation

Quick Start

The fastest way to try it out — no server setup needed:

Connection Options

Flags override environment variables. If --workspace is omitted, the first available workspace is used automatically.

Commands

Info & Health

Resource Listing

Session Operations

Send Message (Streaming)

The send command subscribes to session:event and streams the AI response to stdout in real time:

Raw RPC

invoke sends a request to any channel and prints the response. listen subscribes to a push channel and prints events as they arrive (Ctrl+C to stop).

Run (Self-Contained)

The run command is fully self-contained — it spawns a headless server, creates a session, sends the 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). LLM Configuration:

Validate Server

When no --url is provided, --validate-server automatically spawns a local headless server, runs the validation, and shuts it down. Runs a 21-step integration test covering the full server lifecycle including source and skill creation:
  1. Connect + handshake
  2. credentials:healthCheck
  3. system:versions
  4. system:homeDir
  5. workspaces:get
  6. sessions:get
  7. LLM_Connection:list
  8. sources:get
  9. sessions:create (temporary __cli-validate-* session)
  10. sessions:getMessages
  11. Send message + stream (text response)
  12. Send message + tool use (Bash tool)
  13. sources:create (temporary Cat Facts API source)
  14. Send + source mention (uses the created source)
  15. Send + skill create (writes SKILL.md via Bash)
  16. skills:get (verify skill appears)
  17. Send + skill mention (invokes the created skill)
  18. skills:delete (cleanup)
  19. sources:delete (cleanup)
  20. sessions:delete (cleanup)
  21. Disconnect
Note: This test mutates workspace state — it creates and deletes a temporary session, source, and skill. All resources are cleaned up on completion. Continues on failure and reports a summary. Use --json for machine-readable output:

Troubleshooting