Skip to content(if available)orjump to list(if available)

AGENTS.md – Open format for guiding coding agents

CharlesW

This should've been an .agents¹ with an index.md.

For tiny, throwaway projects, a monolithic .md file is fine. A folder allows more complex projects to use "just enough hierarchy" to provide structure, with index.md as the entry point. Along with top-level universal guidance, it can include an organization guide (easily maintained with the help of LLMs).

  index.md
  ├── auth.md
  ├── performance.md
  ├── code_quality
  ├── data_layer
  ├── testing
  └── etc
In my experience, this works loads better than the "one giant file" method. It lets LLMs/agents add relevant context without wasting tokens on unrelated context, reduces noise/improves response accuracy, and is easier to maintain for both humans and LLMs alike.

¹ Ideally with a better name than ".agents", like ".codebots" or ".context".

skybrian

Except not hidden. Why do people want to hide important files and directories? Particularly documentation? Tradition, I guess, but it's an antipattern that makes everything more opaque.

Maybe robot_docs?

animal_spirits

It's so it doesn't clash with any project that actually has a functional `agents/` directory

p1necone

I've been trying to keep my baked in llm instructions to a terse ~100 line file, mostly headered sections with 5 or so bullet points each. Covering basic expectations for architecture, test mocking, approach to large changes etc. I can see why for some projects that wouldn't be enough but I feel like it covers everything for most of mine.

numpy-thagoras

Would you be open to sharing this here?

asabla

Been using a similar setup, with so far pretty decent results. With the addition of having a short explanation for each file within index.md

I've been experimenting with having a rules.md file within each directory where I want a certain behavior. Example, let us say I have a directory with different kind of services like realtime-service.ts and queue-service.ts, I then have a rules.md file on the same level as they are.

This lets me scaffold things pretty fast when prompting by just referencing that file. The name is probably not the best tho.

riffic

.well-known/

echelon

This. Projects need to stop inventing their own root level files and directories.

Stop polluting the root dir.

I'm not a fan of the name "well-known", but at least it's a convention [1].

I think it'd be great if we took something like XDG [2] and made it common for repositories, build scripts, package managers, tooling configs, etc.

[1] https://www.rfc-editor.org/rfc/rfc8615

[2] https://wiki.archlinux.org/title/XDG_Base_Directory

vinnymac

.config is a good name, and has a small following

https://dot-config.github.io

jitix

I like this idea. Do you have any middleware in your current setup that added the contents of this directory to the agent prompt?

CharlesW

I'd be interested in smarter ways of doing this, but currently I just use my CLAUDE.local.md to serve as the index.md in my example. It includes the 'specialist' .md files with their relative paths and descriptions, and tells Claude Code to use these when planning.

I also have explicit `xnew`, `xplan`, `xcode` and `xcheck` commands in CLAUDE.md that reinforce this. For example, here's my `xnew`:

  ## Remember Shortcuts
  Remember the following shortcuts, which the user may invoke at any time.
  
  ### XNEW
  When I type "xnew", this means:

  ```Understand all BEST PRACTICES listed in CLAUDE.md.
  Your code SHOULD ALWAYS follow these best practices.
  REVIEW relevant documentation in .agents/ before starting new work.
  Your code SHOULD use existing patterns and architectural decisions
  documented there rather than creating new approaches.```

tortilla

I'm building a little tool like this for myself. It's almost ready to be open-sourced. Just need to clean up some code and write better documentation.

blinkymach12

We're in a transition phase today where agents need special guidance to understand a codebase that go beyond what humans need. Before long, I don't think they will. I think we should focus on our own project documentation being comprehensive (e.g. the contents of this AGENTS.md are appropriate to live somewhere in our documentation), but we should always write for humans.

The LLM's whole shtick is that it can read and comprehend our writing, so let's architect for it at that level.

tptacek

