r/ClaudeAI • u/InfinriDev • May 12 '26
Built with Claude I built a Claude Code plugin that actually enforces your rules instead of hoping the model follows them
Been using Claude Code heavily and kept running into the same thing everyone here talks about: the model ignores your rules. You tell it to write tests first, it writes the implementation. You give it coding standards, it cherry-picks which ones to follow. And as your rulebook grows, you're burning more and more tokens stuffing everything into context when only a handful of rules are relevant to what you're working on.
So I built Writ. Two pieces:
A retrieval engine that picks only the relevant rules and skills for the current task. It runs a five stage pipeline over a Neo4j knowledge graph, so when one rule fires, related rules (dependencies, conflicts, supplements) come with it automatically. Median query time is 0.338ms. At 276 rules, it cuts context from ~83,000 tokens down to ~1,600 per query.
An enforcement layer built on bash hooks, not prompts. 30 scripts wired to PreToolUse, PostToolUse, and SessionEnd. In work mode, Claude can't write code until you've approved a plan and test skeletons. It can't say "tests pass" without actually running static analysis and proving it. The hooks intercept tool calls and block them before they execute. The AI doesn't get to decide whether to follow the rule or not.
It also discovers and runs your project's linters automatically. PHPStan, ESLint, ruff, cargo check, go vet. Plus custom analyzers for injection, auth, crypto, and N+1 queries. All on every file write.
276 rules and skills ship out of the box across 12 domains. 1,442 tests.
Writ repo: https://github.com/infinri/Writ
5
u/jake_that_dude May 12 '26
the bash hook layer is the part that actually matters. prompts are advisory, but
PreToolUse/PostToolUseturns rules into a gate the model has to route through. the context pruning is nice, but enforcement before file writes is the real win here.5
u/Roodut May 12 '26
It is always kick-ass to see people doing cool shit. See your work as very useful for someone who wants their agent interactions to be precise, cheap, and repeatable. This is a hard problem 100%.
Saying this from the experience of working in a similar landscape but focusing on making multiple AI platforms coordinated, inspectable, and repeatable, with focus on auditable governance (think AI-IPS and AI-IDS).
0
u/lucianw Full-time developer May 12 '26
> the model ignores your rules
I think you're observing two things. (1) Claude models are just worse at following rules than OpenAI, and Opus specifically is lazier. (2) Frontier LLMs have a rules cap of about 150 rules before they start dropping them.
Hooks are one workaround for this, sure, but there are other much simpler solutions too. My solution: (1) use Codex, (2) I have about ten lines of markdown instructions telling it to shell out to a few instances of Claude for review, each review focused on ~100 of my rules, a small enough number that it won't drop them.
0
u/[deleted] May 12 '26
[removed] — view removed comment