Claude Code Building a Skill


This entry is part 7 of 7 in the series Claude Code

In an earlier post, we met skills: written procedures that Claude follows when a task comes up. In this post, we’ll look at one real skill in detail: what’s in it, why each part is there, and how it gets better over time. The example comes from our small sales pipeline app, a skill for adding a new company.

When is a skill worth writing?

Not every task needs a skill. Write one when:

  • you’ve done the same multi-step task with Claude several times
  • you keep giving the same instructions or making the same corrections
  • the task needs doing a particular way every time

In business terms, it’s a standard operating procedure. You write one when a task is repeated often enough that doing it consistently matters.

What’s in a skill

A skill is a folder inside your project’s .claude\skills folder. The folder’s name becomes the skill’s name. Ours looks like this:

.claude\skills\add-company\
    SKILL.md
    scripts\
        company_lookup.py

SKILL.md holds the instructions. The scripts folder holds a small helper program the skill uses. A skill can be just the one file; extra files are optional.

The description: when to use it

The top of SKILL.md has a short header. The most important line is the description:

---
name: add-company
description: Research and draft a new company for the sales pipeline,
  then check it after I enter it. Use whenever I name a company I want
  added ("how about X?", "add X", "is X in the pipeline?"), or ask for
  companies in a town or an industry.
---

Claude reads only the description up front, and uses it to decide whether a request matches the skill. So the description lists the actual phrases I tend to use. “How about Harbourview Bakery?” doesn’t contain the word “add,” but the description tells Claude that it means the same thing.

Ground rules: what Claude must and mustn’t do

The instructions start with a few rules that apply to the whole task:

## Ground rules
- I enter the data myself through the app's forms. Don't write to
  the database.
- Don't invent facts. Every name, address and website must come from
  a source you found. If sources disagree, say so and leave it out.

The first rule is a choice, not a limitation. Claude could save the company directly, but entering it myself means I also test the app’s forms every time. A skill is where you decide which parts of a job the agent does and which parts you keep.

The second rule matters for any research task. An AI that fills in a plausible-sounding address is worse than one that says “I couldn’t confirm the address.”

The steps

Next come the steps, in order:

## Steps
1. Check for duplicates. Run the lookup script with a few pieces of
   the name and the website. If there's a match, ask whether to update
   the existing record instead.
2. Research. Search the web. Find the official name, website, street
   address and what the company sells.
3. Draft the entry as a table I can copy field by field, with a short
   list of sources.
4. After I save it, run the lookup script again and check every field
   was filled in.

Notice that the skill checks before and after. Step 1 prevents duplicates, and step 4 catches anything that went wrong when the entry was saved. It’s the plan-do-check-act loop again, written into the procedure.

Helper scripts

Step 1 runs company_lookup.py, a short Python program that searches the database for a name. Claude could write a new database query every time, but a tested script gives the same reliable answer each time and is faster. The script only reads the database; it can’t change anything.

You don’t need to write the script yourself. Ask Claude: “Write a small script for this skill that searches the companies table by name, read-only.”

Let the skill learn

The best skills grow. Each time something goes wrong or I correct Claude, the lesson goes into the skill so it doesn’t happen again. A few lines from mine:

- Include the state in searches: "Springfield" alone returns
  dozens of towns.
- Leave latitude and longitude for me; don't guess coordinates.
- If a company I say I added isn't in the database, ask whether I
  entered it on the live site by mistake.

None of these were in the first version. Each one came from a real mistake, and each one means that mistake doesn’t happen again.

Using the skill

There are two ways:

  • Type /add-company in the Claude prompt box.
  • Just ask: “How about Harbourview Bakery?” Claude matches it to the description and follows the skill.

Either way, Claude loads the full instructions only when it needs them, so a skill costs almost nothing until it’s used.

Let Claude write the first draft

You don’t have to write a skill from scratch. The easiest way is to do the task with Claude a couple of times first, then say: “Turn what we just did into a skill.” Claude writes the SKILL.md from the session: the steps, the checks and the corrections you made along the way.

Then read it carefully, like any other change. It’s your procedure, so make sure it says what you want. And when you notice yourself correcting Claude during the task, tell it: “Add that to the skill.”

Project skills and personal skills

A skill in your project’s .claude\skills folder works only in that project, and it’s saved in git with the rest of the project. If you have a skill you’d use everywhere, such as how you like commit messages written, put it in the skills folder inside the .claude folder in your user folder instead. It’s then available in all your projects.

Leave a comment