Skip to content

Use from an AI agent

witnyx check reads a software bill of materials (SBOM) and reports what it found. When an AI coding agent runs it, it switches to agent mode: one JSON document on standard output, short progress lines on standard error, and fixed notes that tell the agent how to report the result. This page is for the people who set up an agent. The agent’s own instructions are AGENTS.md and a skill, both in the repository.

check, init and upload decide whether an agent runs them. The first match wins:

  1. --agent turns agent mode on, and --no-agent turns it off.
  2. WITNYX_AGENT: 1 or true means an agent, and 0 or false means not an agent. Any other value is ignored.
  3. AGENT, then AI_AGENT: any value except an empty one, 0 or false means an agent. A plain name in the value, such as my-agent, becomes the agent’s name in the report.
  4. The variables that coding agents set, in this order: CLAUDECODE (Claude Code), CURSOR_AGENT (Cursor), GEMINI_CLI (Gemini CLI) and CODEX_SANDBOX (OpenAI Codex). Any value that is not empty means that agent.
  5. Otherwise the caller is not an agent. It is CI when GITHUB_ACTIONS is true or CI is 1 or true, and a person in every other case.

Values are compared without regard to letter case or surrounding spaces. When the flag or WITNYX_AGENT turns agent mode on, the agent’s name still comes from the variables of steps 3 and 4.

Cursor also sets its variable in its editor terminals, so a person working there gets agent mode; pass --no-agent to get the text report. An agent that sets none of these variables passes --agent.

The report records the decision in caller: type is agent, ci or human; name names the agent or CI system when it is known; and detectedBy names the flag or variable that decided, such as flag:--agent or env:CLAUDECODE. A check through the MCP server always runs as an agent, with detectedBy set to mcp.

version, cache update and schema print the same output in every mode.

  • Standard output carries exactly one JSON document: the report, or the error document when the check cannot run. Invalid arguments to check, init and upload give the error document too. upload prints its own document; see its reference page.
  • The JSON is ASCII only, so any JSON parser reads it.
  • Standard error carries short progress lines that start with witnyx: . There is no colour and no prompt.
  • The exit codes are the same: 0 when no failure rule triggered, 1 when one did, 2 when the check could not run.
  • init prints its plan and writes only with --write.

Put --agent after the command name, as in witnyx check --agent. An error that comes before the command name, such as a misspelt command, is printed as plain text.

Here is an excerpt of a report for an agent, from an SBOM with an actively exploited vulnerability:

Terminal window
$ witnyx check bom.json --agent
{
"schema" : "https://witnyx.dev/schemas/report/v1.json",
"caller" : {
"type" : "agent",
"detectedBy" : "flag:--agent"
},
"result" : {
"status" : "fail",
"complete" : true,
"failOn" : [ "exploited" ],
"triggeredBy" : [ "exploited" ],
"exitCode" : 1
},
"nextActions" : [ "Upgrade org.apache.logging.log4j:log4j-core to 2.15.0 (CVE-2021-44228)", "Add SECURITY.md with a security contact (email address or URL); witnyx init creates a template", "Publish .well-known/security.txt with Contact and Expires (RFC 9116)" ],
"regulatoryNote" : {
"text" : "An actively exploited vulnerability is in a component you ship. If it affects your product and the product is sold in the EU, reporting under the EU Cyber Resilience Act (Article 14) may apply. This check recorded when you were made aware. This is not legal advice.",
"relayVerbatim" : true,
"notLegalAdvice" : true
},
"agentNotes" : [ "Do not add or approve 'not affected' entries without asking the user; leave approvedBy empty.", "If result.complete is false, tell the user the check is incomplete; do not describe it as passing.", "Exit code 1 means the failure rule triggered, not that the tool failed.", "Relay regulatoryNote.text verbatim; it is not legal advice." ]
}

Standard error of the same kind of run, here without a path, so the check finds the SBOM itself:

Terminal window
$ witnyx check --agent
witnyx: no SBOM given, using bom.json
witnyx: checking bom.json (3 components)
witnyx: done: fail, exit code 1

When the check cannot run, standard output carries the error document instead, and the exit code is 2:

Terminal window
$ witnyx check bom.json --agent --fail-on exploitd
{
"schema" : "https://witnyx.dev/schemas/error/v1.json",
"error" : {
"code" : "WX-CONFIG",
"message" : "Unknown value 'exploitd' in --fail-on.",
"hint" : "Supported values: exploited, critical, high, eol, quality:<min %>, none.",
"retryable" : false
}
}

error.retryable says whether running again unchanged may succeed.

