Chapter 4 · Writing the SKILL.md¶
A SKILL.md has one job: change what the agent does. Two things decide whether it succeeds — whether the skill triggers (the description) and whether the instructions get followed (the body). This chapter gives you the systematic version of both.
The description: engineering a trigger¶
The description is loaded into the agent's context at every session, for every task. The agent scans it and decides: is this skill relevant to what I'm being asked right now? Treat it as a retrieval problem, not a summarization problem.
The formula¶
[What it does] + [When to use it] + [Trigger keywords] + [What NOT to use it for]
Written in third person, under 1024 characters:
description: Extract text and tables from PDF files, fill forms, and merge
documents. Use when working with PDF documents or when the user mentions
PDFs, forms, or document extraction. Do not use for Word or Excel files.
Six rewrites¶
Study the difference — the bad ones describe, the good ones route:
| Weak (describes) | Strong (routes) |
|---|---|
| Helps with documents. | Extract text and tables from PDF files, fill PDF forms, merge PDFs. Use when working with PDFs, forms, or document extraction. |
| Writes commit messages. | Write git commit messages from staged changes following Conventional Commits. Use when the user asks to commit, asks for a commit message, or mentions conventional or semantic commits. |
| Database stuff. | Query and explain the Postgres schema, run read-only SQL analysis, and generate migrations. Use when the user mentions the database, schema, tables, columns, migrations, or asks about stored data. |
| Reviews code. | Review code for security, correctness, and maintainability following team standards. Use when reviewing pull requests, examining diffs, or when the user asks for a code review or a second pair of eyes. |
| Handles deploys. | Deploy the service to production and staging following the runbook: health checks, migrations first, rollback procedure. Use when the user asks to deploy, ship, release, or roll back. |
| Excel helper. | Analyze Excel spreadsheets: create pivot tables, generate charts, clean data. Use when the user mentions Excel, spreadsheets, .xlsx files, or tabular data analysis. |
Trigger hygiene¶
- Include the user's vocabulary. If people say "ship it" and "put it in prod", the deploy skill's description should contain deploy, ship, release, production.
- Lean slightly pushy. Agents tend to under-trigger. Loading a skill that turns out to be unnecessary costs a few hundred tokens; missing one costs the whole workflow. Add "even if they don't explicitly say X" clauses for near-miss phrasings.
- Add negative triggers when skills overlap. If you have both
code-reviewerandsecurity-auditor, each description should say what it's not for, or both will fire on every diff. - No angle brackets. Keep the description plain text — XML tags can break prompt assembly in some agents.
- Don't describe the reader ("I can help you…", "You can use this…"). Third person, always: "Extracts…", "Generates…", "Writes…".
The body: instructions that get followed¶
Be concise — the agent is already smart¶
The context window is shared with the user's task, conversation history, and other skills. Every token you spend explaining what a PDF is competes with the actual work. The default assumption: the agent already knows how to do most things; it's missing your context, not general ability.
# ❌ Padding
PDF (Portable Document Format) files are a common file format that contains
text and images. To extract text from a PDF, you'll need a library. There
are many libraries, but we recommend pdfplumber because...
# ✅ Only what the agent doesn't know
Use pdfplumber for text extraction:
import pdfplumber
with pdfplumber.open(path) as pdf:
text = pdf.pages[0].extract_text()
Imperative voice, with the why¶
Write instructions as commands ("Run git status before staging"). Explain
why when the rule isn't obvious — models follow guidance better when they
understand the reason, and they can apply the reason to cases your rule
didn't anticipate:
# ❌ Enforcement without explanation
NEVER USE --no-verify. ALWAYS RUN TESTS FIRST.
# ✅ The why does the work
Don't bypass hooks with --no-verify: pre-commit hooks are the last line of
defense against broken main, and skipping them moves that cost to everyone
downstream. If a hook is genuinely broken, report it instead.
If you find yourself writing all-caps MUSTs, the rule probably needs a better explanation, not louder formatting.
Choose the right degrees of freedom¶
Match how tightly you specify a step to how fragile it is:
| Freedom | Format | Use when | Example |
|---|---|---|---|
| High | Prose guidance | Many valid approaches; context decides | Code review guidelines |
| Medium | Pseudocode, templates, checklists | A preferred pattern with acceptable variation | Report structure |
| Low | Exact commands, scripts | Correctness critical; one right way | Database migrations, release steps |
Over-specifying flexible tasks produces rigid, unusable output; under-specifying fragile tasks produces improvisation. Misallocation here is the root cause of most "the agent ignored my instructions" complaints.
Workflow pattern¶
For multi-step procedures, number the steps and make the expected outcome of each explicit. Checklists help the agent track long workflows:
## Release workflow
Copy this checklist and track progress:
- [ ] 1. Verify CI is green on main
- [ ] 2. Run scripts/generate_changelog.py --write
- [ ] 3. Bump version in pyproject.toml
- [ ] 4. Tag and push: git tag v$VERSION && git push --tags
- [ ] 5. Confirm the deploy health check passes
Examples beat rules¶
If output quality depends on format or taste, show a literal example — one example outperforms a paragraph of description:
## Commit message format
Input: "Added JWT authentication with login endpoint and token validation"
Output:
feat(auth): implement JWT-based authentication
Add login endpoint and token validation middleware so sessions survive
server restarts without the old cookie fallback.
Feedback loops for fragile steps¶
When a step can fail silently, make validation a mandatory step in the body, with the recovery procedure attached:
1. Generate the output file.
2. Validate immediately: python scripts/validate.py output/
3. If validation fails: read the reported violations, fix the file, and
re-run validation. Only proceed when it exits 0.
Chapter 6 shows the scripts these loops call.
Frontmatter beyond name and description¶
---
name: changelog-forge
description: >
Generate CHANGELOG.md entries from git history using a deterministic
script. Use when preparing a release, writing release notes, updating a
changelog, or when the user mentions changelog or release notes.
license: MIT
compatibility: Requires git and Python 3.9+
metadata:
author: paladini
version: "1.2.0"
---
license— a short license name or pointer to a bundled file. Set it whenever you distribute skills.compatibility— only when there are real environment requirements ("Requires git and Python 3.9+"). Most skills don't need it.metadata— an arbitrary string→string map. Putauthorandversionhere; registries and your future self will thank you.allowed-tools(experimental) — pre-approves specific tools so the agent doesn't prompt for permission mid-workflow:allowed-tools: Bash(git log:*) Bash(git diff:*) Read. Support varies by agent; treat it as an optimization, not a security boundary.
A canonical skeleton¶
Steal this structure — it maps to how agents actually consume the file:
---
name: my-skill
description: [what + when + keywords]
---
# My Skill
One-paragraph purpose statement.
## Workflow
1. Step with expected outcome.
2. Step, with the script or reference it uses.
3. Validation step, with failure handling.
## Rules
- Boundaries: what the skill must never do.
## Examples
One realistic input → expected output pair.
## Reference files
- Read [references/DEEP_TOPIC.md](references/DEEP_TOPIC.md) when [condition].
Chapter 5 · Progressive Disclosure — what
to move out of the body and into references/.