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 its guard checks each command, file edit and file write against them, and against the rules already in your CLAUDE.md, AGENTS.md and Cursor rules (0.7.9), before it runs: Claude Code asks you first when one may break a rule, and Cursor and Codex ask or stop the call (0.7.9).
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 PreToolUse hook in Claude Code (and, since 0.7.9, as Cursor's and Codex's hooks before a tool call): 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 shell commands, edits and writes in Claude Code, Cursor and Codex, not MCP tools or what a script changes when it runs. Where Cursor or Codex can't ask, it stops the call and you let it through with jevmem guard allow <code>; a hook there that times out lets the call run, and Codex's own docs say some of its tool paths skip the hook. 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, 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 carries the hooks, the MCP server and the rule for every window. Until it is on the Cursor Marketplace, copy this repository's cursor-plugin/ folder to ~/.cursor/plugins/local/jevmem and reload the window, then run jevmem setup in each project (the steps). The Add to Cursor button on cursor.directory installs the MCP server only (the entry), so the agent can read the memory but nothing is saved or checked.
Already have a CLAUDE.md? The guard reads its rules without an import. If you also want its lines in JEVMEM.md, so they come back like saved ones, jevmem import shows what it would add and --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). In Cursor and Codex it is a hook, and a hook that times out or fails lets the call run.
- 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.