← ClaudeAtlas

enforcer-ruleslisted

Write, test and wire a claude-code-enforcer rule — the custom maven-enforcer rules that fail the build when CLAUDE.md, AGENTS.md, README.md or the .claude configuration is malformed. Use when adding or changing a rule, when configuring severity/reportFile/baselineFile, or when the user says "enforcer rule", "the doc check fails", or "wire a rule into the pom".
adamw7/tools · ★ 11 · Data & Documents · score 74
Install: claude install-skill adamw7/tools
# Enforcer Rules Skill Add or change a rule in `claude-code-enforcer`, the module of custom `maven-enforcer-plugin` rules that guard this repository's agent-facing files. Every rule follows the same shape, so getting the shape right is most of the work. ## The two-phase build (there is no shortcut) A maven-enforcer rule must be resolvable as a JAR *before* the build that uses it runs, so a change to a rule needs two commands: ```bash mvn -pl claude-code-enforcer -am install # 1. publish the rule locally mvn -N validate -DenforceClaudeMd # 2. quick root-only doc check ``` Skipping step 1 runs the *previous* rule against your new expectations. The check is opt-in (`claude-md-enforce` profile, activated by `-DenforceClaudeMd`), so ordinary builds are unaffected; `.github/workflows/maven.yml` is the only workflow that opts in. ## Anatomy of a rule ```java @Named("myNewRule") // the pom's <myNewRule> element public class MyNewRule extends ClaudeCodeEnforcerRule { private File someFile; // injected from the configuration @Override public void execute() throws EnforcerRuleException { requireDocument(someFile, "someFile"); // build-setup checks first String content = requireContent(someFile, "someFile"); List<String> violations = new ArrayList<>(); // ... collect every problem, never stop at the first ... report("What went wrong, in one line:", viola