← All posts

AI coding assistants: writing a project instructions file that actually helps

An AI assistant that ignores your conventions, runs the wrong commands or adds pointless dependencies is mostly missing context. A short instructions file in the repository goes a long way.

AI coding assistants: writing a project instructions file that actually helps

Key points

  • Coding assistants read an instructions file at the root of the repository (AGENTS.md, CLAUDE.md and so on).
  • Put in what the tool can’t guess: commands, house rules, areas it must leave alone.
  • A short, current file beats a long one nobody reads, and it never replaces CI.

In our first weeks using AI assistants on WordPress projects, we kept fixing the same things: unescaped output, tests run with the wrong command, an npm package pulled in for a three-line function. The tool wasn’t really the problem; it just didn’t know our rules. Every repository now has an instructions file, and those repetitive fixes have all but disappeared.

Where the file goes

Each tool has its own convention: AGENTS.md is read by several assistants, Claude Code reads CLAUDE.md, and GitHub Copilot reads .github/copilot-instructions.md. Check the docs for whatever your team uses. When several tools are in play, we keep one reference file and point the others at it, so there’s only one version to maintain.

The file is versioned with the code. It changes in the same pull requests and gets reviewed like everything else.

What actually belongs in it

Our rule of thumb: only write down what an experienced developer new to the project couldn’t work out alone. There’s no need to explain what a WordPress hook is; there’s every need to say which command runs the tests. Here’s the baseline we use on a custom theme:

# Instructions for coding assistants

## Project
Custom WordPress theme + `wts-core` plugin (business logic).
PHP 8.2+, WordPress 6.6+.

## Commands
- Tests: `composer test`
- Standards: `composer lint` (WordPress Coding Standards)
- Blocks: `npm run build` (never edit `build/` by hand)

## Rules
- Escape all HTML output (`esc_html`, `esc_attr`, `wp_kses_post`).
- Every admin action checks a nonce and `current_user_can()`.
- No new Composer or npm dependency without asking.
- User-facing strings go through `__()` with the `wts` text domain.

## Do not touch
- `wp-content/plugins/` except `wts-core`
- Migrations already deployed in `wts-core/migrations/`

The security rules are there because forgetting them is the most expensive mistake. The dependency line stops the assistant from adding packages it finds convenient but your team would have to maintain for years.

Mistakes that make the file useless

  • Too long. Past a page, the important instructions get lost. For detailed documentation, link to the relevant file instead of pasting it in.
  • Out of sync with the code. If the file says PHP 8.2 and composer.json says 7.4, the assistant will follow whichever it happens to read. Review the file on every upgrade.
  • Secrets. No passwords, API keys or private admin URLs, ever. The file is read by tools and shared with anyone who has the repository.
  • Wishful thinking. “Write clean code” changes nothing. “Public functions have a test in tests/” can be checked.

Keep it alive, and keep your CI

The best cue to add a rule is a correction you’re making for the second time. Add it, in one line. And remove rules that no longer apply.

An instructions file steers the assistant; it doesn’t guarantee anything. Rules that matter are still checked automatically: PHPCS with the WordPress standards, the test suite, and a human review before every merge. The file cuts down the back-and-forth; CI catches whatever slips through anyway.

FAQ

Should each developer have their own file?

The repository file holds the rules shared by the whole project. Personal preferences, like how much explanation you want, belong in each tool’s own settings, outside the repository.

Is the file useful for new human developers too?

Often, yes. Commands, rules and sensitive areas are exactly what you explain on someone’s first day. Some of our clients use it as an onboarding cheat sheet alongside the README.

Want to bring AI into how your team builds software without lowering the bar? We work with teams on WordPress and SaaS projects, from setting up the tooling to code review.

Share LinkedIn Facebook X WhatsApp
</>

webtestudio

Web agency: custom WordPress sites, premium themes and SaaS software.

Discuss your project →