semgrep-rule-variant-creator — Claude Code skill
Ports completed Semgrep rules to selected languages and creates separate rule and test directories. Use it when you already have a rule to adapt.
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a claude-codeWhat semgrep-rule-variant-creator does
This skill takes an existing Semgrep rule, target languages, and produces an independent rule directory with tests for each language. Every target goes through its own cycle, including an applicability decision and validation. A language judged inapplicable gets no output directory.
Run the workflow with /semgrep-rule-variant-creator:port-rule-to-languages. It requires rulePath, a languages array, and an absolute referencesDir; outputDir is optional. The reference path matters: relative paths and unexpanded variables are rejected.
The workflow passes the rule by file path instead of copying its text between phases. Its phase order puts tests before rule writing, and validation failures can be retried up to three times.
What it helps with
- port an existing Semgrep rule to Go
- create separate rule and test directories
- check whether a pattern applies to a target language
- retry validation after a failed check
Example prompts for the agent
- `/semgrep-rule-variant-creator:port-rule-to-languages` Port `rules/check.yml` to Go using an absolute `referencesDir`.
- Run `/semgrep-rule-variant-creator:port-rule-to-languages` with `rulePath` set to `rules/check.yml` for Go and Java.
- Use `/semgrep-rule-variant-creator:port-rule-to-languages` and write variants to `outputDir` `semgrep-variants`.
How to install semgrep-rule-variant-creator
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a claude-code2Manually: put the files in place
~/.claude/skills/semgrep-rule-variant-creator/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/semgrep-rule-variant-creator/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a codex2Manually: put the files in place
.agents/skills/semgrep-rule-variant-creator/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a cursor2Manually: put the files in place
.cursor/skills/semgrep-rule-variant-creator/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install trailofbits/skills semgrep-rule-variant-creator2Manually: put the files in place
.github/skills/semgrep-rule-variant-creator/SKILL.md1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a gemini-cli2Platform CLI
gemini skills install https://github.com/trailofbits/skills --path plugins/semgrep-rule-variant-creator/skills/semgrep-rule-variant-creatorManually: put the files in place
.devin/skills/semgrep-rule-variant-creator/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set35
The whole set →Similar
Questions about semgrep-rule-variant-creator
How do I install semgrep-rule-variant-creator in Codex?
Run npx skills add trailofbits/skills --skill semgrep-rule-variant-creator -a codex. The installed skill file is .agents/skills/semgrep-rule-variant-creator/SKILL.md.
What does semgrep-rule-variant-creator do?
It adapts an existing Semgrep rule for selected languages and creates separate rule and test directories. Each language is assessed independently before the result is validated.
What is required to run a port?
You need the source rule path, target languages, and an absolute referencesDir. outputDir is optional; otherwise output goes to the current working directory.