Security
~8 min readUpdated: December 2026

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

Context Clash Cross-Tool AGENTS.md and CLAUDE.md Conflict Detection Pipeline in Smoke Monkey

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.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Examplecontext-clash-audit-agent.ts
context-clash-audit-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// CI Auditor Agent that unifies AGENTS.md, CLAUDE.md, and .github/copilot-instructions.md
const 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);
Video Guides

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 PairSampled / Population PairsConflict Prevalence [95% CI]Dominant Risk
AGENTS.md – Claude49 / 23221.77% [8.84, 36.77]%Stale build & test commands
AGENTS.md – Copilot40 / 17820.22% [7.50, 34.87]%Divergent lint & style gates
Claude – Copilot42 / 16518.43% [7.14, 32.10]%Conflicting API / architecture rules
Claude – Cursor23 / 2412.50%Different directory conventions
AGENTS.md – Cursor21 / 229.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:

  1. 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.
  2. 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.
  3. 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:

bash
# 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 || true

Pair 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.

Google Search Questions & Answers

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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness