1. Home
  2. Library
  3. AI Tooling Crash Course for Developers
  4. Topics
  5. Base Instruction Files

Stage 1 — Base Instruction Files (AGENTS.md / CLAUDE.md)

A base instruction file is a short file an AI coding tool reads automatically, before doing any work on a project. It stops the agent guessing your conventions or getting told the same things every session.

Relevant if you use one of these tools and want it to stop making wrong assumptions. Skip if you've never set one up.

Deep-dive on baseline topic #1, split out from topic #10 per the 2026-08-23 correction in topic-index.md. This doc covers the file itself: what goes in it, root-vs-nested precedence, provider loading mechanics. Cross-project memory/ledgers are a separate question — see memory-and-progress-ledgers.md.

Framing constraint (per topic-index.md's 2026-08-23 correction): AGENTS.md is the primary, provider-agnostic source of truth here — not CLAUDE.md. Provider files are researched as thin pointers to it. No pick is made in this doc, options and evidence only.

What is a base instruction file?

A plain Markdown file, checked into a repo (or a user config folder), that a coding agent reads before it starts — no prompt required.

AGENTS.mdthe one source of truthCLAUDE.mdthin wrapper: "see AGENTS.md"copilot-instructions.mdthin wrapperCodex CLI, Cursor, othersClaude CodeCopilotkeep it short: pointers, not proseCLAUDE.mdthin wrapper: "see AGENTS.md"copilot-instructions.mdthin wrapperpoint toAGENTS.mdthe one source of truthread byEvery tool ends up reading itCodex CLI, Cursor, othersClaude CodeCopilotkeep it short: pointers, not prose
Write the rules once. Provider files only point at them.

Two names that matter:

  • AGENTS.md — provider-agnostic, read by 30+ tools.
  • CLAUDE.md — Claude Code's own name for the same idea.

Cursor, Copilot, Gemini CLI, and most other agents have their own equivalents (table below).

Why it exists. An agent starting cold on a repo has no idea how you build, test, deploy, or what conventions you follow. It has to guess or ask, every session. This file is a standing answer to "how does this project work," loaded once per session instead of re-explained every time. Same problem a README solves for humans — different reader, different needs: executable commands over prose, explicit boundaries over onboarding narrative.

What belongs in it:

  • Build/test/lint commands, with real flags — not "run the tests."
  • Code-style conventions the agent should match.
  • Where things live in the repo.
  • What's off-limits (files not to touch, patterns not to introduce).
  • Project-specific gotchas the agent would otherwise trip over.

What doesn't: general product docs, architecture explainers for new hires, anything a human reads but an agent never acts on. That's a README or docs/ARCHITECTURE.md's job.

Global vs. repo-local. Most agents support two scopes:

  • A repo file (checked into git, shared with everyone who clones it).
  • A personal config file (~/.claude/CLAUDE.md, ~/.codex/AGENTS.md) — applies across every project, never shared.

Global holds your personal habits. Repo-local holds what's true about this codebase regardless of who's working on it.

Root vs. nested. A single root file covers the whole repo. Some agents also support one file per subdirectory (frontend/AGENTS.md alongside backend/AGENTS.md), loaded only when the agent works in that subtree — so a monorepo doesn't force every session to load rules for parts it isn't touching. Support varies by tool (§2).

Provider-agnostic vs. provider-specific. AGENTS.md works unmodified across any agent that reads it. CLAUDE.md and other vendor-named files are read only by their own tool. Common pattern: write one AGENTS.md, have provider files import or symlink to it — no duplicate instructions to maintain.

Why bother: less time re-explaining project context every session, more consistent output (agent matches your conventions instead of generic defaults), and a place to encode hard constraints ("never touch migrations/") that would otherwise only live in your head.

1. Governance, and the "60,000 repositories" claim

AGENTS.md is a real, governed convention. Released by OpenAI in August 2025, it's now one of three anchor project contributions to the Agentic AI Foundation (AAIF) — alongside MCP (Anthropic) and goose (Block). Announced by the Linux Foundation on 2025-12-09, confirmed against agents.md itself: "now stewarded by the Agentic AI Foundation under the Linux Foundation." Founding Platinum members: AWS, Anthropic, Block, Bloomberg, Cloudflare, Google, Microsoft, OpenAI.

"60,000+ repositories"AGENTS.md adoption claimself-reported by the projectno independent count60.03% file-level adoptionamong newly created GitHub projectsarXiv:2606.07448measures something elsetreat as marketinga different metric≠"60,000+ repositories"AGENTS.md adoption claimself-reported by the projectno independent counttreat as marketing≠60.03% file-level adoptionamong newly created GitHub projectsarXiv:2606.07448measures something elsea different metric
Do not conflate the two numbers.

The spec is thin by design. The canonical repo, agentsmd/agents.md, states plainly: "AGENTS.md is just standard Markdown. Use any headings you like." No mandatory fields, no schema.

The "60,000+ repositories" adoption figure (repeated in the Linux Foundation release and on agents.md itself) traces to a single origin: the project's own self-reporting. No independent third party reproduces the count, and it's a December 2025 figure still being carried forward as current. Treat it as a marketing data point, not a verified metric.

A different, unrelated number — 60.03% file-level agent-adoption among newly created GitHub projects, from arXiv:2606.07448 — measures something else entirely. Don't conflate the two.

2. Per-provider loading mechanics

Confirmed against official docs where available. "Not documented" means the vendor's own docs don't state it — not that the answer is unknown.

Reads AGENTS.md nativelyCursorCopilotCopilot CLICodex CLIopencodeZedAmpWindsurfClineJulesNeeds a bridgeClaude Code@AGENTS.md import or symlinkGemini CLIcontext.fileName configNo discovery at allAiderexplicit --read onlyprecedence rules are mostly unpublished: only Codex, opencode, Zed, Amp and Cursor state oneReads AGENTS.md nativelyCursorCopilotCopilot CLICodex CLIopencodeZedAmpWindsurfClineJulesNeeds a bridgeClaude Code@AGENTS.md import or symlinkGemini CLIcontext.fileName configNo discovery at allAiderexplicit --read onlyprecedence rules are mostly unpublished: onlyCodex, opencode, Zed, Amp and Cursor state one
Compatibility at a glance. The vendor lists overstate it (Aider is listed but does not read it).
Tool Reads AGENTS.md natively? Nested discovery Documented precedence Global/user file
Claude Code No — reads CLAUDE.md; bridged via @AGENTS.md import or symlink Yes, ancestors at launch + subdirs lazily Concatenated, root→cwd ~/.claude/CLAUDE.md
Cursor Yes, root + nested Yes, nested overrides parent on conflict Team → Project → User Rules, merged UI-based User Rules
GitHub Copilot (IDE/coding agent) Yes, incl. nested Yes Not documented Web/CLI/JetBrains only
Copilot CLI Yes Yes Explicitly none — "does not define a general precedence order" $HOME/.copilot/
Gemini CLI No, needs context.fileName config Yes Concatenated ~/.gemini/GEMINI.md
OpenAI Codex CLI Yes (originator) Yes, root→cwd, one file per dir Nearer file overrides — concatenated in order ~/.codex/AGENTS.md, AGENTS.override.md checked first
opencode Yes, preferred over CLAUDE.md Yes, walks up from cwd Nearest AGENTS.md → global → CLAUDE.md fallback ~/.config/opencode/AGENTS.md
Zed Yes, but ranked below 5 other filenames in a 9-entry list No — top-level of worktree only First match in ordered list wins Rules Library (app-level)
Amp Yes Yes — most thorough: ancestors always, subtree on file access Per-directory fallback chain $HOME/.config/amp/AGENTS.md
Windsurf/Cascade (Devin Desktop) Yes Yes, auto-scoped per directory Not documented Not documented
Cline Yes (merged via a long-stalled PR) Workspace + global combined Workspace wins on conflict ~/Documents/Cline/Rules
Aider No — no auto-discovery of any kind n/a n/a Explicit --read/config only
Google Jules Yes Root only n/a Not documented

Two flags:

  • agents.md's own "supported tools" list includes Aider, whose own docs contradict it. Treat that list as a self-claim, not a compatibility matrix.
  • Precedence is mostly unpublished — only Codex, opencode, Zed, Amp, and Cursor state a resolution order. Copilot CLI explicitly disclaims having one.

Provider docs checked: Claude Code memory, Cursor rules, GitHub Copilot docs, Gemini CLI, opencode rules, Zed AI rules, Amp manual, Devin/Cascade AGENTS.md docs, Cline rules, Aider conventions, Google Jules docs.

3. What actually belongs in the file — official guidance vs. the empirical record

Anthropic's own docs give a concrete target: "under 200 lines per CLAUDE.md file... longer files consume more context and reduce adherence." No measurement is published behind that guidance.

Having a file at allcompliance 0% -> 67.7%File length (25-500 lines)no detectable effectContext files vs success-2% to +4%, cost up 19-23%Session lengthadherence decays within a sessionso: invest in hooks and short sessions, not in trimming the fileHaving a file at allcompliance 0% -> 67.7%File length (25-500 lines)no detectable effectContext files vs success-2% to +4%, cost up 19-23%Session lengthadherence decays within a sessionso: invest in hooks and short sessions, not intrimming the file
What the controlled studies actually found. Single-study magnitudes.

The only controlled tests of this specific claim contradict it. Three independent studies, checked directly:

  • ETH Zurich SRI Lab (arXiv:2602.11988, Gloaguen/Mündler/Müller/Raychev/Vechev) — SWE-bench Lite + a 138-issue benchmark, 4 agents including Claude Code and Codex. Context files did not generally improve task success (−0.5% to −2% for LLM-generated files, +4% for developer-written ones) and increased inference cost 19–23% regardless. Repository overviews specifically — "despite being popular and recommended" — proved unhelpful.
  • Damon McMillan (arXiv:2605.10039, solo author, weaker provenance) — factorial study across 1,650 real Claude Code sessions, varying file length 25–500 lines, rule position, structure. No detectable contrast on compliance after correction for multiple testing. The one real effect: within-session decay — roughly 5.6% lower compliance odds per additional function generated, regardless of file design.
  • Prakhar Khatri (arXiv:2607.27250, independent researcher, weakest provenance) — 288 runs, no significant effect on correctness from having a context file at all. Near-miss failures traced to implementation skill, not missing repo knowledge.

Honest synthesis: having a file at all matters — compliance went from 0% to 67.7% with vs. without one, per McMillan. Its length and internal structure are not shown to matter. If anything decays adherence, it's session length, not file length — a stronger argument for hooks (deterministic enforcement) than for editing file structure.

Descriptively, GitHub's own analysis of 2,500+ repositories (Matt Nigh, GitHub Blog, 2025-11-19) found effective files converge on executable commands with flags, testing practices, real code-style examples over prose — "one real code snippet showing your style beats three paragraphs describing it." No length prescription given.

Compaction, answered directly by the docs: root-level CLAUDE.md survives /compact — Claude re-reads it from disk and re-injects it. Nested files and paths:-scoped rules reload only when Claude reads files they apply to, so they decay under compaction until re-triggered. Argument for keeping load-bearing rules at root.

4. Nested files and the local-override pattern

Nested AGENTS.md (root for global rules, per-subtree files only where a subtree genuinely differs) is a named, repeatable practice — confirmed via Maximiliano Contieri (O'Reilly author) and Simon Boudrias (Datadog).

Working in frontend/~/.claude/CLAUDE.md (personal)repo/AGENTS.md (root: always loaded)repo/frontend/AGENTS.md (subtree)repo/backend/AGENTS.mdnot loaded: wrong subtreeAgent contextconcatenated, root to cwdLocal overrideCLAUDE.local.md (Claude Code)AGENTS.override.md (Codex)Root router filedispatches to nested filesby task type (Boudrias)Working in frontend/~/.claude/CLAUDE.md (personal)repo/AGENTS.md (root: always loaded)repo/frontend/AGENTS.md (subtree)repo/backend/AGENTS.mdnot loaded: wrong subtreeAgent contextconcatenated, root to cwdLocal overrideCLAUDE.local.md (Claude Code)AGENTS.override.md (Codex)Root router filedispatches to nested files by task type(Boudrias)
Global, root, then the subtree you are in.

Boudrias adds a counter-argument: proximity-based discovery only works if the agent is already working from that subfolder, or is told to @-reference it. His fix: a root-level router file that explicitly dispatches to nested files by task type, not nesting alone.

The local-override filename is AGENTS.local.md, not AGENTS.md.local. Mostly convention, not tooling — Contieri himself hedges "support varies by tool; check your documentation."

What's actually native:

  • Claude Code's CLAUDE.local.md — documented, gitignore-friendly. Real gotcha: it only exists in the worktree it was created in; use an @~/.claude/... import to share across worktrees.
  • Codex CLI's AGENTS.override.md — checked before AGENTS.md at both global and per-directory scope.
  • opencode explicitly declined this (issue #16110, closed "not planned"). Everywhere else, a file by that name is simply not read.

5. ADRs as agent context — folklore, not yet a spec

Both sources cited for a 2026 "agent-optimized ADR" trend check out as real — BrainGrid and Actual AI — but both are vendor content marketing, not independent research. No quantitative validation in either.

AGENTS.md / CLAUDE.mdStanding conventionLoaded every session"How we work here"An ADRPoint-in-time record of one decisionCarries the whyStops an agent refactoring the reason awayEvidence statusBrainGrid and Actual AI: vendor content marketing, noquantitative validationadr.github.io has no agent contentClosest "standard"AgDR records decisions made BY an agent, not fed TO oneLow stars, effectively solo-maintainedBottom line: no canonical agent-optimized ADR format yet. Know the idea, do not adopt a templateAGENTS.md / CLAUDE.mdStanding conventionLoaded every session"How we work here"An ADRPoint-in-time record of one decisionCarries the whyStops an agent refactoring the reason awayEvidence statusBrainGrid and Actual AI: vendor contentmarketing, no quantitative validationadr.github.io has no agent contentClosest "standard"AgDR records decisions made BY an agent, notfed TO oneLow stars, effectively solo-maintainedBottom line: no canonical agent-optimized ADRformat yet. Know the idea, do not adopt atemplate
The mechanism is plausible and untested.

The mechanism-level argument (an agent blind to why a decision was made will confidently refactor the reason away) is plausible and untested. adr.github.io itself has no agent-related content as of this pass.

The one attempt at a real standard, me2resh/agent-decision-record ("AgDR"), records decisions made by an agent, not decisions fed to one — a different problem. Low star count, effectively solo-maintained.

Bottom line: no canonical agent-optimized ADR format yet. Worth knowing the idea, not worth adopting a specific template.

6. Drift, linting, and generation tooling — traction flagged bluntly

  • agent-sh/agnix — a real linter/LSP (400+ self-claimed rules across 9 tools) with editor plugins and a GitHub Action. The only tool in this category with anything resembling a real project around it.
  • One-person / near-zero traction, worth knowing but not depending on:
    agent-sh/agnix: the only real projectLinter and LSP, 400+ self-claimed rules across 9 tools, editor plugins and a GitHub ActionOne-person or near-zero traction: worth knowing, not depending onclaude-code-auto-memoryauto-maintains CLAUDE.md;healthiest of the smallones, solo, pre-1.0Archienear-zero forks, lowadoptionagents-lintchecks the file stillmatches the codebase; rightidea, no adoptioncclintonly one with a sizebudget: ~10KB warningCI check patternFail the build if CLAUDE.md is not a symlink or one-line@AGENTS.md importDemand signalclaude-code#6235: open since 2025-08-21, 5,000+ reactions,largest request on the trackeragent-sh/agnix: the only real projectLinter and LSP, 400+ self-claimed rulesacross 9 tools, editor plugins and a GitHubActionOne-person or near-zero traction: worthknowing, not depending onclaude-code-auto-memoryauto-maintains CLAUDE.md; healthiest of thesmall ones, solo, pre-1.0Archienear-zero forks, low adoptionagents-lintchecks the file still matches the codebase;right idea, no adoptioncclintonly one with a size budget: ~10KB warningCI check patternFail the build if CLAUDE.md is not a symlinkor one-line @AGENTS.md importDemand signalclaude-code#6235: open since 2025-08-21,5,000+ reactions, largest request on thetracker
    Traction flagged bluntly.
  • The CI check pattern (fail the build if CLAUDE.md isn't a symlink or a one-line @AGENTS.md import) is real and matches Anthropic's own suggested pattern. Windows needs Administrator/Developer Mode for symlinks, so the @AGENTS.md import is the portable version.
  • Demand for native AGENTS.md support in Claude Code is real: anthropics/claude-code#6235, open since 2025-08-21 with 5,000+ reactions — the largest open feature request on the tracker. Secondary reporting says Anthropic indicated in May 2026 that native support is "not planned for now"; no primary Anthropic statement confirms this directly.

Workaround: a symlink or @AGENTS.md import (§4, above).

7. Anti-patterns and failure modes

The strongest-sourced risk in this doc: a cloned repo's own AGENTS.md is a live prompt-injection vector, not a theoretical one.

Malicious dependencydetects it runs in an agentWrites AGENTS.mdclaims "absolute authority"Agent obeys itover the user's own rulesCredentials leaveAWS, npm, git tokensseen: Codex CLI exec mode followed attacker-controlled AGENTS.md silentlydon't auto-trust a cloned repo's instruction fileMalicious dependencydetects it runs in an agentWrites AGENTS.mdclaims "absolute authority"Agent obeys itover the user's own rulesCredentials leaveAWS, npm, git tokensseen: Codex CLI exec mode followedattacker-controlled AGENTS.md silentlydon't auto-trust a cloned repo'sinstruction file
A live prompt-injection vector, demonstrated by NVIDIA and Backslash.

NVIDIA's AI Red Team (Daniel Teixeira, 2026-04-20) demonstrated a real chain: a malicious dependency detects it's running inside an agent's environment, writes an AGENTS.md claiming "absolute authority" that supersedes the user's own instructions — and instructs the agent's own PR-summarization step to hide the change from reviewers.

Backslash Security (2026-07-06) found OpenAI Codex CLI's non-interactive exec mode would silently follow attacker-controlled AGENTS.md instructions to exfiltrate AWS/npm/git credentials. OpenAI shipped a partial model-level fix; the underlying claim — safety gating is mode-dependent, not invariant — stands unaddressed.

Practical read: don't auto-trust a cloned repo's instruction file the way you'd trust your own.

Other named failure modes:

  • Anthropic's own docs admit contradictory rules get resolved arbitrarily, and ship a claudeMdExcludes setting because monorepo ancestor files from other teams pollute context by default.
  • Clay Tercek's critique, "AGENTS.md Is Not a README" adds two sharp points: committing an instruction file imposes one person's workflow on a whole team, and personal local files don't track your git branch, so they go stale by construction.
  • A widely-reported (but not independently primary-sourced here) 2026 incident — Apple shipping internal CLAUDE.md files inside a consumer app — worth logging as a category example (committed instruction files leaking internal context), even unconfirmed.

8. Practical read for this setup

Consistent with topic-index.md's framing constraint: research and write any future instruction-file work provider-agnostically — AGENTS.md first, CLAUDE.md/others as thin @-imports, not the reverse.

Order of authorshipAGENTS.md first; CLAUDE.md and others as thin @-imports, not the reverseThe empirical record says: do not spend effort trimming file lengthKeep root content load-bearingIt survives compaction; nestedcontent does not until re-triggeredDo not blanket-trust a clonedrepo fileSee section 7Compensate for decay withhooksWithin-session decay is the problem,not the fileOrder of authorshipAGENTS.md first; CLAUDE.md and others asthin @-imports, not the reverseThe empirical record says: do not spendeffort trimming file lengthKeep root content load-bearingIt survives compaction; nested content doesnot until re-triggeredDo not blanket-trust a cloned repofileSee section 7Compensate for decay with hooksWithin-session decay is the problem, not thefile
Three moves that follow from the evidence.

The empirical record (§3) argues against spending effort trimming file length, and toward:

  • Keep root-level content load-bearing — it survives compaction, nested content doesn't until re-triggered.
  • Don't blanket-trust a cloned repo's own instruction file (§7).
  • Treat within-session decay as the thing hooks should compensate for, not file editing.

Once ~/.claude/CLAUDE.md is revisited per _architecture/BACKLOG.md's flagged item (unreviewed merge of an old personal version and an AI-suggested rewrite), this doc's §2–4 is the reference to check it against.

Sources

Linux Foundation press release (2025-12-09, AAIF formation); agents.md; aaif.io/projects/agents-md; github.com/agentsmd/agents.md; arXiv 2606.07448; official docs — code.claude.com/docs/en/memory, code.claude.com/docs/en/hooks, Cursor (cursor.com/docs/context/rules), GitHub Copilot (docs.github.com/copilot), Gemini CLI (github.com/google-gemini/gemini-cli), OpenAI Codex CLI docs, opencode.ai/docs/rules, zed.dev/docs/ai/rules, ampcode.com/manual, docs.devin.ai/desktop/cascade/agents-md, docs.cline.bot/customization/cline-rules, aider.chat/docs/usage/conventions.html, jules.google/docs; arXiv 2602.11988 (ETH Zurich), 2605.10039 (McMillan), 2607.27250 (Khatri), 2509.14744 (PROFES 2025, note: numbers cited elsewhere for this paper did not match on direct fetch); GitHub Blog, Matt Nigh, "How to write a great agents.md" (2025-11-19); Maximiliano Contieri, "Use Nested AGENTS.md Files"; Simon Boudrias, DEV.to (Datadog); BrainGrid and Actual AI on agent-optimized ADRs; adr.github.io; github.com/me2resh/agent-decision-record; github.com/agent-sh/agnix; github.com/severity1/claude-code-auto-memory; github.com/BitRaptors/Archie; github.com/giacomo/agents-lint; github.com/felixgeelhaar/cclint; anthropics/claude-code#6235; NVIDIA AI Red Team, Daniel Teixeira (2026-04-20); Backslash Security, Amit Waizman (2026-07-06); Clay Tercek, "AGENTS.md Is Not a README" (2026-05-27).

4 / 19