Skip to content
mentoor

Topic 2 of 5 · 5 min read

Writing a SKILL.md that triggers reliably

Goal: Rewrite a skill's description and body so the agent loads it for the intended tasks, follows its steps and runs its bundled script instead of improvising.

A good skill has a description that says what it does and when to use it, a body of short numbered steps, and a script for anything that must be exact. The agent picks a skill by reading the description, so the description does most of the work.

Check yourself · 1 of 3

Which part of a skill most directly decides whether the agent loads it for a task?

Choose one answer

Why it matters

An agent sees dozens of descriptions and decides, task by task, which to load. If yours reads "Helps with releases", it competes with everything else release-related and often loses. If it names the trigger, the agent has a clear test. The body then decides whether the agent follows your process or invents its own.

How to write it

1. The description names the job and the trigger. Say what the skill produces and which requests should activate it. Include the words people actually use.

2. The body is a procedure, not an essay. Numbered steps, each an action with a visible result. State the output format. Say what to do when something fails.

3. Put exact work in a script. Models are good at judgement and unreliable at arithmetic, sorting and string formats. If a step is deterministic, such as listing merged pull requests since the last tag, write scripts/collect_prs.py and tell the agent to run it. The script gives the same result every time.

4. Push detail into reference files. The style guide, the full API table and rarely used edge cases go in references/. The body says when to read each one: "If the release includes a breaking change, read references/breaking.md."

5. Keep the body short. If it grows past a few hundred lines, split it. Everything in the body is in context once the skill loads.

Before and after

---
name: release-notes
description: Helps with releases.
---
Write good release notes. Be clear and concise.

The agent has no trigger and no process. It will improvise a different format each time.

---
name: release-notes
description: Write release notes for a tagged version from merged pull requests. Use when asked for release notes, a changelog entry or "what shipped in vX".
---
1. Run `python scripts/collect_prs.py --since-last-tag` and read its JSON output.
2. Group items under Added, Changed, Fixed using the PR labels.
3. For any item labelled `breaking`, read `references/breaking.md` and follow its wording.
4. Write the notes to `CHANGELOG.md` in the format of the newest existing entry.
5. If the script exits with an error, stop and report it. Do not guess the PR list.

What goes wrong

  • Describing the skill, not the trigger. "A skill about changelogs" does not tell the agent when to use it.
  • Steps that say "be careful". Vague advice gets vague results. Write what to check and how.
  • Letting the model do what a script should. Counting commits by hand produces a plausible wrong number.
  • One giant body. Long text dilutes the steps that matter and costs context on every use.

Examples

Fixing a vague description

Weak: description: Helps with databases.

Better: description: Write and review SQL migrations for our Postgres schema. Use when asked to add, rename or drop a column or table, or when a migration file is changed.

The second names the artefact (migrations), the database, and the phrases that should trigger it. It also states a second trigger, a changed migration file, which the first version would miss.

Moving a calculation into a script

A skill says "work out the next version number from the commit messages". The agent counts by eye and gets it wrong on a long history.

Fix: add scripts/next_version.py that reads the git log and prints the version. The step becomes "Run python scripts/next_version.py and use its output." The judgement stays with the model; the arithmetic does not.

Key points

  • The description decides whether the skill loads, so it should say what the skill does and which requests should trigger it, in the words people use.
  • The body works best as short numbered steps with a defined output and an instruction for the failure case.
  • Deterministic work such as listing, counting or formatting belongs in a bundled script that the steps tell the agent to run.
  • Long or rarely used detail belongs in reference files, with the body saying exactly when to read each one.
  • A skill body stays in context once loaded, so keeping it short protects the rest of the task.

Common mistakes

  • Writing a description that explains the skill's topic but never says when to use it, so the agent has no trigger to match.
  • Filling the body with general advice such as 'be thorough' instead of numbered steps with checkable results.
  • Asking the model to do counting, date maths or exact formatting when a bundled script would give the same answer every time.
  • Putting every detail in SKILL.md instead of reference files, which makes the loaded skill long and hides the key steps.

Check yourself · 2 of 3

A skill step reads: 'Count the commits since the last tag and compute the next version.' What is the best improvement?

Choose one answer

Check yourself · 3 of 3

Which description is most likely to make the skill trigger when someone asks for a changelog entry?

Choose one answer

Practice items, not counted towards your mastery.

Start here