codeql
What it does
This skill runs CodeQL, a code analysis tool, on your project and reports security issues found by following data from input to dangerous operations. It is for security engineers and developers who want a deep scan.
When to use it
- βWhen you want a thorough static security scan of a codebase in a supported language.
- βWhen you need to know whether user input can reach a dangerous function in your code.
- βWhen simple pattern searches miss problems that depend on several files working together.
Skill link
https://github.com/trailofbits/skills/blob/main/plugins/static-analysis/skills/codeql/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 you to run a CodeQL security scan on my repository and list the likely vulnerabilities.β
5 new skills a week. 1 minute to read.
How it works
The agent builds a database from the source code, checks that it captured the code properly, and runs a set of security queries. It then reports the results with the paths data took through the code.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
CodeQL Analysis
Supported languages: Python, JavaScript/TypeScript, Go, Java/Kotlin, C/C++, C#, Ruby, Swift.
Skill resources: Reference files and templates are located at {baseDir}/references/ and {baseDir}/workflows/.
Essential Principles
Database quality is non-negotiable. A database that builds is not automatically good β a cached build extracts nothing while reporting success.
Data extensions catch what CodeQL misses. Django, Spring, and Express projects still wrap database calls, request parsing, and shell execution in project-specific APIs that no shipped model covers.
Explicit suite references prevent silent query dropping. Never pass pack names to
codeql database analyzeβ each pack'sdefaultSuiteFileapplies hidden filters that can produce zero results. Always generate a.qls.Zero findings needs investigation, not celebration. It can mean poor extraction, missing models, the wrong packs, or suite filtering. Run
{baseDir}/scripts/check_db_quality.pyafter the build, confirm{baseDir}/scripts/verify_query_suite.pyexited zero for the suite in use β the generation scripts run it, so invoke it by hand only for a reused or hand-edited suite β and say in the report that both passed.macOS Apple Silicon requires workarounds for compiled languages. Exit code 137 is an
arm64e/arm64mismatch, not a build failure. Try Homebrew arm64 tools or Rosetta before falling back tobuild-mode=none.Follow workflows step by step. Each phase gates the next; skipping quality assessment or data extensions leaves the gap invisible in the results.
Each Bash call is a fresh shell
Nothing carries across a Bash call: not variables, not arrays, not functions sourced from
build_log.sh. Every block below that uses a value must re-establish it in the same block.
The workflows point back here rather than repeating it; what they do state is the specific
damage at that site, because each one fails differently and silently:
- a lost function makes
run_loggedexit 127, which the build ladder reads as a failed method and walks down to--build-mode=none, never having invoked CodeQL - a lost array expands to nothing, so every
--threat-modeland--model-packsthe user chose is dropped while the final report still lists them as used - a lost scalar under
set -uaborts the block withunbound variable
Output Directory
All generated files (database, build logs, diagnostics, extensions, results) 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_codeql_1. If that already exists, increment to_2,_3, etc.
In both cases, always create the directory with mkdir -p before writing any files.
Set USER_SPECIFIED_DIR to the literal path from the user's prompt before running this,
or leave it unset to auto-increment. Nothing else assigns it.
# Resolve output directory
USER_SPECIFIED_DIR="${USER_SPECIFIED_DIR:-}" # substitute the user's path here, if any
if [ -n "$USER_SPECIFIED_DIR" ]; then
OUTPUT_DIR="$USER_SPECIFIED_DIR"
else
BASE="static_analysis_codeql"
N=1
while [ -e "${BASE}_${N}" ]; do
N=$((N + 1))
done
OUTPUT_DIR="${BASE}_${N}"
fi
mkdir -p "$OUTPUT_DIR"
The output directory is resolved once at the start before any workflow executes. All workflows receive $OUTPUT_DIR and store their artifacts there:
$OUTPUT_DIR/
βββ rulesets.txt # Selected query packs (logged after Step 3)
βββ codeql.db/ # CodeQL database (dir containing codeql-database.yml)
βββ build.log # Build log
βββ codeql-config.yml # Exclusion config (interpreted languages)
βββ diagnostics/ # Diagnostic queries and CSVs
βββ extensions/ # Data extension YAMLs
βββ raw/ # Unfiltered analysis output
β βββ results.sarif
β βββ run-all.qls | important-only.qls
βββ results/ # Final results (filtered for important-only, copied for run-all)
βββ results.sarif
Database Discovery
A CodeQL database is identified by the presence of a codeql-database.yml marker file inside its directory. When searching for existing databases, always collect all matches β there may be multiple databases from previous runs or for different languages.
**Discovery co
FAQ
Which languages does it cover?
The skill covers Python, JavaScript and TypeScript, Go, Java and Kotlin, C and C++, C#, Ruby, and Swift.
Why does a zero-finding result need checking?
No findings can mean the scan missed the code. The skill runs quality checks to confirm the results mean something.
Does it run on Apple Silicon Macs?
Yes, with extra steps for compiled languages, which the skill describes.
Details
Original description by the author
Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and taint tracking analysis. Triggers on "run codeql", "codeql scan", "build codeql database", "SAST scan", "taint analysis", "dataflow analysis", or "find vulnerabilities in this repo". Covers Python, JavaScript/TypeScript, Go, Java/Kotlin, C/C++, C#, Ruby, and Swift. Supports "run all" (security-and-quality + security-experimental) and "important only" (high-precision) scan modes, and creates data extension models for project-specific sources and sinks. For fast single-file pattern matching, or when no bui
repo: trailofbits/skills
Popularity
- GitHub stars
- 8.0k
- Ranking position
- #12707
- 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.