# 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).

Last updated: 2026-12-04 · jevmem 0.7.11 · [Install](https://jevmem.dev/install/) · [Source on GitHub](https://github.com/Avinash-jetwani/jevmem)

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](https://github.com/Avinash-jetwani/jevmem/blob/main/results/ab-automem-2026-11-02-audit.json); [method](https://github.com/Avinash-jetwani/jevmem/blob/main/docs/benchmark.md#against-claude-codes-auto-memory-077)). On a held-out set of 274 tool calls, the guard caught 66 of 68 rule breaks ([results](https://github.com/Avinash-jetwani/jevmem/blob/main/results/guard-heldout-v2-2026-09-30-v061.json)).

## 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:

```text
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](https://jevmem.dev/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](https://jevmem.dev/guard/#limits).

## Set it up

You need a [TypeSafe API key](https://console.typesafe.ai/keys), which jevmem's requests are billed to, and Claude Code 2.1.273 or later.

1. In the Claude app: **Plugins → Discover → jevmem → Add**.
2. Install the CLI the plugin runs:
   ```bash
   npm install -g jevmem
   ```
3. 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):
   ```bash
   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:

```bash
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):

```bash
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](https://jevmem.dev/install/#the-cursor-plugin-076)). The **Add to Cursor** button on [cursor.directory](https://cursor.directory/plugins/jevmem) installs the MCP server only ([the entry](https://github.com/Avinash-jetwani/jevmem/blob/main/docs/mcp.md#cursor)), 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](https://jevmem.dev/install/).

## The limits, in short

- jevmem needs a TypeSafe API key ([where to get one, and the install steps](https://jevmem.dev/install/)).
- Message text is sent to TypeSafe to be scored, with common secrets scrubbed first ([what leaves your machine](https://jevmem.dev/privacy/)).
- 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 watch` runs, 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](https://jevmem.dev/install/#works-with)).
- 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](https://jevmem.dev/compare/)).
- The guard is a backstop, not a sandbox ([what it misses](https://jevmem.dev/guard/#limits)). 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](https://jevmem.dev/pane/)).

Every limit, with the numbers: [the FAQ](https://jevmem.dev/faq/#what-are-jevmems-limits).
