CLI
The Sleepwalker CLI is a command-line client for the Sleepwalker API.
Use it when you want the same actions available in the Console, MCP, and API from a terminal, script, or CI job. The CLI does not run analysis locally. It sends requests to Sleepwalker, polls when needed, and saves persisted results back to the Console.
Install
Section titled “Install”Install globally:
npm install -g @sleepwalkerai/clisleepwalker initOr run one command without installing:
npx @sleepwalkerai/cli doctorThe public package is:
@sleepwalkerai/cliAuthentication
Section titled “Authentication”The CLI uses Sleepwalker API keys. Create a key in the Sleepwalker Console, then choose one of two setup paths.
For CI jobs or short-lived shells:
export SLEEPWALKER_API_KEY=sw_api_live_...sleepwalker doctorFor a local machine:
sleepwalker auth key set sw_api_live_...sleepwalker doctorThe stored key is written to your local Sleepwalker config file. It is masked in CLI output and should never be committed.
Configuration
Section titled “Configuration”Show current configuration:
sleepwalker config showUse a different API base URL:
sleepwalker config set api-base-url https://api.sleepwalker.aiClear the override:
sleepwalker config clear api-base-urlEnvironment variables:
| Variable | Purpose |
|---|---|
SLEEPWALKER_API_KEY | API key for authenticated requests. |
SLEEPWALKER_API_BASE_URL | API base URL. Defaults to https://api.sleepwalker.ai. |
SLEEPWALKER_CONFIG_DIR | Override local config directory. Useful for tests and isolated environments. |
NO_COLOR | Disable ANSI color. |
FORCE_COLOR | Force ANSI color in non-interactive terminals. |
Setup Check
Section titled “Setup Check”For the guided setup checklist:
sleepwalker initFor an interactive command picker after authentication:
sleepwalker menuRun:
sleepwalker doctordoctor checks:
- API key source;
- API base URL;
- authenticated access to the Sleepwalker API;
- available and used credits when the API can be reached.
Use JSON output in automation:
sleepwalker doctor --jsonRead Commands
Section titled “Read Commands”Read commands do not consume credits.
sleepwalker creditssleepwalker usagesleepwalker activity list --limit 10sleepwalker tests list --type ai_citationssleepwalker reports by-url https://example.comUseful patterns:
sleepwalker reports by-url https://example.com --type content_intelligence --days 30sleepwalker activity list --kind all --limit 20 --jsonPage Serialization
Section titled “Page Serialization”Use page serialization when a script or agent needs Sleepwalker’s normalized content view for a URL.
sleepwalker page serialize https://example.comLimit response size:
sleepwalker page serialize https://example.com --max-chars 4000 --offset 0AI Visibility
Section titled “AI Visibility”Suggest prompts:
sleepwalker visibility suggest-prompts https://example.com --brand ExampleCreate a run:
sleepwalker visibility run https://example.com \ --brand Example \ --prompt "What are the best options for this problem?" \ --platform perplexity \ --platform openai \ --watchFor retryable scripts, provide your own idempotency key:
sleepwalker visibility run https://example.com \ --brand Example \ --prompt "How is Example described?" \ --platform perplexity \ --idempotency-key visibility-example-001Use a prompt file:
sleepwalker visibility run https://example.com \ --brand Example \ --prompt-file prompts.txt \ --platform perplexity,openai,grok,geminiCheck status later:
sleepwalker visibility status <run_id> --resultsList recent runs:
sleepwalker visibility list --limit 20Content Intelligence
Section titled “Content Intelligence”Run a direct score:
sleepwalker ci score https://example.comCreate a persisted Content Intelligence run:
sleepwalker ci run https://example.com --depth full --watchFor retryable scripts:
sleepwalker ci run https://example.com \ --depth full \ --idempotency-key ci-example-homepage-001Check status later:
sleepwalker ci status <run_id> --resultList recent runs:
sleepwalker ci list --limit 20Watch Mode
Section titled “Watch Mode”--watch polls until the run reaches a terminal state.
By default, watch mode stops after 15 minutes. Override it:
sleepwalker visibility run https://example.com \ --brand Example \ --prompt "How is Example described?" \ --platform perplexity \ --watch \ --max-wait-seconds 1800If the wait limit is reached, the CLI exits non-zero and tells you which status
command to run later. With --json, the timeout response remains machine
readable.
JSON Output
Section titled “JSON Output”Add --json when another tool should parse the response:
sleepwalker ci run https://example.com --depth full --jsonHuman output is optimized for terminal reading. JSON output returns the raw API response.
Credit Behavior
Section titled “Credit Behavior”The CLI uses the public API. That means:
- read commands are unmetered;
- billable actions use the same credit rules as API, MCP, and Console actions;
- blocked or failed non-billable work follows the same release behavior as the API;
- persisted AI Visibility and Content Intelligence runs appear in the Console.
Public Developer Repo
Section titled “Public Developer Repo”The CLI source lives in the public Sleepwalker developer repository alongside API and MCP examples:
github.com/followanton/sleepwalker
That repository contains client code and examples only. The hosted engine, provider integrations, billing systems, database schema, and deployment operations remain private.