Skip to content

debug: why does Claude Code override EGC rules instead of following them? #647

Description

@Fmarzochi

The problem

EGC ships mandatory rules for every supported tool: persistent memory via egc-memory, skill routing via egc-guardian, session hooks (SessionStart, PreCompact, PreToolUse), and orchestration protocols. These rules are injected at install time into each tool's native config format: CLAUDE.md for Claude Code, GEMINI.md for Gemini CLI, AGENTS.md for Codex, .cursor/rules/ for Cursor, .windsurf/rules/ for Windsurf, and so on.

In practice, AI tools frequently ignore them. They start sessions without calling get_state. They run shell commands without calling validate_command. They skip orchestrate_task on non-trivial work. They do not call update_state at session end. The model reads the rules, acknowledges them, and then proceeds to violate them within the same session.

This is not a bug in the config syntax. The rules load correctly. The question is why the model does not follow them reliably.

What we want to understand

  • Is this specific to Claude Code, or do Gemini CLI, Codex, Cursor, Windsurf, Kiro, and others show the same drift?
  • Does the severity vary by model or by tool? (e.g., does Gemini CLI follow get_state more consistently than Claude Code?)
  • Is this a context window issue (rules loaded too early, displaced by later content)?
  • Is it a system prompt priority issue (provider defaults overriding user instructions)?
  • Does enforcement differ between hook-based injection (Claude Code, Gemini CLI) and rules file injection (Cursor, Windsurf)?
  • Is there a reliable pattern for when a model complies vs. when it drifts?

What we are asking for

Install EGC and test with any tool you use:

npm install -g @egchq/egc && egc init

EGC supports: Claude Code, Gemini CLI, Codex CLI, Cursor, Windsurf, Kiro, Trae, Amp, VS Code Copilot, Zed, OpenCode, Antigravity, CodeBuddy, Continue.dev.

Then:

  1. Run a real session with your tool: ask it to do any non-trivial coding task
  2. Observe: does it call get_state at start? Does it call validate_command before shell commands? Does it call update_state at the end?
  3. Comment here with:
    • Which tool and model you tested (e.g. Claude Code with claude-sonnet-4-6, Cursor with GPT-4o)
    • Which EGC rules it followed and which it skipped
    • Whether the behavior is consistent across sessions or random
    • Any workaround you found that improved compliance

You do not need to submit a fix. A detailed observation from one tool is already valuable. Reports from multiple tools are even better -- they let us tell whether this is a Claude-specific issue or a universal LLM behavior.

Why this matters

EGC is built on the premise that AI tools can follow structured protocols reliably. If models consistently override their own rules regardless of the tool wrapper, that is a fundamental finding about current LLM instruction-following that belongs in the open. If it is tool-specific, there may be a configuration fix.

If you find a reliable way to improve rule compliance in any supported tool, open a PR -- that fix belongs in the core runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions