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:

bash
discovery --help
discovery search --help

discovery 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 a discovery-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

OptionWhat it does
--jsonPrint machine-readable JSON (schema discovery.v1). Accepted anywhere on the command line. Setting DISCOVERY_JSON=1 does the same.
--case CASEWork 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.
--helpShow help for any command.

#JSON output

With --json, every reply is one JSON document:

json
{"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

CodeMeaning
0OK
1Error
2Usage (the command was typed wrong)
3Not found
4Blocked by privacy or access (for example, agent access is off for the case)
5Needs a person to confirm or act
6Busy: the app or another command is changing the case; wait and retry
7Engine unavailable: the app's engine stopped mid-command; run it again
8Over 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

CommandWhat it does
discovery versionPrint the engine version.
discovery doctorCheck 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-guidePrint the Markdown guide for AI agents.
discovery models listList the downloadable models and whether each is installed.
discovery models fetch NAMEDownload 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

CommandOptionsWhat it does
case listList 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 CASEMake 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), --replaceAdd a case exported elsewhere. A person must confirm at a terminal. Then ingest rescan checks for changes.

#Reading the case

CommandOptionsWhat it does
statusJob 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 NRead 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 NLook for new, changed and removed files, then read what's pending. Exits 6 while a run is going.
ingest estimateHow 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 benchmarkMeasure 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 NList jobs, one per file and stage.
jobs retry--file-id N (repeatable), --stage STAGEPut failed jobs back in the queue.
log show--lines N / -n N (100), --grep TEXTThe end of the activity log. Works even when the engine is stuck.
log pathWhere 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:

OptionMeaning
--kind KINDOnly this kind: pdf, image, tiff, docx, txt, eml, msg, xlsx, csv, audio, video, … Repeatable.
--from YYYY-MM-DD / --to YYYY-MM-DDOnly documents dated on or after / on or before.
--undated / --no-undatedWith a date range, keep undated documents (the default) or not. (Not on timeline.)
--category IDOnly documents with this category. Repeatable.
--person NAMEOnly documents mentioning this person or organization, written as you'd read it. Repeat for documents mentioning all of them.
--folder all|confidential|otherAll files (default), only the confidential folder, or everything else.

#Commands

CommandOptionsWhat 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 NSearch 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 LOCATIONOne passage's full text by its citation, with the citations before and after it.
doc listthe filters, --limit N (100), --offset N, --ocr / --no-ocrThe 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 NMany documents at once as short cards: what each is, who wrote to whom, people named, thread, copies, opening text.
thread show DOCUMENTEvery message of an e-mail thread, oldest first.
timeline [QUERY]--any, the filters, --by day|month|year, --limit N (200), --offset NDated documents in date order.
people [NAME]--type PERSON|ORG|ACCOUNT|ADDRESS|PHONE|EMAIL|GOV_ID|DOB (repeatable), --limit N (50), --min-docs NThe people and organizations in the case, or one of them in detail.
contacts [NAME]--with NAME, --limit N (50), --offset NWho wrote to whom, from e-mail headers. With --with: every message between two people.

#Connections

CommandOptionsWhat it does
connections pair A BEverything 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 NEvery 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-runCreate a study and (by default) run it.
connections study run STUDYRun a study again.
connections study show STUDYA study's items and, pair by pair, where they meet.
connections study listThe 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 NWhere two of a study's items meet (A and B are item numbers).
connections study review STUDY--question TEXTQueue 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.

CommandOptionsWhat it does
review start QUESTION--doc ID (repeatable), --query WORDS / -q, --any, --thread ID, the filtersQueue documents in date order for a question.
review add REVIEWsame as review startAdd 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 REVIEWHow far it got.
review show REVIEW--decision relevant|not_relevant|unsure|undecided / -d, --limit N (200), --offset NEach document and its call.
review listThe case's reviews, newest first.
review close REVIEWMark a review finished (it can still be read and marked).

#Highlights

CommandOptionsWhat it does
highlight list--status proposed|approved|rejected, --doc ID, --limit N (200), --offset NThe highlights, in document order, with counts per status.
highlight add LOCATION--quote TEXT (required), --reason TEXT, --category NAMEPropose 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

CommandOptionsWhat it does
export highlighted-pdfs--out PATH (required), --real-namesA yellow-highlighted PDF of every document with approved highlights, in a new folder inside --out.
export exhibit-index--out PATH (required), --real-namesThe 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

CommandOptionsWhat it does
db schemaWhat 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 SQLsameOne 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.

OptionWhat it does
--add-to-pathAlso put the tool's folder on your PATH (zsh profile on a Mac, user Path on Windows). Asks first.
--yesAnswer 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:

bash
"/Applications/Discovery Engine.app/Contents/Resources/engine/python/bin/python3" -I -B -m discovery_engine doctor

and on Windows:

powershell
& "$env:LOCALAPPDATA\Discovery Engine\engine\python\python.exe" -I -B -m discovery_engine doctor