Sub topic 13
Choosing the right mechanism
This chapter assumes you have read the earlier chapters on persistent project instructions, reusable prompt files, custom agents, and agent skills. You should know what a context window is, and you should be comfortable with Markdown files that carry YAML frontmatter. File names and frontmatter fields differ between products, so check your tool's documentation before copying any example.
The decision in one sentence
You now have four ways to give an agent instructions. Persistent project instructions (for example an AGENTS.md file) are always loaded. Prompt files are loaded when you invoke them. Custom agents change who is working and what that worker may touch. Skills are loaded when the agent decides they match the task.
The right choice depends on three things: who starts the work, what the work needs to be allowed to do, and how much text must sit in the context window before it is needed.
What each mechanism is good at
| Mechanism | Who triggers it | What it controls | Context cost |
|---|---|---|---|
| Persistent instructions | Always on | Project-wide facts and rules | Paid on every request |
| Prompt file | You, by name | One task: steps and output format | Paid only when invoked |
| Custom agent | You, or another agent that delegates | Role, tools, permissions | Role prompt loaded when the agent runs |
| Skill | The agent, based on its description | A repeatable capability, plus files | Description always; body and files on demand |
Keep this table in mind while reading the rest of the chapter. Each row answers a different question, so the mechanisms are not interchangeable.
Questions to ask, in order
1. Does every task need this?
If a rule applies to nearly every request (the build command, the test command, the naming convention), it belongs in persistent project instructions. Anything else should stay out of that file. Persistent text is paid for on every request, and it competes with your actual task for attention.
2. Do you want to start it yourself?
If the workflow is something you deliberately kick off, such as "review my staged changes" or "fix issue 214", use a prompt file. You choose the moment, and the instructions load only then. A prompt file is also the simplest option, so prefer it when it is enough.
If the workflow takes an input, such as an issue number, use the placeholder syntax your tool supports. The $ARGUMENTS example from the earlier chapter is one common form.
3. Does the work need different permissions or a different role?
If the answer is yes, you need a custom agent. A prompt file can say "do not edit any files", but that is only a request in text. An agent with a tool list that contains only read tools cannot edit files at all, because the edit tool is not available to it. Use an agent when:
- the work should be read-only, or limited to one folder or command set
- the role is distinct enough that a long, focused prompt helps (a reviewer, a documentation writer, a security auditor)
- you want the work done in a separate context so that its details do not fill your main conversation, in tools that run agents that way
4. Should the agent pick it up by itself?
If you want the capability to appear whenever a matching task comes up, without you remembering to call it, use a skill. The agent sees only the name and description of each skill at first. It reads the full SKILL.md when the task matches, and it opens bundled files only when the instructions point to them. This makes skills cheap to keep installed and suited to large or detailed procedures with scripts and reference files.
The trade-off is control. A skill runs only if the agent judges the description relevant. A description that is vague or too narrow means the skill is skipped, or fires at the wrong time.
The decision flow
The flow is a starting point. Real workflows often end up as a combination, as the next section shows.
Combining mechanisms
The mechanisms work together. Some common pairings:
- Prompt file that calls an agent. A
/reviewprompt file starts the work, and a read-onlycode-revieweragent does it. You get an explicit trigger and enforced permissions. Whether a prompt file can select an agent depends on your tool. - Agent that uses skills. A documentation agent has write access to the
docsfolder. Achangelog-entryskill holds the format rules. The agent loads the skill only when it writes a changelog. - Persistent instructions that point to skills. A one-line note in
AGENTS.mdsuch as "release steps are in the release skill" costs almost nothing and helps the agent find the skill.
Worked example: three workflows
Suppose your team has three recurring jobs.
- Pre-commit review. You run it before every commit, you want the same output format each time, and it must not change files. This is a prompt file for the steps and format, paired with a read-only agent if you want the "no edits" rule enforced rather than requested.
- Changelog entries. Anyone might ask for one in many ways ("draft release notes", "add this to the changelog"). The format rules are long and live in a reference file. This is a skill, with a description that names those phrasings.
- "We use pnpm, not npm." Every task needs it, and it is one line. This is persistent project instructions.
Notice that the first two could technically be written as the wrong mechanism and still partly work. A changelog prompt file works if you remember to call it. A review skill might trigger, but you lose a predictable trigger. The wrong choice usually costs you reliability or context, not correctness.
Common mistakes
- Putting everything in persistent instructions. The file grows, every request pays for it, and important rules get buried. Move task-specific procedures into prompt files or skills.
- Relying on a prompt to enforce limits. "Never modify files" is a request. If it matters, remove the write tools.
- Creating an agent for a task that needs no special role or permissions. An agent adds setup to maintain. If only the steps differ, a prompt file is enough.
- Writing a skill with a vague description. "Helps with documents" will either never match or match everything. Name the task and the phrases a user would say.
- Duplicating the same rules across mechanisms. When a convention changes, you have to update it in several places, and the copies drift apart. Keep one source of truth and point to it.
- Assuming features are the same across tools. Some products have no skills, no prompt-file arguments, or different agent formats. Verify what your tool supports before you design around a feature.
Checking your choice
After you pick a mechanism, test it against realistic requests, as the next chapter describes. Signs that you chose wrong:
- You keep forgetting to invoke a prompt file. Consider a skill.
- A skill fires when you did not want it. Consider a prompt file, or narrow the description.
- The agent changes files it should not touch. Consider a custom agent with a restricted tool list.
- Responses ignore your rules in long sessions. Check whether too much is loaded permanently.
Exercise
Your team wants a "deploy to staging" procedure. It has eight steps, runs a script, and changes real infrastructure. Which mechanism would you choose, and why?
Show answer
A prompt file, or a custom agent invoked by name, with the script kept in the repository. Deployment has side effects, so a person should decide when it runs, which rules out automatic selection by a skill. If you want to limit which commands can run, use a custom agent with a restricted tool list. A skill is acceptable only if your tool lets you disable automatic invocation.
Exercise
You want an agent to summarize pull requests without any chance of editing code. Is "Do not edit files" in a prompt file enough? What would you use instead, or in addition?
Show answer
It is not enough, because it is only a text request that the model can fail to follow. Use a custom agent whose tool list has only read tools such as Read, Grep, and Glob. The agent then has no edit tool to call. You can still keep the "do not edit" sentence as a clear statement of intent.
Exercise
A 40-line section of AGENTS.md explains how to write database migrations. Only about one task in ten involves migrations. Where should it move?
Show answer
Move it into a skill (or a prompt file if you prefer to trigger it yourself). Only the short description then stays in context on every request, and the full procedure loads when a migration task appears. Leave a one-line pointer in AGENTS.md if you want to help the agent find it.