create-rule

create-rule is a command for Claude Code from allsmog/vuln-scout. It costs 18 tokens per session (600 once invoked), scanned A, original, MIT.

A command that turns a confirmed security weakness into a Semgrep rule, written in YAML. Semgrep is a code-scanning tool that looks for matching patterns.

In plain words
What is it for?
Creating a custom Semgrep rule from a finding ID or a file and line number, saving it to a chosen directory, and optionally testing it.
Why use it?
It preserves a known vulnerability pattern so later scans can find similar problems elsewhere in the codebase.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the vuln-scout plugin — 32 skills, 15 commands, 9 agents shipped together

Good fit Creating a custom Semgrep rule from a finding ID or a file…

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/allsmog/vuln-scout/create-rule
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/allsmog/vuln-scout

Made for: Claude Code.

Or install vuln-scout, the plugin that ships this one along with the rest of its 32 skills, 15 commands, 9 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for create-rule

README.md
[![agentmods](https://agentmods.dev/badge/commands/allsmog/vuln-scout/create-rule.svg)](https://agentmods.dev/commands/allsmog/vuln-scout/create-rule)
Your own site
<a href="https://agentmods.dev/commands/allsmog/vuln-scout/create-rule"><img src="https://agentmods.dev/badge/commands/allsmog/vuln-scout/create-rule.svg" alt="Measured on agentmods" height="20"></a>
Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 600 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00018 $0.00600
Opus 5 $0.00009 $0.00300
Sonnet 5 $0.00004 $0.00120
Haiku 4.5 $0.00002 $0.00060

Measured 7d ago against content hash 0d99648dc2f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

create-rule scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

vuln-scout/commands/create-rule.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Create Custom Detection Rule

Generate a Semgrep YAML rule from a confirmed vulnerability pattern. The rule captures the anti-pattern so future scans detect similar issues across the codebase.

Usage

/vuln-scout:create-rule VSCOUT-0003
/vuln-scout:create-rule src/api/users.ts:42
/vuln-scout:create-rule VSCOUT-0003 --output .semgrep/rules/ --test

Flags

Flag Effect
finding-id Finding ID from .claude/findings.json to generate a rule for
file:line Alternative: specify the vulnerable code location directly
--output Directory to save the rule (default: .claude/custom-rules/)
--test Run the generated rule against the codebase to verify it works

Workflow

Step 1: Extract the vulnerability pattern

If a finding ID is provided, load it from .claude/findings.json and read the evidence code excerpts. If a file:line is provided, read the surrounding code context.

Identify:

  • The dangerous sink (the function call that is vulnerable)
  • The unsafe pattern (how user input reaches the sink)
  • The language of the code

Step 2: Generate the Semgrep rule

Create a YAML rule with:

  • id: vuln-scout.custom.<descriptive-name>
  • pattern or pattern-either: captures the anti-pattern
  • pattern-not: excludes safe variants (parameterized queries, etc.)
  • message: explains the vulnerability and how to fix it
  • severity: ERROR for exploitable, WARNING for potential
  • languages: detected from the source file
  • metadata: category: security, cwe, confidence
  • fix (optional): auto-fix pattern if applicable

Step 3: Test the rule (if --test)

semgrep --config <generated-rule-file> --json <target-path>

Verify:

  • The rule catches the original finding
  • False positive rate is acceptable (< 20%)
  • The rule works on the correct language

Step 4: Save

Write the rule to the output directory. Report the file path so it can be committed and used in future scans.

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 74 lines · 18 tokens per session scan A 0d99648dc2f9

Subscribe to this mod's changes

create-rule is a command published in the GitHub repository allsmog/vuln-scout (24 stars, last pushed 2mo ago), licensed MIT. It adds 18 tokens to every session and 600 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.