Use when the user wants to fix, remediate, or resolve a security risk or vulnerability (\"how do I fix this risk\", \"remediate this finding\"): Apiiro remediation prompts, Guardian AI fixes, and server-side AutoFix jobs. To list risks: guardian-risks.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Guardian Fix?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/apiiro-guardian-fix)
---
name: guardian-fix
description: "Use when the user wants to fix, remediate, or resolve a security risk or vulnerability (\"how do I fix this risk\", \"remediate this finding\"): Apiiro remediation prompts, Guardian AI fixes, and server-side AutoFix jobs. To list risks: guardian-risks."
---
# Apiiro Fix
Remediate security risks via the Apiiro CLI.
## Recommended: one-shot fix
`apiiro risks fix <id>` does the whole remediation in a single command: it tries
the deterministic, Apiiro-curated remediation first and automatically falls back
to Guardian AI when there isn't one (for example, diff-scan risks). It returns a
single unified result.
```bash
apiiro risks fix <risk-id>
apiiro risks fix <risk-id> --repository-key <key> # scope the Guardian fallback explicitly
apiiro risks fix <risk-id> -o json # machine-readable
```
JSON result shape:
```json
{ "is_prompt": true, "content": "<remediation>", "success": true, "source": "curated" }
{ "is_prompt": true, "content": "<remediation>", "success": true, "source": "guardian" }
```
`source` tells you whether the remediation is the deterministic curated one
(`curated`) or was generated by Guardian (`guardian`). The repository for the
Guardian fallback is auto-detected from the current git remote unless
`--repository-key` is given.
Then **apply the fix**: use the returned `content` to make the code changes.
### Passing risk context (automation / IDE integrations)
`--context <path>` takes a path to a plain JSON file of the shape
`{ "branch": "<branch>", "risk": { ...full risk object... } }` — `risk` is the
complete risk data from the scan result, `branch` (optional) scopes the
Guardian fallback to the branch where the risk was found. The caller writes
the file (e.g. to a temp directory) and cleans it up after the run; the CLI
only reads it. The risk data is handed to Guardian **verbatim**, so it
remediates exactly that risk instead of looking it up by id — which is what
lets it fix **diff-scan risks**, whose ids aren't in the queryable store (an
id lookup alone returns nothing). It's ignored on the curated path, so it's
safe to always pass.
```bash
apiiro risks fix <risk-id> --repository-key <key> --context /tmp/risk-context.json -o json
```
## Manual two-step (equivalent, for control)
If you want to run the steps yourself:
1. `apiiro risks <risk-id> --remediate` — curated remediation. If `is_prompt: true`, apply `content`. If `is_prompt: false`, go to step 2. On `error: unknown option '--remediate'` (older CLI), use `apiiro risks remediate <risk-id>`.
2. `apiiro ask "how do I remediate risk <risk-id>?" --timeout 120` — Guardian fallback. On `unknown command 'ask'` (older CLI), use `apiiro guardian query` with the same arguments.
## Options
`-o, --output <json|text>`, `-f, --file <path>`, `--repository-key <key>` (fix only), `--context <path>` (fix only), `--no-color`.
## Server-side AutoFix
Use AutoFix to queue fixes on the server and follow their jobs. Ask the user before either write, then pass `--yes` when running it from an agent; an unattended write without `--yes` is refused.
```bash
apiiro autofix trigger <riskKey...> --yes
apiiro autofix trigger <riskKey...> --dry-run --yes
apiiro autofix
apiiro autofix --risk <riskKey> --status Queued AgentWorking
apiiro autofix --status Completed --status Failed -o json
apiiro autofix <jobId>
apiiro autofix <jobId> --open-pr --yes
```
Trigger accepts 1-100 distinct risk keys, removes duplicates, and prints `jobs` and `skipped` reasons.
If every risk is skipped, the command exits nonzero. `--dry-run` pushes a branch without opening a pull request; organization simulation settings can also force a dry run.
`--open-pr` works only on a completed dry-run job with no pull request yet (`canOpenPr: true`). Opening a pull request is queued. Read the job again to see `pullRequest.url`, `pullRequest.number` (a string), and `pullRequest.status`.
Job details include `canOpenPr`, job and per-risk failure reasons, per-risk status, summary, and changed files.
List filters: `--risk <riskKey>` and repeatable, variadic `--status <statuses...>`.
Allowed statuses: `Queued`, `AssemblingContext`, `AgentWorking`, `Completed`, `Failed`, `Cancelled`.
Lists keep newest-first server order and fetch 5 pages of 20 jobs by default.
Use `--page-size` (max 100) and `--max-pages` (-1 for no limit) to fetch more; a warning reports truncation.
Job IDs and `--open-pr` cannot combine with list filters or paging flags.
All AutoFix modes support `-o json|text` and `-f <path>`; list JSON is `{ items, truncated }`; other modes preserve server fields. Put trigger flags after `trigger`, for example `apiiro autofix trigger <riskKey...> --yes -o json`.
AutoFix requires read permission for reads and write permission for writes. Trigger can also return a permission error when AI consent is off for the organization.