Skip to content

Course · Claude Code · Skills

Package a repeated procedure as a skill the agent runs itself

Some work you hand the agent is the same every time. Take the small TypeScript payments service this course uses as its running example (every page restates the facts it needs). Its CLAUDE.md already legislates most of a branch wrap-up: run tests with npm test, never commit without passing tests, every bug fix must include a regression test. Its package.json adds lint and build scripts, and build runs tsc, so it doubles as the typecheck. So when a branch is ready, the ritual is fixed - test suite, regression test, lint, typecheck - and you narrate it, in full, at the end of every task. Narrating it is cheap once. Narrating it every time, and forgetting a step some of the time, is the cost this chapter removes.

There are two kinds of saved work in Claude Code, and it helps to tell them apart before writing anything. In the payments example, a recurring ledger audit was saved as a subagent: a markdown file in .claude/agents/ naming the tools and instructions a separate worker runs in its own context. That retired the briefing - the paragraph you used to type before every audit - but every run still begins with you. Nothing in that file notices on its own that a change touches the ledger and an audit is due. A skill is the other kind: a procedure that notices its own moment. You say I think this is ready and the agent runs the wrap-up without being asked which procedure to use.

A skill is a folder with a SKILL.md inside it. YAML frontmatter says when to use it; the markdown body says what to do. Claude Code loads a listing of skill names and descriptions into context so the agent knows what is on the shelf; a skill’s body loads only when invoked. When your request matches a description, the agent pulls in its instructions and follows them - no slash command typed, no procedure re-pasted. The skills page documents the mechanism; this chapter walks one procedure through it.

The listing is a budget, not a guarantee. Every skill name is always present, but the text under it is capped: the description and the optional when_to_use field together are truncated at 1,536 characters per skill by default. Separately, the listing itself has a budget that scales at about one percent of the context window; when it overflows, Claude Code drops descriptions starting with the skills you invoke least. A skill marked disable-model-invocation: true stays out of the listing entirely until you run it by hand.

So the cost model: a name always in view, a description usually in view, a body that costs nothing until its moment arrives. This is the course’s context principle at work - a skill makes task-specific guidance available when needed, not in every turn. A repeated procedure fits that model. A fact you need in every turn does not - which is why facts live in rules instead.

Across three lessons, one wrap-up becomes a thing the agent owns:

  • Write the skill - the folder, the SKILL.md, and four steps phrased so a failure stops the run instead of slipping past it.
  • Make it fire at the right moment - the description is the trigger surface; tune it until the ritual activates when a branch is ready and stays quiet otherwise.
  • Choose the right container - skill, slash command, or subagent: which one a given piece of work actually wants, and when the answer is rules or neither.

By the end, you stop narrating the wrap-up, and it stops being a list you can forget half of. Start by writing the skill.