Auditing AGENTS.md & CLAUDE.md: Do Agent Context Files Match Real Code?

An empirical study of 3,602 repository context files (1,463 AGENTS.md, 1,307 CLAUDE.md, 780 Copilot, 52 GEMINI.md/.cursorrules) across 3,346 open-source projects (arXiv:2611.29916) tested 41,090 path claims and 184 dependency rules against real codebases. While 97.8% of file-path claims are accurate, 18% (33/184) of architectural dependency rules were already broken on the day they were written, and agent-assisted commits broke rules 1.8x more often than human commits.
Auditing AGENTS.md & CLAUDE.md: Do Agent Context Files Match Real Code?: An empirical study of 3,602 repository context files (1,463 AGENTS.md, 1,307 CLAUDE.md, 780 Copilot, 52 GEMINI.md/.cursorrules) across 3,346 open-source projects (arXiv:2611.29916) tested 41,090 path claims and 184 dependency rules against real codebases. While 97.8% of file-path claims are accurate, 18% (33/184) of architectural dependency rules were already broken on the day they were written, and agent-assisted commits broke rules 1.8x more often than human commits. 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.
- Empirical Context Hygiene: Understand where `AGENTS.md` and `CLAUDE.md` succeed (97.8% valid file paths) versus where they silently mislead agents.
- Eliminate Aspirational Rules: Detect dependency rules that were already violated by legacy imports on the day the Markdown file was committed.
- Prevent 1.8x Agent Erosion: Across 7,480 commits, agent-assisted patches violated stated rules at 0.29% vs 0.16% for human commits.
- Executable CI & Harness Gates: Convert natural-language boundary rules into deterministic TypeScript/ESLint/AST checks enforced inside Smoke Monkey.
import { createAgent } from '@smoke-monkey/harness';const contextAuditor = createAgent({agentId: 'agents-md-conformance-checker',provider: 'anthropic',model: 'claude-sonnet-4-5',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'ask',run_command: 'allow',},});async function auditContextClaims() {const result = await contextAuditor.run('Parse all path references and module import constraints in AGENTS.md and CLAUDE.md, verify every path exists on disk, and run dependency-cruiser to detect violated rules.');console.log('Conformance Audit:', result.summary);}auditContextClaims().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
What Does the Territory Study Reveal About AGENTS.md & CLAUDE.md?
Repository context files (AGENTS.md, CLAUDE.md, .github/copilot-instructions.md, GEMINI.md, .cursorrules) provide coding agents with architecture maps at session startup. Analyzing 3,602 context files across 3,346 projects (median 530 stars, 1,843 commits, 142 lines per context file), researchers checked 41,090 path claims and 184 structural dependency rules across commit history.
The core finding splits maps from rulebooks: developers keep path claims remarkably fresh—only 2.2% are genuine errors (outperforming READMEs at 3.5%), and 61% of stale paths are repaired when code moves, usually in the same commit. By contrast, 33 of 184 dependency rules (18%) were already broken on the day they were written, usually by pre-existing legacy code, and almost never repaired.
Empirical Breakdown: Path Claims, Dependency Rules & Commit Violations
Evaluating 7,480 historical commits (including 1,728 agent-traced commits across TypeScript, Python, Go, C#, Rust, and Java) quantifies how context drift behaves in active engineering teams.
| Audit Dimension | Sample Size | Key Finding | Operational Takeaway |
|---|---|---|---|
| Context File Distribution | 3,602 files / 3,346 repos | 1,463 AGENTS.md, 1,307 CLAUDE.md, 780 Copilot, 52 other | AGENTS.md is the leading cross-tool standard |
| Path Claims Accuracy | 41,090 path claims | ~5% missing, 2.2% real errors (vs 3.5% READMEs) | Context files are reliable codebase directory maps |
| Stale Path Remediation | Historical refactors | 61% fixed (most in same commit) | Devs update paths during refactors |
| Dependency Rules at Birth | 184 structural rules | 33 / 184 (18%) broken on day 1 | Markdown rules often encode wishful architecture |
| New Rule Breaks in Commits | 7,480 commits | Agent 0.29% vs Non-agent 0.16% (1.8x ratio) | Prose rules cannot replace AST import checks |
Never Encode Aspirational Architecture in AGENTS.md
When an agent reads an aspirational rule (e.g., 'UI never imports DB') alongside legacy code that violates it, the agent mirrors existing patterns in the code rather than obeying prose.
Automated Path & Import-Rule Verification in CI
Pair your AGENTS.md and CLAUDE.md files with an automated CI check that validates every backticked file path and enforces module import boundaries via dependency-cruiser or Python import-linter.
# 1. Verify backticked paths referenced in AGENTS.md / CLAUDE.md exist on disk
node -e '
const fs = require("fs");
for (const f of ["AGENTS.md", "CLAUDE.md"].filter(fs.existsSync)) {
const paths = [...fs.readFileSync(f, "utf8").matchAll(/`([a-zA-Z0-9_.-]+\/[a-zA-Z0-9_./-]+)`/g)].map(m => m[1]);
const missing = paths.filter(p => !p.includes("*") && !fs.existsSync(p));
if (missing.length) { console.error(f, "stale paths:", missing); process.exit(1); }
console.log(f, "verified paths:", paths.length);
}'
# 2. Enforce structural import boundaries deterministically instead of relying on prose
npx --yes dependency-cruiser --config .dependency-cruiser.cjs srcEnforcing Architectural Invariants in Smoke Monkey Harness
In Smoke Monkey Harness, repository context files serve strictly as navigation hints while invariant enforcement lives inside deterministic verification hooks (run_command running dependency-cruiser, tsc --noEmit, and unit tests before commit). That keeps AGENTS.md honest as a map and blocks the 1.8x architectural drift rate on agent-generated pull requests.
Frequently Asked Questions
Q:How accurate are file paths inside AGENTS.md and CLAUDE.md?
Across 41,090 path claims in 3,346 open-source repos, only 2.2% were real path errors—making agent context files more accurate than standard READMEs (3.5% error rate).
Q:Why do architectural dependency rules in context files fail so often?
Researchers confirmed 33 of 184 dependency rules (18%) were already violated by older code on the day the context file was written, reflecting desired architecture rather than actual code structure.
Q:Do AI coding agents break architectural rules more often than humans?
In an exploratory analysis of 7,480 commits, agent-assisted commits introduced new rule breaks 1.8x more often (0.29% vs 0.16%), though the absolute count (14 confirmed breaks) was small.
Q:How should I fix architectural drift in CLAUDE.md or AGENTS.md?
Keep file paths and build commands in `AGENTS.md`, audit legacy exceptions before writing boundary rules, and enforce import restrictions in CI using `dependency-cruiser` or `import-linter`.
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.