To fix multi-agent instruction precedence conflicts across AGENTS.md, .cursor/rules, and Claude Skills, establish a strict scope hierarchy: isolate global defaults in a centralized skill manager, restrict repository root files to immutable project standards, and enforce tool-specific execution precedence so competing AI coding agents never overwrite shared code.
Symptoms: How Multi-Agent Precedence Conflicts Manifest in Shared Codebases
Instruction collisions between AI coding assistants rarely produce obvious syntax errors; instead, they manifest as subtle, frustrating behavioral regressions during routine development. When team members employ different coding assistants—such as Cursor, Anthropic Claude Code, OpenAI Codex, and Google Antigravity—each agent reads its own configuration file while remaining completely oblivious to neighboring instruction files.
In engineering organizations supporting multi-agent workflows, these instruction collisions typically surface in four destructive ways:
- Contradictory Linter and Formatter Thrashing: Cursor's
.cursor/rules/style.mdcinstructs the agent to enforce Biome with single quotes and no semicolons, whileCLAUDE.mdspecifies ESLint and Prettier with double quotes. When an engineer reviews a PR using Claude Code after another authored it in Cursor, the assistant silently reformats the entire diff, generating hundreds of spurious lines of code changes. - Package Manager Lockfile Corruption: The repository root
AGENTS.mdexplicitly dictatespnpm install --frozen-lockfile, but a legacy.cursorrulesfile contains an unmaintainednpm run testdirective. An agent invoking test execution withnpminadvertently generates a roguepackage-lock.json, desynchronizing the repository'spnpm-lock.yaml. - Test Framework and Mocking Divergence: Claude Code uses a modular skill in
.claude/skills/test.mdconfigured to generate Vitest test suites with in-memory SQLite mocks. Simultaneously, Cursor rules mandate Jest with Dockerized container fixtures. The resulting test files use conflicting assertion syntax and fail in CI. - Type System and Schema Wars: One instruction file requires strict runtime validation using Zod schemas with PascalCase interfaces, while an adjacent instruction file demands lightweight TypeScript
typealiases with manual type guards. The codebase begins accumulating redundant, incompatible typing layers across feature branches.
What Causes Instruction Collisions Between AGENTS.md, .cursorrules, and Claude Skills?
Instruction collisions occur when multiple AI coding agents parse overlapping instruction files without a shared coordination layer. Because Cursor parses .cursor/rules/*.mdc, Claude Code parses CLAUDE.md and ~/.claude/skills, OpenAI Codex evaluates AGENTS.md, and Google Antigravity inspects workspace guidelines, conflicting instructions are simultaneously loaded into agent context windows without deterministic conflict resolution.
According to the official Cursor Rules for AI documentation: "Project rules in .cursor/rules allow you to provide context that is specific to your project... Cursor will always prioritize project-specific rules over user-level instructions."
However, Cursor's parser evaluates only its own directory hierarchy; it does not check whether its directives contradict the guidelines laid out in CLAUDE.md or AGENTS.md.
Similarly, the Anthropic Claude Code documentation emphasizes that "CLAUDE.md is loaded automatically into Claude Code's context at the start of every session... providing shared project context that guides tool invocation and command generation across collaborators."
The core breakdown stems from three fundamental architectural discrepancies across runtime parsers:
- Eager Ingestion vs. Lazy Loading: Monolithic
.cursorrulesfiles and rootAGENTS.mddocuments are eagerly ingested at session initialization, burning between 2,000 and 8,000 tokens of static context on every prompt turn. In contrast, Claude Code skills use modularSKILL.mddefinitions that consume under 150 tokens of frontmatter context until specific intent triggers on-demand activation. When an eagerly loaded file contains outdated conventions, it persistently overrides the nuanced logic of lazy-loaded skills. - Scope Granularity Mismatches: Cursor supports path-specific glob matching (such as
globs: src/api/**/*.tsin.cursor/rules/api.mdc), whereas rootCLAUDE.mdapplies repository-wide blanket instructions. When a developer modifies an API route, Cursor executes scoped directives while Claude Code applies generic root directives, yielding diametrically opposed architectural outputs. - Competitor Blind Spots: No major AI coding assistant natively reads, reconciles, or respects the configuration formats of its competitors. An instruction written into
.cursor/rulesis completely invisible to an engineer operating in Claude Code, and a workflow automated via~/.claude/skillsdoes not exist for an engineer in Codex or Windsurf. If your team is experiencing duplicate instruction files across multiple microservices, see our guide on detecting and consolidating duplicate AI agent skills across repositories.
How Do Coding Agents Prioritize Conflicting Instructions? Cross-Runtime Resolution Matrix
Each coding agent evaluates instructions according to its own proprietary precedence hierarchy, which ignores the configuration files of competitor agents. Understanding the exact evaluation order within Claude Code, Cursor, Codex, and Google Antigravity is essential for structuring multi-agent repositories without rule collisions.
When multiple AI instruction files coexist in a single Git repository, each assistant resolves internal precedence using the following strict hierarchy:
| Agent Runtime | Priority 1 (Highest) | Priority 2 | Priority 3 | Global / Fallback Scope | Competitor File Parsing |
|---|---|---|---|---|---|
| Cursor (v0.42+) | Active chat prompt & attached file context | Glob-matched .cursor/rules/*.mdc | Always-on .cursor/rules/*.mdc | Legacy root .cursorrules & User Rules | Ignores CLAUDE.md & SKILL.md |
| Claude Code (v0.2.9+) | Inline user command / slash skill trigger | Local project .claude/skills/ | Repository root CLAUDE.md | Global user ~/.claude/skills/ | Ignores .cursor/rules & AGENTS.md |
| OpenAI Codex CLI | Direct terminal invocation arguments | Local repository AGENTS.md | Subdirectory AGENTS.md files | Global ~/.codex/config.toml | Ignores .cursorrules & CLAUDE.md |
| Google Antigravity | Active step instructions & tool overrides | Workspace AGENTS.md / Guidelines | Project skills in .gemini/skills/ | Global user ~/.gemini/antigravity/ | Can inherit root AGENTS.md |
| Windsurf Cascade | In-editor chat prompt & @-mentions | Root .windsurfrules | Directory-specific Cascade rules | Global Windsurf memories / settings | Ignores CLAUDE.md & .cursor/rules |
Notice the immediate architectural conflict: Cursor considers .cursor/rules/*.mdc authoritative, Claude Code considers CLAUDE.md authoritative, and Codex considers AGENTS.md authoritative. If these files are maintained independently by different team members, the repository has no single source of truth. For an in-depth architectural breakdown of format differences, see our comparison of Claude skills vs. Cursor rules.
The Sprawl Moment: The Silent Formatter Override That Blocked the Hotfix
It is 11:30 PM on a Friday when an on-call engineer pushes an urgent payment-gateway security patch. Engineer A authored the fix in Cursor, where .cursor/rules/api.mdc strictly mandated snake_case payload parameters and Vitest snapshot tests. Engineer B reviews and verifies the patch using Claude Code in terminal, where an older CLAUDE.md in the repository root has an un-synced rule enforcing camelCase and custom mock assertions. Running /review in Claude Code silently refactors the API schema to conform to CLAUDE.md, breaking the payment gateway's wire protocol and wiping out Engineer A's test assertions. The staging deployment fails CI, the release is blocked for two hours, and the engineering team is left arguing over which AI config file holds legal authority over the repository.
How Do You Detect and Debug Instruction Conflicts in a Shared Repository?
You can detect instruction collisions by implementing an automated repository linting script that parses all agent configuration files and flags contradictory directives. Comparing rule keys for package managers, linting targets, and code style schemas across CLAUDE.md, AGENTS.md, and .cursor/rules exposes precedence ambiguities before agents execute destructive edits.
To identify instruction drift across your codebases, add the following automated diagnostic script (audit-agent-precedence.py) to your repository tooling or CI pre-merge checks:
#!/usr/bin/env python3
"""
Audit multi-agent instruction files (CLAUDE.md, AGENTS.md, .cursor/rules)
for conflicting directives in package managers, testing frameworks, and linters.
"""
import sys
import re
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
# Files to inspect
INSTRUCTION_TARGETS = [
REPO_ROOT / "CLAUDE.md",
REPO_ROOT / "AGENTS.md",
REPO_ROOT / ".cursorrules",
*REPO_ROOT.glob(".cursor/rules/*.mdc"),
*REPO_ROOT.glob(".claude/skills/*/SKILL.md"),
]
def scan_file_for_patterns(path: Path) -> dict:
if not path.is_file():
return {}
content = path.read_text(encoding="utf-8", errors="ignore")
# Extract package managers
pms = set(re.findall(r'\b(pnpm|npm|yarn|bun)\b', content, re.IGNORECASE))
# Extract test runners
tests = set(re.findall(r'\b(vitest|jest|pytest|playwright)\b', content, re.IGNORECASE))
# Extract linters / formatters
linters = set(re.findall(r'\b(biome|eslint|prettier|ruff|black)\b', content, re.IGNORECASE))
return {
"file": str(path.relative_to(REPO_ROOT)),
"package_managers": {p.lower() for p in pms},
"test_runners": {t.lower() for t in tests},
"linters": {l.lower() for l in linters},
}
def audit_conflicts():
findings = [scan_file_for_patterns(p) for p in INSTRUCTION_TARGETS if p.is_file()]
all_pms = {pm for f in findings for pm in f["package_managers"]}
all_tests = {t for f in findings for t in f["test_runners"]}
conflicts_detected = False
print("=== Multi-Agent Instruction Precedence Audit ===")
if len(all_pms) > 1:
print(f"[!] CONFLICT: Multiple package managers detected across agent files: {all_pms}")
for f in findings:
if f["package_managers"]:
print(f" - {f['file']}: {f['package_managers']}")
conflicts_detected = True
if len(all_tests) > 1:
print(f"[!] CONFLICT: Divergent test runners detected across agent files: {all_tests}")
for f in findings:
if f["test_runners"]:
print(f" - {f['file']}: {f['test_runners']}")
conflicts_detected = True
if not conflicts_detected:
print("[✓] Clean: No conflicting package manager or test framework directives found.")
sys.exit(0)
else:
print("\nAction Required: Consolidate directives into a canonical root specification.")
sys.exit(1)
if __name__ == "__main__":
audit_conflicts()Running this script ensures that changes introduced by engineers using Cursor are validated against instructions ingested by Claude Code and Codex before code is pushed to production. If an individual tool's rules are being ignored entirely, refer to our diagnostic breakdown for fixing Cursor rules not working or learn how to sync AGENTS.md across Git worktrees.
Four Architectural Rules to Eliminate Instruction Conflicts Permanently
To resolve multi-agent instruction precedence permanently, teams must replace chaotic file sprawl with an intentional architectural hierarchy. Follow these four structural rules to eliminate collisions across all coding agents:
1. The Root Boundary Principle
Restrict repository root files (CLAUDE.md and AGENTS.md) strictly to immutable, objective project facts: supported runtime versions, exact package manager commands, build targets, and CI verification scripts. Never include personal editor preferences, prompt styling rules, or lengthy conversational guidelines in root files. Keeping root instruction files under 500 tokens prevents context bloat and eliminates ideological style conflicts.
2. Establish a Single Canonical Specification
Treat AGENTS.md as the canonical repository baseline. If your developers use Cursor or Claude Code, generate or symlink tool-specific configuration files (such as .cursor/rules/repo-baseline.mdc) directly from the canonical baseline. When package versions or test commands change, update the single source file so all dependent agent configurations update simultaneously without drift.
3. Decouple Procedural Logic into Modular Skills
Transition complex workflows—such as database migrations, API design rubrics, or PR reviews—out of static configuration files and into modular SKILL.md packages. Because skills load dynamically on invocation rather than permanently occupying model context, they never generate passive precedence conflicts with general repository guidelines.
4. Enforce Context Budget Ceilings
Cursor's legacy .cursorrules format has a soft degradation ceiling around 12,000 characters (approximately 3,000 tokens), beyond which the model begins dropping earlier instructions to accommodate new conversation turns. Enforce strict budget limits: root instructions should not exceed 100 lines, and individual scoped rules should stay under 80 lines to preserve working memory for agent reasoning.
How Does Prompttly Provide a Single Source of Truth for Agent Instructions?
Prompttly solves multi-agent instruction precedence by acting as a centralized, cloud-synced skill library that orchestrates rule deployment across all your AI coding tools. By synchronizing verified skills directly into native folders for Claude Code, Cursor, Codex, and Antigravity, Prompttly prevents configuration drift and eliminates contradictory repository rules.
Prompttly is a skill manager for AI agents — one library for your skills and prompts that syncs into Claude Code, Codex, ChatGPT, and Claude and is one hotkey away on your Mac, so your setup follows you across every machine, repo, and tool.
Instead of manually reconciling conflicting markdown files in every repository, Prompttly establishes a unified management layer across your entire development environment:
- Native Two-Way Filesystem Sync on Mac: Prompttly automatically writes your verified library into
~/.claude/skills/for Claude Code,~/.codex/skills/for Codex, and global rules for Cursor. Edits made in one tool sync across all runtimes instantly. - Sub-200ms Mac Hotkey Palette: Press a global keyboard shortcut to search your entire prompt and skill collection and insert verified instructions directly into Ghostty, Cursor, VS Code, or browser windows without clipboard thrashing.
- Universal MCP Connection: Connect any AI agent directly to Prompttly over the Model Context Protocol (MCP) to retrieve authoritative instructions on demand with zero static context waste.
- Version History and Rollbacks: Track every modification to your prompts, rules, and skills with centralized version control, ensuring rogue agent edits can be audited and reversed in one click.
When your team is ready to scale beyond messy local dotfiles and conflicting repository configs, explore our buyer's guide to the best AI prompt managers for teams or evaluate open-source approaches in our analysis of AI skill managers on GitHub.
Frequently Asked Questions About Multi-Agent Instruction Precedence
Does Cursor read CLAUDE.md or AGENTS.md automatically?
By default, Cursor does not parse CLAUDE.md or AGENTS.md during routine prompt compilation unless you explicitly configure a symlink, include the file in your context via an @-mention, or reference it from inside a .cursor/rules/*.mdc instruction file. Cursor prioritizes its native .cursor/rules/ directory and root .cursorrules file.
What happens when an inline skill command contradicts a repository root instruction?
When an inline skill command contradicts a repository root instruction, runtime behavior depends on the agent. Claude Code gives runtime prompt skills immediate tactical precedence over general CLAUDE.md instructions for that specific task. Cursor treats scoped .cursor/rules/*.mdc glob rules as higher priority than root guidelines, which can lead to silent regressions if glob rules omit repo-wide constraints.
How do you handle multi-agent instruction precedence in large monorepos with multiple subpackages?
In large monorepos, handle instruction precedence by restricting the root AGENTS.md or CLAUDE.md file to global repository policies (such as monorepo tooling, lockfile rules, and PR standards). Place package-specific guidelines inside subpackage directories using nested .cursor/rules or scoped SKILL.md packages to prevent frontend guidelines from contaminating backend service agents.
Why should engineering teams transition from monolithic .cursorrules files to modular SKILL.md packages?
Monolithic .cursorrules files inject between 2,000 and 8,000 tokens of static instructions into every single LLM context window regardless of task relevance, rapidly consuming model context and increasing inference latency. Modular SKILL.md packages use lightweight YAML frontmatter descriptions consuming under 150 tokens, allowing agents to load detailed execution logic only when specifically triggered.
Related Prompt Resources
Unify agent instruction precedence across every tool
Stop managing conflicting .cursorrules, AGENTS.md, and CLAUDE.md files by hand. Use Prompttly to maintain one synchronized instruction library across Claude Code, Cursor, Codex, and Antigravity.