# npm CLI reference

> All eight quelltest npm commands (find, score, generate, verify, gate, mcp, eval, mocks) with every flag, the JSON report shape and exit codes 0 to 6.

Canonical page: https://quelltest.com/docs/npm/cli

The `quell` command has eight subcommands: `find`, `score`, `generate`, `verify`, `gate`, `mcp`, `eval` and `mocks`. This page lists every command, every flag accepted by quelltest 0.3.1 and every exit code, so you can script it in CI or give it to an agent. Run `npx quell --help` for the same information in the terminal.

## What is the general syntax?

```text
quell <find|score|generate|verify|gate|mcp|eval|mocks> [PATH] [options]
```

- `PATH` is a directory or a single file and defaults to `.`. At most one path is accepted.
- If the first argument is not a command but looks like a path (it contains a slash, starts with a dot, has an extension, or exists), the command is `find`: `npx quell src` equals `npx quell find src`.
- Options accept `--name value` and `--name=value`. `--` ends option parsing.
- `-h`/`--help` and `-v`/`--version` print help and the version.

## What does each command do?

| Command | Purpose | Runs your code? |
| --- | --- | --- |
| `find [PATH]` | List risk-ranked edge-case candidates per function. | No |
| `score [PATH]` | Print the share of candidates your tests execute, from coverage data. | No |
| `generate [PATH]` | Write tests for guards it can analyse; notes for the rest. | Only with `--verify` |
| `verify TEST_FILE --source FILE` | Prove a test fails when the source is mutated. | Yes (your tests) |
| `gate --diff REF` | Detect weakened tests in a change. | No |
| `mcp` | MCP server on stdio with tools `find`, `verify`, `gate`. | Through `verify` |
| `mocks [PATH] --examples FILE` | Compare annotated stubs with recorded API examples. | No |
| `eval` | Run the bundled benchmark and print JSON. | Yes (bundled fixtures) |

## Which options apply to which command?

### Reporting options (`find`, `score`, `generate`)

| Option | Meaning |
| --- | --- |
| `--json` | Print the full report as JSON. |
| `--sarif` | Print SARIF 2.1.0 for GitHub code scanning (`find`, `score`). |
| `--coverage FILE` | `coverage-final.json` (Istanbul) or `lcov.info`. Default: `./coverage/coverage-final.json`, then `./coverage/lcov.info`. |
| `--diff REF` | Only candidates on lines changed since the merge-base with `REF`, including uncommitted and untracked files. |
| `--all` | Show covered candidates too and do not truncate the list. |
| `--top N` | Number of candidates to print (default 10, minimum 1). |
| `--threshold N` | Exit 1 when the score is below `N` (integer, 0 or more); exit 3 when there is nothing to score from. |
| `--include GLOB` | Only scan matching files. Repeatable. |
| `--exclude GLOB` | Skip matching files. Repeatable; `--ignore` is an alias. Also read from `.quellignore`. Patterns match paths relative to the scanned directory. |
| `--min-confidence L` | Only findings at least this trustworthy: `low`, `medium` or `high`. |
| `--include-tests` | Scan test files too. |

### `generate` options

