---
title: "CLI reference"
description: "Every openaudit command and flag: targets, output formats, auditor selection, baselines, diff mode, exit codes and agent mode."
url: https://openaudit.se/docs/cli/
---

# CLI reference

Requires [Bun](https://bun.sh) 1.4 or later.

## Usage

```sh
openaudit [target] [flags]          # same as: openaudit audit [target]
```

`target` is a directory (default `.`), a file, an `http(s)://` URL, `image:<ref>` for a container image, or `cloud:<aws|azure|gcp|kubernetes>` for a live cloud account (opt-in Prowler, using your ambient credentials). openaudit detects what the target contains (Node, Python, Docker, Terraform, Kubernetes, GitHub Actions, Android/iOS, ...) and runs the auditors that apply.

| Flag | Meaning |
| --- | --- |
| `-f, --format <list>` | `terminal` (default), `json`, `sarif`, `markdown`, `html`. Repeatable or comma-separated. More than one format requires `--out`. |
| `-o, --out <dir>` | Write `openaudit-report.<ext>` for each format into `<dir>`. |
| `--json` | Agent mode: the JSON report on stdout and nothing else. No progress output. |
| `--fail-on <severity>` | Exit 1 if any finding is at least `critical`/`high`/`medium`/`low`/`info`. Default `none`. |
| `--only`, `--exclude <patterns>` | Choose auditors by id (`web.headers`), prefix (`web`) or glob (`code.*`). |
| `--category <list>` | Only run auditors in these categories, e.g. `security,accessibility`. |
| `--baseline <report.json>` | Suppress findings already in an earlier JSON report, so only new findings count. |
| `--diff <ref>` | Keep only findings in files changed since the git ref (`<ref>...HEAD`), e.g. `origin/main` on a pull request. Findings with no file are dropped. The report records the ref and the dropped count. |
| `--offline` | Make no network requests except to the target (skips OSV lookups and similar). |
| `--browser`, `--max-pages <n>` | Drive a real Chromium through Playwright for URL targets (needs `playwright-core` and a Chromium). |
| `-H, --header "Name: value"` | Extra header for the target origin only, e.g. an auth cookie for staging. Repeatable. |
| `--agentic`, `--model <id>` | Run the LLM-driven auditors. Needs `ANTHROPIC_API_KEY` or Claude Code auth. |
| `--ai` | Attach an AI-prioritised summary to the report. Uses `ANTHROPIC_API_KEY`, else your Claude Code login. If both fail, openaudit prints a warning and continues. |
| `--config <path>`, `--no-config` | Use a trusted config file, or ignore the target's `openaudit.config.json(c)`. |
| `--concurrency <n>`, `-q/--quiet`, `--verbose` | |

Other commands:

| Command | |
| --- | --- |
| `openaudit list [--json] [--target-kind url]` | Auditors (id, engine, categories, targets, external tool, on/off by default) and playbooks |
| `openaudit doctor [--json]` | Bun version, external tools on PATH, Playwright/Chromium, AI credentials |
| `openaudit init [--force] [--print]` | Write an `openaudit.config.jsonc` tailored to the project (`--print` shows it instead) |
| `openaudit schema [report\|config]` | JSON Schema (draft 2020-12) of the report or the config file |
| `openaudit mcp [--http]` | Start the MCP server on stdio, or over Streamable HTTP with `--http` |

### Exit codes

| Code | Meaning |
| --- | --- |
| `0` | Audit completed and no finding reached `--fail-on` |
| `1` | At least one finding at or above `--fail-on` |
| `2` | Usage error, invalid config, or the target could not be resolved |
| `3` | `--fail-on` was set but an auditor errored or timed out, so the gate could not be fully checked |

Exit code 3 fails closed, so a target cannot pass CI by crashing the auditor that would have flagged it. Pass `--allow-errors` to accept partial results. Skipped auditors (missing tool, offline) never change the exit code; their status and reason are recorded in the report.

## Agent mode (`--json`)

```sh
openaudit . --json --fail-on high > report.json; echo $?
openaudit schema > report.schema.json   # validate the output
```

- stdout carries exactly one JSON document, with keys in a stable order (`schemaVersion`, `tool`, `target`, `summary`, `results[].findings[]`). Nothing else is written to stdout, and no progress is shown on stderr.
- Findings are sorted by severity. Each one has `ruleId`, `severity`, `category`, `location` (`file`/`line` or `url`/`selector`), `evidence` (redacted), `remediation`, `references` and a `fingerprint`.
- To check a fix, re-run the audit with `--baseline report.json --fail-on low`. Exit code 0 means no new findings appeared.

## Help output

Printed by the CLI itself, so it always matches the version the site was built with.

### `openaudit --help`

```
DESCRIPTION
  Audit codebases, URLs, web apps, containers, IaC and mobile builds for security, accessibility, performance, SEO, privacy and more. Exit codes: 0 ok, 1 findings at/above --fail-on, 2 usage or target error.

USAGE
  openaudit <subcommand> [flags] [<target>]

ARGUMENTS
  target string    Directory, file, http(s) URL or image:<ref> (default: .) (optional)

FLAGS
  --format, -f string      Output format(s): terminal, json, sarif, markdown, html, csv. Repeat or comma-separate; several need --out
  --out, -o string         Write openaudit-report.<ext> per format into this directory
  --only string            Only these auditors: id, prefix or prefix.* (repeatable, comma list)
  --exclude string         Skip these auditors (same patterns as --only)
  --category string        Only auditors in these categories, e.g. security,accessibility
  --fail-on string         Exit 1 if any finding is at least this severe: critical, high, medium, low, info, none
  --offline                No network access except to the target itself
  --browser                Drive a real browser (Playwright) for URL targets
  --max-pages integer      Max pages to crawl for URL targets
  --header, -H string      Extra request header for the target origin, "Name: value" (repeatable)
  --agentic                Enable agentic (LLM) auditors; needs ANTHROPIC_API_KEY or Claude Code auth
  --ai                     Attach AI insights (prioritised summary) to the report
  --model string           Model id for agentic auditors and --ai
  --baseline string        Earlier JSON report; its findings are suppressed (only new findings count)
  --diff string            Only report findings in files changed since this git ref (e.g. origin/main), for pull requests
  --concurrency integer    Auditors run in parallel (default 4)
  --json                   Agent mode: JSON report on stdout, nothing else on stdout or stderr progress
  --quiet, -q              No progress or notices on stderr
  --verbose                Terminal output lists every finding with details
  --config string          Trusted config file. Without it, openaudit.config.json in the target is read with restrictions
  --no-config              Ignore openaudit.config.json in the target
  --allow-errors           With --fail-on, do not fail when an auditor errors or times out

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)

SUBCOMMANDS
  audit     Audit a target (the default command)
  list      List auditors and playbooks
  doctor    Check Bun, external tools, browser and AI credentials
  init      Create openaudit.config.jsonc, tailored to the project
  mcp       Start the MCP server: stdio by default (Claude Code, Cursor, Codex, ...), or --http for remote agents
  schema    Print the JSON Schema of the report (or config) so agents can validate output
EXAMPLES
  # Audit the current directory
  openaudit

  # Audit a live site with a real browser
  openaudit https://example.com --browser --max-pages 20

  # Agent/CI mode: JSON on stdout, exit 1 on high+ findings
  openaudit . --json --fail-on high

  # Write reports/openaudit-report.sarif and .html
  openaudit . -f sarif,html -o reports

  # Audit a container image
  openaudit image:nginx:1.27 --only container

  # Fail only on findings that are new since the baseline
  openaudit . --baseline main-report.json --fail-on medium

  # Use openaudit from Claude Code over MCP
  claude mcp add openaudit -- bunx @openaudit/cli mcp
```

### `openaudit audit --help`

```
DESCRIPTION
  Audit a target (the default command)

USAGE
  openaudit audit [flags] [<target>]

ARGUMENTS
  target string    Directory, file, http(s) URL or image:<ref> (default: .) (optional)

FLAGS
  --format, -f string      Output format(s): terminal, json, sarif, markdown, html, csv. Repeat or comma-separate; several need --out
  --out, -o string         Write openaudit-report.<ext> per format into this directory
  --only string            Only these auditors: id, prefix or prefix.* (repeatable, comma list)
  --exclude string         Skip these auditors (same patterns as --only)
  --category string        Only auditors in these categories, e.g. security,accessibility
  --fail-on string         Exit 1 if any finding is at least this severe: critical, high, medium, low, info, none
  --offline                No network access except to the target itself
  --browser                Drive a real browser (Playwright) for URL targets
  --max-pages integer      Max pages to crawl for URL targets
  --header, -H string      Extra request header for the target origin, "Name: value" (repeatable)
  --agentic                Enable agentic (LLM) auditors; needs ANTHROPIC_API_KEY or Claude Code auth
  --ai                     Attach AI insights (prioritised summary) to the report
  --model string           Model id for agentic auditors and --ai
  --baseline string        Earlier JSON report; its findings are suppressed (only new findings count)
  --diff string            Only report findings in files changed since this git ref (e.g. origin/main), for pull requests
  --concurrency integer    Auditors run in parallel (default 4)
  --json                   Agent mode: JSON report on stdout, nothing else on stdout or stderr progress
  --quiet, -q              No progress or notices on stderr
  --verbose                Terminal output lists every finding with details
  --config string          Trusted config file. Without it, openaudit.config.json in the target is read with restrictions
  --no-config              Ignore openaudit.config.json in the target
  --allow-errors           With --fail-on, do not fail when an auditor errors or times out

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)

EXAMPLES
  # Audit the current directory
  openaudit

  # Audit a live site with a real browser
  openaudit https://example.com --browser --max-pages 20

  # Agent/CI mode: JSON on stdout, exit 1 on high+ findings
  openaudit . --json --fail-on high

  # Write reports/openaudit-report.sarif and .html
  openaudit . -f sarif,html -o reports

  # Audit a container image
  openaudit image:nginx:1.27 --only container
```

### `openaudit list --help`

```
DESCRIPTION
  List auditors and playbooks

USAGE
  openaudit list [flags]

FLAGS
  --json                  Machine-readable output
  --target-kind string    Filter: codebase, url, webapp, container, iac, mobile

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
```

### `openaudit doctor --help`

```
DESCRIPTION
  Check Bun, external tools, browser and AI credentials

USAGE
  openaudit doctor [flags]

FLAGS
  --json    Machine-readable output

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
```

### `openaudit init --help`

```
DESCRIPTION
  Create openaudit.config.jsonc, tailored to the project

USAGE
  openaudit init [flags]

FLAGS
  --force         Overwrite an existing config
  --print         Print the config instead of writing it
  --dir string    Project directory (default: .)

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
```

### `openaudit mcp --help`

```
DESCRIPTION
  Start the MCP server: stdio by default (Claude Code, Cursor, Codex, ...), or --http for remote agents

USAGE
  openaudit mcp [flags]

FLAGS
  --http                     Serve MCP over Streamable HTTP instead of stdio (loopback by default)
  --host string              HTTP bind address (default 127.0.0.1)
  --port integer             HTTP port (default 7337)
  --token string             HTTP bearer token (or OPENAUDIT_MCP_TOKEN); generated on loopback if omitted, required off loopback
  --root string              HTTP: directory that local targets must resolve inside (repeatable)
  --allow-origin string      HTTP: browser Origin allowed to connect (repeatable)
  --allow-host string        HTTP: extra Host header value accepted (repeatable)
  --persist-reports          HTTP: save reports under <root>/.openaudit/reports (off by default over HTTP)
  --allow-cloud              HTTP: accept cloud:<provider> targets (uses the server's credentials)
  --allow-images             HTTP: accept image:<ref> targets on non-loopback binds (registry host is still checked)
  --allow-agentic            HTTP: let clients run agentic auditors (spends the server's ANTHROPIC_API_KEY)
  --allow-private-targets    HTTP: allow URL targets on private/loopback/metadata addresses (non-loopback binds only block them by default)

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
```

### `openaudit schema --help`

```
DESCRIPTION
  Print the JSON Schema of the report (or config) so agents can validate output

USAGE
  openaudit schema [flags] [<name>]

ARGUMENTS
  name choice    Which schema (default: report) (optional)

GLOBAL FLAGS
  --help, -h                                          Show help information
  --version, -v                                       Show version information
  --completions <bash|zsh|fish|powershell|sh|pwsh>    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
```
