# Commands

The commands you use most, the flags they share, output formats, and exit codes.

Run `lafke --help` for every command, and `lafke <command> --help` for the flags of one command.

## Dependency trust

These commands read your lockfiles and `lafke.lock`.

| Command | What it does |
| --- | --- |
| `lafke init` | Detects the project's lockfiles, writes the first `lafke.lock`, and says what to do next. It refuses to overwrite an existing `lafke.lock`. |
| `lafke scan` | Scans a project and evaluates dependency trust. It fails on current policy violations, even when those states are already locked. |
| `lafke lock` | Writes `lafke.lock`. |
| `lafke diff` | Shows trust drift against `lafke.lock`. |
| `lafke verify` | Verifies the current project against `lafke.lock`. It fails when there is trust-relevant drift. |
| `lafke explain <package>` | Explains why a dependency is trusted: digest, source, provenance, signature, trust chain, ownership, capabilities, vulnerabilities, and malicious-package reports. |
| `lafke update` | Shows how the trust state differs from `lafke.lock`. With `--write`, it records the new state. |
| `lafke accept <finding-id>` | Accepts a finding until a date, with a reason. Exceptions live in `.lafke/exceptions.yaml` and never change `lafke.lock`. |

```sh
lafke update . --write
```

Without `--write`, `update` changes nothing on disk, so its report is a preview to review. `--write` refuses to record a state with untrusted or unknown artifacts; add `--no-fail` to record it anyway.

## Findings and reports

| Command | What it does |
| --- | --- |
| `lafke audit` | Audits dependencies against OSV and reports findings by severity. |
| `lafke sast` | Finds vulnerabilities, committed secrets, and unsafe infrastructure settings in your own source code. Needs the analysis engine. |
| `lafke security` | Combines dependency auditing with source, secret, and infrastructure analysis in one severity-ranked report. Needs the analysis engine. |
| `lafke sbom export` | Writes `lafke.lock` as a CycloneDX or SPDX SBOM. |
| `lafke sbom verify` | Checks a CycloneDX or SPDX SBOM against `lafke.lock`. |
| `lafke graph` | Draws the dependency graph, colored by trust status. |
| `lafke doctor` | Checks the project setup for security problems. |

`audit` and `doctor` exit 1 when a finding is at or above `--fail-on` (default `high`). The values are `critical`, `high`, `medium`, `low`, and `info`.

`sast` analyzes Go, JavaScript and TypeScript, Python, Java, Kotlin, C#, PHP, and Ruby. Analysis is offline.

`security` does not need or write a `lafke.lock`. If it finds no supported lockfile, it marks dependency analysis as unchecked in the report.

## Flags many commands share

| Flag | What it does |
| --- | --- |
| `--offline` | Skips remote lookups. Remote evidence is then recorded as `unknown`. |
| `--network <mode>` | Sets the network mode: `public-only`, `offline`, or `allow-all`. See [Privacy](/docs/privacy). |
| `--policy <file>` | Uses this policy file. |
| `--profile <name>` | Uses a built-in policy profile: `default` or `strict`. Not combinable with `--policy`. |
| `--lock <file>` | Uses this path for `lafke.lock`. |
| `--format <format>` | Sets the output format. See below. |
| `--output <file>` | Writes the report to this file instead of stdout. |
| `--no-fail` | Does not fail on findings or trust violations. Operational errors still fail. |
| `-r`, `--recursive` | On `scan`, `lock`, `verify`, `diff`, and `audit`: runs for every project under the path that has a supported lockfile, each with its own `lafke.lock`. |

## Output formats

`--format` takes `text` (the default), `json`, `sarif` for code scanning, `junit` for JUnit XML, or `markdown` for a pull request comment. `graph` also takes `mermaid` and `dot`.

`scan --format json` emits the lock document.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | Success, or no trust drift. |
| `1` | A trust violation or a finding. |
| `2` | A configuration or operational error. |
