Lesson 4 of 5 · 4 min read
AGENTS.md and Agent Skills
In this lesson
TL;DR: An agent starts every task knowing nothing about your repository or your procedures. AGENTS.md fixes the first gap: a Markdown file at the root (and optionally in subdirectories) with build and test commands, conventions and things not to touch; the file nearest the code being edited takes precedence, and the user's explicit instructions override all of them. Agent Skills fix the second: each skill is a folder with a
SKILL.md, and only its name and short description sit in context until a task needs it, when the body loads, followed by any reference files or scripts it points to. Both are context the model reads. Neither grants a permission; what the agent may actually do is still decided by the harness.
After this lesson, you should be able to write a useful AGENTS.md and explain its precedence rules, structure a skill so it loads progressively, choose between a skill, an MCP server, a subagent and a hook for a given need, and keep instructions from being mistaken for controls.
Before you read
Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.
1A team pastes its full deployment runbook, coding standards and incident playbooks into the system prompt of its coding agent. Quality drops on ordinary tasks. Why, and what is the alternative?
AGENTS.md
Checked November 2026 against agents.md: AGENTS.md is described as a simple, open format for guiding coding agents, a README written for agents. It is plain Markdown with no required fields. The site lists many coding agents that read it, among them Codex, Jules, Cursor, Gemini CLI, the GitHub Copilot coding agent, Devin, Aider, goose and Windsurf, and it is now stewarded by the Agentic AI Foundation alongside MCP and A2A.
Precedence. Nested files are allowed. An agent reads the nearest AGENTS.md in the directory tree, so the closest file to the code being edited wins, and explicit instructions from the user override every file. A monorepo can keep shared rules at the root and package-specific commands next to each package.
What belongs in it.
| Put in AGENTS.md | Keep out of it |
|---|---|
| Exact commands to build, test, lint and format | Secrets, tokens, internal URLs that should not leave the repo |
| Conventions the code does not make obvious | Long design essays the agent rarely needs |
| Where things live; generated files not to edit | Rules you need enforced (say them, but enforce them elsewhere) |
| How to verify a change before calling it done | Procedures only some tasks need (make those skills) |
Keep it short and current. A stale command in AGENTS.md is worse than none, because the agent trusts it.
Agent Skills
Checked November 2026 against the specification at agentskills.io: a skill is a directory containing a SKILL.md, optionally with scripts/, references/ and assets/. The format was originally developed by Anthropic and released as an open standard.
SKILL.md starts with YAML frontmatter:
| Field | Rule |
|---|---|
name | Required. Up to 64 characters, lowercase letters, digits and hyphens, no leading, trailing or double hyphens, and it must match the folder name |
description | Required. 1 to 1,024 characters: what the skill does and when to use it |
license, compatibility, metadata | Optional |
allowed-tools | Optional and marked experimental: tools the skill expects to use |
Progressive disclosure is the point of the format:
- 1
1 · Metadata
at startup, every skill
- Name and description
- About 100 tokens each
activate - 2
2 · SKILL.md body
when a task activates it
- The procedure itself
- Recommended under 5,000 tokens, 500 lines
open - 3
3 · Files and scripts
only if the body points to them
- References read on demand
- Scripts run; only their output enters context
Here is the budget arithmetic and the frontmatter rules, as a harness would apply them:
import re
NAME = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$")
def validate(folder, meta):
errors = []
name = meta.get("name", "")
if not NAME.match(name) or len(name) > 64:
errors.append("name must be lowercase words joined by single hyphens, max 64")
if name != folder:
errors.append("name must match the folder")
if not 1 <= len(meta.get("description", "")) <= 1024:
errors.append("description must be 1 to 1024 characters")
return errors
skills = {
"release-notes": {"name": "release-notes", "description": "Draft release notes from merged PRs. Use when asked to prepare a release.", "body_tokens": 1800},
"db-migration": {"name": "db-migration", "description": "Write and verify a reversible schema migration. Use for any change to tables.", "body_tokens": 3200},
"Incident_Runbook": {"name": "Incident_Runbook", "description": "On-call steps.", "body_tokens": 4100},
}
for folder, meta in skills.items():
if validate(folder, meta):
print(folder, validate(folder, meta)[0])
startup = sum(100 for f, m in skills.items() if not validate(f, m))
all_bodies = sum(m["body_tokens"] for m in skills.values())
print(startup, all_bodies)
# => 200 9100
Two valid skills cost about 200 tokens at startup; loading every body up front would cost 9,100 on every task. The third skill is rejected before it ever reaches the model, because its name breaks the rules.
Skill, MCP server, subagent or hook?
| Need | Use | Why |
|---|---|---|
| A procedure the model should follow sometimes | Skill | Loads only when relevant; can bundle scripts |
| Access to a system the agent cannot otherwise reach | MCP server | Adds tools and data with their own authorization |
| Work that would flood the main context | Subagent | Separate context window and budget; returns a summary |
| A rule that must hold every time | Hook or permission | Runs in code at a fixed event, whatever the model decides |
| Facts about this repository | AGENTS.md | Always relevant to work in that tree |
The common mistake is putting a must-hold rule in AGENTS.md or a skill ("never push to main") and treating it as enforced. Write it there so the model plans around it, and enforce it with a permission or a pre-tool hook.
What can go wrong
- Skill bloat. Dozens of skills with vague descriptions compete for activation; the model loads the wrong one or none. Fewer skills with precise "use when" descriptions work better.
- Stale instructions. An AGENTS.md command that no longer works sends the agent down a failing path with confidence. Test the commands in CI.
- Untrusted skills. A skill from elsewhere can contain instructions and scripts. Review it like code before installing, and run its scripts with the same sandbox and permissions as any other command.
- Instructions as authority. Text the model reads is guidance. Permissions, sandboxes and hooks are controls.
Say it in 30 seconds
"AGENTS.md is a plain Markdown README for coding agents, now under the Agentic AI Foundation: build and test commands, conventions and boundaries, with nested files where the closest one to the edited code wins and the user's prompt overrides everything. Agent Skills are folders with a SKILL.md whose required name and description load at startup, about a hundred tokens each, while the body loads when a task activates it and bundled references and scripts load on demand. I use AGENTS.md for always-relevant repo facts, skills for occasional procedures, MCP for access to systems, subagents for work that would flood context, and hooks or permissions for anything that must hold, because none of these files grants authority."
Check yourself
Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.
1A monorepo has an AGENTS.md at the root and another in packages/billing. The agent edits packages/billing/refund.py. Which instructions apply, and what overrides both?
2What loads into context for a skill before any task uses it, and why does that make its description important?
3AGENTS.md says 'never run migrations against production'. Is that a control?