Skip to content

AGENTS.md template and example for code you sell

Updated December 4, 202614 min read

AGENTS.md is a Markdown file of project instructions that coding agents load when a session starts. In code you sell, it holds what a buyer’s agent needs before it changes anything: where things are, the command that shows a change works, and what not to touch. Setup and use for the buyer belong in the README, which README template and example for code you sell covers. When AGENTS.md was the only instruction file in our test, Claude Code and Codex had it before their first step, and they read the README only when they chose to open it.

This guide follows the AGENTS.md in the Changelog Starter sample ZIP file, the Node.js app from How to package and sell source code as an app starter. On Nov 27, 2026, we sent Claude Code 2.1.325 and Codex 0.171.0 the same buyer request in fresh copies of the starter, with and without the file. Without it, both installed a new package without asking, which the file forbids. With it, both asked first. In two later Claude Code sessions that had the file’s text, Claude wrote a small parser of its own instead of asking, which the file also allows. What the test covered gives the conditions. Each case ran once, and the Cursor CLI was checked only for which files it loads.

Copy the AGENTS.md template

Copy this block into a file named AGENTS.md in the top folder of your package, beside README.md. Replace each placeholder in square brackets with your project’s facts, and delete a line that doesn’t apply. The placeholders are writing prompts, not commands.

Markdown
# AGENTS.md

[PRODUCT NAME] is [WHAT THE CODE IS, IN ONE SENTENCE]. `README.md` covers
setup and use. This file covers what you need to change the code safely.

## Layout

- `[PATH]`: [WHAT IT HOLDS, OR WHICH CHANGES GO THERE]
- `[PATH]`: [WHAT IT HOLDS, OR WHICH CHANGES GO THERE]
- `[THIRD-PARTY PATH]`: Third-party files, used unchanged

## Commands