It's not just understanding the codebase, it's also stylistic things, like "use this assert library to write tests", or "never write comments", or "use structured logging". It's just as useful --- more so even --- on fresh projects without much code.

time0ut

Honestly, everything I have written in markdown files as AI context fodder is stuff that I write down for human contributors anyway. Or at least stuff I want to always write down, but maybe only halfway do. The difference now is it is actually being read, seemingly understood, and often followed!

naniwaduni

... most of which would also be valuable information to communicate when onboarding new devs.

jaggederest

Yeah I agree. I think the best place for all this lives in CONTRIBUTING.md which is already a standard-ish thing. I've started adding it even to my private projects that only I work on - when I have to come back in 3 or 4 months, I always appreciate it.

ameliaquining

If there were already a universal convention on where to put that stuff, then probably the agents would have just looked there. But there's not, so it was necessary to invent one.

theletterf

Yes! That was precisely my point here: https://news.ycombinator.com/item?id=44837875

goosejuice

I suspect machine readable practices will become standard as AI is incorporated more into society.

A good example is autonomous driving and local laws / context. "No turn on red. School days 7am-9am".

So you need: where am I, when are school days for this specific school, and what datetime it is. You could attempt to gather that through search. Though more realistically I think the municipality will make the laws require less context, or some machine readable (e.g. qrcode) transfer of information will be on the sign. If they don't there's going to be a lot of rule breaking.

iknowstuff

Those particular signs are just stupid. The street should be redesigned with traffic calming, narrowing and chicanes so that speeding is not possible.

Slapping on a sign is ineffective

username223

Very strong "reverse centaur" vibes here, in the sense of humans becoming servants to machines, instead of vice versa. Not that I think making things more machine-readable is a waste of time, but you have to keep in mind the amount of human time sacrificed.

4b11b4

I agree with this general sentiment, but there might be some things you want to force into the context every time via a specific agent file.

joegibbs

I think they'll always need special guidance for things like business logic. They'll never know exactly what it is that you're building and why, what the end goal of the project is without you telling them. Architectural stuff is also a matter of human preference: if you have it mapped out in your head where things should go and how they should be done, it will be better for you when reading the changes, which will be the real bottleneck.

mvkel

This is mostly true if the existing codebase is largely self documented, which is rare

rr808

One of the most common usages I see from colleagues is to get agents to write the comments so you can go full circle. :)

TZubiri

This applies to mcp too

spawarotti

At this point AGENTS.md is a README.md with enough hype behind it to actually motivate people to populate it with contents. People were too lazy to write docs for other people, but funnily enough are ok with doing it for robots.

This situation reminds me a bit of ergonomic handles design. Designed for a few people, preferred by everyone.

wfhrto

The difference now is that people are actively trying to remove people (others and themselves) from software development work, so the robots have to have adequate instructions. The motivation is bigger. To dismantle all human involvement with software development is something that everyone wants, and they want it yesterday.

nicklo

I think it’s the reverse - people were too lazy to read the docs so nobody was motivated to write them.

With an agent I know if I write once to CLAUDE.md and it will be read by 1000’s of agents in a week.

blinkymach12

I like this insight. We kind of always knew that we wanted good docs, but they're demotivating to maintain if people aren't reading them. LLMs by their nature won't be onboarded to the codebase with meetings and conversations, so if we want them to have a proper onboarding then we're forced to be less lazy with our docs, and we get the validation of knowing they're being used.

masters3d

AGENTS.md fine but I hope the pattern sticks around. Another way is to use the README.md with different sections for humans or agents. As agent content windows expand to being able to load all the context in a repo, it will not matter much.

alphazard

Isn't the promise of AI that we don't have to adhere to precise formats? We can just write it down in whatever format makes the most sense to us, and any impedance mismatch is on the machine to figure out?

sqs

Just the filename is standardized. The contents aren't, which is exactly right. From the site:

> Are there required fields?

