Skip to content

CLI Reference

Claude edited this page Oct 30, 2026 · 4 revisions

Checked against v0.7.0 on October 30, 2026.

CLI reference

The command line runs the same code as the app and is meant for debugging, scripting and the build gates (kestrel/cli.py, module docstring). Related pages: REST API, MCP server, Adding a job board adapter.

Kestrel never submits an application or sends a message for you. No command below does either. render only writes a file on your machine, and you send it yourself.

Entry points

pyproject.toml declares one console script under [project.scripts]:

[project.scripts]
kestrel = "kestrel.cli:app"

kestrel.cli:app is a Typer app built in kestrel/cli.py. How you reach it depends on how Kestrel is installed.

Install Command
Source checkout uv run kestrel <command>
Windows installer %LOCALAPPDATA%\Programs\Kestrel\kestrel-cli.exe <command>
macOS app /Applications/Kestrel.app/Contents/MacOS/Kestrel <command>
Linux AppImage the AppImage file itself, ./Kestrel.AppImage <command>

The paths for the installed apps come from docs/DEVELOPERS.md. In a packaged build the single entry point is kestrel/desktop/__main__.py. With no arguments it opens the desktop window. With any argument it hands the arguments to the same Typer app and sets the program name to kestrel, so --help reads the same whichever executable you ran.

& "$env:LOCALAPPDATA\Programs\Kestrel\kestrel-cli.exe" doctor --quick
uv run kestrel doctor --quick

There is no kestrel/__main__.py, so python -m kestrel does not work. To open the desktop window from source, run uv run python -m kestrel.desktop (docs/DEVELOPERS.md).

Global behavior

The root app defines no options of its own. Running kestrel --help lists only the three options Typer adds to every app:

Option Meaning
--install-completion Install shell completion for the current shell.
--show-completion Print the completion script.
--help Show help and exit.

There is no --version, --verbose, --quiet, --config-dir or --data-dir. Use the version command to print the version. To point Kestrel at a different data folder, set the KESTREL_DATA_HOME environment variable (kestrel/paths.py, data_home()).

Before any command except reset runs, the root callback seeds the default config files into the data folder, and ignores any error while doing so (kestrel/cli.py, _main). reset is excluded so that seeding cannot make a folder look like a Kestrel folder just before reset judges it.

Where the data lives (kestrel/paths.py):

OS Data folder
Windows %LOCALAPPDATA%\Kestrel
macOS ~/Library/Application Support/Kestrel
Linux $XDG_DATA_HOME/kestrel, or ~/.local/share/kestrel

Inside it, config/ holds the YAML files, data/kestrel.db is the SQLite database, .env holds API keys, and runtime.json records the port of a running server.

Command overview

Command Purpose
setup Guided first run: hardware profile, Ollama or a hosted provider, doctor.
doctor Preflight report.
models build Build the derived Ollama models.
db upgrade, db current Run or show database migrations.
provider status, test, set-key, use Manage the hosted backend used for Tier 3.
scan Fetch sources, normalize, dedupe, enqueue embeddings.
run Run the tiered pipeline.
worker Drain the queue without a new Tier 0 sweep.
evaluate Force one opportunity through Tier 1 and Tier 2.
escalate Preview or send one opportunity to the Tier 3 hosted frontier.
doc seed, doc import Seed example documents, decompose a resume.
render Render a document master to PDF.
calibrate, train Learning loop: weight proposals and reranker training.
goldset regen Rebuild a gold set from your labels.
bench Benchmark models or prompt versions.
export Dump the pipeline to JSON or CSV.
backup, restore Back up or restore the data folder.
serve Run the API and worker without the desktop window.
mcp Run the MCP server alone.
reset Back up, then wipe to a first-run state.
version Print the version.
screenshots Capture documentation screenshots (source checkout only).
research Run company research for an organization Kestrel already knows.

Setup and health

kestrel setup

Guided first-run setup (kestrel/setup.py). It runs as the callback of the setup sub-app, so it takes options but no subcommand. With no options it detects hardware, finds or installs Ollama, pulls and builds models, and runs the doctor. Each step prints its result and the command it ran or wants you to run (docs/DEVELOPERS.md).

