Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

semgrep-rule-creator

Skill by trailofbits

Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns and code patterns. Aimed at developers and security engineers who write their own static analysis detections.

  • Score 92
  • 8.6k stars
  • CC-BY-SA-4.0
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install semgrep-rule-creator

Built from the published package, never by AI.

git clone --depth 1 https://github.com/trailofbits/skills /tmp/skills && mkdir -p ~/.claude/skills && cp -r /tmp/skills/plugins/semgrep-rule-creator/skills/semgrep-rule-creator ~/.claude/skills/semgrep-rule-creator

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install semgrep-rule-creator in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

Semgrep rule creator is an agent skill from Trail of Bits that guides an assistant through writing custom Semgrep rules. It follows a test-first workflow: analyze the problem, write tests with ruleid and ok annotations, inspect the AST, write the rule, and iterate until semgrep --test passes. For data flow vulnerabilities it prioritizes taint mode, and it asks the assistant to read the Semgrep documentation before writing any rule.

Each rule is saved in its own directory as a YAML file plus a test file. The skill rejects shortcuts such as skipping tests or optimizing too early, and it forbids generic language rules and todook or todoruleid annotations. It does not run existing rulesets. For that, the source points to a separate static-analysis skill. It is intended for people who need custom static analysis detections.

Written from the project's SKILL.md and checked against it.

What it can do

  • Rule creationWrites Semgrep rules for specific bug patterns and security vulnerabilities.
  • Taint mode rulesBuilds data flow rules that track untrusted input reaching dangerous sinks.
  • Test-first workflowWrites ruleid and ok test cases before writing the rule itself.
  • Test verificationRuns semgrep --test until all tests pass before optimizing the rule.
  • AST analysisInspects the AST structure to find syntactic variations the rule must match.
  • Documentation readingFetches Semgrep and Trail of Bits Testing Handbook docs before writing rules.

What you need

  • Semgrep CLI

Try asking

  • Write a Semgrep taint rule for user input reaching eval in Python.
  • Create a Semgrep rule that flags os.system calls built from user input.
  • Write Semgrep tests with ruleid and ok cases for my new custom rule.

Good to know

  • Does not run existing Semgrep rulesets.
  • Each YAML file must contain only one Semgrep rule.
  • Generic language rules (languages: generic) are not allowed.
  • todook and todoruleid test annotations are forbidden.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: plugins/semgrep-rule-creator/skills/semgrep-rule-creator/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: Bash Read Write Edit Glob Grep WebFetch

  • SKILL.md7 KB
  • agents/openai.yaml249 B
  • assets/trail-of-bits-mark.svg3 KB
  • references/quick-reference.md6 KB
  • references/workflow.md8 KB

Alternatives to semgrep-rule-creator

All alternatives →

Compare with function_health, windows-privilege-escalation or github-actions-advanced

semgrep-rule-creator: common questions

What does semgrep-rule-creator do?

It guides an assistant in writing custom Semgrep rules with tests, aimed at security vulnerabilities, bug patterns and code patterns.

Does it run existing Semgrep rules?

No. The source says to use the static-analysis skill for general analysis without custom rules.

What output does it produce?

Each rule goes in a directory named after the rule id, containing one YAML rule file and one test file.

How do I install semgrep-rule-creator?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is semgrep-rule-creator free?

The code is published under the CC-BY-SA-4.0 licence. The service it connects to may have its own pricing.

Is semgrep-rule-creator safe to use?

It scores 92 of 100. Grades: maintenance A, licence C, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to semgrep-rule-creator?

Similar skills: function_health, windows-privilege-escalation, github-actions-advanced, propose-security-hardening.

semgrep-rule-creator Install

Add to stack

Loading.