Documentation / Reference
CLI reference
shield-llm is a thin client. It sends attacks to your chatbot from the machine it runs on. The attack catalogue, the judge and the stored results live on this instance. New attacks reach every installed CLI on the next scan, without an upgrade.
On this page
Install and connect
npm install -g shield-llm
shield-llm login --key <api-key> --api-url https://shield-llm.comYou need Node.js 22.3 or later. Create the key under Settings > API Keys. shield-llm --help lists the commands, shield-llm <command> --help the options of one command.
Global behaviour
- Which instance. In this order:
--api-urlon the command, theSHIELD_API_URLenvironment variable, the URL saved bylogin. With none of them, the command stops with exit code 2. There is no default instance. - Credentials are saved in
~/.shield-llm/credentials.json, readable by your user only. SetSHIELD_LLM_HOMEto keep them under another folder. - Configuration is read from
shield.config.jsonin the current folder, or from-c <path>. Options on the command line win over the file. - Environment. A
.envfile in the current folder is loaded at start.$NAMEin an authentication value reads the environment variableNAME.
Commands
scan
Run a security scan against a chatbot.
shield-llm scan [options]Target
| Option | Description |
|---|---|
-c, --config <path> | Path to shield.config.json. Default: the file in the current folder. |
-e, --endpoint <url> | Chatbot URL, without a config file (quick mode). |
--auth <type> | bearer or api-key. OAuth2 is configured in the file only. |
--token <value> | The bearer token or API key value. $NAME reads it from the environment. |
--auth-header <name> | Header that carries the API key. Default X-API-Key. |
--response-field <path> | Dot path to the reply text. Default response. |
--request-body <json> | Request body template, with {{prompt}}. |
--allow-private-urls | Allow a chatbot on localhost or a private network, with -e or with a config file. |
What to run
| Option | Description |
|---|---|
--preset <name> | dev, quick, owasp, frontier, standard or full. Default standard. |
--crescendo | Add the multi-turn attacks. Always on with full. |
--mcp-harness [port] | Start a decoy MCP server (port 4300 by default), to be the only MCP server the agent under test connects to, and run the MCP attacks through it. The verdict rests on the tool calls the agent makes, not on its reply. The agent must list the tools again in each conversation: an attack whose tools it never listed (it kept a list from earlier) is skipped, never scored. |
--mcp-host <host> | Interface the decoy MCP server binds to. Default 127.0.0.1; 0.0.0.0 for an agent in a container, which also makes the URL path a per-scan secret. |
--mutate [ids] | Also send encoded variants of each single-turn attack (zero-width characters, homoglyphs, base64 and others). Comma-separated ids, or no value for all. --mutate list prints them. Variants are scored apart from the main score. |
--load-custom-tests | Add your active custom tests from this instance. |
--pack <id> | After the scan, run this test pack (for example shield-brand) against the same chatbot. Repeat the option to run several packs. The packs read the profile of the config file, and their results are shown apart from the score. |
--custom-only | Run only custom tests. No preset attack is sent. |
--system-prompt <text>, --system-prompt-file <path> | Accepted for compatibility. Today they only change the key of the resume checkpoint: the text is sent neither to the chatbot nor to the judge. |
Pacing and limits. The scan paces itself; these are for difficult targets.
| Option | Description |
|---|---|
--concurrency <n> | Attacks in parallel, 1 to 10. Default 4. Backs off by itself when throttled. |
--delay <ms> | Minimum delay between requests. |
--max-delay <ms> | Ceiling of the adaptive delay. Default 5000. |
--retries <n> | Retries after a 429 or a gateway error. Default 3. |
--max-floor-throttles <n> | Throttles in a row at the minimum pace before stopping. Default 3. |
--max-unjudged <percent> | Share of answers the judge may fail to rule on before the scan is incomplete. Default 10. |
--max-not-executed <percent> | Share of attacks that may never run before the scan is incomplete. Default 20. |
--no-resume | Ignore saved progress and start over. |
--checkpoint-dir <path> | Where progress is saved. Default .shield-llm/checkpoints. |
Pass or fail
| Option | Description |
|---|---|
--min-score <n> | Fail when the score is below n. |
--fail-on-critical | Fail when a CRITICAL finding is found. |
--no-fail-on-critical | Report CRITICAL findings without failing. |
--compliance-threshold <n> | Compute the EU AI Act assessment and fail below n (0 to 100). |
Without any threshold, a scan always passes. Once one threshold is set, a CRITICAL finding fails the run unless you pass --no-fail-on-critical.
Output
| Option | Description |
|---|---|
-o, --output <format> | json, markdown or sarif. Without it, the CLI prints a summary only. The PDF reports come from the scan page. |
--output-file <path> | Write the report to a file instead of the terminal. |
--write-json <path> | Also write a JSON copy, whatever --output is. |
--include-full-payloads | Keep the chatbot's full answers in the JSON on disk. By default they are shortened. |
--ci | JSON on stdout, progress on stderr, no spinner. |
--no-progress | No spinner. |
--eu-ai-act | Print the EU AI Act assessment after the scan. |
--evidence-bundle <path> | Write the checksummed evidence bundle. Implies --eu-ai-act. |
--api-url <url> | Use this instance for this command. |
init
shield-llm initAsk a few questions and write shield.config.json: the endpoint URL, the authentication, the shape of the request body, the response field, extra headers, the default preset.
validate
shield-llm validate [-c <path>]Check the configuration file. Sends nothing.
test-connection
shield-llm test-connection [-c <path>] [-m <text>]Send one harmless message to the chatbot and print its reply. No attack, no judge, no account needed. -m, --message replaces the default greeting.
probe-carriers
shield-llm probe-carriers [-c <path>] [--ci]Check whether invisible Unicode characters (zero-width, tag characters, private-use area, soft hyphen, variation selectors) survive your chatbot's input pipeline and reach the model. A transport diagnostic: no attack, no judge, nothing uploaded, no account needed. The attacks that use those characters are run by scan --mutate.
retest
shield-llm retest <scan-id> [options]Replay the attack behind each finding of a stored scan, together with the neighbouring attacks of the same defect, and mark each finding fixed or still vulnerable on this instance. A finding is fixed only when none of them succeeds. Fix and verify
| Option | Description |
|---|---|
--finding <attack-id> | Retest only this finding. Repeat for several. |
--exact-only | Replay only the exact attack of each finding, without the neighbouring attacks. |
-c, --config <path>, -e, --endpoint <url>, --auth <type>, --token <value>, --auth-header <name>, --response-field <path>, --request-body <json>, --allow-private-urls | Same as scan. |
--ci | JSON on stdout, no spinner. |
--no-progress | No spinner. |
--api-url <url> | Use this instance for this command. |
Exit codes: 0 every finding fixed, 1 at least one still vulnerable, 2 configuration or credentials, 3 network.
import
shield-llm import <file> --scan <scan-id> [options]Attach the result file of another red-team tool to a completed scan: a promptfoo result file (promptfoo eval -o results.json) or a garak report (garak.<id>.report.jsonl). The instance's judge re-judges each attempt; the tool's own verdict is kept for comparison only. The results are shown on the scan page and in the security PDF, apart from the score and marked as declared by you. Nothing is sent to the chatbot. Importing the same file again skips what is already stored.
| Option | Description |
|---|---|
--scan <scan-id> | The completed scan to attach the results to. Required. |
--format <tool> | promptfoo or garak. Default: detected from the file. |
--ci | JSON summary on stdout. |
--no-progress | No progress line. |
--api-url <url> | Use this instance for this command. |
Exit codes: 0 imported, 2 refused (file, format, credentials or scan), 3 network. Running a red-team tool against a hosted model API can get your account with that provider suspended: point such tools at a test deployment.
fix
shield-llm fix [scan-id] [options]Write the correction brief of a scan: each finding, its exchange and how to fix it, for the developer or the coding agent who maintains the chatbot. With a codebase block in the configuration, patch the findings with remediation recipes in your working tree instead. Fix and verify
| Option | Description |
|---|---|
--scan <id> | The scan to fix (same as the argument). |
--report <path> | A JSON report from scan --write-json, instead of a scan id. |
--brief [path] | Write the correction brief (by default shield-fix-brief-<scan-id>.md in the current folder), even when the configuration has a codebase block. |
-c, --config <path> | Configuration file. With a codebase block, fix patches the code; without one, it writes the brief. |
--explain | Show which recipes apply and which anchors would unlock more. |
--json | The plan as JSON (implies --explain). |
--dry-run | Print the diff, write nothing. |
--revert | Remove every block these recipes wrote. |
--only <ids> | Patch only these findings: attack ids or finding fingerprints, comma-separated, to ship and verify one fix alone. A name that is no finding of the scan stops the run and lists the findings. |
--min-confidence <n> | Minimum judge confidence for a finding to be patched. Default 0.8. |
--allow-dirty | Write even if the git working tree has uncommitted changes. |
--no-benign-baseline | Skip the capture of normal answers before patching. |
--verify | Redeploy with codebase.redeploy, replay the original and holdout attacks and the benign suite. |
--replays <n> | With --verify: replay each attack n times, 1 to 10. It counts as closed only if every replay is. Default 3. |
--yes | Do not ask before running the redeploy command. |
--assume-benign-green | Without a judge, record the benign check as passed without running it. Recorded as such. |
--rescan | After verifying, replay the original scan's attacks and report the score change. For information only. |
--open-pr | Branch, commit, push and open a pull request, only if every patch passed. Implies --verify. |
--allow-unverified | Open the pull request even though nothing verified the patch. The PR says so. |
--pr-branch <name> | Branch name. Default shield/fix-<hash of the findings>. |
--pr-base <name> | Base branch. Default: your current branch. |
--draft | Open the pull request as a draft. |
--no-push | Commit locally and print the push and PR commands. |
--api-url <url> | Use this instance for this command. |
Give a scan id or --report, not both. Exit code 1 when a live verification refused a patch.
verify-claims
shield-llm verify-claims [options]Replay the attacks of every open fix record and confirm or refuse it. Run it from your deploy job. Fix and verify
| Option | Description |
|---|---|
-c, --config <path> | Configuration file. |
--deployed-at <iso> | The deploy time. Implicit when run right after a deploy. |
--ci | JSON output. |
--replays <n> | Replay each attack n times, 1 to 10. It counts as closed only if every replay is. Default 3. |
--assume-benign-green | Without a judge, record the benign check as passed without running it. Recorded as such. |
Exit code 1 when at least one record is still vulnerable or overfit. Must be logged in to reach a verdict.
report
shield-llm report <scan-id> [-o json|markdown] [--output-file <path>] [--api-url <url>]Fetch a stored scan, with its verification status. Default format JSON.
tests
shield-llm tests [-c <path>] [--remote] [--api-url <url>]List the custom tests in the configuration file, and with --remote those active on this instance.
attacks
shield-llm attacks [--severity <level>] [--api-url <url>]Summarise the attack catalogue served by this instance, optionally for one severity.
presets
shield-llm presets [--api-url <url>]List the presets this instance serves.
login, logout
shield-llm login --key <api-key> [--api-url <url>]
shield-llm logoutlogin checks the key (it starts with sk_shield_) and saves it. A rejected key stops with exit code 2. logout deletes the saved credentials.
Configuration file
shield.config.json, written by init or by hand.
| Key | Description |
|---|---|
endpoint.url | The chatbot's URL. Required. |
endpoint.auth | { "type": "none" }, { "type": "bearer", "token" }, { "type": "api-key", "header", "value" } or { "type": "oauth2", "clientId", "clientSecret", "tokenUrl", "scopes" }. |
endpoint.request.body | The body, with {{prompt}}, and {{history}} for multi-turn on a stateless chatbot. |
endpoint.request.method | POST (default), PUT or PATCH. |
endpoint.request.headers | Extra headers. |
endpoint.request.encoding | json (default), form or multipart. |
endpoint.request.historyFormat | openai or gemini. |
endpoint.response.field | Dot path to the reply text. |
endpoint.response.sessionIdField | Where the chatbot returns a session id, if it uses one. |
endpoint.session | How conversations are kept apart (stateless, client-id, server-id). |
endpoint.timeoutMs | Timeout per request, 1000 to 120000. |
endpoint.allowPrivateUrls | Allow a local or private address. |
endpoint.knownSecrets | Canary strings (8 to 256 characters, up to 20). Any answer that contains one is a proven leak. |
preset, includeCrescendo | Default depth, and multi-turn on or off. |
customTests | Local custom tests: name (unique), prompt, acceptanceCriteria, severity. |
concurrency, delayMs, maxDelayMs, maxRateLimitRetries, maxFloorThrottles, attackTimeoutMs, maxConsecutiveFailures, rateLimitBackoffMs, rateLimitMaxBackoffMs | Pacing and resilience. |
maxUnjudgedPercent, maxNotExecutedPercent | The two completeness limits. |
thresholds | minScore, failOnCritical, maxSeverity, maxVulnerabilities. |
output | format and file. |
codebase | For fix only: root, language (ts, js, py), anchors, redeploy. |
packs | Test packs run after each scan, like --pack. |
profile | What the packs need to know about the bot: company, competitors, allowedScope, sector, locale (en or fr). Never sent to the chatbot as such. |
Output formats
| Format | Use |
|---|---|
json | The full report with the threshold results. For pipelines. |
markdown | A readable table, for a ticket or a wiki. |
sarif | For code-scanning tools such as GitHub's Security tab. |
The CLI writes no PDF: download the PDF reports from the scan page. Download from the scan page
Exit codes
| Code | Meaning |
|---|---|
| 0 | Passed. |
| 1 | A threshold failed. For retest, verify-claims and fix --verify: something is still vulnerable or was refused. |
| 2 | Configuration, usage or credential problem, including a chatbot that refused the scan's credentials mid-run. |
| 3 | Network or runtime problem, including an incomplete scan (rate limiting, judge unavailable, too many attacks not run). |
Files the CLI writes
| File | What |
|---|---|
~/.shield-llm/credentials.json | Your API key and instance URL. |
.shield-llm/checkpoints/ | Progress of running scans, deleted once a scan is saved. |
.shield-llm/claims.json | Fix records, the source of truth for verify-claims. |
shield.config.json | Your configuration. Keep secrets out of it with $NAME. |