tools: Command for Claude Code

.claude/commands/new-enforcer-rule.md

new-enforcer-rule is a command for Claude Code from adamw7/tools. It costs 28 tokens per session (835 once invoked), scanned A, original, MIT.

A command for adding a complete validation rule to the Claude Code Enforcer project. It covers the rule's code, registration, tests, build setup, test example, and documentation.

In plain words
What is it for?
Use it when adding a new enforcer rule from start to finish, including its Java class, Sisu registration, tests, integration-test fixture, Maven setup, and docs.
Why use it?
A rule can compile and pass its own tests but still never run in real builds if registration or project wiring is missing.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: mentions CLAUDE.md; mentions AGENTS.md.

This is adamw7/tools's own configuration. It tells Claude Code how to work on tools itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything tools configures →

Reuse

Borrowing it

Nothing to install: this file belongs to adamw7/tools. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/adamw7/tools/main/.claude/commands/new-enforcer-rule.md
Clone the repo
git clone --depth 1 https://github.com/adamw7/tools

Made for: Claude Code.

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 new-enforcer-rule

README.md
[![agentmods](https://agentmods.dev/badge/commands/adamw7/tools/new-enforcer-rule.svg)](https://agentmods.dev/commands/adamw7/tools/new-enforcer-rule)
Your own site
<a href="https://agentmods.dev/commands/adamw7/tools/new-enforcer-rule"><img src="https://agentmods.dev/badge/commands/adamw7/tools/new-enforcer-rule.svg" alt="Measured on agentmods" height="20"></a>
Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 835 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00028 $0.00835
Opus 5 $0.00014 $0.00417
Sonnet 5 $0.00006 $0.00167
Haiku 4.5 $0.00003 $0.00084

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

Security

Grade A, and why

new-enforcer-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 6d 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.

.claude/commands/new-enforcer-rule.md · 58 lines

What it actually says

Add the enforcer rule described by $ARGUMENTS. Load the enforcer-rules skill first; it carries the detail this checklist only names.

A rule is not done when it compiles and its unit test is green — a rule can be flawless and still guard nothing, because the ways it silently never runs all lie outside the class. Work through every step:

  1. The classclaude-code-enforcer/src/main/java/.../enforcer/<package>/, @Named("<ruleName>"), extending ClaudeCodeEnforcerRule, or DefinitionFormatRule / MultiDefinitionRule when it validates definitions. One package-private setter per parameter. Collect every violation into a List<String> and hand it to report(...) — never throw at the first, and never emit a \n inside one violation, which no baseline could match again.
  2. The Sisu index — add the class to src/main/resources/META-INF/sisu/javax.inject.Named. It is hand-maintained: a rule missing from it compiles, unit-tests green, then fails a real build with "Failed to create enforcer rules with name".
  3. Layeringtext depends on nothing, rule may use text, and the feature packages may use both but never each other. Shared logic goes down, not sideways; EnforcerArchitectureTest fails if it goes sideways.
  4. Naming — keep any helper class clear of the singular of a list parameter in the same package. Plexus infers a list's element type from the child element name and would instantiate the helper instead of String, which fails only in a real build.
  5. Unit tests beside the rule, fixtures in a @TempDir via TestFiles. Assert on the message, not just the throw. Cover: passes when correct, fails once per violation kind, passes on an empty directory, and the build-setup cases that always fail. Use CapturingLogger for what severity=warn logged.
  6. The IT fixtureRuleConfiguration.complete() must configure the rule with every parameter it accepts; EnforcerRuleBuildIT checks that block against the compiled classes and fails if a rule or parameter is missing.
  7. Survive a repository nobody preparedForeignRepositoryEnforcementIT points the same configuration at eight real clones. The rule must reach a verdict on a file it did not expect and a directory that is not there, and report both rather than throwing; where one of the eight really ships the file your rule reads, pin that it read it rather than reported it absent.
  8. Wire it into the root pom's claude-md-enforce profile, one child element per parameter. A rule taking a definition directory can only be wired once that directory exists — add the directory and the wiring in the same change. RepositoryEnforcementIT compares the shipped catalogue against the profile, so an unwired rule needs a documented exemption there.
  9. Document it — a row in the rule catalogue of AGENTS.md and a mention in the ## CLAUDE.md enforcement list of CLAUDE.md. That catalogue is what contributors read.

Then verify, in this order:

mvn -pl claude-code-enforcer -am install
mvn -N validate -DenforceClaudeMd
mvn -pl claude-code-enforcer -am -P integration-tests verify
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. 6d ago First seen · 58 lines · 28 tokens per session scan A 2cf0859c1973

Subscribe to this mod's changes

new-enforcer-rule is a command published in the GitHub repository adamw7/tools (11 stars, last pushed today), licensed MIT. It adds 28 tokens to every session and 835 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.