How do I stop an AI coding agent from breaking my project's rules?
Write each rule where the agent reads it at the start of the work, and have something check the agent's actions against the rules before they run: jevmem keeps the rules in JEVMEM.md in your repo, and in Claude Code its guard checks each command, file edit and file write against them and asks you first when one may break a rule.
In real Claude Code sessions (0.7.7, checked by hand), a change a rule forbids was left in the code in 0 of 15 sessions with jevmem on, against 9 of 15 with no project memory (results; method). On a held-out set of 274 tool calls, the guard caught 66 of 68 rule breaks (results).
Write the rule where the agent reads it #
A rule the agent never sees can't be followed. Claude Code reads CLAUDE.md, Cursor reads its Project Rules and AGENTS.md, and Codex reads AGENTS.md. jevmem saves the rules you state in chat ("don't hand-edit db/migrations/: those files are generated") as lines in JEVMEM.md, gives the ones a prompt needs back to Claude Code on every prompt, sends rules marked always-on at the start of every session, and lets Cursor's and Codex's agents look them up over MCP.
Check the action before it runs #
A rule in the context is a request; a check before the call is a second line. jevmem's guard runs as a Claude Code PreToolUse hook: before a Bash command, an Edit or a Write runs, it finds the saved rules the call may touch and asks Jev whether the call would break one. If so, Claude Code shows you the rule and asks:
jevmem: this may break a saved rule: "Don't hand-edit db/migrations/: those files are generated." (JEVMEM.md)
In block mode, a call that breaks a rule you marked verified with jevmem trust does not run, and Claude is told to tell you about the rule instead of working around it. How the guard reads a call, its modes and its settings: the guard.
What it does not catch #
The guard is a backstop, not a sandbox. It looks at the words a rule and a call share, so a script or a make target that already exists and does the forbidden thing can be missed. It checks Claude Code's Bash, Edit and Write calls, not MCP tools or what a script changes when it runs, and it runs in Claude Code only: Cursor and Codex get the rules, not the check. Every limit: the guard's limits.
Set it up #
You need a TypeSafe API key, which jevmem's requests are billed to, and Claude Code 2.1.273 or later.
- In the Claude app: Plugins → Discover → jevmem → Add.
- Install the CLI the plugin runs:
npm install -g jevmem - In your project's folder, finish the setup in one go (it asks for your key without showing it, turns jevmem on in that folder, and checks the setup):
jevmem setup
Start Claude Code in that project. If you start it before the setup is done, the plugin says once what is left; jevmem doctor checks the setup any time.
Other ways to install: the jevmem marketplace, npm, Cursor, Codex
From the jevmem marketplace:
npm install -g jevmem
claude plugin marketplace add Avinash-jetwani/jevmem
claude plugin install jevmem@jevmem
claude plugin install jevmem-pane@jevmem # the side pane (0.7.5), optional
cd your-project && jevmem setup
With npm only (also sets up Cursor and Codex):
npm install -g jevmem
cd your-project
jevmem init --tool claude # or cursor, codex, claude-desktop, all
In Cursor, the jevmem plugin (0.7.6) carries the hooks, the MCP server and the rule for every window: install it from the Cursor Marketplace once it is listed there, or copy this repository's cursor-plugin/ folder to ~/.cursor/plugins/local/jevmem and reload the window; then jevmem setup in each project (the steps). jevmem is also listed on cursor.directory; its Add to Cursor button installs the MCP server alone (recall, with the entry in docs/mcp.md), so saving still needs the plugin folder or jevmem init --tool cursor.
Already have a CLAUDE.md? jevmem import shows what it would add from it; --apply writes it.
Every step, and what to do if the plugin can't find the CLI: docs/install.md.
The limits, in short #
- jevmem needs a TypeSafe API key (where to get one, and the install steps).
- Message text is sent to TypeSafe to be scored, with common secrets scrubbed first (what leaves your machine).
- It is automatic in Claude Code and, since 0.7.4, in Cursor (as a Cursor plugin since 0.7.6, whose rule sits in every chat), automatic in Codex while
jevmem watchruns, and in Claude Desktop only when the agent calls it; in Cursor, bringing lines back is still the agent's call (what each tool does). - Rules every task must follow reach every session only when they are marked always-on (0.7.1), by Jev's reading or yours (jevmem next to CLAUDE.md).
- The guard is a backstop, not a sandbox (what it misses).
- The side pane is Claude Code only, 2.1.299 or newer: Cursor has no pane, and Claude Code for VS Code draws none yet (the pane).
Every limit, with the numbers: the FAQ.