Option Meaning
--profile TEXT Use this hardware profile instead of the detected one. The profile names listed in docs/DEVELOPERS.md are cpu_8gb, gpu_12gb, gpu_16gb, gpu_24gb, mac_16gb, mac_32gb and mac_64gb.
--yes, -y Run every step without asking.
--dry-run Print every step and the commands it would run, and run nothing.
--hosted No local model: run every tier on a hosted provider under your own key.
--provider TEXT With --hosted: openrouter (default), openmodel, anthropic or openai.
--free With --hosted: offer only models priced at zero (OpenRouter).
--model TEXT With --hosted: one provider model id for every tier.
--model-tier1 TEXT With --hosted: the Tier 1 (and trigger) model id.
--model-tier2 TEXT With --hosted: the Tier 2 (and Tier 3, frontier) model id.
--model-docsel TEXT With --hosted: the document selection model id.
--accept-hosted-disclosure With --hosted: accept the Hosted mode disclosure without the prompt. --yes never accepts it for you.
kestrel setup --dry-run
kestrel setup --profile gpu_16gb --yes
kestrel setup --hosted --provider openrouter --free

The exit code is whatever run_setup returns, and is non-zero when a blocking step fails.

kestrel doctor

Full preflight as a text report. It exits 1 when any check is a blocking failure and 0 otherwise (kestrel/cli.py, doctor).

Option Meaning
--quick Skip the slow live needle and thinking probes.

The doctor also checks that the MCP port is free when MCP is enabled (kestrel/doctor.py, _check_mcp_port).

kestrel models build

Runs ollama create kestrel-<tier> -f <Modelfile> for each Modelfile.* in kestrel/resources/models/. The shipped files are Modelfile.tier1, Modelfile.tier2, Modelfile.tier3 and Modelfile.docsel, so the models are kestrel-tier1, kestrel-tier2, kestrel-tier3 and kestrel-docsel. Exits 1 if no Modelfiles are found or any build fails. It requires ollama on the PATH.

kestrel db upgrade and kestrel db current

db upgrade runs all pending Alembic migrations, creating the schema on first run, and prints the revision it reached. db current prints the applied revision, or not initialized. The app runs migrations itself at startup, and most commands call migrate.run_migrations() before they touch the database.

Hosted backend

provider manages the external backend used for Tier 3 escalation. Backend names are frontier (OpenRouter), openmodel, anthropic and openai (_BACKEND_HELP in kestrel/cli.py).

Command Behavior
kestrel provider status Print the frontier tier's backend, provider, protocol, base URL, model, and whether the key is present.
kestrel provider test [--backend NAME] [--models N] Check the key with the provider and list up to N models (default 15, 0 for none) that can honor a JSON schema. Sends one authenticated metadata request and no operator data. Exits 2 for an unknown backend.
kestrel provider set-key BACKEND Prompt for a key (hidden input) and write it to .env in the data folder. Never written to YAML. Exits 2 for an unknown backend.
kestrel provider use BACKEND MODEL Point Tier 3 at one backend and model by writing the llm.tiers.frontier.backend and llm.tiers.frontier.model setting rows. No restart needed.
kestrel provider set-key frontier
kestrel provider test --models 5
kestrel provider use frontier <model-id>

Ingestion and pipeline

kestrel scan

Fetch, normalize, dedupe and enqueue embeddings for sources. Job boards and ATS sources never call a model. Only signal sources (filings and feeds) do, through the trigger tier.

Option Meaning
--source TEXT Run one source, matched by its exact name. A disabled source named here still runs.
--track TEXT Run every enabled source on a track.
--all Run every enabled source.
--hosted Use the hosted models for the trigger tier.
--local Use the local Ollama models.

With none of --source, --track or --all, the command prints specify --source NAME, --track T, or --all and returns. If more than one is given, --source wins, then --track, then --all (_scan). --hosted and --local are mutually exclusive. If hosted mode is not configured, the command prints the reason and exits 1.

Each source prints one line, name [kind] -> status: counts, with error=... appended on failure. A source error makes the run partial. It does not stop the batch.

kestrel scan --all
kestrel scan --track consulting
kestrel scan --source "SAM.gov federal IT contracts"

There is no kestrel ingest command and no option that takes several source names. To add a single posting by hand, use POST /api/opportunities/ingest (REST API) or the ingest_opportunity MCP tool (MCP server).

