Sub topic 14
Testing and iterating on your instructions
This chapter assumes you have written at least one prompt file, custom agent, or skill, and that you know how each one loads into the context window. File names and frontmatter fields differ between tools, so check your tool's documentation for the exact layout.
Instructions are code that a model interprets. A file that reads well can still fail on real tasks. You find out by running it and watching what happens.
Build a small test set
Collect three to six realistic tasks for each artifact. Include three kinds:
- A typical task the artifact was written for.
- An edge case, such as an empty diff or an issue with missing details.
- A task that should not trigger it, which matters most for skills.
Write the expected result next to each task before you run it. Without a written expectation, you will judge each output by how it feels.
Run, observe, change one thing
Start a fresh session for every run. Earlier turns in a session leak into later ones and hide gaps in your instructions. Then follow this loop.
Change one thing per round. If you edit three lines and the result improves, you do not know which edit helped.
Diagnose by symptom
Most failures fall into a few patterns.
| Symptom | Likely cause | Fix |
|---|---|---|
| A skill never activates | The description does not match how users phrase the request | Add the words and situations users actually use |
| A skill activates on unrelated tasks | The description is too broad | Name the task and add "Use when..." limits |
| The output format varies | The format is described loosely | Show an exact example of the output |
| The agent edits files it should not | The tool list allows writes | Remove the write tool instead of asking in prose |
| Steps are skipped | Instructions are long or buried | Shorten, number the steps, and move detail into reference files |
| `$ARGUMENTS` appears literally | The tool uses a different placeholder syntax | Check the tool's documentation |
A restriction enforced by the tool list is more reliable than one stated in the prompt. Use prose for guidance and tool scoping for hard limits.
Check what the agent actually loaded
Many tools show which files, skills, and tools were loaded, and which tools were called. Use that view. If a skill did not load, the problem is its description. If it loaded but the agent ignored it, the problem is the body. These two problems need different fixes.
Tighten, do not accumulate
When a run fails, it is tempting to add a rule. Rules pile up, cost context on every run, and start to conflict. After each fix, reread the file and delete anything the model already does correctly. Prefer one concrete example over three abstract rules.
Record what you learned
Keep the test tasks in the repository next to the artifact, for example in a tests or examples folder. Rerun them when you change the file and when you switch to a new model, because the same wording can behave differently across models.
Exercise
Your changelog-entry skill never runs when a user types "write release notes for this version". Which part of the skill do you change first, and why?
Show answer
Change the description in the SKILL.md frontmatter. The agent decides whether to load a skill from its description, so it needs to include phrases like "release notes", "changelog", and "draft". Then rerun the same request in a fresh session and check that the skill loads.
Exercise
A code-reviewer agent sometimes edits files even though its prompt says "Never modify files". What is the more reliable fix?
Show answer
Remove write tools from the agent's tool list so it has only read, search, and list tools. A tool restriction is enforced by the tool, while a prompt rule is only a request the model may ignore.