Field What it says
schema Which document this is: the report (https://witnyx.dev/schemas/report/v1.json) or the error document (https://witnyx.dev/schemas/error/v1.json).
result.status pass, fail or incomplete. A failed check can be incomplete too.
result.complete false when some components or required sources were not checked.
result.triggeredBy The failure rules that triggered.
result.exitCode The exit code of the run.
findings Every finding, each with a fix (what to change; fix.files names the manifest files when Witnyx found them) and a docsUrl.
nextActions The steps to take, in order.
dataSources Which sources answered, which came from the cache, and why any failed.
regulatoryNote Present when the report has an actively exploited vulnerability that is not assessed as not affected.
agentNotes The four notes below, in every report for an agent.

The report schema describes every field, and the error schema the error document.

Every report for an agent carries the same four notes in agentNotes, in this order. Reports for people and for CI carry none:

Do not add or approve 'not affected' entries without asking the user; leave approvedBy empty.
If result.complete is false, tell the user the check is incomplete; do not describe it as passing.
Exit code 1 means the failure rule triggered, not that the tool failed.
Relay regulatoryNote.text verbatim; it is not legal advice.

What they ask of the agent:

  1. Ask the user before adding a “not affected” entry, and never approve one. A person fills in approvedBy; Mark a finding “not affected” explains why.
  2. Report an incomplete check as incomplete. It is not a pass, because it says nothing about the components it could not check.
  3. Read exit code 1 as a result, not as an error of the tool: the check ran and the failure rule triggered. Do not change the rule to make the check pass.
  4. Give the user regulatoryNote.text word for word.

regulatoryNote appears when the report has an actively exploited vulnerability that is not assessed as not affected. A pending assessment does not remove it. Its text is fixed, and relayVerbatim and notLegalAdvice are always true. The text report shows the same paragraph to a person.

The note refers to reporting under Article 14 of the EU Cyber Resilience Act, Regulation (EU) 2024/2847 (text on EUR-Lex). Whether that applies to your product is for you to decide, and the note is not legal advice. EU Cyber Resilience Act basics explains what the Act asks of software makers.

nextActions lists the steps in the order to take them:

  1. Upgrade each component that has an actively exploited vulnerability, to the version that fixes it, naming the manifest files when Witnyx found them. When no fixed version is known, the step says to find one.
  2. Fix the SBOM when it fails the EU legal minimum, or raise its completeness when a quality:<min %> rule failed the build.
  3. Add or fix SECURITY.md and security.txt.

Other findings, such as components past their end of life, are not steps of their own: each finding’s fix says what to change.

init in agent mode prints its plan and writes nothing:

Terminal window
$ witnyx init --agent
{
"schema" : "https://witnyx.dev/schemas/init/v1.json",
"files" : [ {
"path" : ".witnyx.yml",
"purpose" : "Witnyx settings: when to fail the build, and vulnerabilities assessed as not affected",
"status" : "planned"
}, {
"path" : "SECURITY.md",
"purpose" : "Security policy template; it names no contact until the owner adds one",
"status" : "planned"
}, {
"path" : ".github/workflows/release-security-check.yml",
"purpose" : "GitHub workflow that runs the release security check on every push and pull request",
"status" : "planned"
} ],
"nextActions" : [ "Run witnyx init again with --write to create the planned files", "Add a security contact (email address or URL) to SECURITY.md" ]
}

The agent shows the plan to the user, and runs witnyx init --agent --write only when the user asks for the files. A file that exists is kept, with a reason, and never changed. The SECURITY.md template names no contact: the agent asks the user for an email address or a web address, and never invents one.

An agent always runs init with --agent. Without it, an agent that is not detected creates the files at once. Configure .witnyx.yml describes the three files.

  • AGENTS.md, in the repository, is the contract for agents: how to run Witnyx, how to read its output, and what an agent must never do.
  • The skill in skills/witnyx-release-check in the repository tells a coding agent when to run the check, after a dependency changes and before a release, and how to report the result to the user. Copy the folder to where your agent loads its skills from.
  • With the MCP server registered, the skill tells the agent to call its check_sbom tool instead of the command. The report and the notes are the same.

See also: Install for putting witnyx where the agent runs.

What you see What to do
JSON where you expected the text report An agent’s variable is set in your shell, for example in Cursor’s terminal. Pass --no-agent.
The text report where an agent expected JSON The agent sets none of the variables. Have it pass --agent.
A plain-text usage error instead of the error document The error came before the command name, such as a misspelt command. Check the command, and put --agent after its name.
The agent calls an incomplete check a pass Point it to result.complete and the second agent note.
The agent treats exit code 1 as a broken tool Point it to the third agent note: the check ran, and the rule triggered.

Witnyx is a record-keeping and workflow tool. It does not certify compliance. Nothing on this site is legal advice.