semgrep-rule-creator

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

507|40|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/waybarrios/opencode-power-pack --skill semgrep-rule-creator-waybarrios
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: semgrep-rule-creator
Source: https://github.com/waybarrios/opencode-power-pack/tree/main/skills/semgrep-rule-creator
Command: npx skills add https://github.com/waybarrios/opencode-power-pack --skill semgrep-rule-creator-waybarrios

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing custom Semgrep rules that accurately detect vulnerabilities without false positives is difficult, and untested rules silently miss bugs or flood teams with noise. This Skill enforces a test-first, iterative workflow so every rule is validated against vulnerable and safe code cases before delivery. ## 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, tracking untrusted input from sources to dangerous sinks with sanitizers. - AST Analysis & Optimization: Uses semgrep --dump-ast to understand code structure and removes redundant patterns after tests pass. - Use Case: You need to detect every place user-controlled input reaches os.system() in a Python codebase. The Skill guides you to write a taint-mode rule, build test cases covering sanitized and unsafe flows, and verify zero false positives. ## Quick Start Ask the AI to create a Semgrep rule that detects a specific vulnerability pattern in your language, with tests validating both vulnerable and safe code examples.

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 for my codebase?▼

Write test cases first with ruleid and ok annotations covering vulnerable and safe code, then analyze the AST with semgrep --dump-ast, write the rule YAML, and iterate with semgrep --test until all tests pass. Optimize patterns only after tests pass.

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. Taint mode reduces false positives by only flagging when untrusted data actually reaches the sink.

How do I test a Semgrep rule for false positives?▼

Run semgrep --test --config <rule-id>.yaml <rule-id>.<ext> from the rule directory. Include ok-annotated safe cases such as sanitized inputs and hardcoded values so false positives surface immediately during testing.

Why is my Semgrep taint rule not matching expected code?▼

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

What are the limitations of generic Semgrep patterns?▼

Generic patterns like pattern: $FUNC(...) match everything and produce useless results. Rules should target specific dangerous functions, use typed metavariables, and avoid languages: generic when targeting a specific language.