Skip to content
Back to skills

Add Rule

ASecurity

Checklist and templates for implementing or changing a Pulse analysis rule (AI-SEC/STR/EFF/COG-NNN or custom). Use whenever a task adds a rule, changes rule detection logic, or adds rule fixtures/docs.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 21, 2026
ai-agentsgosecurity

Works with

  • mcp

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 21, 2026

npx -y skills add SamueleMoscatelli/pulse --skill add-rule --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Rule?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add Rule
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/samuelemoscatelli-add-rule/badge)](https://www.skillsdirectory.com/skills/samuelemoscatelli-add-rule)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add-rule
description: Checklist and templates for implementing or changing a Pulse analysis rule (AI-SEC/STR/EFF/COG-NNN or custom). Use whenever a task adds a rule, changes rule detection logic, or adds rule fixtures/docs.
---

# Adding a Pulse rule

The rule's spec is in `scripts/spec.sh "<RULE-ID>"`. Implement exactly that: detection, severities, FP guards.

## Files to touch (and only these)
1. `crates/pulse-rules/src/<category>/<topic>.rs`: the rule (template: [rule-template.rs](rule-template.rs)). Group related rules in one topic file (e.g. `security/mcp.rs`). Add `mod` lines in `<category>/mod.rs`.
2. `crates/pulse-rules/src/lib.rs`: register it in `RULES` (asset scope) or `PROJECT_RULES` (project scope), keeping ID order.
3. Shared word lists go in `crates/pulse-rules/src/lexicon/<name>.rs` as `pub const` slices, plus a `LazyLock` automaton if needed. Never inline big lists in rule files.
4. `crates/pulse-rules/tests/fixtures/<RULE-ID>/`: ≥ 1 `fail_*` and ≥ 2 `pass_*` (realistic near-misses). Use `.expect` files (`line:col` per line) when location matters. Use `_kind` when the kind can't be inferred.
5. `docs/rules/<RULE-ID>.md` from [doc-template.md](doc-template.md), and add the ID to the `rule_docs!` list in `crates/pulse-rules/src/docs.rs` (embedded for SARIF help and `explain`).
6. Invisible characters, secrets and other content that would trip editors or push protection: build it in a test in `crates/pulse-rules/tests/fixtures.rs` (string concatenation / `\u{...}` escapes), not in fixture files.

## Implementation rules
- `RuleMeta` is a `static`; `kinds` restricts which assets reach `check`, so don't re-check the kind inside.
- Use the asset's cached views (`asset.markdown()`, `normalized()`, `mcp()`, …). Never re-parse.
- Matching on normalized text: map back with `Normalized::source_span` before building a `Finding`.
- Build messages only when a finding fires. Keep them ≤ 100 chars, starting with the problem, quoting the offending snippet (truncated to 40 chars).
- Read options through `ctx.options::<T>(META.id)` (typed, with defaults). Unknown option keys are config errors.
- EFF rules must set `token_waste`.
- Heuristic rule? Add the FP guards from the spec *and* a pass fixture for each guard.
- Never put secrets in messages: redact them.

## Verify
`scripts/check.sh -p pulse-rules` while iterating, then the full `scripts/check.sh`. The fixture harness fails if fixtures or docs are missing for a registered rule, or if a doc strays from the template (title, header line matching the rule meta, sections in order).

Files in this skill

  • SKILL.md2.5 KB
  • doc-template.md819 B
  • rule-template.rs1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.