Command-line reference
Every discovery command and its options, the JSON output, exit codes and citation formats - for the curious, for power users, and for checking what your agent ran.
#Who this is for
You never have to type these commands: your AI agent runs them, and every one shows up on the Agent log screen. This page is for checking what an agent did, for running a quick check yourself (discovery doctor is handy), and for power users.
The tool installs from the Start Up screen (Install command-line tool). On a Mac it is ~/.local/bin/discovery; on Windows %LOCALAPPDATA%\Discovery Engine\bin\discovery.cmd. If it isn't on your PATH, run it by that full path.
Every command has --help with examples:
discovery --help
discovery search --helpdiscovery agent-guide prints the complete guide for AI agents (the same text the app writes to AGENTS.md and CLAUDE.md).
#How the tool behaves
- It shares the app's state. When the app is running, the command talks to its engine. When the app isn't running, the command opens the case itself.
- It works on the current case (the one opened last in the app) unless you name another with
--case. - It shows the case as written: real names, each file's real name and path, a
file://link to the file, and adiscovery-engine://link that opens the document in the app. - Every call is recorded in the case's agent log.
- It never prompts when it isn't run from an interactive terminal. A command that needs a person fails with exit code 5 instead.
#Global options
| Option | What it does |
|---|---|
--json | Print machine-readable JSON (schema discovery.v1). Accepted anywhere on the command line. Setting DISCOVERY_JSON=1 does the same. |
--case CASE | Work on this case (by ID, from case list) instead of the current one. Put it before the command name: discovery --case c3fa9c1d2e4b search …. It doesn't change which case is current. The environment variable DISCOVERY_CASE does the same. |
--help | Show help for any command. |
#JSON output
With --json, every reply is one JSON document:
{"schema": "discovery.v1", "command": "doctor", "ok": true, "data": {}}A failure has "ok": false and an error with code, message and hint. ok is true exactly when the exit code is 0.
Long-running commands (models fetch, watch, ingest run, ingest rescan) print JSON Lines: progress lines with an event key first, then the usual reply as the last line.
#Exit codes
| Code | Meaning |
|---|---|
| 0 | OK |
| 1 | Error |
| 2 | Usage (the command was typed wrong) |
| 3 | Not found |
| 4 | Blocked by privacy or access (for example, agent access is off for the case) |
| 5 | Needs a person to confirm or act |
| 6 | Busy: the app or another command is changing the case; wait and retry |
| 7 | Engine unavailable: the app's engine stopped mid-command; run it again |
| 8 | Over budget (belongs to the app's own AI, off in this version) |
#Citation formats
Commands accept the same citations the app shows: DOC-0417 p.2, EMAIL-0007 msg 3, SHEET-0033 Ledger!row 118, AUD-0004 00:16, VID-0003 00:05 screen, or a Bates number. See Citations, IDs and Bates numbers.
#Setup and health
| Command | What it does |
|---|---|
discovery version | Print the engine version. |
discovery doctor | Check the installation: Python, the data folder, the database extensions, the OCR engine and each model. Exits 1 if any check fails; each failed check says how to fix it. |
discovery agent-guide | Print the Markdown guide for AI agents. |
discovery models list | List the downloadable models and whether each is installed. |
discovery models fetch NAME | Download a model, check it against its pinned checksum and install it (a speech model also fetches the voice detector). Names: parakeet-v2-int8, silero-vad, spacy-en-lg, e5-small-int8, and the optional parakeet-v3-int8. |
#Cases
| Command | Options | What it does |
|---|---|---|
case list | List the cases by ID; the current one is marked *. Names and folders aren't shown. | |
case create NAME | --source PATH (required) | Create a case over a folder. It isn't read until ingest run. |
case open CASE | Make a case the current one. | |
case info [CASE] | The case's ID, database version and file counts by status. | |
case relink [CASE] | --source PATH (required) | Point a case at its folder's new location. |
case export [CASE] | --out PATH (required) | Write the whole case to one .decase file. A person must confirm at a terminal. |
case import FILE | --source PATH, --added SOURCE_ID=PATH (repeatable), --replace | Add a case exported elsewhere. A person must confirm at a terminal. Then ingest rescan checks for changes. |
#Reading the case
| Command | Options | What it does |
|---|---|---|
status | Job counts per stage, time left, what's blocked and why, files searchable. | |
watch | --until-idle, --interval SECONDS (default 1) | Follow progress until stopped, or until nothing is running. Only looks; doesn't start reading. |
ingest run | --workers N | Read the case's files through every stage, then stop. Resumes an interrupted run. If the app is already reading, it follows that run. |
ingest rescan | --workers N | Look for new, changed and removed files, then read what's pending. Exits 6 while a run is going. |
ingest estimate | How long reading will take, by kind of file, without reading anything. | |
ingest timing | --runs N (default 5) | Where each run's time went, and the estimate of time left. |
ingest benchmark | Measure this computer's speed score (10 to 30 seconds, every core). Exits 6 while files are being read. | |
jobs list | --stage inventory|extract|detect|sanitize|index, --status pending|running|done|failed|held, --limit N (100), --offset N | List jobs, one per file and stage. |
jobs retry | --file-id N (repeatable), --stage STAGE | Put failed jobs back in the queue. |
log show | --lines N / -n N (100), --grep TEXT | The end of the activity log. Works even when the engine is stuck. |
log path | Where the activity log is, and its level. |
--workers defaults to half the processor cores, but no more than fit in memory (about 2.5 GB each).
#Finding evidence
#Filters shared by many commands
search, timeline, doc list, doc cards, review start and review add accept:
| Option | Meaning |
|---|---|
--kind KIND | Only this kind: pdf, image, tiff, docx, txt, eml, msg, xlsx, csv, audio, video, … Repeatable. |
--from YYYY-MM-DD / --to YYYY-MM-DD | Only documents dated on or after / on or before. |
--undated / --no-undated | With a date range, keep undated documents (the default) or not. (Not on timeline.) |
--category ID | Only documents with this category. Repeatable. |
--person NAME | Only documents mentioning this person or organization, written as you'd read it. Repeat for documents mentioning all of them. |
--folder all|confidential|other | All files (default), only the confidential folder, or everything else. |
#Commands
| Command | Options | What it does |
|---|---|---|
search QUERY | --mode hybrid|keyword|semantic (default hybrid), the filters, --limit N (20, up to 100), --all, --count-by month|year|kind|person|document (repeatable), --any, --sort date|passages|id, --offset N | Search by words and meaning. Each hit has its citation, a snippet and links. --all lists every document holding the words; --count-by counts them. |
segment show LOCATION | One passage's full text by its citation, with the citations before and after it. | |
doc list | the filters, --limit N (100), --offset N, --ocr / --no-ocr | The case's documents. |
doc show DOCUMENT | --text, --offset N, --limit N (1000) | One document (by ID, Bates number or citation) and the citations of its parts; --text includes the text. |
doc cards [DOCUMENTS…] | --query WORDS / -q, --any, --thread ID, the filters, --sort date|id, --limit N (50), --offset N | Many documents at once as short cards: what each is, who wrote to whom, people named, thread, copies, opening text. |
thread show DOCUMENT | Every message of an e-mail thread, oldest first. | |
timeline [QUERY] | --any, the filters, --by day|month|year, --limit N (200), --offset N | Dated documents in date order. |
people [NAME] | --type PERSON|ORG|ACCOUNT|ADDRESS|PHONE|EMAIL|GOV_ID|DOB (repeatable), --limit N (50), --min-docs N | The people and organizations in the case, or one of them in detail. |
contacts [NAME] | --with NAME, --limit N (50), --offset N | Who wrote to whom, from e-mail headers. With --with: every message between two people. |
#Connections
| Command | Options | What it does |
|---|---|---|
connections pair A B | Everything linking two people: shared documents, passages naming both, e-mails each way, identifiers near both, chains through others. | |
connections passages A B | --limit N (50), --offset N | Every passage naming both within about 500 characters, in date order. |
connections path A B | --max-hops N (3), --limit N (10) | The shortest chains of strong links between two people. |
connections estimate | --person NAME, --known-as "LABEL: words", --event "LABEL: words @FROM..TO" (each repeatable) | What a study would look through, and how long it and an agent's reading would take. |
connections study start [NAME] | --person, --known-as, --event (as above), --run / --no-run | Create a study and (by default) run it. |
connections study run STUDY | Run a study again. | |
connections study show STUDY | A study's items and, pair by pair, where they meet. | |
connections study list | The case's studies, newest first (including those made on the Connections screen). | |
connections study evidence STUDY A B | --kind passage|document|email, --limit N (50), --offset N | Where two of a study's items meet (A and B are item numbers). |
connections study review STUDY | --question TEXT | Queue every document where two items meet as a review for the agent to read and mark. |
Example of an event: --event "Wire transfer: wire, transfer @2019-01-01..2019-06-30".
#Reviews
A review is a record of a call (relevant, not relevant, unsure) on each document that could answer a question. It is kept in the case.
| Command | Options | What it does |
|---|---|---|
review start QUESTION | --doc ID (repeatable), --query WORDS / -q, --any, --thread ID, the filters | Queue documents in date order for a question. |
review add REVIEW | same as review start | Add more documents to the end of the queue. |
review next REVIEW | --size N (10) | The next undecided documents, as cards. |
review mark REVIEW DOCUMENTS… | --decision relevant|not_relevant|unsure / -d (required), --why TEXT, --cite "DOC-0017 p.2; EMAIL-0004" | Record the call for one or more documents. The last call counts. |
review status REVIEW | How far it got. | |
review show REVIEW | --decision relevant|not_relevant|unsure|undecided / -d, --limit N (200), --offset N | Each document and its call. |
review list | The case's reviews, newest first. | |
review close REVIEW | Mark a review finished (it can still be read and marked). |
#Highlights
| Command | Options | What it does |
|---|---|---|
highlight list | --status proposed|approved|rejected, --doc ID, --limit N (200), --offset N | The highlights, in document order, with counts per status. |
highlight add LOCATION | --quote TEXT (required), --reason TEXT, --category NAME | Propose a highlight. The quote must be in the passage (exit 3 quote_not_found otherwise); a short quote that appears twice is refused (exit 2 quote_ambiguous). |
highlight issues | --set TEXT (repeatable) | Show the issue list and the categories, or replace the issue list. |
There is no command to approve or reject a highlight. That is done by a person, on the Highlights screen.
#Exports
| Command | Options | What it does |
|---|---|---|
export highlighted-pdfs | --out PATH (required), --real-names | A yellow-highlighted PDF of every document with approved highlights, in a new folder inside --out. |
export exhibit-index | --out PATH (required), --real-names | The exhibit index, XLSX and CSV, in a new folder inside --out. |
From the command line, exports are sanitized by default; add --real-names for the attorney's copy. The output folder can't be inside the case's source folder.
#Your own notes in SQL
| Command | Options | What it does |
|---|---|---|
db schema | What SQL can read (views of the case: documents, segments, files, entities, mentions, highlights, categories, issues, jobs and more) and write (your own tables). | |
db query SQL | --param VALUE / -p (repeatable), --limit N (200), --timeout SECONDS (10) | One read-only SQLite statement. |
db exec SQL | same | One statement that writes your own tables: notes, labels, links, and any table named custom_…. The case's own tables can't be changed. |
#For people, not agents
discovery install-cli puts the command on the computer, like the Start Up button. It's hidden from --help because an agent has no reason to run it.
| Option | What it does |
|---|---|
--add-to-path | Also put the tool's folder on your PATH (zsh profile on a Mac, user Path on Windows). Asks first. |
--yes | Answer yes to that question, for your own scripts. |
If discovery isn't installed yet, you can reach the same commands through the app's bundled Python, for example on a Mac:
"/Applications/Discovery Engine.app/Contents/Resources/engine/python/bin/python3" -I -B -m discovery_engine doctorand on Windows:
& "$env:LOCALAPPDATA\Discovery Engine\engine\python\python.exe" -I -B -m discovery_engine doctor