# Write an AGENTS.md file your coding agent actually follows

- Author: RomanMotion (https://wurk.fun/user/RomanMotion)
- Published: 2026-11-02
- Updated: 2026-11-03
- Canonical (HTML): https://wurk.fun/blog/write-an-agents-md-file-your-coding-agent-actually-follows
- Cover image: https://ik.imagekit.io/wurk/browser-uploads/f1c626b5c17e7f0a61dfbbe7a20d85ae7b33a20527243aeec2ee1d0a8b87562a/25a0ff7d-63be-4fd9-a50b-d8e6e2b9a0c1/cover-agentsmd.jpg?wurkUpload=v1.jMB-DOoBye9fR_UVANNgVZjlVpf933A4QHwuJBJW6DU

---

You ask your coding agent to fix a small bug, and it uses the wrong package manager or skips the tests. Now you’re spending gig time undoing changes and explaining the project again. A short instructions file can put the commands and boundaries where the agent can find them on the next task.

Create an `AGENTS.md` file at the root of your repository, fill it with your project’s real commands and rules, and check whether your agent reads it. Keep task-specific requirements in the prompt, review the result, and update the file when a recurring mistake reveals a missing rule.

## Give the agent a project starting point

[AGENTS.md](https://agents.md/) is an open Markdown format for project instructions. It gives a coding agent a place to find information such as how to build the app, where the code lives, which files need care, and what checks to run.

A repository is the project folder and its version history. Its root is the top-level folder, alongside files such as the project’s README or package configuration. Put `AGENTS.md` there as a starting point.

This saves you from copying the same setup instructions into every chat. It also gives anyone working on the project one place to review those instructions when the setup changes.

A file on disk doesn’t guarantee that an agent has read or followed it. Check your agent’s documentation and configuration: some tools read `AGENTS.md` automatically, while others need a different filename or setup. If you want to practise on a harness while you set this up, you can [try the zcode agent harness free](https://zcode.z.ai/invite/ALWM9JUA) and confirm what it loads at the start of a task. You can also ask the agent to summarize the relevant project rules before it starts, then verify its work afterward.

Keep the project rules separate from the job itself. “Run the app’s tests” belongs in the standing file; “make the contact form show a useful error when the email is invalid” belongs in the task. For that second part, use the guide to [writing a spec your coding agent can finish and verify](https://wurk.fun/blog/write-a-spec-your-coding-agent-can-finish-and-verify).

## Start with commands and a map

The most useful instructions are often the least glamorous: how to install, run, build, and test this particular project.

Write exact commands and say which directory to run them from. If the app uses a specific package manager, name it and identify the lockfile to keep. Don’t copy commands from the template below without checking that your project actually supports them.

For example, `npm test` is only useful if the project has a working test command. Run the commands yourself when possible. If a check needs setup the agent cannot perform, say what that setup is and require the agent to report the missing check rather than claim it passed.

Next, write a compact map of the project. Aim for five lines: where the app starts, where components or pages live, where server code lives, where tests live, and where generated files or other important assets live. Use your actual paths.

That map helps the agent look in the right place before changing code. It also makes a useful boundary visible: if the task is a small page change, a diff full of unrelated configuration edits deserves a closer look.

## Write rules you can check

“Write clean code” is hard to verify. “Reuse the existing form validation helpers” gives the agent a direction you can check in the changed files.

Include conventions that matter to this project and aren’t already covered by your linter or formatter. If your formatter already handles quotation marks and spacing, repeating those rules adds clutter. A more useful rule might be: “Keep user-facing error messages in the existing messages file.”

Then set boundaries around changes you want to review first. Depending on the project, those might be:

- Ask before adding or updating dependencies.
- Don’t edit existing database migration files without approval.
- Don’t commit secrets, credentials, or real customer data.
- Don’t deploy, push, or change production settings unless asked.

Adjust the list to the actual job. A project that needs a migration should have a rule for proposing one, not a blanket instruction that makes the task impossible.

Finally, define what “done” means. Require a summary of changed files, checks run and their results, and any checks the agent could not run. A failing or unavailable test should be reported plainly, not presented as a pass.

The file is guidance, not a security boundary. Review the diff and keep access to sensitive systems limited even when the instructions say not to touch them.

## Copy this template, then replace the details

This is an **illustrative template** for a small web app. Its commands and paths are examples, not a description of your project. Replace the bracketed fields and remove any line that doesn’t apply before using it.

```markdown
# Project instructions

## Commands

Run from: [project root or exact directory]

- Install: [exact install command]
- Start: [exact development command]
- Build: [exact build command]
- Test: [exact test command]
- Lint: [exact lint command]

Use [package manager] and keep [lockfile] in sync.
If a command fails or cannot run, report the result.

## Project map

- App entry: [path]
- Pages or routes: [path]
- Components: [path]
- Server code or API: [path, or "none"]
- Tests: [path]

## Working rules

- Reuse [existing helper or component] for [specific job].
- Keep changes limited to the requested task.
- Add or update relevant tests when behavior changes.

## Ask before doing these

- Adding or updating dependencies.
- Editing existing migrations or production configuration.
- Pushing, deploying, or changing external services.

## Never

- Commit secrets, credentials, or real customer data.
- Claim a check passed if it was not run.

## Done means

- The requested behavior is implemented.
- Relevant tests and checks have been run, or blockers reported.
- Summarize changed files, results, and remaining risks.
```

If you don’t know a command or path, inspect the project or ask its maintainer. Leaving a placeholder and reporting the gap is safer than inventing a command and calling the job complete.

## Keep it short, then test it

Before saving the file, read each rule as a reviewer. Could you check whether it was followed in the diff, command output, or final handoff? If not, make it more specific or remove it.

Leave out long explanations of the product, temporary priorities, and details that change every week. Link to existing project documentation for deeper context when needed. Never put passwords, API keys, recovery phrases, or client secrets in the file.

Try the instructions on a small task. Ask the agent which commands it plans to run and which files it expects to change. When it finishes, compare its report with the diff and the actual check output. If it missed a rule, check that the file was loaded and that the instruction was clear before adding more text.

When the same mistake happens twice, consider adding one specific line. If the agent keeps changing generated files, identify the path and say what to edit instead. If it keeps using the wrong command, replace the vague instruction with the exact one. Remove rules that no longer match the project.

A tighter file also means fewer wasted runs, which counts if you pay for agent time by plan; this referral link gives [a referral discount on GLM coding plans](https://z.ai/subscribe?ic=R0K78RJKNW) (eligibility and the final price show at checkout). There's [more on our blog](https://claw.rommark.dev) on setting up coding agents.

If this helped you make your next gig easier to verify, a small WURK tip on the post supports more practical guides.
