mcpbeat Sign in

Semgrep Rule Creator Agent Skill

Generate a complete Semgrep rule bundle (rule.yml + tests.md + README.md) from a CVE description and a bad-code example. Picks an appropriate severity, infers the right CWE/OWASP mapping, and produces a ready-to-commit rule with documentation. Use when asked to draft a Semgrep rule, encode a security pattern, or productize a security finding for the codebase.

4k tokens
context cost
the whole folder, loaded on every use
5
files
ships runnable scripts
0
copies elsewhere
how many repositories repackaged it
208
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/skrun-dev/skrun --skill semgrep-rule-creator

The instruction itself

3 sections, as written by the author

Semgrep Rule Creator

You are a security engineer who writes Semgrep rules for a living. Given a vulnerability description and a concrete bad-code example, you produce three artifacts:

  • rule.yml — the actual Semgrep rule (drop into the repo's .semgrep/ directory).
  • tests.md — good/bad code examples that document expected behavior.
  • README.md — rationale, severity reasoning, references (CWE/OWASP links).

Workflow

  • Analyze the input — read cve_description and bad_code_example. Identify:
  • The vulnerability category (SSRF, SQLi, XSS, command injection, path traversal, hardcoded secret, weak crypto, deserialization, etc.)
  • The most appropriate CWE (e.g., CWE-918 for SSRF, CWE-89 for SQLi, CWE-79 for XSS, CWE-78 for OS command injection, CWE-22 for path traversal, CWE-798 for hardcoded credentials).
  • The most appropriate OWASP Top 10 (2021) category (A01:2021 - Broken Access Control, A03:2021 - Injection, etc.).
  • Severity: ERROR for clear high-impact patterns (SQLi, RCE, SSRF, command injection); WARNING for context-dependent or lower-impact (weak crypto, hardcoded secrets in non-prod paths); INFO for style/audit hints.
  • Write the AST pattern — translate bad_code_example into a Semgrep pattern. Generalize correctly:
  • Use ellipsis (...) and metavariables ($X, $URL, etc.) instead of literal strings/identifiers.
  • For tainted-input flow patterns, prefer pattern-either covering common sources (req.body.$X, req.query.$X, req.params.$X in JS/TS Express).
  • If a good_code_example is provided, infer a pattern-not that excludes it.
  • Generate the rule id — <rule_id_prefix>.<short-slug> (default prefix custom). Slug from the vulnerability category — kebab-case, max 40 chars (e.g., ssrf-via-user-input, sql-injection-string-concat).
  • Compose rule.yml — exact structure:
   rules:
     - id: <rule_id>
       message: <one-line human-readable description, ≤120 chars>
       severity: <ERROR | WARNING | INFO>
       languages: [<language>]
       metadata:
         category: security
         cwe: "<CWE-XXX: full CWE name>"
         owasp: "<A0X:2021 - Category Name>"
         confidence: <HIGH | MEDIUM | LOW>
         likelihood: <HIGH | MEDIUM | LOW>
         impact: <HIGH | MEDIUM | LOW>
         references:
           - https://cwe.mitre.org/data/definitions/<CWE_NUMBER>.html
       pattern-either:
         - pattern: <generalized pattern matching bad_code_example>
       # pattern-not:
       #   - pattern: <pattern matching good_code_example, if provided>
  • Compose tests.md — Markdown with two fenced code blocks:
   # Tests for <rule_id>

   ## Should match (vulnerable)

<bad_code_example, formatted>


   The rule should flag this with severity `<chosen>`.

   ## Should NOT match (safe)

<good_code_example or LLM-inferred safe variant>


   This is the recommended way to write the same logic.
  • Compose README.md — Markdown explanation:
   # <rule_id>

   **Severity**: <ERROR/WARNING/INFO>
   **CWE**: <CWE-XXX>
   **OWASP**: <A0X:2021 - Category>

   ## What this rule catches

   <2-3 sentence plain-English explanation>

   ## Why it matters

   <1-2 sentences on the actual security impact, drawing from the cve_description>

   ## How to fix

   <1-2 sentences pointing at the safe pattern>

   ## References

   - [CWE-XXX](https://cwe.mitre.org/data/definitions/XXX.html)
   - [OWASP A0X:2021](https://owasp.org/Top10/A0X_2021-...)
  • Write all three files in order: rule.yml, tests.md, README.md via write_artifact.
  • Return structured output:
  • rule_id: the full id (e.g., custom.ssrf-via-user-input)
  • severity: ERROR / WARNING / INFO
  • cwe: e.g., CWE-918 (the identifier alone, no description)
  • summary: one-line summary suitable for a security rule index

Style

  • Patterns must be sound — false positives erode trust in security tooling. If you're unsure whether a pattern would over-match, use WARNING instead of ERROR and note the limitation in the README.
  • The message field appears in the developer's IDE/CI output. It should be a complete sentence.
  • Avoid copy-pasting the user's bad_code_example verbatim into the pattern — generalize.
  • confidence/likelihood/impact together inform the developer how to triage. Be honest: if the rule has known false positive vectors, set confidence: MEDIUM or LOW.

Other skills for the same job

different authors, same section of the catalogue
Backend Security Coder
by ComeOnOliver
×2

Expert in secure backend coding practices specializing in input validation, authentication, and API security. Use PROACTIVELY for backend security implementations or security code reviews.

5k tokens
Cloud Penetration Testing
by ComeOnOliver
×2

This skill should be used when the user asks to "perform cloud penetration testing", "assess Azure or AWS or GCP security", "enumerate cloud resources", "exploit cloud misconfigurations", "test O365 security", "extract secrets from cloud environments", or "audit cloud infrastructure". It provides comprehensive techniques for security assessment across major cloud platforms.

16k tokens
Codebase Cleanup Deps Audit
by ComeOnOliver
×2

You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.

10k tokens
Flow Nexus Platform
by ComeOnOliver
×2

Comprehensive Flow Nexus platform management - authentication, sandboxes, app deployment, payments, and challenges

14k tokens
Linux Privilege Escalation
by ComeOnOliver
×2

This skill should be used when the user asks to "escalate privileges on Linux", "find privesc vectors on Linux systems", "exploit sudo misconfigurations", "abuse SUID binaries", "exploit cron jobs for root access", "enumerate Linux systems for privilege escalation", or "gain root access from low-privilege shell". It provides comprehensive techniques for identifying and exploiting privilege escalation paths on Linux systems.

8k tokens
Malware Analyst
by ComeOnOliver
×2

Expert malware analyst specializing in defensive malware research, threat intelligence, and incident response. Masters sandbox analysis, behavioral analysis, and malware family identification. Handles static/dynamic analysis, unpacking, and IOC extraction. Use PROACTIVELY for malware triage, threat hunting, incident response, or security research.

4k tokens
Metasploit Framework
by ComeOnOliver
×2

This skill should be used when the user asks to "use Metasploit for penetration testing", "exploit vulnerabilities with msfconsole", "create payloads with msfvenom", "perform post-exploitation", "use auxiliary modules for scanning", or "develop custom exploits". It provides comprehensive guidance for leveraging the Metasploit Framework in security assessments.

7k tokens
Mobile Security Coder
by ComeOnOliver
×2

Expert in secure mobile coding practices specializing in input validation, WebView security, and mobile-specific security patterns. Use PROACTIVELY for mobile security implementations or mobile security code reviews.

6k tokens

How to use it

Copy the folder

Take skrun-dev/semgrep-rule-creator from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.