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.
How agent mode is detected
Section titled “How agent mode is detected”check, init and upload decide whether an agent runs them. The first match wins:
--agentturns agent mode on, and--no-agentturns it off.WITNYX_AGENT:1ortruemeans an agent, and0orfalsemeans not an agent. Any other value is ignored.AGENT, thenAI_AGENT: any value except an empty one,0orfalsemeans an agent. A plain name in the value, such asmy-agent, becomes the agent’s name in the report.- The variables that coding agents set, in this order:
CLAUDECODE(Claude Code),CURSOR_AGENT(Cursor),GEMINI_CLI(Gemini CLI) andCODEX_SANDBOX(OpenAI Codex). Any value that is not empty means that agent. - Otherwise the caller is not an agent. It is CI when
GITHUB_ACTIONSistrueorCIis1ortrue, 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.
What agent mode changes
Section titled “What agent mode changes”- Standard output carries exactly one JSON document: the report, or the error document when the check cannot run. Invalid arguments to
check,initanduploadgive the error document too.uploadprints 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.
initprints 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:
$ 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:
$ witnyx check --agentwitnyx: no SBOM given, using bom.jsonwitnyx: checking bom.json (3 components)witnyx: done: fail, exit code 1When the check cannot run, standard output carries the error document instead, and the exit code is 2:
$ 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.
Read the report
Section titled “Read the report”| 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.
The agent notes
Section titled “The agent notes”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:
- 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. - Report an incomplete check as incomplete. It is not a pass, because it says nothing about the components it could not check.
- 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.
- Give the user
regulatoryNote.textword for word.
The regulatory note
Section titled “The regulatory note”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.
Next actions
Section titled “Next actions”nextActions lists the steps in the order to take them:
- 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.
- Fix the SBOM when it fails the EU legal minimum, or raise its completeness when a
quality:<min %>rule failed the build. - Add or fix
SECURITY.mdandsecurity.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.
Set up a repository from an agent
Section titled “Set up a repository from an agent”init in agent mode prints its plan and writes nothing:
$ 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.
The skill and AGENTS.md
Section titled “The skill and AGENTS.md”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-checkin 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_sbomtool instead of the command. The report and the notes are the same.
See also: Install for putting witnyx where the agent runs.
What can go wrong
Section titled “What can go wrong”| 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.