| Option | Meaning |
| --- | --- |
| `--write` | Write tests and TODO notes to disk. Without it the command is a dry run. |
| `--destination DIR` | Output directory (default `tests/quelltest`). |
| `--runner NAME` | `node`, `jest`, `vitest` or `mocha`. Default: detected from `package.json`. |
| `--verify` | Keep only tests that pass on the original and fail on a source mutant. |
| `--include-covered` | Also generate for candidates your tests already cover. |
| `--llm MODULE` | ESM module whose default export writes tests for findings the rules cannot. It is your code; see [privacy](https://quelltest.com/docs/npm/privacy.md). |

### `verify` options

| Option | Meaning |
| --- | --- |
| `--source FILE` | Source file to mutate. Required. |
| `--runner NAME` | `node` (default), `jest`, `vitest` or `mocha`. |
| `--function NAME` | Only mutate this function. Repeatable. |
| `--findings` | Aim mutation at the lines the scanner flagged. |
| `--min-score N` | Also require `N`% of decided mutants killed (0 to 100). |
| `--handoff FILE` | Write surviving mutants as Markdown an agent can act on. |
| `--command CMD` | Run your own command instead of a runner; `{test}` is replaced by the test path. |
| `--infra-exit CODE` | Exit code your command uses for "the environment failed". Repeatable; counted as inconclusive, never as a kill. |
| `--timeout SECONDS` | Per-run timeout (default 60). |
| `--in-place` | Mutate the source file itself (with a backup) instead of a temporary copy. |
| `--json` | Print the full verification result as JSON. |

### `gate` and `mocks` options

| Option | Meaning |
| --- | --- |
| `--diff REF` | `gate`: git ref to compare against. Required. |
| `--strict` | `gate`: also fail on "expected value changed" review items. |
| `--json`, `--sarif` | `gate`: machine-readable output. `--sarif` wins if both are given. |
| `--examples FILE` | `mocks`: HAR file, JSON examples file or OpenAPI JSON. Required. |
| `--json` | `mocks`: print `{ examples, problems }` as JSON. |

## What are the exit codes?

| Code | Meaning | Commands |
| --- | --- | --- |
| 0 | Success. | all |
| 1 | Score below `--threshold`; or `eval` found noise or wrong verdicts. | `find`, `score`, `generate`, `eval` |
| 2 | Usage or runtime error (unknown option, missing `--source`, bad git ref, unreadable file). | all |
| 3 | `--threshold` given but there is nothing to score from (no coverage evidence). | `find`, `score`, `generate` |
| 4 | `verify` did not verify the test. | `verify` |
| 5 | `gate` found weakened tests. | `gate` |
| 6 | `mocks` found stub drift. | `mocks` |

When `--threshold` is set and the scan finds no candidates at all, the exit code is 0.

```bash
npx quell score src --threshold 60 ; echo $?
npx quell verify tests/pay.test.js --source src/pay.js ; echo $?
npx quell gate ; echo $?
```

```text
Score: not scored (no coverage evidence) | 6 candidates
3
Not verified: test fails on the original code (node --test ...): ReferenceError: test is not defined
4
quell: gate requires --diff REF
Run `quell --help` for usage.
2
```

(The second command used the default `node` runner on a Jest test file, which is why it is not verified: see [how verify works](https://quelltest.com/docs/npm/verify.md).)

## What does the JSON report look like?

`find --json` and `score --json` print one object:

```json
{
  "version": 1,
  "root": "/path/to/project",
  "findings": [
    {
      "id": "7f6b9ca36c8d",
      "file": "src/files.js",
      "line": 4,
      "column": 16,
      "endLine": 4,
      "endColumn": 64,
      "function": "download",
      "category": "risk",
      "rule": "path-traversal",
      "confidence": "high",
      "evidence": "fs.readFileSync('/srv/uploads/' + req.query.name)",
      "suggestion": "request value reaches a file path; test \"../\" and absolute paths and use path.basename or a base-directory check",
      "risk": 10,
      "covered": false
    }
  ],
  "skipped": [],
  "restored": [],
  "suppressed": 0,
  "summary": {
    "total": 13,
    "coverageEvidence": "istanbul",
    "evidenceFile": "coverage/coverage-final.json",
    "score": 15,
    "tier": "edge-cases-uncovered",
    "covered": 2,
    "uncovered": 11
  }
}
```

- `id` hashes the function name and the evidence, not the line number, so it survives unrelated edits.
- `category` is `throws`, `boundary`, `nullish`, `jsdoc`, `schema`, `async`, or `risk` (then `rule` names the rule).
- `confidence` is `low`, `medium` or `high`. `covered` is present only when coverage evidence was given.
- `summary.coverageEvidence` is `none`, `istanbul` or `lcov`. `summary.tier` is `production-ready`, `review-needed`, `edge-cases-uncovered`, `not-scored` or `no-findings`; `score` is `null` unless it was computed.
- `skipped` lists files that could not be parsed; `suppressed` counts findings silenced by [`quell-ignore`](https://quelltest.com/docs/npm/rules.md).

`verify --json` returns `verified`, `reason`, `killed`, `total`, `inconclusive`, `ignored`, `mutationScore`, `isolation` and a `mutants` array. `gate --json` returns `{ issues, ok, checked }`. Treat the report as versioned (`version: 1`) and never parse the human-readable output.

## Is there a library API?

Yes. The package exports `scan`, `score`, `report`, `generate`, `generateWithLlm`, `verifyGenerated`, `toSarif`, `gate`, `gateSarif`, `renderHandoff`, `checkStubs` and `loadExamples` for ESM and CommonJS, with TypeScript declarations.
