Reference for the expandai CLI: fetch pages, search snapshots, manage local auth, and install agent integrations.
Reference for the expandai CLI: fetch pages, search existing snapshots, manage local auth, and install agent integrations. Every command, argument, and flag below is documented exactly as the CLI exposes it.
Need the CLI? Start with Quickstart, then come back here for the full command reference. The expandai package is not published yet, so treat install instructions as provisional and get the current install method from Quickstart. Once expandai is on your PATH, the commands here are the complete surface.
expandai fetch https://news.ycombinator.com
expandai fetch
Jump to: Fetch · Highlights · Auth · Agent setup · Cleanup
Commands are grouped by job. Each one is copyable as written.
| Job | Command | What it does |
|---|---|---|
| Fetch | expandai fetch <url> | Fetch a page, print agent-ready Markdown. |
| Fetch | expandai fetch <url> --format json | Fetch a page, print structured JSON. |
| Highlights |
Config is set through environment variables (EXPAND_API_KEY, EXPAND_API_URL) and the local config file under XDG_CONFIG_HOME. See Auth and configuration.
Batched Fetch has no CLI command today. Start and poll batched runs through the API or SDKs. See Batched Fetch.
expandai fetch <url>Fetch a rendered web page and print agent-ready Markdown.
expandai fetch <url>expandai fetch https://news.ycombinator.com| Argument | Required | Description |
|---|---|---|
url | Yes | URL to fetch. Common bare hosts may be normalized to https://...; localhost URLs are supported. Flag-like or otherwise invalid URLs are rejected. |
| Option | Values | Default | Description |
|---|---|---|---|
--format | text, json | text | Controls CLI output format. |
--search | string |
Output. Default text output prints Markdown to stdout. --format json prints structured Fetch output. With --search, text mode prints Highlights snippets instead of the full page.
The CLI does not expose Include Options through an --include flag today, and --format accepts only text or json, not markdown.
Related: Fetch Overview · Output Model · Include Options · API Reference
expandai fetch <url> --format jsonFetch a page and print structured JSON instead of text Markdown.
expandai fetch https://example.com --format jsonJSON output is what you want when a script needs fields — metadata, Markdown, and State JSON when present — rather than terminal Markdown. State JSON is usually included in the main content; large state may be returned by reference instead.
This is not equivalent to every API Include Options combination. The CLI does not expose the nested include controls that the API offers; for that level of control, call the API directly. See Include Options.
--search and expandai search both return Highlights — the most relevant snippets of a page for a query. text/json Both accept --max-results (1–50, default 5) and --min-score (0–1, default 0.6).
expandai fetch <url> --search <query>Fetch a page and return the most relevant Highlights snippets for a query.
expandai fetch https://example.com --search "pricing"This performs a new Fetch, then runs the query against the captured page. It uses inline Fetch JSON Mode with search in the request payload — not the snapshot-search endpoint — so it always recaptures the URL.
Text output includes source and score headers plus an auditable citation link for each snippet. JSON output follows the API result shape. Default corpus behavior is covered on the Highlights page.
Related: Highlights · Output Model · Playground & Replay · fetch.fetchJson
expandai search <snapshotId> <query>Search an existing snapshot without fetching the page again.
expandai search <snapshotId> <query>expandai search 019... "return policy"| Argument | Required | Description |
|---|---|---|
snapshotId | Yes | Existing snapshot ID to search. |
query | Yes | Search query for Highlights. |
| Option | Values | Default | Description |
|---|---|---|---|
--format | text, json | text | Controls CLI output format. |
--max-results | to |
Use search for snapshot reuse: it queries a page you already captured and skips the network round trip. If you do not have a snapshotId yet, run expandai fetch <url> --search <query> instead.
expandai loginStore local credentials for CLI and local integration use. interactive
expandai loginThe command is interactive and supports two paths: browser login and API-key login. API-key auth is the normal production and server path. Credentials are written to the local Expand CLI config file (see Environment and config). Do not paste API keys into shell history; let login prompt for them.
expandai whoamiCheck which Expand account or credential the CLI is using.
expandai whoamiThis is the first command to run when Fetch, MCP, skills, or hooks fail because of auth. If whoami shows the wrong account or no credential, run expandai login.
expandai logoutClear local stored Expand credentials.
expandai logout| Name | Type | Description |
|---|---|---|
EXPAND_API_KEY | env var | API key override for CLI and API clients. |
EXPAND_API_URL | env var | API base URL override, mainly for staging or self-hosted internal use. |
XDG_CONFIG_HOME |
Authored cURL examples authenticate with the API-key header, not bearer:
x-expand-api-key: $EXPAND_API_KEYThese commands wire Expand into local agent hosts: MCP config, the Expand Skill, and native-fetch hooks. The per-host quickstarts own the recommended setup and verification flow — Claude Code, Cursor, Codex, and OpenCode. agent setup
Install and uninstall commands take an explicit <scope> of global or project. Project scope writes files into the current working directory, so run these from the project root you want them in.
expandai mcp run [--docs]Run the local Expand MCP server over stdio.
expandai mcp runexpandai mcp run --docsMCP clients and generated MCP config launch this command; you rarely run it by hand. Plain mcp run exposes the Fetch tools. --docs additionally exposes Expand docs resources. First-class installers do not enable --docs by default. Full tool schemas live in MCP Tools & Resources; there is no hosted or remote Expand MCP server today.
expandai mcp install <host> <scope>Install Expand MCP config for a supported local agent host.
expandai mcp install <host> <scope>Hosts: claude-code, cursor, opencode, codex. Scopes: global, project.
expandai mcp install codex project
expandai mcp install cursor projectexpandai mcp uninstall <host> <scope>Remove Expand MCP config for a supported host and scope.
expandai mcp uninstall codex projectexpandai skill install <host> <scope>Install the Expand Skill for a supported agent host.
expandai skill install <host> <scope>Hosts: claude-code, cursor, opencode, codex. Scopes: global, project.
expandai skill install codex project
expandai skill install claude-code projectSkills teach agents how to use Expand. Project scope writes skill files into the current project — commit them only if you want the skill enabled for collaborators. The command requires an explicit scope; it does not default to project. Detailed behavior lives on the Expand Skill page.
expandai skill uninstall <host> <scope>Remove the Expand Skill for a host and scope.
expandai skill uninstall codex projectexpandai hook install <host> <scope>Install an Expand hook for hosts that can route native web-fetch behavior through Expand.
expandai hook install <host> <scope>Hosts: claude-code, opencode. Scopes: global, project.
expandai hook install claude-code project
expandai hook install opencode projectHook behavior is host-specific. The host pages own the full setup and verification flow.
expandai hook uninstall <host> <scope>Remove an Expand hook for a host and scope.
expandai hook uninstall opencode projectexpandai hook claude-code and expandai hook opencodeRuntime commands invoked by the Claude Code and OpenCode hook integrations. integration runtime
expandai hook claude-code
expandai hook opencodeThese are integration-facing, not primary user commands. Most users should hook install or hook uninstall and never call them directly — the host invokes them when a hook fires.
expandai uninstall [target] [host] [scope]Remove Expand integration files across hooks, skills, and MCP config.
expandai uninstall [target] [host] [scope]target selects a surface such as all, hook, skill, or MCP.host narrows cleanup to a supported host.scope narrows cleanup to global or project files.expandai uninstall
expandai uninstall mcp codex project
expandai uninstall skill claude-code projectProject-scoped cleanup depends on the current working directory. Run cleanup from the same project root you used during installation, or it will not find the files to remove.
| Topic | Page |
|---|---|
| Install and first fetch | Quickstart |
| Human vs. agent routing | Ways to Use Expand |
| Fetch product behavior | Fetch Overview |
| Output fields |
expandai fetch <url> --search <query>| Fetch a page, return Highlights snippets. |
| Highlights | expandai search <snapshotId> <query> | Search an existing snapshot, no recapture. |
| Auth | expandai login | Store local credentials (browser or API key). |
| Auth | expandai whoami | Report the current auth state. |
| Auth | expandai logout | Clear local stored credentials. |
| MCP | expandai mcp run [--docs] | Run the local stdio MCP server. |
| MCP | expandai mcp install <host> <scope> | Install Expand MCP config for a host. |
| MCP | expandai mcp uninstall <host> <scope> | Remove Expand MCP config for a host. |
| Skills | expandai skill install <host> <scope> | Install the Expand Skill for a host. |
| Skills | expandai skill uninstall <host> <scope> | Remove the Expand Skill for a host. |
| Hooks | expandai hook install <host> <scope> | Install an Expand fetch hook for a host. |
| Hooks | expandai hook uninstall <host> <scope> | Remove an Expand fetch hook for a host. |
| Cleanup | expandai uninstall [target] [host] [scope] | Remove installed Expand integration files. |
| none |
| Returns Highlights snippets for the query instead of the full page Markdown. |
--max-results | 1 to 50 | 5 | Maximum Highlights snippets when --search is used. |
--min-score | 0 to 1 | 0.6 | Minimum Highlights relevance score when --search is used. |
1505 |
| Maximum snippets. |
--min-score | 0 to 1 | 0.6 | Minimum relevance score. |
| env var |
Changes where the CLI stores expandai/config.json. |
~/.config/expandai/config.json | file | Default local config path when XDG_CONFIG_HOME is not set. |
| Include controls | Include Options |
| Highlights | Highlights |
| Citations and replay | Playground & Replay |
| Agent setup | Agent Quickstarts |
| Skill behavior | Expand Skill |
| MCP schemas | MCP Tools & Resources |
| Endpoint contracts | API Reference |