← All news

News / Learn / AI coding tools

How do you write project instructions for coding agents?

You'll be able to write a project instruction file that tells a coding agent how your codebase works and how to change it safely.

A coding agent reads a file of standing instructions before it starts work. That file holds the facts it cannot guess: how to build and test the project, where code lives, and what rules to follow. You write it once, and every session starts from the same shared understanding. Think of it as a short onboarding guide for a new team member who reads very fast but knows nothing about your project.

Agents do not remember your project between sessions by default. Without clear instructions they guess at commands, invent conventions, and repeat the same mistakes. A good instruction file cuts that waste and makes agent output more consistent. It also protects you from quiet errors, such as an agent skipping tests or editing generated files.

Most coding agents look for a plain Markdown file in the repository root. AGENTS.md is a common, tool-neutral name, and some tools use their own file names. The agent loads this file into its context window, which is the limited amount of text it can consider at once. Anything in the file uses up some of that space, so the file should stay short and specific.

Good content covers the things an agent cannot infer from the code alone. List the install, build, lint, and test commands exactly as you run them. Name the main directories and what each one holds. State conventions such as naming, error handling, and which libraries to prefer. Say which files are generated and must not be edited by hand.

Write rules as commands, not essays. A line such as 'Run npm test before reporting a task as done' gives the agent a checkable step. A paragraph of general advice about code quality gives it little to act on. Keep each rule short and concrete, and remove anything that is obvious from reading the code.

Revisit the file when the project changes. When an agent makes the same mistake twice, add a rule that would have prevented it. Remove rules that are stale, because outdated instructions are often worse than none.

A short instruction file for a small Python web service. Adapt the commands to your own project.

# Project instructions

## Commands
- Install: pip install -e ".[dev]"
- Test: pytest -q
- Lint: ruff check . && ruff format --check .

## Layout
- src/app/: application code. Edit here.
- src/app/generated/: produced by codegen. Do not edit by hand.
- tests/: mirror the src/ tree.

## Rules
- Run tests and lint before reporting a task as done.
- Use dataclasses for new data models.
- Do not add a new dependency without asking first.
- Never commit secrets. Use environment variables.

A short sketch to show the idea. Check the official docs of the tool you use.

  • Writing a long, vague file Keep it short and specific. Every line should change what the agent does. Cut general advice that any developer already knows.
  • Listing commands that are wrong or outdated Copy commands from a terminal you have just run successfully. Re-check them whenever build tooling changes.
  • Forgetting the generated and protected files Name the directories and files the agent must not edit by hand, and say where the source of truth lives instead.
  • Trusting the file to enforce rules Instructions are guidance, not a guarantee. Back important rules with automated checks such as tests, linters, and CI so violations get caught.

Learn how context windows limit what an agent can hold at once, and how tool-specific settings and skills can split instructions into smaller, load-on-demand pieces. Also study how to write tests and linters that enforce the same rules your instruction file states.

Is one instruction file enough for a large project?

Often yes, if it stays short. For large projects, keep the root file brief and point to more detailed docs in subfolders for the areas that need them.

Should I put my personal preferences in the shared file?

Put team-wide rules in the shared file. Personal preferences belong in your own tool settings, so they do not affect teammates.

How do I know whether the file is working?

Watch the agent's first few actions. If it runs the right commands and follows the layout without prompting, the file is doing its job. If it keeps guessing, add the missing fact.

Can the agent update the file itself?

It can propose changes, but review them carefully. Agent-written rules can drift or encode mistakes, so treat edits like any other code change.

Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.