agents-md

A guide to AGENTS.md, a file that gives coding agents project-specific instructions. It explains how agents discover these files from global settings down through the project folders, with deeper rules taking priority.

In plain words
What is it for?
Use it when creating, reviewing, or troubleshooting AGENTS.md and AGENTS.override.md files, their discovery order, scope, and precedence.
Why use it?
It clarifies which instructions apply in a repository and how to structure them without exceeding the combined file-size limit.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/agents-md
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 742 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00742
Opus 5 $0.00000 $0.00371
Sonnet 5 $0.00000 $0.00148
Haiku 4.5 $0.00000 $0.00074

Measured yesterday against content hash 440e1c945262, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agents-md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/ai-tools/agents-md.mdc · 45 lines

How it starts

The opening of the file, as written. The whole thing — 45 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AGENTS.md Rules

AGENTS.md is the instruction file for OpenAI Codex (and increasingly, other tools like GitHub Copilot coding agent, Zed, and OpenCode). It's loaded once per session before any work begins.

Discovery Chain

  • Global: ~/.codex/AGENTS.md (or AGENTS.override.md if it exists — override takes priority, only one file at this level)
  • Project: Starting from the Git root, Codex walks down to your current working directory, checking each directory for AGENTS.override.md then AGENTS.md. At most one file per directory
  • Merge order: Files concatenate root-to-leaf, separated by blank lines. Later files override earlier guidance because they appear last in the combined prompt
  • Size limit: 32 KiB combined by default (project_doc_max_bytes config). If you hit it, split instructions into subdirectory files

What Goes In AGENTS.md

  • Working agreements: "Always run npm test after modifying JavaScript files," "Prefer pnpm when installing dependencies"
  • Verification commands: How to build, test, lint, typecheck. Codex runs these to validate its own changes
  • Repo conventions: naming patterns, directory structure expectations, PR requirements
  • Tool preferences: which package manager, which test runner, which formatter — Codex won't guess correctly without this

Override Files

  • AGENTS.override.md in any directory replaces AGENTS.md at that same level — useful for temporary overrides without editing the base file
  • Common use: a services/payments/AGENTS.override.md that says "use make test-payments instead of npm test" for that specific service
  • Delete the override to restore the base instructions

Patterns That Work

  • Keep global (~/.codex/AGENTS.md) minimal — personal preferences that apply everywhere (coding style, preferred tools, commit message format)
  • Project root AGENTS.md handles repo-wide setup: build commands, CI expectations, PR conventions
  • Subdirectory overrides for teams/services with different tooling or constraints
  • Commands first, conventions second — Codex needs to know how to verify its work before anything else

Read the full file on GitHub · 45 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 45 lines · 0 tokens per session scan A 440e1c945262

Subscribe to this mod's changes

agents-md is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 742 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.