semgrep-rule-creator
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.
Security Assessment
Detected risks:
About semgrep-rule-creator
This skill helps developers create custom Semgrep rules for detecting security vulnerabilities, bug patterns, and enforcing coding standards in codebases. It focuses on building high-quality static analysis rules that go beyond simple pattern matching, ensuring detections are accurate and actionable. By guiding users through a structured workflow, it reduces common mistakes such as overly broad rules, missed edge cases, or untested logic. The goal is to produce reliable Semgrep rules that can be safely used in production environments without introducing excessive false positives or negatives.
Key capabilities include a strict test-first workflow where rules must be validated before use, ensuring both vulnerable and safe cases are covered. It emphasizes iterative development: analyzing code structure, writing tests first, implementing rules, and refining them until all tests pass. The skill supports both pattern-based rules and taint mode rules, with a strong preference for taint analysis when tracking untrusted input flow to sensitive sinks. It also highlights common anti-patterns such as overly broad matching, incomplete test coverage, and premature optimization. Users are guided to inspect AST representations when needed to ensure patterns correctly match real code structures. Additionally, it enforces structural constraints like one rule per YAML file and discourages generic or low-specificity configurations.
Typical users include security engineers, AppSec teams, and developers responsible for code quality and vulnerability detection. It is especially useful when building custom detectors for proprietary codebases or organization-specific coding standards. It is also valuable in CI pipelines where precise static analysis rules are required to prevent regressions and security issues.
FAQ
When should I use this skill?
Use it when creating custom Semgrep rules to detect security vulnerabilities, bug patterns, or enforce coding standards. It is intended for building new static analysis detections rather than running existing rulesets or doing general analysis without custom rule creation.
Does this work with all Semgrep-supported languages?
Yes, the rules are designed for Semgrep-supported codebases, but you should avoid generic configurations. Rules should be specific to the target language and avoid overly broad or generic pattern matching.
What are the main requirements when using this skill?
Rules must follow a strict test-first approach, include both vulnerable and safe test cases, and achieve full test coverage before optimization. Each YAML file must contain only one rule, and generic or untested patterns are not acceptable.
When should I use taint mode instead of pattern matching?
Taint mode should be prioritized when tracking data flow from untrusted inputs to dangerous sinks, as it provides more precise detection than simple pattern matching in those scenarios.
Install semgrep-rule-creator
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
trailofbits/skills