> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sila.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Log in, scrape pages, and run crawls from your terminal with the sila command.

The Sila CLI is the `@sila-sh/cli` package. It needs Node.js 20 or later and has no other dependencies.

```bash theme={null}
npx -y @sila-sh/cli@latest --help
```

Install it globally to get the `sila` command:

```bash theme={null}
npm install -g @sila-sh/cli
```

## Get set up

`sila init` logs you in, installs the Sila agent skills, and prints the MCP setup lines.

```bash theme={null}
npx -y @sila-sh/cli@latest init --all --browser
```

| Flag | Description |
| - | - |
| `--all` | Install the skills for every supported agent without asking. |
| `--agent <name>` | Install the skills for one agent. Repeat the flag for more agents. |
| `--browser` | Open the login page in your browser. |
| `--skip-auth` | Skip login. |
| `--skip-skills` | Skip the skills install. |

`init` skips login when you already have a saved key that works. Without `--all` or `--agent`, the skills installer asks which agents to use.

## Log in

```bash theme={null}
sila login
```

The CLI prints a link, or opens it with `--browser`. Open the link, check the terminal name on the page, and click **Authorize**. The CLI waits up to 10 minutes, then saves a new API key.

To use an API key you already have:

```bash theme={null}
sila login --api-key sila_your_key
```

The CLI checks the key before it saves it.

| Command | Description |
| - | - |
| `sila login [--browser] [--api-key <key>]` | Log in with the browser or with a key. |
| `sila logout` | Remove the saved key. The key stays valid until you revoke it on the **API keys** page. |
| `sila status` | Show the CLI version, where the key comes from, your plan, and credits used and remaining. `sila --status` does the same. |

## Scrape a page

```bash theme={null}
sila scrape https://example.com
```

| Flag | Description |
| - | - |
| `-f <formats>` | Comma-separated list of `markdown`, `html`, `signals`, `siteInfo`, `screenshot`. Default `markdown`. |
| `--render` | `auto`, `never`, or `always`. Default `auto`. |
| `-o <file>` | Write the output to a file instead of the terminal. |
| `--json` | Print the full JSON response. |

With a single `markdown` or `html` format, the CLI prints the raw text. With any other formats, or with `--json`, it prints formatted JSON.

```bash theme={null}
sila scrape https://example.com -f markdown,signals
sila scrape https://example.com -f html -o page.html
```

See [Scrape a page](https://docs.sila.sh/api-reference/scrape.md) for the response and [Credits and plans](https://docs.sila.sh/credits-and-plans.md) for costs.

## Crawl a site

```bash theme={null}
sila crawl https://example.com --limit 50 --wait -o ./out
```

| Flag | Description |
| - | - |
| `--limit <n>` | Maximum pages to crawl. |
| `--no-robots` | Ignore `robots.txt`. |
| `--wait` | Wait for the crawl to finish, then fetch every page. |
| `-o <dir>` | Write each page as a markdown file under `<dir>/<host>/`. The home page is `index.md`. Implies `--wait`. |

Without `--wait` or `-o`, the command prints the crawl ID and returns. With `--wait` and no `-o`, it prints a summary instead of writing files.

Manage a crawl by ID:

| Command | Description |
| - | - |
| `sila crawl status <id>` | Show the crawl status and stats. |
| `sila crawl pages <id> [--cursor <n>]` | Show one batch of stored pages. Pass `nextCursor` as `--cursor` for the next batch. |
| `sila crawl cancel <id>` | Stop a queued or running crawl. |

See [Create a crawl](https://docs.sila.sh/api-reference/crawls-create.md) for how crawls work.

## Where the CLI looks for your key

The CLI uses the first key it finds:

1. The `--api-key` flag.
2. The `SILA_API_KEY` environment variable.
3. The saved login in `~/.config/sila/config.json`. If `XDG_CONFIG_HOME` is set, the file is `$XDG_CONFIG_HOME/sila/config.json`.

`sila login` writes the file with owner-only permissions.

| Variable | Description |
| - | - |
| `SILA_API_KEY` | API key to use. |
| `SILA_API_URL` | API base URL. Default `https://api.sila.sh`. |
| `SILA_APP_URL` | Dashboard URL used for login. Default `https://sila.sh`. |

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Success. |
| `1` | The command failed. The CLI prints the API error as `code: message`. See [Errors](https://docs.sila.sh/errors.md). |
| `2` | Authentication failed. Run `sila login`. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.