Context Clash: Detecting AGENTS.md, CLAUDE.md & Copilot Rule Conflicts

Accepted at ACM SAC 2027 (arXiv:2612.00485), Context Clash audits 1,112 canonical coding-agent configuration files across 128 repositories and discovers that roughly 1 in 5 multi-tool repos contain direct cross-tool instruction conflicts—most commonly contradictory CLI commands, package managers, and style rules—while high-precision lexical and NLI detectors catch at most 1 of 23 held-out conflicts.
Context Clash: Detecting AGENTS.md, CLAUDE.md & Copilot Rule Conflicts: Accepted at ACM SAC 2027 (arXiv:2612.00485), Context Clash audits 1,112 canonical coding-agent configuration files across 128 repositories and discovers that roughly 1 in 5 multi-tool repos contain direct cross-tool instruction conflicts—most commonly contradictory CLI commands, package managers, and style rules—while high-precision lexical and NLI detectors catch at most 1 of 23 held-out conflicts. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 21.8% Cross-Tool Conflict Rate: Probability sampling across 128 repos reveals 21.77% conflicts in AGENTS–Claude pairs and 20.22% in AGENTS–Copilot pairs.
- Command & Toolchain Drift Dominates: 16 of 38 conflicting file pairs clash on build, test, or package-manager commands (e.g., npm vs pnpm, pytest flags), followed by Style/API (11) and Polarity (8).
- Detector Limits Quantified: At high-precision thresholds, lexical similarity, NLI, and structured-atom detectors each recover at most 1/23 held-out conflicts.
- High-Recall Triage Workflow: Ranking pairs by NLI contradiction score surfaces 13 of 23 held-out conflicts inside the top 37 candidates for fast human CI review.
import { createAgent } from '@smoke-monkey/harness';// CI Auditor Agent that unifies AGENTS.md, CLAUDE.md, and .github/copilot-instructions.mdconst agent = createAgent({agentId: 'context-clash-ci-auditor',provider: 'anthropic',model: 'claude-sonnet-5-5',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function main() {const result = await agent.run(['Read AGENTS.md, CLAUDE.md, .cursorrules, and .github/copilot-instructions.md if present.','Flag every command, toolchain, version, polarity, or permission contradiction across files against package.json.',].join(' '));console.log('Cross-tool instruction audit:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
CLAUDE.md, AGENTS.md and SKILL.md Explained for Beginners
CLAUDE.md and Agents.md Explained: Stop Repeating Yourself to AI
How Often Do AGENTS.md, CLAUDE.md, and Copilot Instructions Conflict?
Engineering teams increasingly commit separate instruction files for each coding assistant inside the same repository. In arXiv:2612.00485, two independent annotators audited 1,112 canonical files (374 AGENTS.md, 363 Claude, 306 Copilot, 42 Cursor, and 27 Gemini) across a probability sample of 128 repositories.
Every individual file looked valid in isolation, yet roughly 1 in 5 multi-tool repositories contained mutually incompatible instructions—such as telling Claude to run pnpm test while telling Copilot to run npm test --legacy-peer-deps, or reversing linting/branch-protection polarity.
| Tool View Pair | Sampled / Population Pairs | Conflict Prevalence [95% CI] | Dominant Risk |
|---|---|---|---|
| AGENTS.md – Claude | 49 / 232 | 21.77% [8.84, 36.77]% | Stale build & test commands |
| AGENTS.md – Copilot | 40 / 178 | 20.22% [7.50, 34.87]% | Divergent lint & style gates |
| Claude – Copilot | 42 / 165 | 18.43% [7.14, 32.10]% | Conflicting API / architecture rules |
| Claude – Cursor | 23 / 24 | 12.50% | Different directory conventions |
| AGENTS.md – Cursor | 21 / 22 | 9.66% [4.55, 19.89]% | Package-manager drift |
Why Lightweight Automated Detectors Miss Real Contradictions
Across the 38 adjudicated conflicting file pairs, contradictions clustered in Command/toolchain (16), Style/API (11), Polarity (8), Architecture/location (7), Version/dependency (6), Validation/release (5), and Safety/permission (1).
Evaluating automated screeners on a repository-disjoint benchmark of 23 held-out conflicts exposed why naive CI linters struggle:
- High-Precision Collapse: At thresholds calibrated for low false alarms, lexical similarity, Natural Language Inference (NLI), and structured-atom extractors each recovered at most 1 out of 23 held-out conflicts.
- Implicit Domain Negation: Two instructions rarely share exact opposite keywords; for example, *"Use Vitest for all unit suites"* vs *"Run Jest in CI before pushing"* requires repository context to recognize mutual exclusion.
- Top-K Human Triage Works: When NLI is used as a ranker rather than a hard binary classifier, its top 37 ranked pairs surface 13 of 23 real conflicts, cutting manual review volume dramatically.
Markdown Instructions Are Not Hard Guardrails
Even conflict-free AGENTS.md files are advisory text. Enforce destructive command blocks, branch rules, and file-path permissions deterministically inside Smoke Monkey Harness.
Eliminating Instruction Drift with a Single Canonical Config in CI
Consolidate tool-specific prose into a single canonical AGENTS.md and add a lightweight pre-commit check that flags diverging copies or unverified CLI commands:
# 1. Inventory all coding-agent instruction files in the current repository
find . -maxdepth 4 \( -name "AGENTS.md" -o -name "CLAUDE.md" -o -name "GEMINI.md" -o -name ".cursorrules" -o -name "copilot-instructions.md" \)
# 2. Extract fenced/inline package-manager commands to audit drift
grep -rnE "\b(npm|pnpm|yarn|bun|pytest|vitest|jest|cargo)\b" AGENTS.md CLAUDE.md .github/copilot-instructions.md 2>/dev/null || truePair this CI check with Smoke Monkey Harness permission rules (read_file, write_file, run_command) so runtime safety never depends on whether a markdown file drifted last quarter.
Frequently Asked Questions
Q:How prevalent are conflicts between AGENTS.md, CLAUDE.md, and Copilot files?
In arXiv:2612.00485 across 128 sampled repositories, roughly 1 in 5 multi-tool repos had direct conflicts: 21.77% for AGENTS–Claude, 20.22% for AGENTS–Copilot, and 18.43% for Claude–Copilot.
Q:What kinds of instructions conflict most often?
Command and toolchain instructions (build scripts, test runners, package managers) accounted for 16 of 38 conflicting pairs, followed by Style/API rules (11), Polarity reversals (8), Architecture/location (7), and Version/dependency specs (6).
Q:Can an automated NLI or regex script catch all AGENTS.md conflicts?
No. At high-precision thresholds, lexical, NLI, and structured-atom detectors each caught at most 1 of 23 held-out conflicts, though ranking by NLI surfaced 13 of 23 in the top 37 candidates.
Q:What is the cleanest way to prevent Context Clash across AI coding tools?
Maintain one canonical AGENTS.md verified against package.json/Makefile in CI, keep tool-specific wrappers minimal (or symlinked), and enforce hard permissions at the harness layer.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.