> No. AGENTS.md is just standard Markdown. Use any headings you like; the agent simply parses the text you provide.

4b11b4

No, structure and format matters, even if it may not be precise code syntax

ivanjermakov

I'm still not convinced that separating README.md and AGENTS.md is a good idea.

kaycebasques

I've also been debating this: https://technicalwriting.dev/ai/agents/#gotta-keep-em-separa...

(Quoting from that post)

Arguments in favor of keeping them separated:

* Writing style. In agent docs, using all caps might be an effective way to emphasize a particular instruction. In internal eng docs, this might come off rude or distracting.

* Conciseness vs. completeness. In agent docs, you likely need to keep the content highly curated. If you put in too much content, you’ll blast through your API quotas quickly and will probably reduce LLM output quality. In internal eng docs, we ideally aim for 100% completeness. I.e. every important design decision, API reference, workflow, etc. is documented somewhere.

* Differing knowledge needs. The information that LLMs need help with is not the same as the information that human engineers need help with. For example, Gemini 2.5 Pro has pretty good built-in awareness of Pigweed’s C++ Style Guide. I tested that assertion by invoking the Gemini API and instructing it Recite the Pigweed C++ Guide in its entirety. It did not recite in full, but it gave a detailed summary of all the points. So the Gemini 2.5 Pro API was either trained on the style guide, or it’s able to retrieve the style guide when needed. Therefore, it’s not necessary to include the full style guide as AGENTS.md context. (Credit to Keir Mierle for this idea.)

Arguments against:

* Duplication. Conceptually, agent docs are a subset of internal eng docs. The underlying goal is the same. You’re documenting workflows and knowledge that’s important to the team. But now you need to maintain that same information in two different doc sets.

CGamesPlay

> Writing style. In agent docs, using all caps might be an effective way to emphasize a particular instruction. In internal eng docs, this might come off rude or distracting.

To pile on to this, an agent needs to see "ABSOLUTELY NEVER do suchandsuch" to not do suchandsuch, but still has a pretty fair chance of doing it by accident. A talented human seeing "ABSOLUTELY NEVER do suchandsuch" will interpret this to mean there are consequences to doing suchandsuch, like being fired or causing production downtime. So the same message will be received differently by the different types of readers.

diggan

At this point, README.md becomes the "marketing/landing page markdown" and AGENTS.md/CLAUDE.md becomes the ones you visit to get an overview of the actual code/architecture/usage.

andyferris

For ages, many projects have README.md for marketing/landing page (i.e. users) and CONTRIBUTING.md for developers.

Why we don't treat coding agents as developers and have them reading CONTRIBUTING.md is baffling to me.

stingraycharles

It is. README is for humans, AGENTS / etc is for LLMs.

Document how to use and install your tool in the readme.

Document how to compile, test, architecture decisions, coding standards, repository structure etc in the agents doc.

darepublic

Compile, test, architecture would be very welcome in the readme too Id wager

furyofantares

There's a lot of shit in my claude.md that would be condescending to a human. Some of it I don't even mean, it's just there to correct egregious patterns the model loves to do. I'm not gonna write "never write fallback code" in my readme, but it saves a lot of time to prevent claude from constantly writing code that would silently fail if it got past me because it contains a fallback path with hardcoded fake data.

sponnath

Why would these things not be relevant for humans?

throwup238

They are relevant but dumping it all into one document in the project root isn’t as optimal for humans as it is for agents, especially since a lot of that information is irrelevant to someone landing on your repo, who probably just wants to add it to their dependency manifest or install the app followed by usage instructions geared to humans.

crazylogger

We have CONTRIBUTING.md for that. Seems to me the author just doesn't know about it?

lmeyerov

We find it useful:

* Agents still kinda suck so need the help around context management and avoiding foot guns. Eg, we make a < 500loc ai/readme.md with must haves, links to others, and meta how-to-use

