Claude Code Ignores CLAUDE.md Rules — 5 Root Causes & Instant Fixes
Claude Code ignores CLAUDE.md rules for five mechanical reasons: wrong path or filename casing (e.g. claude.md on Linux), silent truncation past 40,000 characters, instruction overload past ~150 directives (IFScale decay), shouting emphasis keywords everywhere (diluting priority), or bare prohibitions without an alternative and reason.
CLAUDE.md 40,000-Character Limit — How Silent Truncation Breaks Safety Rules
Claude Code caps single memory files at 40,000 characters (MAX_MEMORY_CHARACTER_COUNT). Across 4,533 audited GitHub repos, 37 real repositories exceed this ceiling and lose their tail rules silently. Fix it by cutting root CLAUDE.md under 150 lines (~6,000 chars) and moving deep docs into docs/ with conditional read pointers.
CLAUDE.md @import Cycle or Broken @include Path — How to Fix Include Resolution
Claude Code supports @path/to/file.md imports up to 5 recursive hops and skips missing paths or cycles silently. Keep imports strictly one-way (CLAUDE.md -> @AGENTS.md or @docs/topic.md), verify every relative path from the importing file's directory, and never point AGENTS.md back to @CLAUDE.md.
.claude/settings.json Invalid Hook Event — Why Hooks Fail Silently & Auto-Fix
Claude Code matches exact PascalCase hook event names (PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, UserPromptSubmit, Notification, PreCompact, SubagentStop). Over 35 misspelled hook keys appear across real public repos because unknown keys fail silently. Always validate JSON syntax, use exact PascalCase names, set an explicit matcher, and double-quote $CLAUDE_FILE_PATHS.
Cursor .cursor/rules/*.mdc Globs Not Matching — paths: vs globs: & Pattern Pitfalls
Cursor .mdc rules fail to match for four reasons: using Claude Code's paths: key instead of globs:, prefixing globs with a leading slash (/src/**), setting alwaysApply: false without a description or valid glob, or forgetting to quote globs starting with * in YAML frontmatter.
Legacy .cursorrules Deprecated — Clean Migration to .cursor/rules/*.mdc + AGENTS.md
Cursor replaced the single root .cursorrules file with modular .cursor/rules/*.mdc files supporting YAML frontmatter, glob scoping, and team version control. For multi-agent repos (Cursor + Claude Code + Codex), move shared rules into AGENTS.md, keep a thin @AGENTS.md CLAUDE.md pointer, and split Cursor-specific file rules into scoped .cursor/rules/*.mdc files.
AGENTS.md Not Loaded in OpenAI Codex CLI — Discovery Order, Size Cap & Fix
Codex CLI reads AGENTS.md (and AGENTS.override.md) — NOT CLAUDE.md — walking from the Git root down to your current working directory, capped by default at 32 KiB (project_doc_max_bytes). It also does NOT expand Claude Code's @import syntax, so putting @CLAUDE.md inside AGENTS.md leaves Codex with a literal 10-byte line.
.github/copilot-instructions.md Ignored by GitHub Copilot — Path, Frontmatter & Settings Fix
GitHub Copilot looks strictly at .github/copilot-instructions.md for repo-wide guidance and .github/instructions/*.instructions.md with YAML applyTo: globs for scoped files. Common failures include misspelling the filename (copilot-instruction.md singular), placing it in the repo root instead of .github/, or using globs: instead of applyTo: in scoped instruction files.
Conflicting Rules Across CLAUDE.md, AGENTS.md & .cursor/rules — Eliminate Harness Drift
When teams copy-paste instructions across CLAUDE.md, AGENTS.md, .cursor/rules, and copilot-instructions.md, rules drift within weeks and agents contradict each other. Fix harness drift permanently by designating AGENTS.md as the canonical source of truth, replacing CLAUDE.md's duplicated body with a single @AGENTS.md pointer, and auditing conflicts with AgentLint D1.
GitHub Actions Unpinned Tag Supply-Chain Risk (Rule S2) — Pin to 40-Char SHA
58% of audited open-source AI repositories leave GitHub Actions on floating version tags. Because Git tags can be silently force-pushed if an upstream action is compromised, every third-party uses: line should be pinned to a full 40-character commit SHA with a human-readable version comment (# v4), paired with minimal top-level permissions: contents: read.
Prompt Injection in CLAUDE.md / AGENTS.md — How Hidden Rules Hijack Coding Agents
Every CLAUDE.md, AGENTS.md, .cursor/rules file, and .claude/settings.json inside a cloned repository executes as high-privilege context when you open an AI coding agent there. Never grant wildcard auto-approve (Bash(*) or *), enforce explicit deny rules for .env and SSH keys (Rule H5), inspect hidden HTML comments and hook scripts for network calls (Rule H6), and audit untrusted repos in AgentLint before starting a session.
API Keys & Personal Paths Leaked in .cursorrules or CLAUDE.md — Remediation Checklist
Never paste real API keys, bearer tokens, staging DB URLs, or personal /Users/<name> home paths into CLAUDE.md, AGENTS.md, or .cursorrules. Once pushed, rotate the exposed credential immediately, scrub it from Git history, replace it with an environment variable name (process.env.STRIPE_API_KEY), add .env and CLAUDE.local.md to .gitignore (S1 / C5), and enable CI secret scanning (S3).
Claude Code Memory Bloat & Context Rot — Why Longer CLAUDE.md Makes Agents Worse
Peer-reviewed studies (IFScale NeurIPS 2025 and ETH Zurich 2026) prove that instruction compliance drops steadily past ~150 rules and auto-generated context bloat lowers task success in 5 of 8 benchmarks while raising inference cost by 20–23%. Cure context rot by pruning stale rules (C1/D2), capping root CLAUDE.md at 60–150 lines, and loading deep docs conditionally.
Windsurf .windsurfrules / .windsurf/rules Not Working — Character Cap, Trigger Mode & Fix
Windsurf enforces tight size ceilings on workspace rules (6,000 characters per individual rule file and 12,000 characters total across active rules) and requires valid trigger frontmatter (always_on, glob, model_decision, or manual) inside .windsurf/rules/*.md. Split oversized files, pick the right trigger mode, or keep shared rules in AGENTS.md.
Claude Code SKILL.md Frontmatter Error — Fix Unrecognized Skills & Slash Commands
Every Claude Code skill must live at .claude/skills/<skill-name>/SKILL.md (exact uppercase SKILL.md) with valid YAML frontmatter containing both name: (lowercase kebab-case) and description: (explaining when to invoke the skill). Unquoted colons in description:, wrong filename casing (skill.md), or leftover {{PLACEHOLDER}} tokens prevent registration.
Monorepo Nested CLAUDE.md Precedence — How Root vs Package Rules Merge Without Duplication
Claude Code loads root CLAUDE.md eagerly at session start and loads nested subdirectory CLAUDE.md files lazily when it reads or edits files inside those subdirectories. Keep root CLAUDE.md strictly workspace-wide (package manager, workspace filter syntax, repo map, global security) and place stack-specific rules inside apps/*/CLAUDE.md without repeating root instructions.
Want to test your own repo against all 16 failure modes right now?