$npx -y skills add aws/agent-toolkit-for-aws --skill remediating-with-aws-security-agentPull AWS Security Agent findings (penetration tests and code reviews) and drive remediation. Use this whenever the user mentions Security Agent, security findings, pentest or penetration test results, code review findings, vulnerabilities found in their AWS account, "what did the
| 1 | # Security Agent Remediation |
| 2 | |
| 3 | AWS Security Agent is a frontier agent that runs on-demand penetration tests and code |
| 4 | reviews against a customer's applications and reports verified security risks. This skill |
| 5 | takes you from "I have findings somewhere in AWS" to "I'm actively fixing the most |
| 6 | important ones," while keeping the sensitive exploit detail out of source control. |
| 7 | |
| 8 | The flow has four stages, and they matter in order: |
| 9 | |
| 10 | 1. **Discover** which scans exist and how the account is configured (live, read-only). |
| 11 | 2. **Export** the findings to a local gitignored directory. |
| 12 | 3. **Triage** the findings into a prioritized, human-readable plan. |
| 13 | 4. **Remediate** by offering to fix the highest-risk issues. |
| 14 | |
| 15 | ## Why the ordering and the guardrails matter |
| 16 | |
| 17 | Findings contain working attack scripts, reproduction steps, file paths, and sometimes |
| 18 | leaked secrets or environment details. If that lands in a Git repo, a customer can |
| 19 | accidentally commit and publish a step-by-step exploit for their own production system. |
| 20 | So the non-negotiable rule is: **findings are written only to `.security-agent/`, and that |
| 21 | path is gitignored before anything is written.** |
| 22 | |
| 23 | ## Stage 1: Discover scans (live, read-only) |
| 24 | |
| 25 | Find out what the account has. All commands are read-only `list-*` operations. |
| 26 | |
| 27 | AWS Security Agent organizes data as a hierarchy — work down it: |
| 28 | |
| 29 | ``` |
| 30 | Application (account + Region) |
| 31 | └── Agent Space (workspace for design review, code review, and pentests) |
| 32 | ├── Penetration test → Pentest job → Findings |
| 33 | └── Code review → Code review job → Findings |
| 34 | ``` |
| 35 | |
| 36 | Run these to orient yourself and show the user what exists: |
| 37 | |
| 38 | ```bash |
| 39 | aws securityagent list-agent-spaces |
| 40 | aws securityagent list-pentests --agent-space-id <as-...> |
| 41 | aws securityagent list-code-reviews --agent-space-id <as-...> |
| 42 | aws securityagent list-pentest-jobs-for-pentest --agent-space-id <as-...> --pentest-id <pt-...> |
| 43 | aws securityagent list-code-review-jobs-for-code-review --agent-space-id <as-...> --code-review-id <cr-...> |
| 44 | ``` |
| 45 | |
| 46 | Job `status` is one of `IN_PROGRESS`, `STOPPING`, `STOPPED`, `FAILED`, `COMPLETED`. Only |
| 47 | `COMPLETED` jobs have a stable, full set of findings. |
| 48 | |
| 49 | ### Match the codebase to a scan, then confirm |
| 50 | |
| 51 | Agent spaces, pentests, and code reviews are named after the application they target. |
| 52 | Before asking the user to pick from a raw list, make an informed guess about which scan |
| 53 | corresponds to *this* repository — the user is working in a codebase for a reason, and |
| 54 | the relevant findings are almost always for the app in front of them. |
| 55 | |
| 56 | Infer the app identity from the workspace using cheap, high-signal sources: |
| 57 | |
| 58 | - The repository / root directory name and the Git remote URL (`git remote -v`). |
| 59 | - Project manifests and their `name`/`description` (`package.json`, `pyproject.toml`, |
| 60 | `*.csproj`, `go.mod`, `Cargo.toml`). |
| 61 | - README titles, product/steering docs, and any obvious product or company name. |
| 62 | - Distinctive frameworks or domains that match a scan title. |
| 63 | |
| 64 | Compare those signals against the agent space / scan names (case-insensitive, allow |
| 65 | partial and fuzzy matches). |
| 66 | Then **always confirm before exporting** — present your best guess and your reasoning, and |
| 67 | let the user correct it: |
| 68 | |
| 69 | > "This repo looks like **`<product>`** (from `<signal>`), which matches the **<name>** agent |
| 70 | > space. Use that, or pick another? [Other Agent Space names, ...]" |
| 71 | |
| 72 | If nothing matches with reasonable confidence, say so plainly and show the full list rather |
| 73 | than forcing a wrong guess. Never export from a guessed scan without the user's confirmation. |
| 74 | |
| 75 | ## Stage 2: Export findings to `.security-agent/` (gitignored) |
| 76 | |
| 77 | Pull findings using AWS CLI commands. Write everything into `.security-agent/` in the repo — |
| 78 | never to chat or stdout — because findings include working attack scripts, reproduction |
| 79 | steps, and sometimes leaked secrets. |
| 80 | |
| 81 | ### 1. Lock down the output directory before pulling anything |
| 82 | |
| 83 | ```bash |
| 84 | mkdir -p .security-agent |
| 85 | echo '*' > .security-agent/.gitignore |
| 86 | ``` |
| 87 | |
| 88 | ### 2. Resolve the latest COMPLETED job |
| 89 | |
| 90 | You should already have the `agentSpaceId` and the pentest/code-review id from Stage |