kestrel run

Run the tiered pipeline: a Tier 0 sweep, then drain Tier 1, then Tier 2. Ctrl+C stops gracefully. In-flight items finish and the rest stay pending, so the next run resumes them.

Option Meaning
--tier INTEGER Drain only this tier, 1 or 2. Without it the full pipeline runs.
--track TEXT Restrict the Tier 0 sweep to one track.
--limit INTEGER Cap how many new opportunities enter Tier 0 this run.
--hosted Run on the hosted models assigned under Settings > Hosted.
--local Run on the local Ollama models.

The default mode is the one saved in Settings. The command prints run mode: <mode> first. With --tier 1 or --tier 2 it prints a single tier N: ... done, ... errors line, and --track and --limit are ignored in that branch.

kestrel run
kestrel run --tier 2
kestrel run --track employment --limit 50 --local

kestrel worker

Drain embeddings, then Tier 1, then Tier 2, without a new Tier 0 sweep. Ctrl+C stops gracefully. It takes no options.

kestrel evaluate OPPORTUNITY_ID

Force one opportunity through Tier 1, then Tier 2 if Tier 1 passes or promotes it. The opportunity's stage is reset to t0_pass first. Earlier evaluation rows are kept as history and new ones are appended. It takes no options and uses the Settings run mode. An unknown id prints opportunity N not found.

kestrel escalate OPPORTUNITY_ID

Tier 3: send one opportunity to the hosted frontier model. By default it only previews and transmits nothing.

Option Meaning
--confirm Actually transmit the exact payload that was previewed.
--show-payload Print the full payload that would be sent.

The preview shows the destination, model, whether confidential mode redacted the employer, an estimated token count and a confirmation token. If the preview reports a problem, the command exits 2 and does not send. This is the one command whose purpose is to send your data to a third party, and it sends it to a model provider for scoring, not to an employer. It never submits an application.

kestrel escalate 42 --show-payload
kestrel escalate 42 --confirm

Documents

kestrel doc seed

Seed the fictional example document masters (a resume and a capability statement) and the shipped layouts. Prints the new ids.

kestrel doc import FILE

Decompose a Markdown resume or capability statement through prompt P7 and print the proposal. Nothing is written unless you pass --accept, and acceptance is also withheld when the proposal carries flags such as too many derived variants.

Option Default Meaning
--accept off Write the proposal to the database.
--track TEXT employment Track for the document.
--doc-kind TEXT resume Document kind.
kestrel doc import resume.md
kestrel doc import resume.md --accept

There is no doc assess command. The assessment runs from the Documents page.

kestrel render MASTER_ID

Render a document master to PDF.

Option Meaning
--opportunity INTEGER Run the P3 selection for this opportunity, then render the selected variants.
--redact Redact organization names. Confidential mode in Settings also forces redaction.

