semgrep
What it does
This skill runs Semgrep, a code scanning tool, with rule sets chosen for your languages. It is for developers who want a quick, broad security check of their code.
When to use it
- βWhen you want a fast security scan of a project in several languages.
- βWhen you want to see the exact rules that will run before any scan starts.
- βWhen you need a single combined report of findings in a standard format.
Skill link
https://github.com/trailofbits/skills/blob/main/plugins/static-analysis/skills/semgrep/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want to scan my project for security issues with Semgrep, and I want to see the plan before it runs.β
5 new skills a week. 1 minute to read.
How it works
The agent detects the languages in your project, proposes rule sets, and waits for your approval. Then it runs each approved rule set and merges the output into one report. It also says which rule sets did not run.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Semgrep Security Scan
Run a Semgrep scan with automatic language detection, parallel execution, and merged SARIF output.
Essential Principles
- Always use
--metrics=offβ Semgrep sends telemetry by default;--config autoalso phones home. Everysemgrepcommand must include--metrics=offto prevent data leakage during security audits. - User must approve the scan plan (Step 3 is a hard gate) β The original "scan this codebase" request is NOT approval. Present exact rulesets, target, engine, and mode; wait for explicit "yes"/"proceed" before spawning scanners.
- Third-party rulesets are required, not optional β Trail of Bits, 0xdea, and Decurity rules catch vulnerabilities absent from the official registry. Include them whenever the detected language matches.
scripts/run-scans.shgenerates the commands; do not write them yourself β it builds everysemgrepline from the approved list. That is what makes--metrics=off, the--includescoping rule, and the parallel dispatch properties of the code rather than instructions. Give it the approved rulesets and let it run.- Always check for Semgrep Pro before scanning β Pro enables cross-file taint tracking and catches ~250% more true positives. Skipping the check means silently missing critical inter-file vulnerabilities.
- Report what did not run β
scans.jsoncarriesfailedandskippedalongsidescans. 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.
When to Use
- Security audit of a codebase
- Finding vulnerabilities before code review
- Scanning for known bug patterns
- First-pass static analysis
When NOT to Use
- Binary analysis β Use binary analysis tools
- Already have Semgrep CI configured β Use existing pipeline
- Need cross-file analysis but no Pro license β Consider CodeQL as alternative
- Creating custom Semgrep rules β Use
semgrep-rule-creatorskill - Porting existing rules to other languages β Use
semgrep-rule-variant-creatorskill
Output Directory
All scan results, SARIF files, and temporary data are stored in a single output directory.
- If the user specifies an output directory in their prompt, use it as
OUTPUT_DIR. - If not specified, default to
./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.
# 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.sarif
Prerequisites
Required: 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:
# --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 compens
FAQ
Will it run without asking me?
No. The skill requires your clear approval of the scan plan before it starts.
Does it need a paid account?
The skill checks whether Semgrep Pro is available, since Pro finds more cross-file issues. It can run without it.
Does Semgrep send data out?
The skill turns off Semgrep's telemetry on every command to avoid sending data.
Details
Original description by the author
Runs a Semgrep security scan over a codebase: detects languages, selects rulesets, presents the plan for explicit approval, then runs every approved ruleset through scripts/run-scans.sh, which batches the semgrep processes and writes scans.json, and merges the output to SARIF. Supports two scan modes, "run all" for full ruleset coverage and "important only" for security findings at medium-to-high confidence and impact. Uses Semgrep Pro for cross-file taint analysis when it is available. Use when asked to scan code for vulnerabilities, run a security audit with Semgrep, find bugs, or perform st
repo: trailofbits/skills
Popularity
- GitHub stars
- 8.0k
- Ranking position
- #12709
- License
- CC-BY-SA-4.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
audit-context-building
8.0kHelps your agent learn an unfamiliar codebase before a security review, mapping what each function assumes, guarantees and depends on.
algorand-vulnerability-scanner
8.0kHelps your agent scan Algorand smart contracts, written in TEAL or PyTeal, for 11 common security problems such as rekeying attacks and unchecked fees.
audit-prep-assistant
8.0kHelps your agent get a codebase ready for an outside security review, with static analysis, test coverage, dead-code cleanup and clear documentation.
cairo-vulnerability-scanner
8.0kHelps your agent scan Cairo smart contracts on StarkNet for 6 serious problems, including arithmetic overflow, risky cross-layer messages and signature replay.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.