---
title: "CLI"
description: "Implemented commands, flags, environment variables and output behavior."
canonical_url: "https://kitsune.carsxe.com/docs/reference/cli"
markdown_url: "https://kitsune.carsxe.com/docs/reference/cli.md"
last_updated: "2026-11-24"
x_farming_labs_generated_preamble: true
---

# CLI
URL: /docs/reference/cli
LLM index: /llms.txt
Description: Implemented commands, flags, environment variables and output behavior.

# CLI

From a checkout, install workspaces with `bun install` at the repo root, then
run `bun run kitsune <command>` or
`bun run --cwd packages/kitsune kitsune <command>`. Both run in the crawler
package directory. To keep the root as the working directory, invoke
`bun packages/kitsune/src/cli.ts <command>` directly.

The parser supports `--flag value` and bare `--flag`, not `--flag=value` or short
options. Put the URL/file positional argument before bare boolean flags, which
otherwise consume the next non-flag token. Only `--plugin` and `--proxy` have
implemented repeatable-value handling. Unknown flags are parsed but not validated.
No command prints help through a special `--help` implementation: no command
prints usage and exits 0; an unknown command prints usage and exits 1. Caught
errors print `error: <message>` to stderr and exit 1.

## Commands and writes

| Command | Behavior | Writes / stdout |
| --- | --- | --- |
| `kitsune crawl <url>` | Recipe-aware crawl; optional selector or link following. | New `kitsune-results/crawl-<stamp>-<uuid>.jsonl`, result lines and summary. |
| `kitsune batch <file-of-urls>` | Serial crawl of trimmed lines beginning with `http://` or `https://`, recipes selected per URL. | New `kitsune-results/batch-<stamp>-<uuid>.jsonl`, human result lines, progress every 10 URLs and summary. |
| `kitsune probe <url>` | Plain HTTP diagnostic, then browser diagnostic with 3000 ms settle. | HTTP status/time/bytes/verdict; final browser URL/readiness/verdict/title/content counts, forms (up to 8 fields each), 240-character text sample. No result file. |
| `kitsune init <url>` | Inspects with browser, scaffolds a recipe. | `packages/kitsune/recipes/<name>.json` in a source checkout, pretty JSON and refinement hint. Existing recipe at that path is overwritten. |
| `kitsune sites` | Loads package recipes. | Name, match patterns, extraction mode; no file. |
| `kitsune plugins` | Imports configured plugins without launching Chrome. | Plugin inventory, active solver marker and multiple-solver note; no file. |
| `kitsune doctor` | Checks Chrome, proxies, solver keys and egress. | Check lines and parsed proxy form; no file. |

Chrome-backed commands use fixed CDP ports: crawl `9420`, batch `9421`, probe
`9422`, init `9423`. There are no CLI port, headless, output-directory or timeout
flags. Chrome itself may create/use a browser profile; the writes column lists
command data outputs.

## Crawl flags

| Flag | Default | Behavior |
| --- | --- | --- |
| `--value V` | Unset | Passed to a recipe query or site plugin in single-URL crawl. Not forwarded in follow mode. |
| `--selector CSS` | Unset | Forces browser selector extraction to `{ value: ... }`. A missing selector becomes empty when the result would otherwise be ok and has no solved metadata. |
| `--recipe NAME` | Host-matched recipe | Picks an exact recipe name; an unmatched name leaves the recipe undefined. |
| `--json` | False | Prints each record as compact JSON. Summary and follow messages are still printed to stdout. |
| `--follow REGEXP` | Unset | Breadth-first follow of extracted `data.links` on the starting host; regexp applies to pathname + search. Takes precedence over selector. |
| `--depth N` | `1` | Maximum follow depth; start URL is depth 0. Only used with follow. |
| `--limit N` | `25` with follow, otherwise `1` | Follow page limit, including start URL. Only used with follow. |

Follow mode requires a top-level `links` array in extracted data. It de-duplicates
URLs and waits 200 ms between processed pages in addition to crawler pacing.
Flags for numeric values use `Number(value)` with no range validation.

## Batch flags

| Flag | Behavior |
| --- | --- |
| `--input FILE` | Alternative to the positional file, which takes precedence. |

Batch always prints human output. It does not consume crawl-only flags such as
`--json`, `--value`, `--recipe`, `--selector`, `--follow`, `--depth` or `--limit`.

## Shared flags and plugin loading

| Flag | Commands using it | Behavior |
| --- | --- | --- |
| `--proxy SPEC` | crawl, batch, probe, init, doctor | Repeatable; replaces all proxy environment input. |
| `--solver ./p.ts` | crawl, batch, probe, init, plugins | Loaded before all other plugins; first registered solver becomes active. |
| `--plugin ./p.ts` | crawl, batch, probe, init, plugins | Repeatable plugin module paths. |

`sites` reads no flags. `doctor` reads proxy flags but does not import plugins.
Module paths resolve from the process working directory. Each module must default
export a plugin object or a zero-argument factory (which may be async).

