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.
curl -O https://raw.githubusercontent.com/adamw7/tools/main/.claude/commands/new-enforcer-rule.mdgit clone --depth 1 https://github.com/adamw7/toolsWrote 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.
[](https://agentmods.dev/commands/adamw7/tools/new-enforcer-rule)<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>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.
| Model | Per session | Once 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 |
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.
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:
- The class —
claude-code-enforcer/src/main/java/.../enforcer/<package>/,@Named("<ruleName>"), extendingClaudeCodeEnforcerRule, orDefinitionFormatRule/MultiDefinitionRulewhen it validates definitions. One package-private setter per parameter. Collect every violation into aList<String>and hand it toreport(...)— never throw at the first, and never emit a\ninside one violation, which no baseline could match again. - 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". - Layering —
textdepends on nothing,rulemay usetext, and the feature packages may use both but never each other. Shared logic goes down, not sideways;EnforcerArchitectureTestfails if it goes sideways. - 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. - Unit tests beside the rule, fixtures in a
@TempDirviaTestFiles. 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. UseCapturingLoggerfor whatseverity=warnlogged. - The IT fixture —
RuleConfiguration.complete()must configure the rule with every parameter it accepts;EnforcerRuleBuildITchecks that block against the compiled classes and fails if a rule or parameter is missing. - Survive a repository nobody prepared —
ForeignRepositoryEnforcementITpoints 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. - Wire it into the root pom's
claude-md-enforceprofile, 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.RepositoryEnforcementITcompares the shipped catalogue against the profile, so an unwired rule needs a documented exemption there. - Document it — a row in the rule catalogue of
AGENTS.mdand a mention in the## CLAUDE.md enforcementlist ofCLAUDE.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
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.
- 6d ago First seen · 58 lines · 28 tokens per session scan A 2cf0859c1973
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.
Other commands, from other repositories
benchmark
Design and coordinate a reproducible Java performance test.
test
Run the project test suite and report results.
justfile-recipe-short-doc
Shorten justfile recipe doc comments for simple recipes.
generate-and-verify
Trigger annotation processing in the demo module to generate all outputs (DTOs, MCP tools, REST controllers, OpenAPI spec), then verify the generated code compiles and matches expected patterns. List all generated files with a summary of what each contains.
new-generator
Add a new code generator to the annotation processor. Generators produce Java source files or resource files from scanned annotations. Requires.
java-build
Build Java project with Maven or Gradle - compile, test, package.