* Similar to IaaC, useful to separate out as not really ready the same way we read it, and many markdowns are really scripts written in natural language, eg, plan.md.template

trailrunner46

One reason to consider is around context usage with LLMs. Less is generally better and README.md files are often too much text some of which I don’t want in every context window.

I find AGENT.md and similar functioning files for LLMs in my projects contains concise and specific commands around feedback loops such as testing, build commands, etc. Yes these same commands might be in a README.md but often there is a lot more text that I don’t want in the context window being sent with every turn to the LLM.

rogeliodh

Some time ago a lot of projects had a README and a BUILD/README.build/DEVELOPMENT file... I think AGENTS.md is more akin to this last file.

blinkymach12

I had the same thought as I read this example. Everything in the AGENTS.md file should just be in a good README.md file.

esafak

My READMEs don't have things like "don't run the whole test suite unless I instruct you to because it will take too long; run targeted tests instead".

viraptor

Why not? "For most development we recommend running single/specific tests since the whole suite is slow/expensive." sounds like a great thing to put in the readme.

ecb_penguin

That seems exactly like something you would want to tell another developer

sothatsit

You're going to include specific coding style rules in your README? Or other really agent-specific things like guidance about spawning sub-agents?

They are separate for a good reason. My CLAUDE.md and README.md look very different.

bongodongobob

Why would you publish agent specific things to your codebase? That's personal preference and doesn't have anything to do with the project.

petesergeant

Perhaps. I let Claude put whatever it wants in its Claude file and check it’s not batshit from time to time, where I’m very protective of the high-quality README I write for humans. The Claude file has stuff that would be obvious to a human and weird to jam into the README (we use .spec.ts not .test.ts) but that Claude needs in order to get things right.

eats_indigo

In what way is this a format or standard? It's just markdown in a namespce

tptacek

You could get this page down to under 100 words by simply having it say "the name of the file LLM agents will look at for instructions on the repo is AGENTS.md; that's it, that's the standard".

It's a real problem! Every agent right now has their own weird filename. I love David Crawshaw's sketch.dev, but for reasons passing understanding they choose "dear_llm.md" for theirs.

esafak

I created a ticket for adding AGENTS.md support.

edit: They're on it. Not everything has to be complex; sometimes somebody just has to do it.

TZubiri

Easy story points

ethan_smith

Standards derive their value precisely from being simple and widely adopted - think of .gitignore, CONTRIBUTING.md, or LICENSE files that work because everyone agrees on their location and purpose.

chrismorgan

.gitignore is not a standard: it’s a format used by one tool. A few other tools piggy-back on it (e.g. ripgrep ignores paths matching in .gitignore, .hgignore, &c. by default), not infrequently to confusion.

CONTRIBUTING.md is not a standard: it’s a convention pushed by one platform, used by some projects (but many more will not write down such information, or put it in a README file, or put it in some other documentation).

LICENSE is definitely not a standard: it’s one of a wide variety of names people use to hold licensing information, which some tools will be able to detect. I just looked through my /usr/share/licenses, of 1135 files, only 300 are named LICENSE—it’s the most popular single name, sure, with COPYING next at 182, but it’s still definitely a minority, though in certain ecosystems it may be more popular. Any license-detection tooling will be scanning for a lot more file names. “LICENSE” is a very weak convention, compared with the others.

arrowsmith

All the different coding agents put their "rules" in different places: .cursor, CLAUDE.md etc..

It makes no sense and it really needs standardisation. I hope this catches on.

cma

As a workaround you can add a wrapper launcher script that symlinks them and then removes the symlink after you exit

stingraycharles

Yet every agent I use (Claude Code, Gemini and Aider) uses their own custom filename.

It would be nice if it was standardized. Right now I’m using ruler to automate generating these files for all standards as a necessary evil, but I don’t envision this problem being solved soon. Especially because these coding agents also use different styles for consuming MCP configs.

https://github.com/intellectronica/ruler