Loading order is `--solver`, `KITSUNE_SOLVER`, comma-separated `KITSUNE_PLUGINS`,
then repeatable `--plugin` entries. `--solver` does not suppress `KITSUNE_SOLVER`;
both load if supplied. Only the first solver is active in a launched host;
duplicate names fail registration. The inventory command lists the loaded array
without constructing a host, so its display follows loading order, not enforce
ordering or duplicate validation.

Proxy strings support `scheme://user:pass@host:port`, `user:pass@host:port`,
`host:port@user:pass`, `host:port:user:pass`, `user:pass:host:port`, `host:port` and
`scheme://host:port`. Schemes are http, https, socks4 and socks5; an omitted scheme
is http. Lists may use newline, comma or semicolon separators, or a JSON array.
Parsed duplicates are removed. One proxy is picked when the browser launches;
this does not rotate the browser's identity per URL.

## Environment

| Variable | Actual behavior |
| --- | --- |
| `PROXY_URL`, `PROXIES`, `PROXY_LIST` | First variable in this order that yields a nonempty parsed list wins when no `--proxy` is supplied. |
| `KITSUNE_SOLVER` | One plugin module path, loaded after the flag solver. |
| `KITSUNE_PLUGINS` | Comma-separated plugin module paths. |
| `HEADLESS` | Exactly `1` enables headless Chrome; otherwise headed. |
| `JITTER_MIN_MS` | Parsed as a number, default `2500`, when constructing CLI pacing helpers. |
| `JITTER_MAX_MS` | Advertised in CLI help/comments but not read by the implementation. |
| `CAPMONSTER_API_KEY` | Used by loaded CapMonster solver; checked by doctor. |
| `CAPSOLVER_API_KEY` | Used by loaded Capsolver solver; checked by doctor. |
| `TWOCAPTCHA_API_KEY` | Used by loaded 2Captcha solver; checked by doctor. |

The CLI constructs pacing helpers from `JITTER_MIN_MS` (and recipe pace on
crawl), then calls `kit.pace.merge`. Currently merge copies learned domain state,
not base/max settings; a fresh helper has none, so these settings do not replace
the kit's default 800 ms base. No plugins or paid solvers load merely because an
API key is present.

## Output shapes

Human crawl/batch result lines are:

```ts
// mark is 'OK  ' for ok, otherwise verdict.toUpperCase().padEnd(4)
`${mark} [${r.tier}] ${r.url}  ${r.ms}ms  ${r.reason}`
```

Crawl `--json` emits `JSON.stringify(record)` per result. Both commands end with:

```ts
// Values shown here are placeholders for the actual summary values.
'===== SUMMARY ====='
'verdicts: { ... }'
'tiers:    { ... }'
'attempts: <total>   avg <avgMs>ms   rejection rate <rejectionRate>%'
'  <host>: <ok>/<total> ok'
'results: <store.file>'
```

Despite the `attempts` label, total counts stored final URL records, not internal
browser attempts. Results are flushed per JSONL line. Paths are relative to the
working directory; root `bun run kitsune` therefore writes results beneath
`packages/kitsune/kitsune-results`. See [Result records](/docs/reference/records).

### Plugins inventory

Name is `name@version` if version exists, padded to 24 characters. Each line
then shows `site` when present and `SOLVER*` for the first solver, `solver` for
other solvers, followed by the description. Trailing whitespace is trimmed.

```ts
// Exact line formatter (p is a loaded plugin, active is the first solver):
const name = p.version ? `${p.name}@${p.version}` : p.name
const flags = [p.site ? 'site' : '    ', p.solver ? (p === active ? 'SOLVER*' : 'solver ') : '       '].join(' ')
`${name.padEnd(24)} ${flags}  ${p.description ?? ''}`.trimEnd()
// With multiple solvers, a preceding line:
'note: 2 solvers registered, only capmonster is active'
// With none:
'no plugins loaded — pass --plugin ./plugin.ts or set KITSUNE_PLUGINS'
```

### Doctor

Doctor checks the hardcoded Chrome path
`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`, parsed proxies,
three key presences, and direct `https://ipinfo.io/json` egress. With a pool it
also requests egress for up to five proxies. Missing checks print crosses;
they do not themselves cause a nonzero exit.

```ts
// Each initial check: `${ok ? '✓' : '✗'} ${name.padEnd(14)} ${detail}`
// Check names, in order:
['chrome', 'proxies', 'capmonster key', 'capsolver key', '2captcha key', 'egress']
// Proxy checks and final line:
'✓ proxy egress   <scheme://host:port> -> <ip> <city> <country> <org>'
'✗ proxy egress   <scheme://host:port> <error message>'
'parsed form: <host:port:user:pass or n/a>'
```

Chrome detail is the path. Proxies detail is `none (direct)` or
`<size> parsed (<redacted proxy> …)` (ellipsis only for multiple proxies).
Key detail is `configured` or `missing (plugin will skip)`. Direct egress detail
is `<ip> <city> <country> <org>` or `unreachable`. Most proxy displays redact
credentials, but the final parsed form uses `proxyLine` and includes credentials
for the first configured proxy.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
