Memory rules and CLAUDE.md directives not reliably enforced between turns

Open 💬 0 comments Opened Jul 14, 2026 by jeffsinger66

Summary

Claude Code repeatedly violates explicit project rules defined in both CLAUDE.md and a persistent memory system, even after being corrected multiple times in the same session.

Behaviour

The project has two hard rules, written in CLAUDE.md and in memory files:

  1. Never make changes directly to a running service on the shared test host — always capture the change locally first, then deploy.
  2. Always read MEMORY.md before issuing any command, path, or deploy instruction.

Despite these rules being in context, Claude violated them repeatedly in the same session:

  • Made Keycloak client registration policy changes via direct REST API calls against the running instance, with no local Terraform or script capturing the change first.
  • Made a PostgreSQL ALTER MATERIALIZED VIEW and continuous aggregate policy change directly against the live database via psql, again with no local DDL change first.
  • Used wrong credentials for a database connection despite the correct credentials having been stated earlier in the session and a memory rule existing to check before every command.

Each violation was only caught after the fact when the user pointed it out. When corrected, Claude acknowledged the rule, sometimes updated the memory file — and then violated the same rule again in the next relevant action.

Impact

Direct mutations to running services without local capture create state drift: the live environment is ahead of the repository. The next deploy or terraform apply can silently overwrite the change. In this project this has already caused real risk (Keycloak policy changes that would be lost on realm recreate).

Expected behaviour

Rules defined in CLAUDE.md and in the memory system should be consistently applied before taking an action, not just acknowledged after being caught violating them. If the memory system cannot reliably enforce these constraints between turns, that limitation should be surfaced to the user rather than silently ignored.

Environment

  • Claude Code (CLI)
  • Model: claude-sonnet-4-6
  • Platform: macOS (darwin 25.5.0)

View original on GitHub ↗