Skip to main content
Contradiction (2026-10-22): The “What to include” template below (project context, style and conventions sections) conflicts with the ETH Zurich “Evaluating AGENTS.md” study (arXiv:2602.11988, reported via Less Is More Claude Md). That study found that LLM-generated context files, which are mostly overviews of this kind, lowered task success ~2–3% and raised cost > 20%; developer-written files helped only ~4%. Prefer the minimal shape in Evidence: less is more. The template is kept for history.

Agent Context Instructions

A standards document given to an AI coding agent that encodes team conventions, project-specific rules, and quality expectations — so that generated code and reviews match team expectations without per-request guidance.

The problem it solves

Agents without context produce generic output: valid code, but mismatched conventions, wrong error handling patterns, wrong logging format, wrong security posture for the domain. Every PR then becomes a style negotiation rather than a design review.

Format

Typically a markdown file in the repository (e.g., .github/copilot-instructions.md, CLAUDE.md, AGENTS.md). Structure that works well:
  • Distinct section headings
  • Bullet points
  • Short, direct instructions (not prose)
  • Examples of correct patterns where conventions are non-obvious

What to include

Effect

  • Automated reviews become project-specific, not generic
  • Generated code requires fewer revision cycles
  • New team members absorb standards through agent suggestions
  • Code reviews shift from style to architecture and correctness

Key insight

Context instructions are a one-time investment that compounds: every subsequent generation and review benefits. Low-quality instructions are worse than none — they produce false confidence. Keep them short and specific.

The AGENTS.md Ecosystem

AGENTS.md is the dominant cross-provider format — 60k+ open-source projects, stewarded by the Agentic AI Foundation (Linux Foundation). It standardizes what was previously per-tool config (.cursorrules, .clinerules, copilot-instructions.md, CLAUDE.md). Tool support status (2026-05):
  • Codex, OpenCode, Amp, Jules: native AGENTS.md
  • Claude Code: CLAUDE.md (does not read AGENTS.md)
  • Cursor: .cursorrules (plans AGENTS.md support)
  • Aider, Gemini CLI: via config file
Nested files for monorepos: Place AGENTS.md in subdirectories. Closest file to the edited file wins. User prompts override everything. Note: conflict resolution between nested files relies on agent compliance, not enforcement. Per-tool multi-file composition:
  • Claude Code: @path/to/file.md imports
  • Codex: AGENTS.override.md layering; 32 KiB chain limit
  • OpenCode: instructions field in opencode.json (globs + remote URLs)
For limitations of the single-file approach and when hooks are better, see Rules vs. Hooks.

Evidence: less is more

Source: Less Is More Claude Md (blog summary of Gloaguen et al. 2026, 138 issues, 12 repos, 4 agent/model setups; numbers secondary until the paper is ingested).
  • Auto-generated (/init-style) files: ~2–3% lower success, > 20% higher inference cost. Almost all contained a codebase overview the agent could find with ls and the README.
  • Developer-written files: ~+4% success, still more cost and more steps.
  • Context files did not help agents find relevant files faster. Agents followed the extra instructions (more tests, more greps) without solving more tasks.
Shape that follows: a short hand-written file (about 30 lines) with commands, non-obvious rules only, and links to on-demand docs, especially a 2–4 page system-design doc recording decisions, rejected alternatives, component boundaries and known traps. Leave out anything discoverable from the repo: stack, directory tree, style, endpoints, general best practice. Learnings about one area belong in that directory’s instruction file, which loads only when the agent works there.

Protocol vs judgment

Source: Steer Not Script Agent Instructions (opinion, no data). Sort each instruction into one of two kinds:
  • Protocol (output format, phase order, integration contracts, safety gates) should be exact and non-negotiable. Safety gates are better as hooks than prose.
  • Judgment (which pattern, how to handle an error, naming, refactor vs patch) should be principles, end-state quality criteria (“all code passes the lint config”, not “run the linter”), and anti-patterns. Do not name tools or paths for judgment calls; the agent discovers them.
Common failure: scripting judgment (“use library X”) while leaving protocol vague (“format nicely”).

Security rules are mostly unenforced

Source: Do Not Is Not Deny Claude Md (Yan 2026, arXiv 2608.23550; 481 public CLAUDE.md files, LLM classifier validated against two blind human annotators). A security rule in a context file is prose the model interprets; it is not a control. Of 870 retrieved security rules, only about 4-16% had a documented Claude Code control (permission deny/ask/allow, permission mode, filesystem or network sandbox, managed settings) that could enforce the whole rule without added code; 4.4% (95% CI 2.6-6.7%) under the strict, human-adjudicated standard. Rules fail to match when they depend on a condition (“only when releasing”), on content (“never commit secrets”), on meaning or system state, or on data flow. Rule wording (“never”, “do not”, “must”) does not reveal which rules are enforceable, and the file gives no feedback either way: the paper calls it a write-only channel. Practical consequence:
  • For each security rule, ask whether a permissions.deny/ask pattern or sandbox setting can express the full rule. If yes, put it there (see Claude Code Permissions Settings); keeping the prose line too is fine, but the setting is what enforces it.
  • If it needs code (a content or state check), it belongs in a hook, scanner or CI check (Rules vs. Hooks). The paper’s unvalidated classifier split puts about half of all security rules in this bucket.
  • Whatever remains is model-mediated. Treat it as advice, not protection.
Scope: the paper measures whether a matching control exists in Claude Code’s docs, not whether repositories configured one, and its corpus skews to new, low-star projects.
  • AI Coding Agents — the agents that consume these instructions
  • AI Code Review — review quality improves directly with instruction quality
  • AGENTS.md (format) — the cross-provider format
  • Rules vs. Hooks — static files vs. dynamic hooks for context injection
  • Memory Bank Pattern — structured filesystem hierarchy for large-project context
  • Self-Improving Agent Setup — keeping the instruction file small while it learns from corrections
  • Do Not Is Not Deny Claude Md — measured gap between prose security rules and built-in controls

Linked pages