Without --opportunity the default configuration is used. Selection picks among your own variants and never writes new text. If selection fails, defaults are used and the output is flagged [DEFAULTS USED. If the PDF exceeds the page limit, the output is flagged and hide suggestions are printed. There are no --layout or --output options. Output paths come from the document service and are printed after rendering. If the master id does not exist, the command points you to kestrel doc seed.

kestrel render 1
kestrel render 1 --opportunity 42 --redact

Learning loop

Command Behavior
kestrel calibrate [--track TEXT] Recompute dimension-weight proposals from your labels, for both tracks by default. It never applies a proposal. Accept or reject it in the app, or through POST /api/learning/calibration/{cal_id}/accept (REST API). With too few labels it prints that no proposal is possible yet.
kestrel train [--track TEXT] Train and evaluate the reranker, for both tracks by default. It is promoted only if all four criteria hold on held-out data. Prints n_labeled, promoted, the criteria and metrics, or the reason it did not train.
kestrel goldset regen --track TEXT Write goldset.<track>.regenerated.jsonl in the evals folder from your labels. bench uses it in place of the shipped examples. --track is required and must be employment or consulting, otherwise exit 1. It never overwrites the goldset.<track>.jsonl placeholder.

calibrate has no --accept or --reject option, and train has no --force option.

Benchmarking

kestrel bench runs the Tier 2 evaluation prompt against the gold set and reports first-attempt JSON validity, tokens, latency, items per minute, gold-set agreement and a projected 500-item wall-clock time, per model and per track.

Option Meaning
--models TEXT Required. Comma-separated Ollama model names.
--prompt-version TEXT Comma-separated prompt versions such as evaluate/v1.

Vary the models or the prompt versions, never both in one run. Models that are not comparable to a real Tier 2 candidate are listed with a warning before the table. Before each table it prints which answer key the track used, "your labels" or "the shipped examples", and it warns when that key is still the placeholder. The key is looked up in the order described in Benchmarking, including a copy packaged inside the app, so bench also works in the installed app. On a configuration error it exits 2. There is no --hosted or --format option; bench takes Ollama model names only (kestrel/cli.py, bench).

kestrel bench --models model-a,model-b
kestrel bench --models model-a --prompt-version evaluate/v1,evaluate/v2

Data and server commands

kestrel export

Dump opportunities with their latest Tier 2 evaluation. The columns are id, track, title, org, stage, verdict, score, ghost_score, liveness, closed_reason and url. closed_reason says why a posting was marked closed (http_404, http_410 or page_text) and is empty for a posting still open or closed before the column existed. Confidential mode redacts the employer in the output, because an export is a file on disk.

Option Default Meaning
--format TEXT json json or csv.
--track TEXT all Filter to one track.
--out TEXT stdout Output file.

There is no stage filter.

kestrel backup and kestrel restore

backup [--out DIR] writes a timestamped zip containing a consistent copy of the database, the YAML config and the generated documents and prep packs. It never contains .env or the LAN shared key, so API keys and that secret are not in a backup (kestrel/services/backup.py). Without --out the zip goes to the data folder.

restore PATH validates the whole zip before touching anything, snapshots the current database to kestrel.db.pre-restore-<UTC>, restores, then runs migrations so a backup from an older version is upgraded. If the app is running it exits 2 and tells you to restore from Settings or quit first. A rejected zip exits 1.

kestrel serve

Start the API and worker without the desktop window. This is how Kestrel runs on macOS and Linux from a source checkout.

Option Meaning
--no-worker Serve the API without the worker.
--open / --no-open Open the UI in a browser once the server is healthy. The default is on for macOS and Linux when a display is available and KESTREL_HEADLESS=1 is not set, and off on Windows.

There is no --port option. The server binds 127.0.0.1 (all interfaces only when LAN access, server.bind_all, is on) on the first free port of the ladder 8765 to 8774, and falls back to an OS-assigned port if all ten are busy (kestrel/web/serve.py, PORT_LADDER). It writes {"port": ..., "pid": ...} to runtime.json in the data folder, prints the URL, and removes the file when it stops. Ctrl+C stops it. See REST API for what the server exposes.

kestrel mcp

Start the MCP server alone over SSE. The --port option overrides mcp.port, which defaults to 9110. It binds 127.0.0.1 unless LAN access is on, in which case a non-loopback client needs the shared secret. See MCP server.

kestrel reset

Start over from nothing: write a backup zip beside the data folder, then delete the database, config, logs and renders. Meant for validating a build from a clean state.

Option Meaning
--keep-keys Keep .env (API keys). Everything else is removed.
--yes, -y Do not ask for confirmation.

It refuses with exit 2 if Kestrel is running, or if the folder does not look like a Kestrel data folder. Declining the prompt exits 1. API keys are never in the backup, so without --keep-keys they are gone.

Other commands

kestrel version prints the version string. kestrel screenshots runs scripts/capture_screenshots.py against fictional seed data to regenerate docs/images/. It needs a source checkout and Edge through Playwright, and exits 2 if the script is missing. kestrel research ORG [--id N] runs the same company research as the role page, through run_org_research in kestrel/services/org_research.py. The organization must already exist: the name is matched against normalized org names, exactly first and then by substring, and nothing is created. No match exits 1. More than one match lists the ids and exits 1, and --id picks one. It reads public pages only: a company's own site, with robots.txt checked, and SEC EDGAR, under its own fair-access rules. It sends nothing anywhere. When fewer than two sources were available it prints INSUFFICIENT instead of a summary, as the sample-size rule requires. Otherwise it prints the summary, signals with their sources, unknowns and the suggested angle.

Clone this wiki locally