ai ai-agents agents-md delegation methodology

Building Your Own AI Agents: Templates and Patterns

Once you delegate the same task more than twice, stop re-prompting and define an agent. The anatomy of a reusable agent template, and the patterns worth copying.

4 min read

The third time you explain the same role to your AI, you don’t need a better prompt. You need an agent definition.

You’ve felt this. You open a fresh chat, paste in the same context you pasted yesterday, re-explain who the AI should be and what it should watch out for, and only then get to the actual task. That re-explaining is wasted motion. The fix is to write the role down once, as a reusable definition, and hand it the same brief every time.

This piece assumes you already know what an agent is. If you don’t, start with What Are AI Agents and What Are Workflows and Agents. Here we’re past the what. The question is how to template one so the same kind of work gets delegated the same way, every time, without you rebuilding the setup from scratch.

The anatomy of an agent template

A good agent definition has five parts. Miss one and the agent drifts.

Role and purpose. One or two sentences on what this agent is for. Not “a helpful assistant” but “reviews draft contracts and flags anything that commits us to a deadline, a payment, or a liability.” Specific enough that you’d know if it strayed.

Scope. What it owns, and just as importantly, what it doesn’t. “You review the contract language. You do not negotiate, send anything, or make commercial decisions.” Scope is what keeps an agent from helpfully doing something you never asked for.

Tools. What it’s allowed to use. A research agent might search the web and read files. A reviewer should probably read but not write. Naming the tools is naming the blast radius.

Guardrails. The rules learned from getting burned. This is where you transfer your scars, the same idea from Your Agents Know What You Tell Them. “Never claim a number you haven’t verified. If a clause is ambiguous, stop and ask rather than guessing.” Guardrails are the difference between an agent you trust and one you double-check.

The handoff. What “done” looks like, and what the agent gives back. “Return a list of flagged clauses with the risk and a suggested rewrite. Do not mark the review complete if anything is unresolved.” Define done, or the agent will define it for you.

AGENTS.md: the standard for writing this down

You don’t have to invent a format. AGENTS.md is an open standard, used by tens of thousands of projects, for exactly this: a plain file that tells any AI agent how to behave in a given project. Conventions, guardrails, what to run, what to never touch. If your agents operate in a codebase or a repo, this is where the definition lives so every tool reads the same brief.

The principle generalizes past code. Anywhere you have AI doing repeatable work, a written definition beats re-explaining it each session.

Patterns worth templating

Three shapes come up again and again.

The specialist. One narrow job, done well. A specialist agent has a tight scope and a deep brief: the contract reviewer, the changelog writer, the data cleaner. Most of your agents should be specialists. Narrow is reliable.

The reviewer. An agent whose only job is to check another agent’s output, adversarially. “Find what’s wrong with this before it ships.” A reviewer with a skeptical brief catches the confident mistakes a generator makes. Templating the reviewer separately keeps it honest, because it isn’t invested in the work it’s checking.

The orchestrator. Coordinates specialists. It doesn’t do the work itself, it decides which specialist handles what, in what order, and assembles the result. Worth templating only once you have specialists to coordinate. Start here too early and you’ve built a manager with no team.

A starter template

Copy this and fill in the brackets:

# Agent: [name]

Purpose: [one or two sentences - what this agent is for]

Scope:
- You own: [the specific work this agent does]
- You do NOT: [adjacent things it must not do]

Tools you may use: [search / read files / write / send / none]

Guardrails:
- Never [the mistake that has burned you before]
- If [ambiguous situation], stop and ask rather than guessing
- Always flag when [something needs human sign-off]

Done means: [what a complete result looks like and what you return]
Do not mark done if: [the conditions that require escalation instead]

When not to build an agent

Templating has a cost. Skip it for genuine one-offs. If you’ll do this task once, just prompt it.

And be careful with autonomy where a wrong action is expensive. An agent that drafts is low-risk. An agent that sends, pays, deletes, or publishes without a human checkpoint is a different thing. This is the premature autonomy trap covered in What Are Workflows and Agents: the more an agent can act on the world unsupervised, the more its guardrails and handoff have to earn that trust. Build the definition first. Loosen the leash only once it’s proven.

A templated agent is the building block. The next step is wiring it into work that runs without you starting it each time, which is where automating work with AI picks up.