semgrep-rule-creator guides an agent through writing a custom Semgrep rule for a security vulnerability, bug pattern or coding standard. It favors taint mode for data flow issues and pattern matching for simple syntax checks, and it will not accept a rule that lacks tests.
The output is a directory named after the rule id with exactly two files: the YAML rule and a test file annotated with ruleid and ok markers. Every test must pass before the rule is simplified.
What You Get
- A rule-id directory holding one Semgrep YAML rule and one annotated test file
- Tests that cover vulnerable cases, safe cases, edge cases, sanitized input and nested code
- A rule that passes semgrep —test with no missed or incorrect lines
- A final message check that confirms every metavariable in the message interpolates
Common Use Cases
- Detecting an injection bug with a taint mode rule from a source to a sink
- Enforcing a coding standard across a codebase with a simple pattern rule
- Turning a bug found in an audit into a reusable rule with tests
What Makes It Unique
The workflow is strict: tests come first, a hundred percent of them must pass, and generic or multi-rule files are forbidden. It also has the agent dump the AST before writing patterns so they match how Semgrep parses the code, and it puts a re-test step after every simplification. Running existing rulesets is left to the static-analysis skill.
Under The Hood
The skill reads two reference files for the command list and the step-by-step workflow. It tells the agent to fetch seven Semgrep and Trail of Bits documentation pages from raw.githubusercontent.com with the web fetch tool before writing any rule, so it reaches the network. The agent runs the semgrep command line tool in a shell for validation, tests, AST dumps and dataflow traces, and writes the rule and test files to disk in a new rule directory. It uses no bundled scripts.