Skip to content
Docs›CLI›The x-security CLI
@x-security/cli · Apache-2.0 · deterministic

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.

/ 01section

Quickstart

bash
# 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:8001
Install
The CLI ships inside every plugin download (bin/cli.mjs, self-contained, no npm install). Grab any bundle from the download page and run it directly with Node 20+.
/ 02section

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.

FieldTypeDefaultDescription
xsecurity routes <repoDir>inventory—Deterministic route inventory: {method, path, file, line} for every handler in the repo.
xsecurity context --routecontext—Per-route context pack: handler slice, observed inputs/outputs, resolved auth. e.g. --route "POST /login".
xsecurity verify-findinggate—Verifies ONE finding from stdin: citation byte-match, tightness, schema validity. Exit 2 on failure.
xsecurity verify-routegate—Whole-route precision gate that composes findings and checks cross-control consistency.
xsecurity reconcile-inventorygate—Reconciles mount prefixes and grounds agent-claimed routes against the extractor.
xsecurity compile --writeemit—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 --targetemit—Renders compiled policies to an artifact: waf · report · ci.
/ 03section

Gateway verbs

From an annotated OpenAPI spec to running gateway config: compile, test, diff, deploy checks, drift detection.

FieldTypeDefaultDescription
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 mcpserve—Runs the bundled MCP server (stdio JSON-RPC). This is how Cursor and other agents call these verbs.
xsecurity verify-bundlesupply chain—Verifies a signed release bundle: sha256 + Ed25519 signature.
/ 04section

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.

/ 05section

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.

Exit codes
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.