high severitymulti-agent

    Conflicting Rules Across CLAUDE.md, AGENTS.md & .cursor/rules — Eliminate Harness Drift

    Conflict: CLAUDE.md says pnpm + Vitest while .cursor/rules says npm + Jest — agents thrash between PRs.

    Direct-Answer Fix Summary

    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.

    Broken vs. Fixed Configuration

    Broken: Diverged commands across two files
    # CLAUDE.md (updated last week)
    Always use pnpm test (Vitest). Never use npm.
    
    # .cursor/rules/testing.mdc (stale from 6 months ago)
    Run npm run test:jest before every commit.
    Fixed: Single source AGENTS.md + thin @AGENTS.md pointer
    # AGENTS.md (canonical truth)
    ## Verification
    - Fast single test: pnpm vitest run <file>
    - Never run npm; use pnpm --frozen-lockfile.
    
    # CLAUDE.md
    @AGENTS.md

    Why This Happens

    Developers update one tool's config after migrating from Jest to Vitest or npm to pnpm, leaving stale contradictions in the other three agent files. In our 4,533-repo study, dual-entry repos frequently diverge in commands and package managers.

    Step-by-Step Fix

    1. 01
      Consolidate universal rules into AGENTS.md

      Put build/test commands, package manager, architecture map, and hard boundaries in one canonical AGENTS.md.

    2. 02
      Replace duplicated CLAUDE.md body with @AGENTS.md

      Keep CLAUDE.md as @AGENTS.md plus only Claude-specific hook/plugin notes.

    3. 03
      Keep tool adapters strictly additive

      Let .cursor/rules/*.mdc hold only path-scoped conventions without restating repo-wide commands.

    4. 04
      Run /al in Claude Code for deep contradiction review (Rule D1)

      Run the opt-in /al deep review inside Claude Code on major harness refactors to catch subtle cross-file conflicts.

    Automated AgentLint Checks That Catch This

    Frequently Asked Questions

    What happens if an agent sees two contradictory rules in context?

    The model either oscillates unpredictably between them across turns or follows whichever appeared last in the prompt, causing flaky PRs and wasted tool calls.

    Can AgentLint detect contradictory instructions automatically?

    Yes. AgentLint's extended rule D1 (Contradictory rules) specifically audits cross-file and intra-file conflicts across your harness.

    Related Troubleshooting Guides