command_directives/synchronous_remediation/skills/secure-at-inception/SKILL.md
Proactive security scanning for newly generated or modified code. Intelligently detects changes, runs appropriate scans (SAST, SCA, IaC), filters to only NEW issues, and prevents vulnerabilities at the source. Use this skill when: - Agent generates new code files - Agent modifies existing code - User asks to "scan for security issues" or "check my changes" - Before committing changes - User mentions "secure at inception", "proactive scan", or "security check"
npx skillsauth add snyk/studio-recipes secure-at-inceptionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Proactively scan all newly generated or modified code to prevent security vulnerabilities before they enter the codebase. Provides intelligent scanning decisions, caching, and filtering to focus only on NEW issues.
| Scan Type | Trigger Files | MCP Tool |
|-----------|--------------|----------|
| SAST (Code) | Source files: .js, .ts, .py, .java, .go, .rb, .php, .cs, .swift, .kt, .scala, .rs, .c, .cpp, .dart, and more | snyk_code_scan |
| SCA (Dependencies) | Manifests: package.json, requirements.txt, pom.xml, build.gradle, Gemfile, go.mod, Cargo.toml, *.csproj, composer.json, and more | snyk_sca_scan |
| IaC | Infrastructure: .tf, .tfvars, K8s YAML (with apiVersion/kind), template.json/.yaml, ARM JSON, serverless.yml | snyk_iac_scan |
Skip: binary files, non-IaC JSON/YAML, documentation (.md, .txt, .rst), assets, test fixtures.
Check for changes using one of these methods (in order of preference):
git diff --name-only HEAD
git diff --name-only --cached # staged files
git status --porcelain
Use the File Type → Scan Type Reference table above to map each changed file to the appropriate scan. IaC YAML is distinguished from generic YAML by the presence of apiVersion/kind (Kubernetes) or AWSTemplateFormatVersion (CloudFormation).
Run SAST, SCA, and IaC scans in parallel — they are independent of each other. Use the parameters below for each applicable scan type (determined by the File Type → Scan Type Reference table).
snyk_code_scan)path: directory containing changed source files (or project root); scan each file individually if < 5 files changed, otherwise scan the parent directoryseverity_threshold: "medium" (default) or as configuredsnyk_sca_scan)path: project root or directory containing the manifestall_projects: true (for monorepos)severity_threshold: "medium" (default) or as configuredsnyk_iac_scan)path: directory containing IaC filesseverity_threshold: "medium" (default) or as configuredApply these filters before reporting to surface only issues introduced by the current changes.
SAST: Include a finding only if its file+line falls within a modified line range from git diff -U0. Parse @@ -X,Y +A,B @@ hunks to determine changed ranges; exclude findings outside those ranges as pre-existing.
SCA: Include only if a new or updated package now has MORE vulnerabilities or higher severity than before. Apply the Net Improvement Rule — if the change reduces overall vulnerability count or severity, do NOT block.
IaC: Include only if the misconfiguration is in a newly added or modified resource block.
| Mode | Block On | Warn On | Allow | |------|----------|---------|-------| | Strict | Low+ | - | - | | Standard | High+ | Medium | Low | | Relaxed | Critical only | High | Medium, Low |
## Secure At Inception Scan Results
### Summary
| Scan Type | New Issues | Blocked |
|----------------------|------------|---------|
| Code (SAST) | X | Yes/No |
| Dependencies (SCA) | Y | Yes/No |
| Infrastructure (IaC) | Z | Yes/No |
### New Code Vulnerabilities (SAST)
| Severity | Type | File | Line | Description |
|----------|---------------|------------|------|-----------------------|
| High | SQL Injection | src/db.ts | 45 | User input in query |
### New Dependency Vulnerabilities (SCA)
| Severity | Package | Vulnerability | Fix Version |
|----------|------------------|----------------------|-------------|
| Critical | [email protected] | Prototype Pollution | 4.17.21 |
### New Infrastructure Issues (IaC)
| Severity | Resource | Issue | Recommendation |
|----------|----------------|-----------------------|--------------------------|
| High | aws_s3_bucket | Public access enabled | Set block_public_access |
### Recommended Actions
1. `/snyk-fix SNYK-JS-LODASH-1234` - Fix lodash vulnerability
2. Review `src/db.ts:45` for SQL injection fix
### Decision: [BLOCKED / ALLOWED]
[Reason based on severity threshold]
If any NEW issue severity >= threshold:
BLOCKED - do not proceed until fixed
Provide specific fix commands
Else:
ALLOWED - safe to proceed
Note any warnings for future attention
After each scan that finds and helps fix issues, run snyk_send_feedback with:
path: project root (absolute path)preventedIssuesCount: count of NEW issues found (delta, not cumulative)fixedExistingIssuesCount: 0 (this skill prevents, doesn't fix existing issues)Only count issues found in NEW code that would have been committed without this scan.
file + content_hash with a 12-hour TTL; only rescan changed files and batch by directory..snyk policy file to suppress confirmed false positives, then re-run to verify:
ignore:
SNYK-JS-EXAMPLE-12345:
- '*':
reason: 'False positive - input is validated upstream'
expires: 2025-12-31
| Situation | Action |
|-----------|--------|
| Authentication error | Run snyk_auth and retry; prompt user for manual authentication if still failing |
| Scan timeout | Retry once with smaller scope; report partial results if still failing |
| No changes detected | Report "No code changes detected - nothing to scan"; offer full project scan on request |
| Unsupported files only | Report "No scannable files in changes" with a list of skipped file types and reasons |
development
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)
testing
Helps choose secure, healthy open-source packages by evaluating vulnerability status, maintenance health, popularity, community, and security posture. Use this skill when: - Agent needs to import a new dependency - User asks "which package should I use for X?" - User wants to compare packages (A vs B) - User asks "is this package safe?" - User asks for a "secure alternative" to a package - User mentions "dependency health", "package chooser", or "package security"
testing
Helps choose secure, healthy open-source packages by evaluating vulnerability status, maintenance health, popularity, community, and security posture. Use this skill when: - Agent needs to import a new dependency - User asks "which package should I use for X?" - User wants to compare packages (A vs B) - User asks "is this package safe?" - User asks for a "secure alternative" to a package - User mentions "dependency health", "package chooser", or "package security"
development
Software Bill of Materials (SBOM) security analysis for vulnerability assessment and third-party risk management. Validates SBOMs from vendors or generates SBOMs for internal projects. Use this skill when: - User asks to analyze an SBOM file - User mentions "third-party risk" or "vendor security" - User needs to validate a supplier's SBOM - User wants to check SBOM for vulnerabilities - User asks about CycloneDX or SPDX formats