semgrep-rule-creator

Creates and tests custom Semgrep rules for detecting security vulnerabilities and code patterns.

Updated May 17, 2026
One-click install
npx skills add https://github.com/irrit-us/agent_misc --skill semgrep-rule-creator-irrit-us
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: semgrep-rule-creator
Source: https://github.com/irrit-us/agent_misc/tree/main/skills/semgrep-rule-creator
Command: npx skills add https://github.com/irrit-us/agent_misc --skill semgrep-rule-creator-irrit-us

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing Semgrep rules by hand often produces patterns with hidden false positives, missed vulnerable variants, and untested edge cases. This Skill enforces a strict test-first workflow so every custom rule is validated against both vulnerable and safe code before it ships. ## Core Features & Use Cases - Test-first rule creation: Write annotated test files (ruleid:/ok:) before the rule, then iterate with semgrep --test until all tests pass. - Taint mode guidance: Prioritizes taint mode for data flow vulnerabilities (sources, sinks, sanitizers) to reduce false positives on injection-style bugs. - AST-driven pattern writing: Uses semgrep --dump-ast to understand how Semgrep parses code, plus an optimization pass that removes redundant patterns. - Use Case: You need to detect user input reaching eval() in a Python codebase. The Skill walks you through writing tests, building a taint-mode rule, debugging with --dataflow-traces, and optimizing the final YAML. ## Quick Start Ask the agent to create a Semgrep rule that detects a specific vulnerability pattern in your language, and it will produce a tested rule YAML plus an annotated test file.

Frequently Asked Questions about semgrep-rule-creator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a custom Semgrep rule?▼

Start by writing a test file with ruleid and ok annotations covering vulnerable and safe cases, then dump the AST with semgrep --dump-ast to understand code structure. Write the rule YAML, run semgrep --test, and iterate until all tests pass before optimizing patterns.

When should I use Semgrep taint mode instead of pattern matching?▼

Use taint mode when untrusted data flows from a source to a dangerous sink, such as injection vulnerabilities. Pattern matching fits simple syntactic patterns without data flow, but produces more false positives on safe cases like eval with hardcoded strings.

How do I test Semgrep rules with ruleid and ok annotations?▼

Place a comment with ruleid: <rule-id> on the line immediately before code that must match, and ok: <rule-id> before code that must not match. Run semgrep --test --config <rule-id>.yaml <rule-id>.<ext> from the rule directory to validate.

Why is my Semgrep taint rule not propagating?▼

Run semgrep with --dataflow-traces to see sources, sinks, and the flow path. Common causes are overly broad sanitizers, source patterns that do not match actual code, or incorrect focus-metavariable placement on sinks.

How do I reduce false positives in Semgrep rules?▼

Add pattern-not exclusions for safe cases, define sanitizers for validation functions, use pattern-inside to limit scope, and apply metavariable-regex filters. Always include safe test cases so false positives surface during semgrep --test runs.