My coding agents kept forgetting what I told them until I gave every project one shared instructions file
The fix for forgetful agents is a plain text file.
Telling coding agents the same instructions repeatedly became a tiresome task. Every time I began a new session with a coding agent, I had to remind them to run specific commands or follow certain conventions. This became even more burdensome as my set of established coding rules and conventions grew into an unwieldy list that I had to copy across every session.
The solution was to create an AGENTS.md file at the root of every project. This simple Markdown file served as the first point of contact for all agents, ensuring they always began a task with the same level of initial context.
I included everything that I believed an agent needed to know before getting started. This file became the hub for all project-specific instructions, making it easier for me to switch between different AI agents without repeating information. Each time I started a new session with a coding agent, it had a fresh context window, allowing it to familiarize itself with the project and its conventions over time.
Having a unique set of rules for each project made the instructions in the AGENTS.md file almost as important as the code itself. To facilitate this, I committed the AGENTS.md file right alongside the source code. If your project already had a CLAUDE.md file, you simply added an import inside it, using `@AGENTS.md` on one line. Otherwise, Claude would stop looking for more files after finding the former file.
The AGENTS.md file was supported by multiple AI agents, including Codex, Cursor, Claude Code, and many others, making it a versatile solution for storing instructions that you didn't want to tie to a specific company. I found that documenting everything in AGENTS.md stemmed from years of writing README files for people who wouldn't explore the codebase. However, AI agents would be accessing the code, so there was no need to repeat information redundantly.
When writing the instructions for AGENTS.md, I focused on being specific and avoiding ambiguity. For example, instead of telling models to "test your changes," I instructed them to run `npm test` after completing changes and to fix any errors before committing. For larger changes to the UI, I directed models to spin up a test environment and use Playwright to ensure everything looked correct.
The AGENTS.md file was a work in progress, as projects and conventions evolved over time. I regularly updated the instructions to reflect any changes and added a line stating, "If changes you make render a set of instructions in AGENTS.md irrelevant or obsolete, notify the user about it and recommend how it should be updated." This helped me shift some of the file's upkeep to the AI models themselves.
While the AGENTS.md file didn't inherently make the agent more powerful, it saved me time and effort by eliminating the need to repeat instructions. The file primarily served to streamline the process and reduce the cognitive load of starting a new project. The most common sections in my AGENTS.md files included "need-to-knows," "project layout," "database info," and "auth and users," each containing only the essential rules every agent needed to get started.
As a general rule, if you found yourself typing the same instruction across multiple agent sessions, it was worth adding a bullet point to AGENTS.md. Starting with the most common annoyances first proved effective, generating a few lines of content from that alone. Over time, the file grew, but the process of maintaining it became more manageable and less frustrating.
The AGENTS.md file allowed me to dive straight into a project without needing to bring the agent up to speed first, making my coding experience smoother and more efficient.
Rewritten by urgent.news; may contain errors — check the original.
Source: xda-developers.com