Introduction¶
When performing security scans in repositories, the common approach involves installing separate instances of CodeQL or Semgrep, memorizing numerous CLI parameters, and manually merging multiple JSON/SARIF reports. In model-assisted coding scenarios, workflow issues such as “failing to disable telemetry,” “scanning with unconfirmed rule sets,” or “treating build failures as indicating no vulnerabilities” are more prone to occur.
The static-analysis plugin, provided by Trail of Bits in the skills marketplace, encapsulates deep analysis (CodeQL), rapid pattern scanning (Semgrep), and result processing (SARIF) into a set of Agent Skills, accompanied by fixed scripts and workflow commands. The following sections introduce what it is, what it can do, and how to install and invoke it.
What is this¶
static-analysis is a plugin within the Code Auditing category of the Trail of Bits Skills Marketplace, positioned as a “Static Analysis Toolkit”: it utilizes CodeQL and Semgrep for vulnerability discovery, and employs SARIF parsing and merging to unify the result format.
Maintainer and Source: Repository trailofbits/skills; the plugin README lists the authors as Axel Mierczuk and Paweł Płatek. The practices regarding CodeQL and Semgrep align with the static analysis chapters in the Trail of Bits Testing Handbook.
The plugin contains three Skills (the names are the skill identifiers):
| Skill | Function |
|---|---|
codeql |
Deep security analysis such as interprocedural taint and data flow analysis |
semgrep |
Rapid pattern scanning based on rule sets |
sarif-parsing |
Parsing, summarizing, and deduplicating SARIF output from various tools |
The official Skill directories are respectively:
plugins/static-analysis/skills/codeqlplugins/static-analysis/skills/semgrepplugins/static-analysis/skills/sarif-parsing
Core Functions¶
CodeQL (codeql Skill)¶
Targets scenarios requiring database creation and query suite execution, emphasizing “database quality” and “explicit query suites” rather than silent filtering by default suites.
Documented capabilities include:
- Building databases and analyzing languages such as Python, JavaScript/TypeScript, Go, Java/Kotlin, C/C++, C#, Ruby, and Swift.
- Referencing query suites (e.g.,
security-extended, Trail of Bits, Community, etc.) via explicit.qlsfiles, and outputting SARIF/CSV. - Generating data extensions to cover source/sink for project-custom APIs.
- Running
check_db_quality.pyafter building andverify_query_suite.pybefore analysis to avoid the misconception that “zero alerts equals security.” - Scan modes:
run all(security-and-quality + security-experimental) andimportant only(high-precision subset).
Unattended builds can use the workflow /static-analysis:codeql-build, for example:
/static-analysis:codeql-build {"target": "/abs/path", "lang": "cpp"}
The workflow attempts build methods in a ladder (autobuild, custom commands, multi-step, no-build) and returns a clear status if quality thresholds are not met.
Semgrep (semgrep Skill)¶
Targets rapid full-repository or rule-set-driven first-pass static scanning. The design focus is to delegate “command generation” to scripts, reducing the likelihood of the model omitting security constraints when hand-writing CLI commands.
- Detects language and Semgrep Pro availability (Pro is used for cross-file taint analysis).
- Constructs a plan from built-in and third-party rule sets (documentation requires inclusion of Trail of Bits, 0xdea, Decurity, etc.); the third step must be explicitly approved by the user before execution.
- Batch executes scans via
scripts/run-scans.sh; enforces--metrics=off, and writes output to a separateOUTPUT_DIR. - Merges results into
results/results.sarifusingmerge_sarif.py; supports bothrun-allandimportant-onlymodes.
If the rule set approval gate is not required and you wish to run end-to-end with one click, you can use the workflow:
/static-analysis:semgrep-scan {"target": "/abs/path", "mode": "run-all"}
This command is read-only regarding the target directory (no --autofix), and writes are restricted to the output directory; if the output directory is the same as the scan target, execution is refused.
SARIF (sarif-parsing Skill)¶
Used for post-processing when scan artifacts already exist: understanding SARIF 2.1.0 structure, inheriting severity from rules (CodeQL relies on this behavior), using jq or Python (pysarif, sarif-tools) for queries, as well as multi-file aggregation, deduplication, and CI integration patterns.
Scripts and Workflows¶
| Component | Description |
|---|---|
workflows/semgrep-scan.js |
Corresponds to /static-analysis:semgrep-scan, stages: Detect → Select → Scan → Report |
workflows/codeql-build.js |
Corresponds to /static-analysis:codeql-build, stages: Detect → Build → Assess |
skills/semgrep/scripts/run-scans.sh |
Generates semgrep commands based on selected rule sets, clones third-party rule repos, batch runs, and writes scans.json |
skills/semgrep/scripts/merge_sarif.py |
Merges sharded SARIF files |
Official Note: The scanning stage is invoked directly by the workflow calling shell scripts; exit codes and findings come from the tool processes and JSON, not from self-reporting by the model.
Installation and Enablement¶
First, add the Trail of Bits marketplace to Claude Code or a compatible marketplace, then install the static-analysis plugin.
Claude Code: Add Marketplace
/plugin marketplace add trailofbits/skills
Browse and install:
/plugin menu
Install static-analysis plugin (as per plugin README)
/plugin install trailofbits/skills/plugins/static-analysis
Codex CLI
codex plugin marketplace add trailofbits/skills
codex plugin list
codex plugin add <plugin-name>@trailofbits
Replace <plugin-name> with the plugin name in the marketplace (corresponding to the repository directory static-analysis). Codex documentation states it is directly compatible with the Claude plugin marketplace without needing extra sidecar metadata.
For local development, running /plugins marketplace add ./skills in the parent directory of the repository allows mounting a local copy of the marketplace.
Before running, the corresponding CLIs must be installed on the local machine: Semgrep (semgrep --version), CodeQL (codeql --version), as well as jq, uv, etc., used for scripts and merging as mentioned in the documentation. IDE integration methods not separately listed in the official documentation are not expanded upon here.
Typical Usage¶
1. Let the Agent follow the Semgrep Skill’s five-step process (including approval)¶
Specify in the conversation that you want to perform a Semgrep security scan on a code repository. The Skill will:
- Resolve the output directory (default
static_analysis_semgrep_1with incremental naming). - Detect language and Pro status.
- Display rule sets and modes, waiting for explicit “Agree/Continue”.
- Invoke
run-scans.sh. - Merge SARIF and report
failed,skippedfromscans.json.
The target path should use an absolute path; all artifacts should land under $OUTPUT_DIR.
2. One-click Semgrep via Workflow (No Rule Set Approval)¶
Suitable for scenarios where the scan scope is confirmed and only a read-only scan is needed:
/static-analysis:semgrep-scan {"target": "/abs/path/to/repo", "mode": "run-all"}
The mode can also be set to important-only or equivalent semantics according to the Skill documentation (subject to references/scan-modes.md).
3. CodeQL Full Chain or Build Only¶
Complete analysis typically follows: Build Database → Data Extensions → run-analysis workflow; Quick Start requires confirming that codeql, jq, uv are in the PATH.
To delegate only the time-consuming build to the workflow:
/static-analysis:codeql-build {"target": "/abs/path", "lang": "cpp"}
If no-method-succeeded or built-below-threshold is returned, you need to continue interpreting the logs and quality script output within the Skill flow, rather than treating it as scan completion directly.
4. Merging Multi-tool Results¶
The final artifact for the Semgrep path is $OUTPUT_DIR/results/results.sarif. If there are also CodeQL or other SARIF outputs, the sarif-parsing Skill can be enabled for severity parsing, deduplication, and CI-side aggregation.
Applicable Scenarios and Notes¶
Suitable for:
- Systems requiring SAST in AI-assisted auditing, with a desire for fixed constraints on rule sets, metrics, and output directories.
- Repositories requiring both deep CodeQL analysis and a quick Semgrep sweep, unified into SARIF.
- Serializing with other skills in the same marketplace such as
variant-analysisandsemgrep-rule-creator(listed in the plugin README).
Limitations and Pitfalls:
- Semgrep’s cross-file taint capability is limited without Pro; documentation suggests considering CodeQL in this case.
- CodeQL relies on building for compiled languages; issues like exit 137 on macOS Apple Silicon need to be handled according to reference documentation, and
build-mode=noneshould not be the default. - Third-party rule sets require cloning repositories; if
run-scans.shfails, one should not manually subset scans to fake complete results. /static-analysis:semgrep-scansharesreferences/with thesemgrepSkill, but the former skips rule set approval; the choice depends on whether you want to edit the rule list before scanning.
The plugin comes with hermetic tests (tests/run_scan_tests.sh, tests/run_workflow_tests.sh) used to constrain script and workflow behavior, which can be referenced when modifying the plugin locally.
Conclusion¶
static-analysis encapsulates the repetitive steps in professional SAST—selecting rules, disabling telemetry, batch running, merging SARIF, CodeQL database creation, and quality gating—into Skills and fixed workflows. This makes “having the model scan a repository” closer to an auditable process, rather than a one-off CLI invocation.
Plugin and Skill Source Code: https://github.com/trailofbits/skills/tree/main/plugins/static-analysis
Marketplace Overview: https://github.com/trailofbits/skills