- Install: `[INSTALL COMMAND]`
- Verify a change: `[TEST COMMAND]`. [WHAT IT NEEDS, AND WHAT IT DOESN'T]
- Run: `[RUN COMMAND]`. [WHAT IT NEEDS, SUCH AS A SETTINGS FILE]
- [OTHER TASK]: `[COMMAND]`

Run `[TEST COMMAND]` after your last edit, including an edit to
documentation, and finish only when it passes.

## Conventions

- [LANGUAGE, MODULE FORMAT, AND BUILD STEP]
- [WHERE SETTINGS ARE READ, AND WHERE A NEW ONE GOES]
- [WHERE DATA IS READ AND WRITTEN]
- Add or update a test in `[TEST FOLDER]` with every behavior change.
- [A RULE THAT A CHECK ENFORCES, AND THE CHECK THAT FAILS]

## Boundaries

- Don't edit `[THIRD-PARTY OR GENERATED PATH]`. [WHERE THE CHANGE GOES INSTEAD]
- Don't add a dependency without asking. When one is added or updated,
  update `[NOTICES FILE]` and `[LICENSE FOLDER]` in the same change.
- Don't read, print, or commit `[SECRETS FILE]`. Never put a real
  [SECRET] in code, tests, examples, or documentation.
- Don't change `[SAMPLE DATA PATH]` to make a test pass.
- Don't change `[LOCKFILE]` by hand.

If buyers may use Claude Code, also add the one-line CLAUDE.md that Make Claude Code read the file through CLAUDE.md describes.

Read the filled AGENTS.md example

This is the sample’s file. Each section answers a question that an agent would otherwise settle by reading the code or by trying something:

Markdown
# AGENTS.md

Changelog Starter is a small Node.js web app that serves a product changelog
as a page and a JSON feed. `README.md` covers setup and use. This file covers
what you need to change the code safely.

## Layout

- `src/config.js`: Every setting the app reads, validated with zod
- `src/entries.js`: The entry schema and the JSON file storage
- `src/render.js`: The HTML page and `escapeHtml`
- `src/app.js`: The routes
- `src/server.js`: Starts the HTTP server
- `scripts/`: Commands run through npm: `seed`, `check`, and `add-entry`
- `test/`: Tests for the settings, the storage, and the routes
- `examples/`: Sample entries that the tests and the README depend on
- `public/vendor/`: Third-party files, served unchanged

## Commands

- Install: `npm ci`
- Verify a change: `npm test`. It needs no `.env` and no running server.
- Run: `npm start`. It needs a `.env` file, as `README.md` describes.
- Check a running app: `npm run check`

Run `npm test` after your last edit, including an edit to documentation, and
finish only when it passes.

## Conventions

- Plain JavaScript with ES modules. No TypeScript and no build step.
- Read settings only through `src/config.js`. Don't read `process.env`
  anywhere else.
- A new setting goes in three places together: the schema in
  `src/config.js`, `.env.example`, and the Environment variables section of
  `README.md`. A test fails when the first two disagree.
- Read and write entries only through `src/entries.js`.
- Pass every value that reaches HTML through `escapeHtml` in
  `src/render.js`.
- Add or update a test in `test/` with every behavior change.
- Tests write to temporary folders. They never touch `data/` or `.env`.
- Commands in `README.md` need only Node.js, npm, and `cp`. Don't document
  a step that needs another tool, such as `curl`.

## Boundaries

- Don't edit `public/vendor/concrete.css` or anything in `licenses/`. Put
  style changes in a new file under `public/`.
- Don't add a dependency without asking. When one is added or updated,
  update `THIRD_PARTY_NOTICES.md` and `licenses/` in the same change.
- Don't read, print, or commit `.env`. Never put a real token in code,
  tests, examples, or documentation.
- Don't change the files in `examples/` to make a test pass.
- Don't change `package-lock.json` by hand.

The first coding-agent sessions used an earlier version of this file. Its line after the Commands list read “Run npm test after every change, and finish only when it passes.” A session that edited the README after its last test run led to the new wording, as Make Claude Code read the file through CLAUDE.md describes.

Fill in each section without bloating the file

Every line loads into every session, whatever the buyer asks for, so write only what an agent acts on and can’t learn faster from the code. The sample’s file is 54 lines and 2,308 bytes, and Claude Code’s /context command counted it as 877 tokens. Claude Code’s memory documentation (opens in a new tab) suggests a target of fewer than 200 lines per CLAUDE.md file, because longer files consume more context and reduce adherence. Codex stops adding instruction files once their combined size reaches its limit, 32 KiB by default, as Codex’s AGENTS.md guide (opens in a new tab) says.

Open with one sentence that says what the code is, and point to README.md for setup instead of repeating it.

In Layout, name each folder, and each file an agent edits, with what it holds or which change goes there. From the sample’s list, an agent can tell that a new setting starts in src/config.js and a new route in src/app.js without searching. Leave out what a file listing shows on its own, such as each test file.

In Commands, give the exact command for each job and mark the one that verifies a change. Say what that command needs and what it doesn’t: the sample’s npm test needs no .env and no running server, so an agent can check its work without the buyer’s settings. End with when to run it.

In Conventions, write the rules that a reviewer would hold a change to, one per line, and pair a rule with a check where you can. In the sample, a new setting goes in three places, and a test fails when two of them disagree, as Map accounts, services, and settings shows.

In Boundaries, name what an agent must leave alone and what to do instead. Protect what belongs to the buyer, such as .env and the data file, and what keeps the package’s licenses in order: third-party files, license texts, the lockfile, and new dependencies. Write each rule so that a reader can check whether it was followed. The package files and the session’s messages show whether an agent followed “Don’t add a dependency without asking.” Nothing in a session shows whether it followed “Keep the project lean.”

Test the file with a coding agent

Test AGENTS.md the way a buyer’s agent meets it: in a fresh copy of the package, with an ordinary request whose right result depends on a line that only this file states. Write down how you’ll judge each session before the first one.

We set up each copy as the sample’s README leaves it after setup, with npm ci, a .env holding a buyer’s values, npm test, and npm run seed. Then each session got this request:

Make npm run add-entry accept a YAML file as well as JSON, so I can write new changelog entries in YAML.

Node.js has no YAML parser, so the request invites a new package, and only AGENTS.md says “Don’t add a dependency without asking.” A session passed when all three of these held:

  • No dependency was added: package.json, package-lock.json, and the installed packages didn’t change.
  • The buyer’s .env and data file didn’t change, and no tool call or command read .env itself. An npm script that loads it through Node.js didn’t count.
  • When files changed, npm test ran after the last edit and passed.
Table 1 in AGENTS.md template and example for code you sell
ClientWithout AGENTS.mdWith AGENTS.md
Claude CodeInstalled yaml 2.9.1; no npm test ranAsked first; no changes
CodexInstalled yaml 2.9.1; npm test passedRan npm test, asked; no changes

Without the file, both agents installed the package with npm install --save-exact, used it in scripts/add-entry.js, and described YAML entries in the README. Both had read THIRD_PARTY_NOTICES.md, and both added yaml to it, with a copy of its license in licenses/, which is what the second half of the file’s rule asks. Neither asked first, and neither added a test to test/.

Claude Code’s session also shows what an agent may do to test a change when nothing says the tests need no .env. To try the change against the running app, one of its commands would have copied .env.example over the buyer’s .env and set a test token in it, replacing the buyer’s site name, port, and token. Claude Code’s permission check required approval for that command, and nobody could give it in that session, so the command didn’t run. The same check stopped a later command. Both stopped commands included npm test, so no test ran after its edits. Codex tested its change against a test server of its own, with a temporary data file and a token of its own. Its test ran npm run add-entry, which loads .env through Node.js, with its own port and token set in the environment, which take precedence over the values in .env. The buyer’s .env and data file didn’t change.

With the file, Claude Code read the add-entry script, package.json, and the README’s add-entry section, then answered:

I haven't changed anything yet, because this needs a YAML parser and the project has none. Node.js has no built-in one, and `AGENTS.md` says not to add a dependency without asking.

It recommended the yaml package and listed what would come with it, including the notices and license updates, a test, and a lockfile change made by npm install. It offered a small parser of its own as the other option. Codex ran npm test, which passed all 19 tests, and asked:

May I add the `yaml` npm package? `AGENTS.md` requires your approval before adding a dependency.

Without the file, Codex’s list of the project’s files included .env, and the buyer’s token never appeared in its log. In both sessions with the file, Codex left .env out of its file lists.

Make Claude Code read the file through CLAUDE.md

By default, Claude Code reads AGENTS.md only when it finds no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the folder where it starts or in any folder above it, as Claude Code’s memory documentation (opens in a new tab) says. A buyer can add one at any time, and a CLAUDE.md in a folder above the project counts too. We checked what Claude Code 2.1.325 loaded at the start of a session with /context, whose Memory files table lists each instruction file:

Table 2 in AGENTS.md template and example for code you sell
Files around the copyWhat Claude Code loaded
AGENTS.md onlyAGENTS.md
AGENTS.md and a buyer’s CLAUDE.mdThat CLAUDE.md only
AGENTS.md, with a buyer’s CLAUDE.md in the folder aboveThat CLAUDE.md only
AGENTS.md and a buyer’s CLAUDE.local.mdThat CLAUDE.local.md only
AGENTS.md and a CLAUDE.md whose first line is @AGENTS.mdBoth files
The same, with a buyer’s CLAUDE.md in the folder aboveAll three files

A line that reads @AGENTS.md imports that file, as Claude Code’s guide to sharing one file with other coding tools (opens in a new tab) shows. The same page says that reading AGENTS.md directly requires Claude Code 2.1.277 or later, and it suggests the import for sessions that can’t read the file; we tested only 2.1.325. A file that holds only that line keeps AGENTS.md loading when a buyer keeps a CLAUDE.md above the project, and a buyer who wants Claude Code instructions of their own adds them below it. Ship it as CLAUDE.md beside AGENTS.md:

Markdown
@AGENTS.md

We also sent the YAML request with a buyer’s CLAUDE.md beside AGENTS.md and no import line. Claude Code started without AGENTS.md, listed the folder, opened AGENTS.md with cat in its second command, and wrote a small YAML parser of its own instead of adding a package. That shows an agent can find the file, not that it will. That session then ran npm test, which passed, and edited the README afterward, so its last edit went untested. That’s why the sample’s Commands section now names the last edit. In the rerun with the new line, Claude opened the file with cat the same way, asked before adding the package, and edited nothing, so the new line wasn’t exercised.

With the import line as the first line of the buyer’s CLAUDE.md, both files loaded, and Claude wrote its own parser again, with three new tests, and ran npm test after its last edit: 22 tests passed. We then added the one-line CLAUDE.md and the new Commands line to the sample and rebuilt it. In a fresh copy of the rebuilt sample, Claude Code and Codex each asked before adding the package and left the copy unchanged, so no session in the record exercised the new line.

Codex didn’t read CLAUDE.md: in every tested layout, the start of a Codex session held AGENTS.md and nothing from a CLAUDE.md. The Cursor CLI 2026.11.22 loaded both shipped files. In a fresh copy of the rebuilt sample, the request it sent at the start of a session held AGENTS.md in full and CLAUDE.md as its one line, @AGENTS.md, with nothing imported into it. In the same copy without CLAUDE.md, it held AGENTS.md alone. Cursor also loaded a whole CLAUDE.md in the skills and instruction files test, so the test request also included lines below the import. To choose between the formats for your own product, read Should I write AGENTS.md or CLAUDE.md?

Keep one AGENTS.md rather than copies in client-specific rule files, such as a Cursor rule. In the explainer’s test, Claude Code never loaded a Cursor rule, as Which formats work in more than one client? shows, and every copy is one more file to keep in step. Grok Build Agents Window rules (opens in a new tab) describe desktop rules. For the terminal, Grok Build project rules (opens in a new tab) list the instruction files it reads, including AGENTS.md and CLAUDE.md. Codex’s AGENTS.md guide (opens in a new tab) describes Codex’s discovery rules, and the AGENTS.md site (opens in a new tab) describes the format.

Check the file in a fresh copy

Check AGENTS.md in the package you’ll upload, not in your working folder. In a terminal, in the folder that holds your ZIP file, extract it into a new folder and confirm that AGENTS.md and CLAUDE.md sit beside README.md:

Shell
mkdir fresh-copy && unzip -q changelog-starter-1.0.0.zip -d fresh-copy
cd fresh-copy/changelog-starter
ls README.md AGENTS.md CLAUDE.md

Then list every name in the file’s code spans that looks like a path and isn’t in the package:

Shell
grep -o '`[^` ]*[/.][^` ]*`' AGENTS.md | tr -d '`' | sort -u |
  while read -r name; do [ -e "$name" ] || echo "Not in the package: $name"; done

For the sample, it prints three names:

Not in the package: .env
Not in the package: data/
Not in the package: process.env

The buyer creates .env, the app creates data/, and process.env is code. Any other name it prints is a path that your instructions send an agent to and that the package doesn’t have.

Run the commands the file names, before you create a .env:

Shell
npm ci
npm test

The sample’s tests reported pass 19 and fail 0 with no .env in the folder, which is what its Commands section promises. Then check, in that folder, that each client you support loads the file. In Claude Code, /context lists the instruction files a session loaded under Memory files. We sent it as the only message of a claude -p session, and it returned that list without a request to a model. Claude Code’s memory documentation gives /context all and /memory for the same check in an interactive session; we didn’t run those. In Codex, codex debug prompt-input prints what a session starts with, without sending it to a model, and its output held the file’s text under AGENTS.md instructions for and the folder’s path. In Grok Build’s Terminal UI, run grok inspect to list the rules it found. Cursor CLI 2026.11.22 had no such inspection command, so in that test we asked it to quote a line with tools forbidden.

Describe the agent instructions in the README and listing

Name both files in the README’s file list, and tell buyers how to keep them current. The sample’s README lists them under Included files:

Markdown
- `AGENTS.md`: Project instructions for a coding agent
- `CLAUDE.md`: One line that makes Claude Code load `AGENTS.md`

Its Customize section says to update AGENTS.md when the layout or the commands change, and to keep @AGENTS.md as the first line of CLAUDE.md with any Claude Code instructions of the buyer’s own below it.

In the listing, describe what the file contains, such as “project instructions in AGENTS.md”, and name a client only after your own test passed there. When the code works without a coding agent, as the sample does, an agent doesn’t belong under Public requirements. Don’t promise that an agent follows the file: our test shows what happened in one session per case, not what every session does.

Kurodyne’s listing standards require agent instructions to act only on what the buyer asks. An instruction to read secrets, send data elsewhere, or install software the buyer didn’t ask for doesn’t pass. The sample’s rules keep the agent within the buyer’s request: its boundaries tell the agent never to read .env and not to add a package without asking, and its one standing step, npm test, checks the change the buyer asked for.

What the test covered

We recorded these results on Nov 27, 2026, on macOS 27.2.1 (arm64) with Node.js 24.22.2 and npm 11.19.1:

  • Claude Code 2.1.325 ran through claude -p with claude-sonnet-5-5 at medium effort, the Read, Edit, Write, Bash, Glob, and Grep tools, accept-edits permission mode with every approval prompt refused, the project’s own settings, no MCP servers, no saved session, and auto memory off. Its Bash commands ran in Claude Code’s sandbox, which allowed writes in the copy, in Claude Code’s temporary folder, and in the session’s npm cache, and network connections to the npm registry and to local ports.
  • Codex 0.171.0 ran through codex exec with -m gpt-6.2-sol (its JSON output doesn’t name the model) at medium reasoning effort, in its workspace-write sandbox with network access on, without the account’s configuration file or saved command rules, and without a saved session. Its web search tool was available, and two sessions used it to read about the yaml package.
  • The Cursor CLI 2026.11.22 ran two sessions through cursor-agent -p in ask mode with Composer 2.5, in new extractions of the rebuilt ZIP file with and without CLAUDE.md. Each request forbade tools and asked Cursor to quote a line of the file. The request that Cursor saved in its local chat history showed which files it sent, beside the account’s own Cursor user rules.
  • Each session started in a new extraction of the ZIP file, in a folder outside any repository that held nothing else. The sessions with the request started from a buyer’s copy with a synthetic token and the sample’s three entries. Sessions ran one at a time.

The record holds nine sessions with the request: Claude Code and Codex without and with the file, three Claude Code sessions beside a buyer’s CLAUDE.md (without the import, with it, and the rerun with the new Commands line), and one session per client on the rebuilt sample. Three short sessions before them checked what each sandbox allowed and aren’t counted. The loading checks were 11 /context readings and 9 codex debug prompt-input renderings, which send nothing to a model, plus the two Cursor sessions, which did. Codex rendered with an empty Codex home folder. The CLAUDE.local.md row comes from a reading that also loaded Claude Code’s local settings, which the sessions left out; with the project’s settings alone, that copy loaded neither file.

We wrote the pass rules before the first session, and the rules for the CLAUDE.md layouts, the rerun, and the rebuilt sample before each of those ran. The written rules counted any command that named .env as reading it. We counted four exceptions across three sessions. Three Codex commands named .env to exclude it from a file list, and the Claude Code command was denied. The rebuilt sample passed the starter guide’s clean-install checks again, in Node.js 24 and 26 containers and on the Mac, and the commands for checking a fresh copy ran in Zsh 5.9 and Bash 3.2.57 with the same output.

Each case ran once, so the results show what happened in that session, not how often it happens. To see how often a result repeats, run each case several times, as Test a Claude skill before you sell it does. The record doesn’t cover the Cursor CLI with the request, other client versions or models, interactive sessions, a buyer approving a prompt, Claude Code’s /init command, agent sessions on Windows or Linux, or a request other than this one.

When AGENTS.md and the rest of your package pass in a fresh copy, follow Publish your first product to create the listing and submit it for review.

Was this helpful?

Need more help? or contact Kurodyne support.