agentleFS
anthrilanthril/vibe-guard/.claude/skills/new-rule/SKILL.md

new-rule

Skill2 starsChanged 8 months agoApache-2.0View on GitHub

Scaffold a new VGuard rule with source file, test, and preset registration. Use when the user says "create a rule", "add a new rule", "scaffold rule", or wants to implement a new guardrail check.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. SonarSource/SonarJS★ 1.3ksame name
    2. SonarSource/sonar-java★ 1.2ksame name
    3. jajupmochi/agent-harness★ 1same name
    4. TheLatentSpaceLab/Qubito★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user for these if not provided:

    line 20
  2. Very specific:

    Use the template at .claude/skills/new-rule/templates/rule.ts.

    line 33
  3. Very specific:

    Use editCheck: true if the rule applies to Write events (auto-generates Edit variant)

    line 36
  4. Very specific:

    Follow fail-open: wrap in try/catch, return { status: 'pass' } on error

    line 37
  5. Very specific:

    Use the template at .claude/skills/new-rule/templates/rule.test.ts.

    line 49
  6. Distinctive:

    Test for the pass case (rule allows valid input)

    line 50
  7. Distinctive:

    Test for the block/warn case (rule catches violations)

    line 51
  8. Distinctive:

    Test for edge cases (empty input, missing fields)

    line 52
  9. Very specific:

    Test that internal errors return { status: 'pass' } (fail-open)

    line 53
  10. Very specific:

    If the rule is relevant to a specific preset (e.g., a Next.js-specific rule), add it to the preset's rules object in …

    line 57

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create New VGuard Rule: $ARGUMENTS

Generate a complete VGuard rule following project conventions.

What This Skill Creates

  1. Rule file at src/rules/<category>/<rule-name>.ts
  2. Test file at tests/rules/<category>/<rule-name>.test.ts
  3. Registration in src/rules/<category>/index.ts
  4. Preset entry (optional) in relevant preset files

Required Information

Ask the user for these if not provided:

  • Category: security, quality, or workflow
  • Rule name: kebab-case identifier (e.g., no-hardcoded-urls)
  • Description: What this rule prevents and why
  • Severity: block (prevents operation), warn (allows but warns), info (informational)
  • Events: PreToolUse, PostToolUse, Stop, or a combination
  • Tools: Which tools to match (e.g., Edit, Write, Bash, Read)
  • File patterns (optional): Globs to match (e.g., *.ts, *.sql)

Implementation Steps

1. Create Rule File

Use the template at .claude/skills/new-rule/templates/rule.ts. Key requirements:

  • Export a Rule object satisfying the interface in src/types.ts
  • The check() function receives HookContext and returns RuleResult
  • Use editCheck: true if the rule applies to Write events (auto-generates Edit variant)
  • Follow fail-open: wrap in try/catch, return { status: 'pass' } on error

2. Register the Rule

In src/rules/<category>/index.ts, add:

import { <ruleName> } from './<rule-name>.js';
registerRules([<ruleName>]);

3. Create Test File

Use the template at .claude/skills/new-rule/templates/rule.test.ts. Must include:

  • Test for the pass case (rule allows valid input)
  • Test for the block/warn case (rule catches violations)
  • Test for edge cases (empty input, missing fields)
  • Test that internal errors return { status: 'pass' } (fail-open)

4. Add to Presets (Optional)

If the rule is relevant to a specific preset (e.g., a Next.js-specific rule), add it to the preset's rules object in src/presets/<preset>.ts.

5. Verify

npm run type-check
npm test -- --reporter verbose tests/rules/<category>/<rule-name>.test.ts
npm test

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.