The x-security CLI
The standalone correctness core. Every verb is deterministic, stateless code; no LLM provider is imported, and detection verbs make no network calls. This is the same binary the Claude Code and Cursor plugins shell out to; everything the plugins verify, you can run by hand or in CI.
Quickstart
# Inventory every route in the repo (no model, no network)
$ xsecurity routes ./my-api
# Generate gateway config from your annotated OpenAPI spec
$ xsecurity generate openapi.yml --target coraza --out ./waf
# Coverage report: what the perimeter enforces, what it can't
$ xsecurity report openapi.yml --coverage --format html
# CI drift gate: exit 2 if the deployed gateway disagrees with the spec
$ xsecurity validate openapi.yml --target kong --gateway http://kong:8001bin/cli.mjs, self-contained, no npm install). Grab any bundle from the download page and run it directly with Node 20+.Detection verbs
The verbs a coding agent drives during a scan. Each one is a hard gate: findings that fail verification exit non-zero and never become policy.
| Field | Type | Default | Description |
|---|---|---|---|
xsecurity routes <repoDir> | inventory | — | Deterministic route inventory: {method, path, file, line} for every handler in the repo. |
xsecurity context --route | context | — | Per-route context pack: handler slice, observed inputs/outputs, resolved auth. e.g. --route "POST /login". |
xsecurity verify-finding | gate | — | Verifies ONE finding from stdin: citation byte-match, tightness, schema validity. Exit 2 on failure. |
xsecurity verify-route | gate | — | Whole-route precision gate that composes findings and checks cross-control consistency. |
xsecurity reconcile-inventory | gate | — | Reconciles mount prefixes and grounds agent-claimed routes against the extractor. |
xsecurity compile --write | emit | — | Compiles verified route findings into x-security policy files in .x-security/policies/. |
xsecurity audit <repoDir> | gate | — | Re-validates every stored policy control and proves citation coverage. |
xsecurity emit --target | emit | — | Renders compiled policies to an artifact: waf · report · ci. |
Gateway verbs
From an annotated OpenAPI spec to running gateway config: compile, test, diff, deploy checks, drift detection.
| Field | Type | Default | Description |
|---|---|---|---|
xsecurity generate <spec> | compile | — | OpenAPI + x-security → native gateway config. --target one of the supported WAF/gateway targets; deterministic: same input, byte-identical output. |
xsecurity validate <spec> | drift | — | Drift detection between spec and a deployed gateway (file or admin API). Exit 2 on critical drift. CI-friendly. |
xsecurity test <spec> | test | — | Closed loop: generate config, boot the gateway in Docker, replay traffic, assert allow/deny. |
xsecurity report <spec> | report | — | OWASP API Top 10 coverage / annotation coverage. Formats: table, json, sarif, csv, html. --strict-fidelity fails on unenforceable fields. |
xsecurity diff <old> <new> | diff | — | Diff the generated config between two spec versions. Review the blast radius before deploy. |
xsecurity verify <spec> | post-deploy | — | Did the gateway actually load our artifacts? Threshold-gated (default 90%). |
xsecurity init <spec> | scaffold | — | Adds empty x-security blocks to bare operations. |
xsecurity migrate <spec> | upgrade | — | Schema version migration, e.g. --from 0.4 --to 0.5. |
xsecurity mcp | serve | — | Runs the bundled MCP server (stdio JSON-RPC). This is how Cursor and other agents call these verbs. |
xsecurity verify-bundle | supply chain | — | Verifies a signed release bundle: sha256 + Ed25519 signature. |
Targets
Five native config generators (kong, coraza, bunkerweb, openappsec, envoy) plus capability matrices for cloudflare and aws-apigw used by feasibility reports. See the gateway import guide for per-target load commands.
Network behavior
Exactly one verb leaves your machine: xsecurity push, the explicit opt-in that uploads verified policies to the hosted platform. It reads its token from the environment, re-runs the local audit first, and refuses non-allowlisted hosts. Everything else is file I/O, plus the gateway admin APIs you point validate/verify at, and Docker for test.
0 success · 1 usage/IO error · 2 verification or drift failure · 3 zero-emission/schema error · 4 fidelity violation under --strict-fidelity. Built for CI gates.