ameliaquining

Jules uses AGENTS.md, which indicates that Google is on board with it as the standard. If Gemini Code Assist continues to be a thing (I'm not sure whether Jules is intended to succeed it) then presumably it will support AGENTS.md as well. In the meantime you can configure Gemini Code Assist to use an arbitrary filename.

I don't see a reference to a specific filename in Aider's documentation, can you link to it?

Anthropic appears to be the major holdout here.

4b11b4

While I understand why... ruler seems like something we should not need

faangguyindia

I am developing a coding agent that currently manages and indexes over 5,000 repositories. The agent's state is stored locally in a hidden `.agent` directory, which contains a configuration folder for different agent roles and their specific instructions. Then we've a "agents" folder with multiple files, each file has

<Role> <instruction>

Agent only reads the file if its role is defined there.

Inside project directory, we've a dot<coding agent name> folder where coding agents state is stored.

Our process kicks off with an `/init` command, which triggers a deep analysis of an entire repository. Instead of just indexing the raw code, the agent generates a high-level summary of its architecture and logic. These summaries appear in the editor as toggleable "ghost comments." They're a metadata layer, not part of the source code, so they are never committed in actual code. A sophisticated mapping system precisely links each summary annotation to the relevant lines of code.

This architecture is the solution to a problem we faced early on: running Retrieval-Augmented Generation (RAG) directly on source code never gave us the results we needed.

Our current system uses a hybrid search model. We use the AST for fast, literal lexical searches, while RAG is reserved for performing semantic searches on our high-level summaries. This makes all the difference. If you ask, "How does authentication work in this app?", a purely lexical search might only find functions containing the word `login` and functions/classes appearing in its call hierarchy. Our semantic search, however, queries the narrative-like summaries. It understands the entire authentication flow like it's reading a story, piecing together the plot points from different files to give you a complete picture.

It works like magic.

jzig

Tell me more!

faangguyindia

The agent I’m developing is designed to improve or expand upon "old codebases." While many agents can generate code from scratch, the real challenge lies in enhancing legacy code without breaking anything.

This is the problem I’m tackling, and so far, the approach has been effective. It's simple enough for anyone to use: the agent makes a commit, and you can either undo, squash, or amend it through the Git UI.

The issue is that developers often skip reviewing the code properly. To counter that, I’m considering shifting to a hunk-by-hunk review process, where each change is reviewed individually. Once the review is complete, the agent would commit the code.

The concept is simple, but the fun lies in the implementation details—like integrating existing CLI tools without giving the agent full shell access, unlike other agents.

What excites me most is the idea of letting 2–3 agents compete, collaborate, and interpret outputs to solve problems and "fight" to find the best solution.

That’s where the real fun is.

Think of it as surgeons scalpel approach rather than "steam roller" approach most agents take.

aeon_ai

I am not anti-AI - perhaps obviously.

But this is wildly insufficient as a standard, and wholly lacks innovation on the dimension of 'context management' as a discipline.

null

[deleted]

cortesi

I have a tiny, relevant weekend project:

https://github.com/cortesi/agentsmd

This is a command-line tool that lets you generate your AGENTS.md and CLAUDE.md files from common sources. So, for instance, if you have Rust-specific guidance for models, you can define it once, and then automatically include it in any project that contains Rust based on the `lang()` language matcher.

This is one of those small tools I now use many times a day to maintain and update ubiquitous agents files. Maybe other folks will find it useful too.

rblatz

We are going the opposite way, putting instructions in md files and putting instructions in the Claude.md file when it should read those instructions.

ekusiadadus

How are you actually running this in practice with Claude Code? Do you just tell Claude to always read and follow AGENTS.md, or do you also use an MCP server to strictly control which commands (like pnpm test or pnpm lint) it can run? I’d love to hear what workflows or best practices have worked well for you in day-to-day use.

j45

I have Claude Code maintain the files and reference links between them.