Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Run Semgrep static analysis scan on a codebase using parallel subagents. Supports two scan modes — "run all" (full ruleset coverage) and "important only" (high-confidence security vulnerabilities). Automatically detects and uses Semgrep Pro for cross-file taint analysis when available. Use when asked to scan code for vulnerabilities, run a security audit with Semgrep, find bugs, or perform static analysis. Spawns parallel workers for multi-language codebases.
.claude/skills/trailofbits-semgrep/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 113% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 148% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 94% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 79% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 85% | 0% |
Run a Semgrep scan with automatic language detection, parallel execution, and merged SARIF output.
--metrics=off — Semgrep sends telemetry by default; --config auto also phones home. Every semgrep command must include --metrics=off to prevent data leakage during security audits.scripts/run-scans.sh generates the commands; do not write them yourself — it builds every semgrep line from the approved list. That is what makes --metrics=off, the --include scoping rule, and the parallel dispatch properties of the code rather than instructions. Give it the approved rulesets and let it run.scans.json carries failed and skipped alongside scans. A ruleset whose repo would not clone, or whose scan exited non-zero, must appear in the report. A partial scan presented as a complete one is worse than no scan.semgrep-rule-creator skillsemgrep-rule-variant-creator skillAll scan results, SARIF files, and temporary data are stored in a single output directory.
OUTPUT_DIR../static_analysis_semgrep_1. If that already exists, increment to _2, _3, etc.In both cases, always create the directory with mkdir -p before writing any files.
bash# Resolve output directory if [ -n "$USER_SPECIFIED_DIR" ]; then OUTPUT_DIR="$USER_SPECIFIED_DIR" else BASE="static_analysis_semgrep" N=1 while [ -e "${BASE}_${N}" ]; do N=$((N + 1)) done OUTPUT_DIR="${BASE}_${N}" fi mkdir -p "$OUTPUT_DIR/raw" "$OUTPUT_DIR/results"
The output directory is resolved once at the start of Step 1 and used throughout all subsequent steps.
$OUTPUT_DIR/
├── rulesets.json # The approved plan (Step 3), read by run-scans.sh (Step 4)
├── scans.json # What ran, failed, skipped, and covered nothing (Step 4)
├── raw/ # Per-scan raw output (unfiltered)
│ ├── python-python.json # <language>-<ruleset> for language-scoped rules
│ ├── python-python.sarif
│ ├── python-django.json
│ ├── python-django.sarif
│ ├── all-security-audit.json # all-<ruleset> for cross-language rules, run once
│ ├── all-security-audit.sarif
│ └── ...
└── results/ # Final merged output
└── results.sarifRequired: Semgrep CLI (semgrep --version). If not installed, see Semgrep installation docs.
Optional: Semgrep Pro — enables cross-file taint tracking, inter-procedural analysis, and additional languages (Apex, C#, Elixir). Check with:
bash# --metrics=off because Principle 1 has no exceptions, and this is the first semgrep command # of a run. stderr is kept because "OSS only" has several causes (logged out, no subscription, # registry blocked) and the run downgrades silently for all of them. if PRO_ERR=$(semgrep --pro --validate --metrics=off --config p/default 2>&1); then echo "Pro available" else echo "OSS only" echo " reason: $(printf '%s' "$PRO_ERR" | tail -n 3)" fi
Limitations: OSS mode cannot track data flow across files. Pro mode uses -j 1 for cross-file analysis (slower per ruleset, but parallel rulesets compensate).
Select mode in Step 2. Mode affects both the scan flags and post-processing.
| Mode | Coverage | Findings Reported | |------|----------|-------------------| | Run all | All rulesets, all severity levels | Everything | | Important only | All rulesets, pre- and post-filtered | Security vulns only, medium-high confidence/impact |
Important only applies two filter layers:
--severity WARNING --severity ERROR (CLI flag)category=security, confidence∈{MEDIUM,HIGH}, impact∈{MEDIUM,HIGH}See scan-modes.md for metadata criteria and jq filter commands.
┌──────────────────────────────────────────────────────────────────┐
│ MAIN SESSION (this skill) │
│ Step 1: Detect languages + check Pro availability │
│ Step 2: Select scan mode + rulesets (ref: rulesets.md) │
│ Step 3: Present plan + rulesets, get approval [⛔ HARD GATE] │
│ Step 4: Run scripts/run-scans.sh with the approved rulesets │
│ Step 5: Post-filter, merge, report, delete repos/ │
└──────────────────────────────────────────────────────────────────┘
│ Step 4: Bash
▼
┌──────────────────────────────────────────────────────────────────┐
│ scripts/run-scans.sh │
│ clone each third-party repo once, into repos/ │
│ generate one semgrep command per ruleset │
│ ├── python p/python, p/django --include=*.py│
│ ├── javascript p/javascript --include=*.js│
│ ├── docker p/dockerfile │
│ └── cross-language p/security-audit, p/secrets, │
│ the cloned repos (no filter) │
│ run in batches of --jobs, exit code read per process │
│ write scans.json — scans, failed, skipped │
└──────────────────────────────────────────────────────────────────┘The approval gate stays in the session; the script is execution only and asks nothing. The approved list reaches it as a JSON file, so the scan cannot reach a ruleset the user declined.
Cross-language rulesets go in one shared unit rather than being repeated per language. p/security-audit, p/secrets, and the third-party repos scan the whole target unscoped, so running them once per language ran the identical command N times and left the SARIF merge to dedup the copies.
This plugin ships /static-analysis:semgrep-scan, which runs the whole scan end to end: detect languages and Pro, select rulesets from rulesets.md, run scripts/run-scans.sh, merge and report. Pass it a JSON object, not prose:
/static-analysis:semgrep-scan {"target": "/abs/path", "mode": "run-all"}It does not stop for ruleset approval. Invoking it with a target is the opt-in, the same way /variant-analysis:variants works. That is safe to do because the scan is read-only over the target — no --autofix, every write inside the output directory — so the approval gate below is a scope confirmation rather than a safety one. What ran is recorded in rulesets.json and scans.json either way.
Use the workflow when you want the scan run; work the five steps below when the ruleset selection itself matters and you want to see and edit the list first.
Follow the detailed workflow in scan-workflow.md. Summary:
| Step | Action | Gate | Key Reference | |------|--------|------|---------------| | 1 | Resolve output dir, detect languages + Pro availability | — | Use Glob, not Bash | | 2 | Select scan mode + rulesets | — | rulesets.md | | 3 | Present plan, get explicit approval | ⛔ HARD | AskUserQuestion | | 4 | Run the scans | — | scripts/run-scans.sh | | 5 | Post-filter, merge, report, clean up | — | Merge script (below) |
Task enforcement: On invocation, create 5 tasks with blockedBy dependencies (each step blocks the previous). Step 3 is a HARD GATE — mark complete ONLY after user explicitly approves.
Merge command (Step 5):
bash# run-all uv run {baseDir}/scripts/merge_sarif.py "$OUTPUT_DIR/raw" "$OUTPUT_DIR/results/results.sarif" \ --scans "$OUTPUT_DIR/scans.json" # important-only, once the JSON post-filter has run over every file in raw/ uv run {baseDir}/scripts/merge_sarif.py "$OUTPUT_DIR/raw" "$OUTPUT_DIR/results/results.sarif" \ --important --scans "$OUTPUT_DIR/scans.json"
--scans drops the output of scans listed under .failed. A scan that died part-way may still have written a .sarif, and under --important that file has no post-filter beside it, which is an error rather than an empty filter. Without the flag one dead scan denies every healthy scan a merged result. The excluded files are named on stdout, so they can go in the report.
The post-filter reads metadata SARIF does not carry, so it cannot be re-run against the merged file; --important instead keeps the findings the JSON filter kept, matched on (rule, file, line). Without it results.sarif is unfiltered while the JSON side is not.
| Component | Purpose | |-----------|---------| | scripts/run-scans.sh | Builds every scan command from the approved rulesets, runs them in batches, and writes scans.json |
Step 4 is a Bash call. No subagent runs any part of the scan: exit codes and finding counts are read from the processes and the JSON they wrote.
| Shortcut | Why It's Wrong | |----------|----------------| | "User asked for scan, that's approval" | Original request ≠ plan approval. Present plan, use AskUserQuestion, await explicit "yes" | | "Step 3 task is blocking, just mark complete" | Lying about task status defeats enforcement. Only mark complete after real approval | | "I already know what they want" | Assumptions cause scanning wrong directories/rulesets. Present plan for verification | | "Just use default rulesets" | User must see and approve exact rulesets before scan | | "Add extra rulesets without asking" | Modifying approved list without consent breaks trust | | "Third-party rulesets are optional" | Trail of Bits, 0xdea, Decurity catch vulnerabilities not in official registry — REQUIRED | | "Use --config auto" | Sends metrics; less control over rulesets | | "I'll just run the semgrep commands myself" | run-scans.sh is what enforces --metrics=off, the --include rule and the output-directory --exclude. Hand-written commands drop them silently | | "The script failed, I'll run semgrep directly to get something" | A non-zero exit means no scan succeeded. Report that and stop; a hand-run subset reads as a full scan | | "Some scans failed, the run still finished" | failed and skipped are part of scans.json. Report them or the user reads a partial scan as a clean one | | "Pro is too slow, skip --pro" | Cross-file analysis catches 250% more true positives; worth the time | | "Semgrep handles GitHub URLs natively" | URL handling fails on repos with non-standard YAML; always clone first | | "Cleanup is optional" | Cloned repos pollute the user's workspace and accumulate across runs | | "Use . or relative path as target" | Subagents need absolute paths to avoid ambiguity | | "Let the user pick an output dir later" | Output directory must be resolved at Step 1, before any files are created |
| File | Content | |------|---------| | rulesets.md | Complete ruleset catalog and selection algorithm | | scan-modes.md | Pre/post-filter criteria and jq commands |
| Workflow | Purpose | |----------|---------| | scan-workflow.md | Complete 5-step scan execution process | | scripts/run-scans.sh | The scan runner Step 4 calls |
$OUTPUT_DIRrun-scans.sh exited 0 and wrote $OUTPUT_DIR/scans.jsonfailed and skipped from scans.json are empty, or listed in the reportsemgrep command used --metrics=off$OUTPUT_DIR/rulesets.json at the Step 3 gate, and passed tothe scanner unchanged
coveredNothing from scans.json is empty, or listed in the report$OUTPUT_DIR/raw/results.sarif exists in $OUTPUT_DIR/results/ and is valid JSON--important, unfiltered results preserved in raw/$OUTPUT_DIR/repos/| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | pass→fail | 15,546 | 20,180 | +30% | 1 | 1 | 0% | 1,608 | 5,831 | +263% | 0 | 0 | — |
case-01 | fail→fail | 8,467 | 10,805 | +28% | 1 | 1 | 0% | 895 | 4,638 | +418% | 0 | 0 | — |
case-02 | fail→fail | 10,801 | 11,230 | +4% | 1 | 1 | 0% | 857 | 4,617 | +439% | 0 | 0 | — |
case-03 | fail→fail | 9,922 | 24,304 | +145% | 1 | 1 | 0% | 1,079 | 4,523 | +319% | 0 | 0 | — |
case-04 | pass→pass | 16,521 | 15,573 | -6% | 1 | 1 | 0% | 2,688 | 6,137 | +128% | 0 | 0 | — |
case-05 | pass→pass | 18,002 | 17,345 | -4% | 1 | 1 | 0% | 3,208 | 6,723 | +110% | 0 | 0 | — |
case-07 | fail→pass | 11,680 | 3,449 | -70% | 1 | 1 | 0% | 1,901 | 4,044 | +113% | 0 | 0 | — |
case-08 | fail→pass | 9,812 | 3,849 | -61% | 1 | 1 | 0% | 1,655 | 4,103 | +148% | 0 | 0 | — |
case-09 | pass→pass | 12,161 | 9,098 | -25% | 1 | 1 | 0% | 1,855 | 5,002 | +170% | 0 | 0 | — |
case-10 | fail→pass | 14,165 | 4,666 | -67% | 1 | 1 | 0% | 2,241 | 4,350 | +94% | 0 | 0 | — |
case-11 | fail→pass | 17,407 | 8,839 | -49% | 1 | 1 | 0% | 2,820 | 5,046 | +79% | 0 | 0 | — |
case-12 | fail→pass | 14,848 | 6,619 | -55% | 1 | 1 | 0% | 2,453 | 4,538 | +85% | 0 | 0 | — |
case-13 | pass→pass | 11,407 | 11,898 | +4% | 1 | 1 | 0% | 1,370 | 4,356 | +218% | 0 | 0 | — |
case-14 | fail→pass | 11,625 | 5,793 | -50% | 1 | 1 | 0% | 1,637 | 4,374 | +167% | 0 | 0 | — |
case-15 | fail→pass | 12,575 | 3,225 | -74% | 1 | 1 | 0% | 1,944 | 4,030 | +107% | 0 | 0 | — |
case-16 | fail→pass | 9,576 | 3,137 | -67% | 1 | 1 | 0% | 1,447 | 4,035 | +179% | 0 | 0 | — |
case-17 | fail→pass | 12,254 | 6,143 | -50% | 1 | 1 | 0% | 2,177 | 4,633 | +113% | 0 | 0 | — |
case-18 | pass→pass | 19,074 | 21,144 | +11% | 1 | 1 | 0% | 3,234 | 5,227 | +62% | 0 | 0 | — |
case-23 | fail→pass | 11,364 | 3,059 | -73% | 1 | 1 | 0% | 1,793 | 4,070 | +127% | 0 | 0 | — |
case-19 | fail→pass | 9,696 | 3,859 | -60% | 1 | 1 | 0% | 1,482 | 3,971 | +168% | 0 | 0 | — |
case-20 | pass→pass | 5,360 | 2,654 | -50% | 1 | 1 | 0% | 801 | 3,875 | +384% | 0 | 0 | — |
case-21 | fail→pass | 11,732 | 4,012 | -66% | 1 | 1 | 0% | 1,700 | 4,044 | +138% | 0 | 0 | — |
case-22 | fail→pass | 13,499 | 3,302 | -76% | 1 | 1 | 0% | 2,094 | 3,954 | +89% | 0 | 0 | — |
case-24 | fail→pass | 21,653 | 2,630 | -88% | 1 | 1 | 0% | 1,103 | 3,960 | +259% | 0 | 0 | — |
case-25 | fail→pass | 13,960 | 8,745 | -37% | 1 | 1 | 0% | 2,077 | 4,837 | +133% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 24 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +56 percentage points is the difference between those two pass rates over the 24 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 8/10/2026 | +18% |
Other measured skills in the registry, with their headline benchmark lift.