AI Help

How do I keep Claude Code following CLAUDE.md after /compact?

Store durable rules in the applicable CLAUDE.md file and inspect which instruction files the current session loads after compaction.

Steps to follow

  1. Confirm the working directory and location of the project's CLAUDE.md. Keep recurring commands and constraints concise and remove conflicting duplicates.
  2. After /compact, inspect loaded memory or instruction files using the controls supported by your installed version. Ask Claude to restate the relevant rule.
  3. Test a small task and inspect its commands and diff. If a rule is missed, reduce ambiguity and report a reproducible case with the version.

Example in practice

Illustrative example. A rule requires npm run typecheck before completion. After compaction, verify the command's actual output in the session.

Related AI help

Official guidance

Claude documentation