Back to Skills

semgrep-rule-variant-creator

Creates language variants of existing Semgrep rules. Use when porting a Semgrep rule to specified target languages. Takes an existing rule and target languages as input, produces independent rule+test directories for each language.

5,355stars472forksUpdated 5/24/2026

Security Assessment

Critical Risk(10/100)

Detected risks:

Remote Code Execution([references/workflow.md] Exec(, [references/workflow.md] exec(, [references/applicability-analysis.md] pickle.loads)
Command Injection([references/workflow.md] os.system, [references/workflow.md] subprocess.call, [references/workflow.md] shell=True)
Security Score10/100

About semgrep-rule-variant-creator

The semgrep-rule-variant-creator skill is designed to simplify the process of porting existing Semgrep rules to different programming languages. It addresses the challenge of adapting vulnerability detection rules across polyglot codebases, where a pattern valid in one language may require careful translation and validation in another. By automating the creation of language-specific rule variants and their associated tests, this skill helps ensure consistent security analysis and reduces the risk of human error during manual rule translation. Its structured workflow enforces rigorous applicability analysis and test-driven validation, ensuring that the ported rules are not only syntactically correct but semantically meaningful in each target language.

The main capabilities of this skill include generating independent rule directories for each target language, producing YAML rule files along with annotated test files, and enforcing a strict four-phase cycle for each language: applicability analysis, test creation, rule creation, and validation. It prevents common pitfalls such as assuming identical AST structures, skipping test creation, or performing superficial syntax translations. Each variant must pass all tests before proceeding, guaranteeing high-quality rule coverage. Additionally, the skill guides users through rationalizations that often lead to errors and promotes a disciplined approach to language-specific rule adaptation, emphasizing that each language requires a complete and independent workflow.

This skill is particularly useful for security engineers, developers, and DevSecOps professionals who need to maintain consistent Semgrep rule coverage across multiple languages. Typical use cases include translating universal vulnerability patterns to language-specific rules, expanding rule applicability in diverse codebases, and maintaining high-quality security detection standards across organizational projects. By providing a methodical and test-first approach to rule porting, the semgrep-rule-variant-creator enables users to efficiently manage rule variants, reduce technical debt, and ensure reliable vulnerability detection across all supported programming languages.

FAQ

Can this skill create new Semgrep rules from scratch?

No, this skill is specifically for porting existing Semgrep rules to new languages. For creating new rules, the semgrep-rule-creator skill should be used.

What input does the skill require?

It requires an existing Semgrep rule, provided either as a YAML file path or YAML content, along with one or more target languages to port the rule to.

Does it work for minor syntax changes within the same language?

No, the skill is not intended for minor syntax variations. It is designed for creating full language variants where applicability and AST structures may differ.

How are the output files organized?

For each target language, a separate directory is created containing the ported YAML rule file and a corresponding test file with appropriate language extension and annotations.

Are tests mandatory for each variant?

Yes, test creation is required before rule creation, and each variant must pass 100% of its tests before proceeding to the next language.

All Files

4 files
SKILL.md7.8 KB
View
references/workflow.md13.2 KB
View
references/applicability-analysis.md7.3 KB
View
references/language-syntax-guide.md7.3 KB
View

Install semgrep-rule-variant-creator

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill