Blog
AGENTS.md File Guide: How to Structure Instructions for AI Agents
If you want the short answer, an AGENTS.md file should tell an AI agent how to work in a specific environment, what rules matter most, what tools to prefer, and what good output looks like.
That is why it matters.
A lot of teams know they need instructions for their agents, but their files end up bloated, vague, or inconsistent. Then they wonder why the agent keeps missing obvious rules.
Usually the problem is not that the agent refused to listen. The problem is that the instruction file did not make the operating model clear enough.
This guide explains what an AGENTS.md file should do, what to include, what to leave out, and how to structure it so the agent becomes easier to manage over time.
What is an AGENTS.md file?
An AGENTS.md file is a workspace instruction file that tells an AI agent how to behave in a given project or operating environment.
Depending on the system, it can include:
- role and scope
- tool preferences
- safety boundaries
- file conventions
- escalation rules
- output standards
- coordination instructions with other agents or people
The file is not there to sound impressive. It is there to make the agent more reliable.
Why AGENTS.md matters
Most agents do better when the environment is explicit.
If the agent knows the role it is playing, which tools to favor, how to talk to the user, what standards define a good result, and when to stop and ask, the output gets steadier.
That is the real benefit.
An AGENTS.md file reduces ambiguity.
What to include in an AGENTS.md file
Identity and role
What is this agent for? A coding helper, a research assistant, an operator, a marketer, or something more specialized?
Operating rules
What should the agent do by default? What should it avoid? What requires approval?
Tool guidance
If certain tools are preferred, say so. If certain tools are risky or restricted, say that too.
Output standards
What makes the work good enough to ship? This is where quality bars, formatting preferences, and verification steps become very useful.
Coordination rules
If the agent needs to hand off to a teammate, another agent, or a human owner, the file should explain when and how.
What not to put in AGENTS.md
Not everything belongs there.
Avoid stuffing the file with:
- long archives of old decisions
- temporary one-off instructions
- raw transcripts
- overly generic advice
- duplicated rules that already live somewhere more appropriate
If everything goes into the file, the important parts lose weight.
What a good AGENTS.md file feels like
A good file is specific enough to shape behavior and short enough that the important rules stay visible.
It should answer questions like:
- who am I in this environment?
- what work am I responsible for?
- what tools should I use first?
- what quality bar must I hit?
- when should I ask for help or approval?
That clarity is what makes the file useful.
AGENTS.md and OpenClaw
OpenClaw is one of the clearest environments for understanding why instruction files matter, because the platform combines sessions, workspace files, skills, and agent-specific behavior in one runtime.
The skills docs also show that workspace-level resources can override broader shared ones through precedence rules. That same general lesson applies to instruction design: local, relevant guidance usually beats broad, generic guidance.
The getting started docs reinforce the broader point that OpenClaw is designed around an operating environment, not just single prompts. You install it, onboard it, verify the gateway, open the dashboard, and then work inside a durable system. That makes explicit agent instructions even more important.
A practical AGENTS.md structure
Here is a simple structure that works well.
1. role
Define the agent identity and scope.
2. defaults
Explain how it should work when no special instruction is given.
3. tools
List preferred tools, restricted tools, and common patterns.
4. quality standards
Spell out what a complete answer or finished task should include.
5. escalation
Describe when to pause, ask, or hand work off.
Common mistakes
Being too vague
If every line sounds reasonable but nothing is actionable, the file will not improve behavior much.
Writing for humans only
The file should be readable to humans, but it also needs to guide agent behavior directly.
Mixing permanent rules with temporary project notes
That makes the file unstable.
Never revising it
If the environment changes and the file does not, the instructions slowly become misleading.
Internal links worth reading next
- Workspace files
- Skills guide
- What is OpenClaw
- How to write AGENTS.md for OpenClaw
- OpenClaw workspace design best practices
Official references:
Final take
The best AGENTS.md file is not the longest one. It is the one that makes the agent easier to direct, easier to trust, and easier to manage in real work.
That is the bar.
FAQ
What is an AGENTS.md file?
It is a workspace instruction file that tells an AI agent how to behave in a specific environment.
What should an AGENTS.md file include?
Role, operating rules, tool guidance, quality standards, and escalation logic.
How long should an AGENTS.md file be?
Long enough to be clear, short enough that the important rules stay visible.
What should stay out of AGENTS.md?
Old transcripts, one-off notes, duplicated rules, and vague filler.
Why does AGENTS.md improve agent output?
Because it reduces ambiguity and gives the agent a clearer operating model.
A simple test for instruction quality
Give the file to someone else on the team and ask them to answer one question: what would this agent do by default, and what would it avoid?
If they cannot answer quickly, the file is probably too fuzzy.
That matters because the same ambiguity that confuses a teammate will usually confuse the agent too.
Why structure matters more than clever wording
You do not need beautiful prose in AGENTS.md. You need clear operating guidance.
That usually means:
- short sections
- explicit defaults
- obvious escalation rules
- specific quality bars
- direct tool guidance
Clear structure beats stylish vagueness every time.
How AGENTS.md evolves well
The best files are revised when the environment changes, not constantly rewritten for every temporary need. That keeps them stable enough to trust and flexible enough to stay current.
A good rule is to update the file when the operating model changes, not when one unusual task appears.
One practical rule
Write the file so the agent can tell what is mandatory, what is preferred, and what is just helpful background. If every instruction sounds equally important, prioritization gets messy.
Why AGENTS.md and memory should not be the same file
AGENTS.md is for durable operating rules. Memory is for facts that help with continuity. Mixing the two makes both systems harder to maintain.
Keeping them separate usually leads to better behavior and easier updates.
Where AGENTS.md pays off first
Teams usually feel the benefit fastest in repeatable work. Drafting, coding, research, support prep, and operations tasks all get easier when the agent has a stable operating guide.
That is when the file stops feeling optional and starts feeling like infrastructure.
Another practical habit
Review the file after major workflow changes, tooling changes, or team policy changes. Small scheduled reviews are better than waiting until the instructions are obviously stale.
A short AGENTS.md example structure
A clean file often includes a short role section, a short defaults section, a short tools section, a short quality bar section, and a short escalation section. That structure is easy to scan and easy to maintain.
It also gives the agent a clearer operating model.
Another review question
Could a new teammate understand how this agent works by reading the file once? If not, the structure probably needs tightening.
That is a useful test because good agent instructions should also be legible to humans who maintain the system.
Why clear defaults matter
Defaults do a lot of work. When the user does not specify every detail, the agent falls back to what the file says is normal. That is why vague defaults lead to vague behavior.
Clear defaults save time on every task after that.
A final structure note
Keep high-priority rules near the top. If the most important constraints are buried, the file becomes harder to use and harder to maintain.
That small change improves clarity quickly.
What teams usually notice first
Once AGENTS.md is cleaned up, the agent often becomes more consistent before it becomes more sophisticated. That is a good trade. Reliability is usually more valuable than extra flair.
Related posts
View allAI Agent Runbook Template: How to Build Repeatable Agent Workflows
April 24, 2026
A practical AI agent runbook template for OpenClaw teams, including what to include, how to structure approvals and escalation, and how to turn one-off workflows into repeatable operations.
How to Install OpenClaw on Ubuntu
April 20, 2026
A practical guide to installing OpenClaw on Ubuntu, running onboarding, checking gateway health, and fixing the setup issues that trip up first-time installs.
OpenClaw Mac Mini Setup Guide: How to Run an Always-On Agent at Home
April 20, 2026
A practical guide to setting up OpenClaw on a Mac Mini, installing the gateway daemon, keeping it stable, and turning it into a reliable always-on home agent box.