Documentation

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

bash
npm install -g shield-llm
shield-llm login --key <api-key> --api-url https://shield-llm.com

You 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-url on the command, the SHIELD_API_URL environment variable, the URL saved by login. 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. Set SHIELD_LLM_HOME to keep them under another folder.
  • Configuration is read from shield.config.json in the current folder, or from -c <path>. Options on the command line win over the file.
  • Environment. A .env file in the current folder is loaded at start. $NAME in an authentication value reads the environment variable NAME.

Commands

scan

Run a security scan against a chatbot.

bash
shield-llm scan [options]

Target

OptionDescription
-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-urlsAllow a chatbot on localhost or a private network, with -e or with a config file.

What to run

OptionDescription
--preset <name>dev, quick, owasp, frontier, standard or full. Default standard.
--crescendoAdd 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-testsAdd 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-onlyRun 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.

OptionDescription
--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-resumeIgnore saved progress and start over.
--checkpoint-dir <path>Where progress is saved. Default .shield-llm/checkpoints.

Pass or fail

OptionDescription
--min-score <n>Fail when the score is below n.
--fail-on-criticalFail when a CRITICAL finding is found.
--no-fail-on-criticalReport 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

OptionDescription
-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-payloadsKeep the chatbot's full answers in the JSON on disk. By default they are shortened.
--ciJSON on stdout, progress on stderr, no spinner.
--no-progressNo spinner.
--eu-ai-actPrint 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

bash
shield-llm init

Ask 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

bash
shield-llm validate [-c <path>]

Check the configuration file. Sends nothing.

test-connection

bash
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

bash
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

bash
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

OptionDescription
--finding <attack-id>Retest only this finding. Repeat for several.
--exact-onlyReplay 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-urlsSame as scan.
--ciJSON on stdout, no spinner.
--no-progressNo 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

bash
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.

OptionDescription
--scan <scan-id>The completed scan to attach the results to. Required.
--format <tool>promptfoo or garak. Default: detected from the file.
--ciJSON summary on stdout.
--no-progressNo 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

bash
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

OptionDescription
--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.
--explainShow which recipes apply and which anchors would unlock more.
--jsonThe plan as JSON (implies --explain).
--dry-runPrint the diff, write nothing.
--revertRemove 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-dirtyWrite even if the git working tree has uncommitted changes.
--no-benign-baselineSkip the capture of normal answers before patching.
--verifyRedeploy 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.
--yesDo not ask before running the redeploy command.
--assume-benign-greenWithout a judge, record the benign check as passed without running it. Recorded as such.
--rescanAfter verifying, replay the original scan's attacks and report the score change. For information only.
--open-prBranch, commit, push and open a pull request, only if every patch passed. Implies --verify.
--allow-unverifiedOpen 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.
--draftOpen the pull request as a draft.
--no-pushCommit 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

bash
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

OptionDescription
-c, --config <path>Configuration file.
--deployed-at <iso>The deploy time. Implicit when run right after a deploy.
--ciJSON output.
--replays <n>Replay each attack n times, 1 to 10. It counts as closed only if every replay is. Default 3.
--assume-benign-greenWithout 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

bash
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

bash
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

bash
shield-llm attacks [--severity <level>] [--api-url <url>]

Summarise the attack catalogue served by this instance, optionally for one severity.

presets

bash
shield-llm presets [--api-url <url>]

List the presets this instance serves.

login, logout

bash
shield-llm login --key <api-key> [--api-url <url>]
shield-llm logout

login 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.

KeyDescription
endpoint.urlThe 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.bodyThe body, with {{prompt}}, and {{history}} for multi-turn on a stateless chatbot.
endpoint.request.methodPOST (default), PUT or PATCH.
endpoint.request.headersExtra headers.
endpoint.request.encodingjson (default), form or multipart.
endpoint.request.historyFormatopenai or gemini.
endpoint.response.fieldDot path to the reply text.
endpoint.response.sessionIdFieldWhere the chatbot returns a session id, if it uses one.
endpoint.sessionHow conversations are kept apart (stateless, client-id, server-id).
endpoint.timeoutMsTimeout per request, 1000 to 120000.
endpoint.allowPrivateUrlsAllow a local or private address.
endpoint.knownSecretsCanary strings (8 to 256 characters, up to 20). Any answer that contains one is a proven leak.
preset, includeCrescendoDefault depth, and multi-turn on or off.
customTestsLocal custom tests: name (unique), prompt, acceptanceCriteria, severity.
concurrency, delayMs, maxDelayMs, maxRateLimitRetries, maxFloorThrottles, attackTimeoutMs, maxConsecutiveFailures, rateLimitBackoffMs, rateLimitMaxBackoffMsPacing and resilience.
maxUnjudgedPercent, maxNotExecutedPercentThe two completeness limits.
thresholdsminScore, failOnCritical, maxSeverity, maxVulnerabilities.
outputformat and file.
codebaseFor fix only: root, language (ts, js, py), anchors, redeploy.
packsTest packs run after each scan, like --pack.
profileWhat 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

FormatUse
jsonThe full report with the threshold results. For pipelines.
markdownA readable table, for a ticket or a wiki.
sarifFor 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

CodeMeaning
0Passed.
1A threshold failed. For retest, verify-claims and fix --verify: something is still vulnerable or was refused.
2Configuration, usage or credential problem, including a chatbot that refused the scan's credentials mid-run.
3Network or runtime problem, including an incomplete scan (rate limiting, judge unavailable, too many attacks not run).

Files the CLI writes

FileWhat
~/.shield-llm/credentials.jsonYour API key and instance URL.
.shield-llm/checkpoints/Progress of running scans, deleted once a scan is saved.
.shield-llm/claims.jsonFix records, the source of truth for verify-claims.
shield.config.jsonYour configuration. Keep secrets out of it with $NAME.
CLI reference | Shield LLM