Skills: giving the agent a procedure
“The model knows about the world. It does not know how your company does things.”
Objective
Understand the difference between memory and procedural knowledge, implement a skill registry with progressive disclosure, and measure the real context savings this separation produces.
6.1 The problem skills solve
A model knows many things, but it does not know how your company does things. It does not know that the weekly report has a specific format, that a deploy requires two approvers, that the database query needs a tenant filter. This knowledge is procedural, specific to your context, and is not in the model’s weights.
The naive solution is to paste everything into the system prompt. It works for two weeks, and then the prompt has fifteen thousand tokens, half of them irrelevant to the current task, and the model starts getting confused.
Skills solve this with a simple idea: separate the index from the content.
6.2 Progressive disclosure
The agent receives, in the prompt, only a list of names and short descriptions. When it decides it needs a skill, it loads it — and only then does the full body enter the context.
Listing 6.1. Skill registry with an index and on-demand loading.
class SkillRegistry:
def __init__(self, root: Path) -> None:
self.root = root
self._cache = {}
for f in root.glob("*/SKILL.md"):
meta, body = parse_frontmatter(f.read_text(encoding="utf-8"))
self._cache[f.parent.name] = (meta, body)
def index(self) -> list[dict]:
"""What goes into the prompt: metadata only."""
return [{"name": n, "description": m.get("description", "")}
for n, (m, _) in self._cache.items()]
def load(self, name: str) -> str:
"""The full body, only when the skill is chosen."""
return self._cache[name][1]
The savings are large and measurable. With a single skill, the difference is already 74%; with twenty, the difference between the index and the total content is the difference between a viable prompt and one that overflows.
Listing 6.2. Output: index versus full content.
A) all skills pasted into the prompt: 560 chars
B) only the index in the prompt: 146 chars
savings: 74%
loaded on demand: 560 chars
6.3 The format of a skill
A skill is a Markdown file with frontmatter. Three things matter in its structure: the description (which is what the agent sees in the index), the procedure (which is what it follows), and the pitfalls (which is what keeps it from repeating your mistakes).
Listing 6.3. File environment-report/SKILL.md.
---
name: environment-report
description: How to inspect the local environment and produce a
short report.
---
# Environment report
## When to use
When the user asks "where am I running" or for an environment summary.
## Procedure
1. Run `python --version` for the interpreter version.
2. Run `pwd` for the working directory.
3. Run `ls` to take inventory of the workspace.
## Output format
Three lines: `python: <version>`, `cwd: <path>`, `files: <n>`.
## Pitfalls
- Do not run destructive commands (`rm -rf`, `format`) — the harness
blocks them and that burns a step of the budget.
- `pwd` in git-bash returns an MSYS path (`/c/...`), not a Windows one.
The pitfalls section is the one people forget and the one that pays off the most. An agent that knows pwd in git-bash returns an MSYS path will not spend three steps trying to understand why the path does not exist on Windows.
The description is what decides loading. The agent chooses to load a skill based only on its name and description. A vague description (“useful for reports”) is never chosen; a precise description (“inspects the local environment and produces a three-line report”) is chosen at the right moment. Investing ten minutes in the description saves many steps.
6.4 Skills as procedural memory
There is an important difference between memory and skill, and confusing them is expensive.
| Memory | Skill | |
|---|---|---|
| Content | Facts about the user, the environment, the project | How to do a task |
| When it loads | Always, on every turn | Only when relevant |
| Size | Must be small | Can be long |
| Example | “The user uses Windows and git-bash” | “How to generate the weekly report” |
Table 6.1. Memory versus skill.
The rule of thumb: if the information applies to every session regardless of the task, it is memory. If it applies to one type of task, it is a skill. Memory that grows too much pushes out useful information; a skill that always loads is memory in disguise.
6.5 Composite skills
A skill can reference auxiliary files — scripts, document templates, checklists. The convention that scales is to treat SKILL.md as the index of the skill itself: the body says what to do and when to use each supporting file, and the agent loads only what it needs.
Listing 6.4. Structure of a skill with supporting files.
skills/weekly-report/
SKILL.md <- index, always loaded if the skill is chosen
references/format.md <- loaded only if the agent will write the report
scripts/collect.py <- executed, not read into context
The third line is the most important and the least obvious: a script does not need to pass through the model’s context. It is executed by a tool, and only the output comes back. A 400-line Python script costs zero tokens; the same logic described in prose would cost thousands.
6.6 When the skill is not loaded
The most common failure mode of a skill system is not loading too much — it is not loading. The agent performs the task the generic way, ignoring that there is an in-house procedure.
Three causes, in order of frequency:
-
Vague description. The model does not associate the current task with the skill.
-
Index missing from the prompt. The agent does not know the skill exists. This happens when the index is loaded only on the first turn and context compaction removes it.
-
Weak instruction. The system prompt says “consider using skills” instead of “before performing a recurring task, check whether there is an applicable skill”.
The second cause connects this chapter to the previous one: the skill index must be treated as an anchor, not as disposable content during compaction.
Common pitfall
Writing a giant skill that covers “everything about deployment”. The agent that loads it receives thousands of tokens of which it will use 10%. The right split is by discrete task:
production-deploy,deploy-rollback,post-deploy-check— each loadable on its own.