semgrep-rule-variant-creator

Ports existing Semgrep rules to target languages with test-driven validation.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill semgrep-rule-variant-creator-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: semgrep-rule-variant-creator
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/semgrep-rule-variant-creator
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill semgrep-rule-variant-creator-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Porting a Semgrep rule to another language is error-prone: AST structures differ, equivalent APIs vary, and naive syntax translation produces rules that miss vulnerabilities or flood results with false positives. This Skill enforces a disciplined per-language workflow so each ported variant actually detects the intended vulnerability. ## Core Features & Use Cases - Applicability Analysis: Determines whether a vulnerability pattern (e.g., SQL injection, command injection) meaningfully applies to each target language before any porting work begins. - Test-First Variant Creation: Writes annotated test files (ruleid/ok cases) in the target language before writing the rule, then validates with semgrep --test until all tests pass. - Independent Per-Language Cycles: Produces a separate rule+test directory for each target language, completing the full 4-phase cycle per language. - Use Case: You have a Python taint-mode rule detecting command injection and need Go and Java equivalents. The Skill analyzes applicability, researches exec.Command and Runtime.exec equivalents, and outputs validated python-command-injection-golang and python-command-injection-java directories. ## Quick Start Port my existing Semgrep rule python-sql-injection.yaml to Go and Java, creating tested rule variants for each language.

Frequently Asked Questions about semgrep-rule-variant-creator

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

FAQPage Schema
How do I port a Semgrep rule to another language?

Analyze whether the vulnerability class applies to the target language, write annotated test cases first, then translate patterns using AST dumps from semgrep --dump-ast. Validate with semgrep --test until all tests pass before moving to the next language.

How do I test Semgrep rules with annotations?

Place a ruleid: comment on the line immediately before code that must be flagged, and ok: before code that must not match. Run semgrep --test --config rule.yaml test-file to verify all annotations pass.

When should a Semgrep rule not be ported to a language?

Skip porting when the vulnerability class does not exist in the target language, such as buffer overflows in Python or prototype pollution outside JavaScript. Document the NOT_APPLICABLE verdict with reasoning instead of forcing a meaningless rule.

Why does my Semgrep taint rule miss matches in another language?

Taint sources, sinks, and sanitizers differ across languages, so patterns translated literally often fail. Use semgrep --dataflow-traces to see where taint stops, and adjust source and sink patterns to match the target language's actual APIs.

What is the difference between semgrep-rule-creator and this variant creator?

semgrep-rule-creator builds a new rule from a bug pattern description, while this Skill ports an existing rule to one or more target languages. The variant creator adds applicability analysis and runs an independent creation cycle per language.