Axiom Lift

Claude Code · CLAUDE.md · AGENTS.md

Claude Code ignoring your CLAUDE.md? Why rules fade and how to make them stick

Rules in CLAUDE.md or AGENTS.md followed at first, then ignored. The three reasons it happens, the checks and fixes that work today, and what to keep out of the file.

30 September 2026

Three ways a rules file fails: never loaded, compacted away, crowded out

The issue, as reported

It is one of the most widely reported complaints about coding agents: you write the house rules into CLAUDE.md (or AGENTS.md), the agent follows them for a while, and then it doesn't. Well over a hundred developers have described it across dozens of threads on the Claude Code, Codex and OpenCode trackers, some open for more than a year.

The reports fall into a few patterns:

What developers report

FadesRules obeyed for the first few turns, slipping by turn ten, gone by turn twenty.
After a compactThe session carries on, but the rules, and sometimes the objective itself, are no longer followed.
Never loadedNested files or AGENTS.md silently not read in some modes, versions or setups.
Safety rules"Never push to main" or "ask before deleting" broken, even when marked mandatory in capitals.
BloatThe file is trimmed, then grows back within weeks, and nobody is sure which lines still matter.

People have started calling the file "advisory". That is closer to the truth than it sounds.

Why it happens

There are three different failures here, and they need different fixes.

After a compact: the root CLAUDE.md is re-read from disk, a subfolder CLAUDE.md waits until a file there is read, and a rule said only in chat is summarised away
Where a rule goes missing. Only the project-root file comes back after every compact; everything else depends on what gets read, or was never on disk.

How to fix it today

Steps are for Claude Code unless noted.

  1. Check what actually loaded

    Run /context and look under Memory files. If a file isn't listed, Claude can't see it. /memory lists every location and opens the files. In Codex, run codex --ask-for-approval never "Summarize the current instructions.". If Claude Code skips AGENTS.md, check you're on v2.1.281 or later and have no CLAUDE.md or CLAUDE.local.md on the path, or set Project instructions in /config to claude-md-and-agents-md.

  2. Cut the file to what every session needs

    Target under 200 lines. Keep build commands, conventions and "always do X" rules, written so they can be checked: "Run npm test before committing", not "test your changes". Remove contradictions. Imports with @path tidy a long file but don't shrink it, because imported files load at launch too. From v2.1.283, /doctor prompt-audit lists outdated and conflicting instructions and proposes edits.

  3. Move part-specific rules into path-scoped files

    Rules that only matter for one area go in .claude/rules/ with a paths: line, so they load when Claude reads a matching file. The trade-off: they don't survive a compact until a matching file is read again. Anything that must hold all session belongs in the root CLAUDE.md, without paths:.

    ---
    paths:
      - "src/api/**/*.ts"
    ---
    - Every endpoint validates its input with the shared schema.
  4. Turn every "never" into a hook

    For rules that must hold regardless of what the model decides, the docs point to hooks. A PreToolUse hook that exits with code 2 blocks the call, and what it writes to stderr is passed to Claude as the reason. Save as .claude/hooks/no-push.sh and make it executable (chmod +x); it needs jq:

    #!/bin/bash
    COMMAND=$(jq -r '.tool_input.command')
    if echo "$COMMAND" | grep -Eq 'git push.*(main|master)'; then
      echo "Blocked: never push to main. Open a pull request." >&2
      exit 2
    fi
    exit 0
  5. Register the hook

    Add it to .claude/settings.json in the project, matching the Bash tool (hooks guide):

    {
      "hooks": {
        "PreToolUse": [{
          "matcher": "Bash",
          "hooks": [{
            "type": "command",
            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/no-push.sh"
          }]
        }]
      }
    }
  6. Re-state the essentials after every compact

    A SessionStart hook with the compact matcher runs after compaction and its output is added to the context. Use it for the two or three rules that keep slipping; keep .claude/keep.md short.

    {
      "hooks": {
        "SessionStart": [{
          "matcher": "compact",
          "hooks": [{
            "type": "command",
            "command": "cat \"$CLAUDE_PROJECT_DIR\"/.claude/keep.md"
          }]
        }]
      }
    }
  7. Use one file for every tool

    Put the shared rules in AGENTS.md, an open format that Codex and OpenCode read. If you also keep a CLAUDE.md, start it with an import so Claude Code reads both in every session, with Claude-only rules underneath:

    @AGENTS.md
    
    ## Claude Code only
    Use plan mode for changes under src/billing/.

What the fix doesn't cover

A hook only catches what its pattern matches

The example above stops git push origin main, but not a plain git push while you're on main, or a push done through a script. Hooks are exact, and most rules ("keep functions small", "don't add dependencies without asking") can't be written as a pattern at all. Those stay advisory, and a shorter, sharper file is the best you can do.

The other gap is what the file gets used for. Rules files bloat because they become the only place a project's history can live: why the API is versioned that way, which approach was tried and dropped, what was decided last Tuesday. Every such line loads in every session and dilutes the rules that matter, and when a decision changes, the old line often stays.

How Axiom Lift helps (partly)

Axiom Lift doesn't make a model follow rules, and nothing here replaces hooks or a good CLAUDE.md. What it does is take the project's history off the rules file's hands, so the file can go back to being short.

A small helper on your computer reads the conversations Claude Code, Codex and OpenCode already save, and picks out the requirements, decisions and corrections as you work. The next session asks Axiom over MCP and gets back the few lines that are true now on that subject, not the whole history.

The free fix

  • CLAUDE.md or AGENTS.md holds the rules, and often the project's history too
  • Every line loads into every session, relevant or not
  • When a decision changes, someone has to find and edit the old line
  • Hooks enforce the few rules that can be written as a pattern

With Axiom

  • The rules file keeps the rules; decisions and their reasons live in Axiom
  • Before each prompt, Axiom adds a few lines about what's already decided on that subject
  • Change your mind and the old decision is struck through, not erased, linked to when it was said
  • On Pro, it notices when a later conversation changed an earlier decision
What goes where: the rules file keeps short checkable rules, hooks enforce the never-rules, Axiom keeps decisions and their reasons and hands back the relevant few lines
A short rules file, hooks for the rules that must hold, and the project's history kept somewhere that hands back only what the current prompt needs.

What it doesn't do here:

It installs with one command in a desktop terminal, on Mac, with Linux and Windows in beta (it needs Python 3), and shows you what it found before anything is sent. The free plan covers one computer; Pro is £12.99 a month.

Keep the rules file for rules

One command in the terminal where you use Claude Code, Codex or OpenCode. Free, no card.

Try it free →

Claude, Codex and OpenCode are trademarks of their owners; Axiom works alongside them and is not affiliated.