Complete security remediation workflow. Scans code for vulnerabilities using Snyk, fixes them, validates the fix, and optionally creates a PR. Supports both single-issue and batch mode for multiple vulnerabilities. Use this skill when: - User asks to fix security vulnerabilities - User mentions "snyk fix", "security fix", or "remediate vulnerabilities" - User wants to fix a specific CVE, Snyk ID, or vulnerability type (XSS, SQL injection, path traversal, etc.) - User wants to upgrade a vulnerable dependency - User asks to "fix all" vulnerabilities or "fix all high/critical" issues (batch mode)
90
88%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Complete security remediation workflow: Parse → Scan → Analyze → Fix → Validate → Summary → (Optional) PR
Modes:
Parse user input to extract:
code, sca, or both (inferred from context)| Signal | Mode | Scan Type |
|---|---|---|
| "all", severity filter, count ("top 5"), or "batch" | Batch | both |
| Specific vuln ID, single type, file reference, or no batch indicators | Single (default) | — |
| Explicit "code"/"sast"/"static" | — | code |
| Explicit "sca"/"dependency"/"package"/package manager name | — | sca |
SNYK- or CVE- ID provided | — | both |
| Vulnerability type (XSS, SQL injection, path traversal, etc.) or file reference | — | code |
| Package name reference | — | sca |
| No hints | — | both (highest priority issue) |
mcp_snyk_snyk_code_scan and mcp_snyk_snyk_sca_scan on project root.stop_on_failure=true, else continue.Batch limits: max 20 vulnerabilities, max 15 files modified, max 3 fix attempts per item.
Invoke scans with the target path. Examples:
# Code scan
mcp_snyk_snyk_code_scan:
path: "/absolute/path/to/project" # or subdirectory for targeted scans
# SCA scan
mcp_snyk_snyk_sca_scan:
path: "/absolute/path/to/project" # always project root (manifest location)mcp_snyk_snyk_code_scan on target pathmcp_snyk_snyk_sca_scan on project rootAfter selecting vulnerability type, collect ALL instances of that same Snyk ID in the same file. Fix all of them together.
Display a brief summary: type (Code/SCA), ID, severity, title, and for Code — instance count + file/line table; for SCA — package, fix version, dependency path.
Read all vulnerable locations. Identify type (SQL injection, XSS, path traversal, command injection, sensitive data exposure, hardcoded secrets, crypto issues, etc.). Review Snyk's remediation guidance.
Document: vulnerability type, root cause, fix approach, security mechanism, instance count.
Common patterns:
Identify manifest files, whether dependency is direct or transitive, and which direct dep pulls in the vulnerable transitive.
grep -r "from 'package'" --include="*.ts" --include="*.js"
grep -r "require('package')" --include="*.ts" --include="*.js"Add TODO comments with migration notes if complex breaking changes detected.
Edit ONLY the necessary dependency to the LOWEST version that fixes the vulnerability. Preserve file formatting.
Run appropriate install command (npm install, yarn install, pip install -r requirements.txt, mvn dependency:resolve, etc.).
Run same scan as Phase 2 (using identical path parameter). Verify ALL targeted instances are resolved.
Compare pre/post scan. Record all additional vulnerabilities resolved by the upgrade (ID, severity, title).
Run project tests (npm test, pytest, etc.). On failure: prefer adjusting fix over changing tests; only modify tests for legitimate behavioral changes. Max 2 attempts.
Run project linter if configured; fix any formatting issues introduced.
Display a concise remediation summary including:
End with a visually separated PR prompt:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## Should I create a PR for this fix? (yes / no)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━mcp_snyk_snyk_send_feedback:
fixedExistingIssuesCount: [total issues fixed]
preventedIssuesCount: 0
path: [absolute project path]IMPORTANT: Do NOT proceed until the user explicitly confirms.
Display overall results (attempted/fixed/partial/failed/skipped), breakdown by severity (fixed vs remaining), detailed per-item results for code and SCA vulns, files modified, validation results, and a table of issues NOT fixed with reasons.
End with:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
## Should I create a single PR for all these fixes? (yes / no)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━mcp_snyk_snyk_send_feedback:
path: [project root]
fixedExistingIssuesCount: [total across all vulns]
preventedIssuesCount: 0Branch: fix/security-batch-YYYYMMDD or fix/security-critical-high-batch.
Default: single commit with all changes (offer per-vuln commits if user prefers).
PR body: summary table of code fixes (vuln, file, CWE, severity), dependency upgrades (package, old→new, CVEs fixed), validation checklist, note that each fix was validated independently.
git statusVerify uncommitted changes exist and are security-fix related. If none: report and STOP.
Format: fix/security-<identifier> (e.g., fix/security-SNYK-JS-LODASH-1018905, fix/security-cwe-79-xss, fix/security-path-traversal-server).
git checkout -b fix/security-<identifier>Stage only security-fix related files. Do NOT stage unrelated changes, IDE files, or build artifacts.
git add <files>
git commit -m "fix(security): <description>
Resolves: [Snyk ID or CVE]
Severity: [Critical/High/Medium/Low]"git push -u origin fix/security-<identifier>
gh pr create --title "Security: <title>" --body "<body>" --base mainDo NOT use --label flags.
PR body should include: vulnerability details (ID, severity, type), changes made, files changed, and validation checklist (Snyk scan passes, tests pass, no new vulnerabilities introduced).
Display PR URL, branch, title, and next steps (review, request reviews, merge when approved).
| Situation | Action |
|---|---|
| Auth error | Run mcp_snyk_snyk_auth, retry once; if still failing STOP |
| Scan timeout/failure | Retry once; if still failing STOP and report |
| Vulnerability not found | Report clearly and STOP — do not guess or fix something else |
| Unfixable code vuln | Add TODO comment with context; report with manual remediation suggestions; no partial/broken fixes |
| SCA — no fix available | Document clearly; suggest alternatives (replace package, patch, accept risk); no changes |
| Partial success (code) | Keep successful fixes; add TODO for unfixed instances; report partial success with breakdown |
| Not a git repo | STOP — cannot create PR |
| Branch already exists | Generate unique branch name with timestamp |
| gh not authenticated | Suggest gh auth login |
Rollback triggers (revert ALL changes if):
Single Mode: Fix one vulnerability TYPE per run (all instances). Minimal changes only. No new vulnerabilities. Tests must pass. No scope creep or refactoring. Always prompt for PR.
Batch Mode adds: User must approve plan before starting. Max 20 vulnerabilities, 15 files. Validate each fix before proceeding. Partial success allowed. Single PR for all batch fixes (unless user requests otherwise).
Single Mode: vulnerability documented → fix applied → re-scan clean → tests pass → summary shown → Snyk feedback sent → PR prompt asked → PR created if confirmed.
Batch Mode: full scan done → plan shown and approved → all items attempted → each fix validated → results tracked → batch summary shown → Snyk feedback sent → PR prompt asked → single PR created if confirmed.
adb5a9a
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.