---
title: CLI reference
description: Every command, flag, and exit code.
icon: terminal
---

```txt
lawlint [options] <file.txt|file.md|file.docx|->
lawlint init [options]
lawlint learn <path> [options]
lawlint rules [--json]
lawlint rules test <path> [options]
lawlint self-update [options]
```

The file argument defaults to `-` (stdin), so a bare `lawlint` reads a pipe.

## Linting options

| Prop | Type | Default | Description |
| - | - | - | - |
| `FILE?` | `path` | `"-"` | File to lint. "-" reads stdin. |
| `--format?` | `"pretty" \| "json" \| "prompt"` | `"pretty"` | Human-readable output, machine-readable JSON, or an AI revision brief for the flagged text. |
| `--rules?` | `ID,ID` | - | Run only the listed rules. Full ids or bare aliases. |
| `--disable?` | `ID,ID` | - | Run every rule except the listed ones. |
| `--markdown?` | `flag` | - | Strip fenced code blocks from the input. Enabled automatically for .md files. |
| `--max-warnings?` | `N \| inf` | `"inf"` | Exit 1 when warnings exceed N. |
| `--fix?` | `flag` | - | Apply machine-applicable fixes to FILE in place. For .docx, as native tracked changes with a review comment per fix. |
| `--diff?` | `flag` | - | Show what --fix would change, or did change, as a colored diff. |
| `--judge?` | `flag \| =MODEL` | - | Run the soft-rule AI judge. Bare --judge uses the model from lawlint init; --judge=MODEL overrides it. Requires the = form when passing a model. |
| `--quiet?` | `flag` | - | Suppress pretty output while preserving the exit status. |
| `--rule-dir?` | `DIR` | - | Additional rule package directory. Repeatable; merged over the built-ins. Available on every command. |
| `--no-update-check?` | `flag` | - | Skip the once-a-day check for a newer release. Available on every command. |

### Model specs

`--judge=MODEL`, `init --ai`, and `learn --model` share one grammar:

| Spec | Provider |
| ---- | -------- |
| `anthropic:<model>` | Anthropic |
| `openai:<base-url>#<model>` | Any OpenAI-compatible endpoint |
| `foundry:<deployment>` | Azure AI Foundry |

`init --ai` additionally accepts the shorthands `qwen` and `gemma`.

## `lawlint init`

Sets up the project: AI-model, judge, Markdown, and custom-rule choices, written
to `.lawlint/config.json`. API keys go to a user-level credential file, never
into the project.

| Prop | Type | Default | Description |
| - | - | - | - |
| `--yes?` | `flag` | - | Accept the default answer for every prompt (non-interactive). |
| `--force?` | `flag` | - | Overwrite an existing .lawlint/config.json. |
| `--ai?` | `MODEL` | - | Model preference, skipping the catalog prompt: qwen, gemma, or a full spec. |

See [Setting up AI features](/docs/guides/ai-setup).

## `lawlint learn <path>`

Mines a personal rule package from your own prior writing: a local statistical
pass over the full corpus, an AI mining pass over a small sample, and a
self-check so no generated rule flags your own text.

| Prop | Type | Default | Description |
| - | - | - | - |
| `PATH` | `path` | - | A file or directory of your writing (.docx, .md, .txt). |
| `--out?` | `DIR` | `.lawlint/rules/personal` | Where to write the generated rule package. |
| `--model?` | `MODEL` | - | Mining model, overriding the lawlint init AI preferences. |

See [Learning your voice](/docs/guides/learn).

## `lawlint rules`

```sh
lawlint rules --json
```

Prints metadata for every loaded rule — id, tier, scope, severity, description,
intent, rationale, and documentation URL — as JSON. Combine with `--rule-dir` to
include a package.

### `lawlint rules test <path>`

Runs each Markdown rule's own flag and pass examples and reports the result per
example.

| Prop | Type | Default | Description |
| - | - | - | - |
| `FILE_OR_DIR` | `path` | - | A rule file or a rule package directory. |
| `--judge?` | `flag \| =MODEL` | - | Judge inferential rules' examples. Without it, they are skipped. |
| `--offline?` | `flag` | - | Skip inferential examples and never load a judge model. Conflicts with --judge. |

See [Authoring rules](/docs/guides/authoring-rules#testing-a-package).

## `lawlint self-update`

| Prop | Type | Default | Description |
| - | - | - | - |
| `--check?` | `flag` | - | Report current and latest version and whether an update is available. Downloads nothing. |
| `--force?` | `flag` | - | Reinstall even when already on the latest version. |
| `--version?` | `X` | - | Install this specific version instead of the latest. |

## Exit codes

| Code | Meaning |
| ---- | ------- |
| `0` | No error-severity findings, and warnings within `--max-warnings`. |
| `1` | An error-severity finding, or warnings over `--max-warnings`. |
| `2` | An I/O or configuration error — the document was never linted. |
