Skip to main content
Back to Blog
AIDevOpsDocumentation

The AGENTS.md Protocol: Bridging the Human-Machine Gap

Usman Ali Qureshi

Usman Ali Qureshi

27 Jan, 2026 · 4 min read

Your AI copilot keeps making weird suggestions? Probably because it doesn't really know your project. Here's how one file fixes that.

Digital handshake between code documentation and AI

Something weird is happening in software development right now. We're not just writing code anymore. We're spending a surprising chunk of our time explaining our code to AI tools.

You've experienced it. You open Cursor or Windsurf or Copilot, ask it to refactor a simple function, and it suggests a library you've never heard of. Or it rewrites your component using a state management pattern your team explicitly banned three months ago. Or it creates an API route in a project that's configured for static export.

The AI isn't stupid. It's just working blind. It has no idea about the decisions your team already made.

Your README Isn't Enough

Every AI coding assistant reads your README when it starts a session. But READMEs are written for humans. They're full of implied context, unstated assumptions, and things that "everyone on the team knows" but nobody bothered to write down.

Stuff like: "We don't use API routes because we deploy as a static export." Or: "The WordPress API v1.0 is broken for installation counts, always use v1.2." Or: "Don't add client-side state management. We do everything through React Server Components."

These are constraints that live in a senior engineer's head. They get passed down through code reviews and Slack messages and pairing sessions. An AI assistant has access to none of that tribal knowledge.

AGENTS.md is basically a README written specifically for your AI teammates.

It's a high-density context file that gives the AI exactly what it needs to make good decisions about your codebase. You're separating the "what" (your source code) from the "how" and "why" (your constraints, conventions, and architectural decisions).

What Good Context Looks Like

The whole point is to write down the stuff that humans absorb through osmosis but machines need stated explicitly.

Three principles guide what goes into it:

Translation. Take your human goals (business requirements, architecture decisions, deployment constraints) and express them as machine-readable rules. "We deploy to a subdirectory" becomes "all asset paths must account for the /freshstart/ basePath."

Token efficiency. Don't dump 5,000 words of scattered documentation and hope the AI figures it out. Give it 50 focused lines of what actually matters for making correct coding decisions. AI context windows are limited. Every word should earn its spot.

Portability. This file lives in your repo, not in some IDE-specific config. If you switch from Cursor to Windsurf to something else entirely, your project context travels with the codebase. No reconfiguring, no re-prompting.

A Practical Example

Start with hard rules, then add nuance. Don't overwhelm it. Here's roughly how I structure mine:

# AGENTS.md

## 1. Mission
"This is a Next.js 16 portfolio built for static export.
We prioritize performance and minimal client-side JavaScript."

## 2. The Stack (Non-Negotiable)
- **Framework**: Next.js 16 (App Router)
- **Styling**: Tailwind CSS (Utility-first)
- **State**: React Server Components heavily preferred over client state.

## 3. Don't Do This
- No API Routes. We're static export.
- No useEffect for data fetching. Use fetch() in RSCs.
- No new dependencies without asking.

## 4. Things That Trip People Up
- "We deploy to a subdirectory. Image paths need to account
   for this basePath."
- "The WordPress API v1.0 is broken. Always use v1.2."

Notice the structure. Mission first so the AI understands the big picture. Then the non-negotiable constraints. Then the gotchas that would otherwise waste time debugging.

I keep mine under 100 lines. If it's getting longer than that, you probably need to refactor the document, not add more to it.

Does It Actually Make a Difference?

Yeah. Noticeably.

When I added an AGENTS.md to a Django project I was consulting on, the AI stopped suggesting synchronous views for my async-only codebase. That was a suggestion it had been making on almost every generation before.

In a Flutter project, it stopped mixing GetX and Riverpod patterns in the same codebase. It finally understood that we'd picked Riverpod and committed to it.

In my own portfolio site (this one), it stopped trying to create API routes for the contact form. It understood that we're static export and the email handling goes through a PHP script on the server.

The AI goes from acting like a random contractor who just walked in off the street to acting like someone who's actually read the onboarding docs. That's a massive difference when you're using AI assistance for hours every day.

Context Engineering Is the Next Skill

We spent the last two years talking about prompt engineering. Write the right prompt and get better output. That's fine for one-off conversations, but for codebase-level assistance, prompts are too ephemeral. They disappear when the session ends.

What we're moving toward is context engineering. Setting up persistent, structured context that shapes every interaction the AI has with your project. Your code is the text. AGENTS.md is the subtext. By making that subtext explicit, you're giving the AI a foundation that sticks around.

Don't let your project be a mess of scattered configs and assumed knowledge. Write it down. Keep it in the repo. Update it when decisions change.

Your AI tools will produce better code. And honestly, the next human developer who joins the project will thank you too. Good documentation has never hurt anyone.

References:

Working on a WordPress project?

Let's talk about what you're building.

I'm available for custom plugin development, performance optimization, and headless WordPress projects.