CLI commands and flags
This page documents every Doc Detective command and flag. The primary invocation is npx doc-detective.
Synopsis
A bare invocation with no command runs tests; the available commands are install, lsp, and debug. Use --version to print the installed version, and --help or -h to print usage. The CLI is strict: unknown flags cause an error instead of being ignored.
Run and global flags
These flags apply to the default run command. Each has a config-file equivalent; see Configuration precedence.
Negating boolean flags
Every boolean run flag has a --no- negation form; the ones you’ll typically reach for are: --no-hints, --no-auto-screenshot, --no-auto-record, --no-auto-update, and --no-exit-on-fail. (Other boolean flags, such as --dry-run and --allow-unsafe, can be negated the same way with --no-dry-run and --no-allow-unsafe.)
Notes on individual flags:
--reporters: see reporters and artifacts for therunFolderreporter and the built-in output formats.--cache-dir: see the cache directory guidance.--shell:runShelldocuments its steps, and shell selection covers how the default is chosen.--dry-run: the resolved test plan is printed to stdout, so you can pipe it (for example,npx doc-detective --dry-run | jq).--auto-update: skipped automatically when theCIenvironment variable is set, which GitHub Actions, GitLab CI, CircleCI, and most CI systems do—so CI pipelines usually don’t need--no-auto-update. To pin the version deterministically everywhere (including runners that don’t setCI), setautoUpdate: falsein config or pass--no-auto-update.--testand--spec: patterns match if they appear anywhere in the ID; anchor a pattern with^and$to require an exacttestIdorspecIdmatch. Each value is split on commas before the parts are compiled as regexes, so a pattern can’t contain a literal comma (for example,--test "step{1,3}"is split intostep{1and3}).
There is no flag to select the platform, browser, or headless mode for a run—those are contexts defined in your config (--browser-fallback only controls what happens when a selected browser can’t start). For containerized and headless runs, see Docker and headless runs.
Commands
Doc Detective runs tests when you invoke it without a command, and exposes named commands for setup, editor integration, and diagnostics.
Default (run tests)
With no command, doc-detective runs tests and takes no positional arguments; control its behavior with the flags in the Run and global flags section.
install
The install command group manages Doc Detective’s lazy-installed runtime assets—npm packages, browser binaries, ffmpeg, agent tools, and mobile toolchains. Its subcommands are agents, runtime, browsers, bash, android, ios, status, and all. For every subcommand, option, and example, see the install reference.
lsp
Start the Doc Detective language server (LSP) over stdio for editors and AI agents. It also ships as a standalone command, doc-detective-lsp.
This is distinct from install agents: the language server (lsp) exposes editor and AI-agent integrations over the LSP protocol, while install agents installs the Agent Skills and slash commands documented in the agent tools overview.
debug
Print diagnostic information about the runtime environment (OS, Doc Detective version, tool versions, browsers, referenced env vars) and exit without running tests.
Exit codes
The standalone doc-detective CLI does not exit with a non-zero code when tests fail—it exits non-zero only on a crash or invalid configuration. To gate CI on test failures, parse the results summary from the reporter output (the JSON reporter), or use the GitHub Action’s exit-on-fail behavior.
The default json reporter writes a testResults-<timestamp>.json file into the --output directory (it prints the path as See detailed results at …); read that file’s summary to decide whether the run passed. The debug command exits non-zero when it finds an invalid configuration. The specific non-zero value isn’t a stable contract, so gate CI on the parsed results, not on which non-zero code the process returns.
Configuration
Config auto-discovery
When you omit --config, the CLI looks for a config file in the current directory in this order: .doc-detective.json, then .doc-detective.yaml, then .doc-detective.yml. If none exists, it runs with defaults. When you pass --config, that path is authoritative—a mistyped path fails rather than falling back.
Configuration precedence
Doc Detective merges configuration in this order:
- File config and the
DOC_DETECTIVE_CONFIGenvironment variable (the environment value merges over the file). - Validation against the
config_v3schema. - CLI flag overrides.
- Runtime: the runner and reporters read only the merged config.
CLI flags override the validated config; they don’t bypass it, and every flag maps to a camelCase config key.
Invocation
npx doc-detective ...is the primary invocation.- Global or local install: install with npm, then call
doc-detective .... See installation. - Docker: the images use the entrypoint
npx doc-detective, sodocker run <image> --input ...passes flags straight to the default run command. See Docker and headless runs.
Examples
Run tests over a directory:
Preview the resolved plan without running:
Run a filtered subset with specific reporters:
Start the language server: