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
- Claude Code:
@path/to/file.mdimports - Codex:
AGENTS.override.mdlayering; 32 KiB chain limit - OpenCode:
instructionsfield in opencode.json (globs + remote URLs)
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 withlsand 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.
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.
Security rules are mostly unenforced
Source: Do Not Is Not Deny Claude Md (Yan 2026, arXiv 2608.23550; 481 publicCLAUDE.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/askpattern 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.
Related
- 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
- Agent Harness
- AgentOps (boshu2)
- AGENTS.md (format)
- AI Code Review
- AI Coding Agents
- AI-Specific Code Pitfalls
- Claude Code → Cross-Platform Migration Matrix
- Compound Engineering
- Deep Modules
- Domain Glossary (CONTEXT.md)
- Indirect Prompt Injection
- Memory Bank Pattern
- Rules vs. Hooks
- Self-Improving Agent Setup
- Software Documentation