Your course progress0 of 14 chapters

Chapter 11

Custom Skills and Automation

In chapter 10 we briefly touched on skills. In this chapter we go deep: how to build "work recipes" Claude can trigger on its own, pass them arguments, feed them live data from the project, and limit what they're allowed to do.

A skill is basically a written work recipe. Instead of explaining to Claude every time "this is how we review code here", you write it once in a file. From then on, Claude knows to pull out the recipe when it's relevant, and you can trigger it with a short command like /review-pr.

Skills vs. everything else

Regular requestCLAUDE.mdSkillMCP
What it isA one-off messageStanding rulesA written workflowA connection to an external tool
When it loadsWhen you write itAlways, in every conversationOnly when neededWhen Claude uses the tool
What it gives ClaudeA taskContext and rulesHow to do a specific taskThe ability to touch another system
Example"Review the code""Git messages in the imperative""This is how we review a PR, in 7 steps""Access to Notion"

Where skills live

LocationPathAvailable to
Personal~/.claude/skills/<name>/SKILL.mdYou, in all projects
Project.claude/skills/<name>/SKILL.mdEveryone working on the project (saved in Git)
Plugin<plugin>/skills/<name>/SKILL.mdWherever the plugin is enabled, named /plugin-name:skill-name

Each skill is a folder. The folder name is the command name. Here's a project with three skills:

Folder structure
my-project/
└── .claude/
    └── skills/
        ├── review-pr/
        │   ├── SKILL.md          ← required: the instructions
        │   └── checklist.md      ← loaded only when needed
        ├── generate-tests/
        │   ├── SKILL.md
        │   └── examples/
        │       └── sample.test.ts
        └── deploy/
            ├── SKILL.md
            └── scripts/
                └── smoke-test.sh ← a script that runs, not read

The anatomy of SKILL.md

A SKILL.md file has two parts: a frontmatter between two --- lines, with settings, and a body with the instructions themselves.

.claude/skills/summarize-changes/SKILL.md
---
name: summarize-changes
description: Summarizes uncommitted changes and flags anything risky. Use when the user asks what changed, wants a commit message, or asks to review their diff.
---
 
## Current changes
 
!`git diff HEAD`
 
## Instructions
 
Summarize the changes above in two or three bullet points, then list any
risks you notice such as missing error handling, hardcoded values, or tests
that need updating. If the diff is empty, say there are no uncommitted changes.

(This is an example from the official docs. The !`git diff HEAD` line is special, and we'll explain it below.)

The important frontmatter fields

All fields are optional, but description matters a lot: Claude uses it to decide when to use the skill.

FieldWhat it does
nameThe command name. Defaults to the folder name
descriptionWhat the skill does and when to use it. This is what Claude reads to decide
when_to_useAdditional triggering context, appended to the description
argument-hintA hint shown in autocomplete, for example [file-path]
argumentsNames for arguments, so you can use them as $name
disable-model-invocationtrue = only you trigger it. Claude won't trigger it on its own
user-invocablefalse = only Claude triggers it. It won't appear in the / menu
allowed-toolsTools allowed without asking while the skill runs
disallowed-toolsTools blocked while the skill is active
model / effortA model or effort level for this turn
context: forkRuns the skill in a separate subagent (chapter 12)
agentWhich kind of subagent, together with context: fork
pathsThe skill loads automatically only when working on matching files
shellbash (default) or powershell, for running injected commands

When Claude triggers it, and when you do

There are two ways to trigger a skill:

  • Automatically: Claude reads the descriptions, and if your request matches, it loads the skill on its own.
  • Manually: type / and the skill's name, at the start of the message, optionally with arguments. A name in the middle of a sentence doesn't trigger the skill, it only gives Claude permission to use it.
Frontmatter settingYou can triggerClaude can triggerGood for
(default)✔✔Most skills
disable-model-invocation: true✔✘Actions with consequences: deploying, sending, deleting
user-invocable: false✘✔Background knowledge only Claude needs, like writing conventions

Arguments: passing information to a skill

When you trigger a skill manually, everything you write after the name is passed to it as arguments:

VariableWhat it containsExample: /generate-tests lib/servings.ts unit
$ARGUMENTSAll the text after the skill namelib/servings.ts unit
$0 or $ARGUMENTS[0]The first argumentlib/servings.ts
$1The second argumentunit
$nameA named argument, per the arguments field

A few notes:

  • An argument with spaces? Wrap it in quotes: /generate-tests "lib/my file.ts".
  • If the skill doesn't use any variable, Claude Code appends the arguments to the end of the instructions on its own.
  • To write a literal dollar sign, put a backslash before it: \$1.00.

Injecting live data: !`command`

This is one of the most powerful capabilities. A line of the form !`git status` inside SKILL.md runs before Claude sees the skill, and its output replaces it. That way the skill reaches Claude already containing up-to-date information, without it having to search.

One-line injection
## Current branch
!`git branch --show-current`
 
## Changes vs. main
!`git diff main...HEAD --stat`

Building three skills

1. /review-pr: a code review to your standard

Claude Code already has a built-in /code-review. So why build your own? Because every project has things that matter to it: on the recipe site, for example, accessibility for older users and readable copy.

.claude/skills/review-pr/SKILL.md
---
name: review-pr
description: Review the current branch against main using this project's checklist (accessibility for older users, readable copy, mobile layout). Use when the user asks for a review, before opening a PR, or before merging.
allowed-tools: Bash(git diff *) Bash(git log *) Bash(npm run build)
disallowed-tools: Edit Write
---
 
## Branch
!`git branch --show-current`
 
## Commits on this branch
!`git log main..HEAD --oneline`
 
## Changed files
!`git diff main...HEAD --stat`
 
## Instructions
 
1. Read the full diff with `git diff main...HEAD`.
2. Run `npm run build` and report whether it passes.
3. Review against [checklist.md](checklist.md).
4. Report findings grouped by severity (high / medium / low),
   each with file and line.
5. Do NOT fix anything. End with a one-line verdict: ready to merge or not.
.claude/skills/review-pr/checklist.md
# Project review checklist
- All user-facing text is clear, plain language.
- Text is at least 18px; buttons have text, not only icons.
- Works on a 375px-wide phone screen.
- No secrets, API keys, or personal data in the diff.
- No new dependencies unless they were discussed.
- No ts-ignore, eslint-disable, or swallowed errors.

Notice three decisions in the file:

  • allowed-tools pre-approves only read and build commands, so the review runs without questions.
  • disallowed-tools: Edit Write guarantees the reviewer won't fix anything during the review. A review should produce findings, not changes.
  • The checklist in a separate file loads only when the review runs. That keeps SKILL.md short and focused.

To trigger it:

Inside Claude Code
/review-pr

2. /generate-tests: tests for a file, with an argument

.claude/skills/generate-tests/SKILL.md
---
name: generate-tests
description: Generate unit tests for a given file, following the project's existing test style. Use when the user asks to add or write tests for a file or function.
argument-hint: [file-path]
---
 
Write tests for: $0
 
1. Read $0 and list every exported function and its edge cases
   (empty input, zero, very large numbers, missing fields, non-English text).
2. Look at examples/sample.test.ts and match its style exactly.
3. Write the tests next to the file, as <name>.test.ts.
4. Run only the new test file. If a test fails, decide whether the test
   or the code is wrong. Never weaken a test just to make it pass.
5. Summarize: how many tests, what they cover, what failed and why.

To trigger it:

Inside Claude Code
/generate-tests lib/servings.ts

3. /deploy: deploying, manual trigger only

.claude/skills/deploy/SKILL.md
---
name: deploy
description: Ship the current main branch to production through Vercel
disable-model-invocation: true
allowed-tools: Bash(npm run build) Bash(git status *) Bash(git log *)
---
 
Deploy checklist:
 
1. Confirm we are on main and the working tree is clean (`git status`).
   If not, STOP and tell me what is uncommitted.
2. Run `npm run build`. If it fails, STOP and show the errors.
3. Show me the commits that will go live (`git log origin/main..HEAD --oneline`)
   and WAIT for my explicit approval.
4. Only after I approve: `git push origin main`. Vercel deploys automatically.
5. Tell me where to watch the deployment, and remind me to run the
   live-site checklist from chapter 9.

Notice:

  • disable-model-invocation: true: only you trigger it. Claude will never decide on its own to deploy.
  • git push isn't in allowed-tools: so the push still asks for approval, even inside the skill. And if you set an ask rule for git push in chapter 8, it keeps working.
  • Explicit stopping points ("STOP", "WAIT"): good skills for sensitive actions include places where they stop and ask.

Permissions and control

ToolWhat it doesWhere
allowed-toolsPre-approves tools while the skill runs. Does not block other toolsIn the skill's frontmatter
disallowed-toolsBlocks tools while the skill is activeIn the skill's frontmatter
disable-model-invocationManual trigger onlyIn the skill's frontmatter
Skill(...) rulesBlock, or require approval for, triggering skills.claude/settings.json
skillOverridesDecide which skills are visible and how.claude/settings.json
disableSkillShellExecutionDisables all injected commands.claude/settings.json

Permission rules for skills are written like all the permission rules from chapter 8:

.claude/settings.json
{
  "permissions": {
    "ask": ["Skill(deploy *)"],
    "deny": ["Skill(dangerous-cleanup)"]
  }
}

Now, every time /deploy is triggered, Claude Code asks for approval, and the dangerous-cleanup skill is blocked entirely.

Let Claude write the skill

You don't have to write skills by hand. Claude knows the format well:

Weak prompt

Make me a skill

Strong prompt

Create a skill called new-recipe in the .claude/skills folder: it takes a recipe as free text or an image, breaks it into the structure in lib/recipes.ts, shows me the result for approval, and only after approval adds it, runs the build and commits to git. The description should make it trigger when I paste a recipe. Explain each frontmatter field you chose.

The strong prompt defines the process, the approval stopping point and when the skill should trigger. “Explain each field” turns it into a lesson.

Writing good skills: five principles

  1. One skill, one task. "PR review" and "writing tests" are two skills, not one.
  2. Only steps in SKILL.md. Background, examples and long lists go in supporting files. The recommendation: under 500 lines in SKILL.md, with the most important things first.
  3. A defined output format. "Report by severity, with file and line" beats "report what you found".
  4. Stopping points for sensitive actions. "STOP" and "WAIT for approval" before anything hard to undo.
  5. Learn from mistakes. Add a learnings.md file to the skill's folder, and ask Claude to update it when something didn't work. Next time the skill will be better.

Community skills

You don't have to invent everything yourself. There are large collections of ready-made skills:

alirezarezvani/claude-skills

A GitHub repository, MIT licensed, with about 390 skills across 20 areas: engineering, marketing, product management, finance and more. Examples of what you'll find there:

SkillWhat it does
skill-security-auditorScans a skill before installing and returns pass / warn / fail
playwright-proWriting browser tests and fixing flaky tests
dependency-auditorChecking packages, licenses and planning upgrades
incident-commanderManaging production incidents and writing a post-incident report
mcp-server-builderBuilding an MCP server from an API spec

You can install through Claude Code's plugin system, or simply copy a single skill's folder into ~/.claude/skills/:

Inside Claude Code
/plugin marketplace add alirezarezvani/claude-skills
/plugin install engineering-skills@claude-code-skills

aitmpl.com (Claude Code Templates)

aitmpl.com is an interactive catalog of skills, agents, commands, settings and MCP servers, based on the open-source project claude-code-templates (MIT license). You can browse the site, or run the command-line installer:

In the terminal
npx claude-code-templates@latest

Read all the files in the .claude/skills/[skill name] folder I downloaded from the internet. Explain to me what the skill does, which commands it runs and when, which files and services it accesses, and whether there's anything suspicious or dangerous in it. Don't trigger it and don't run anything from it

Exercise: the project's skill kit

On the recipe site (or any project with Git):

  1. Create the three skills from the chapter: review-pr, generate-tests and deploy.
  2. Type / and check that all three appear in the menu.
  3. Run /review-pr on a branch with a small change. Did the reviewer avoid fixing things?
  4. Write "add tests for the servings calculator file" without typing /. Did Claude trigger generate-tests on its own?
  5. Write "looks like everything's ready, maybe we should deploy?". Claude shouldn't trigger deploy on its own.
  6. Ask Claude to build a fourth skill of your own, for example new-recipe.
  7. Add an ask rule for Skill(deploy *) in .claude/settings.json.

Finished the exercise?

0 of 8

Summary

  • Skill = a written work recipe: a folder with SKILL.md, in .claude/skills/ (project) or ~/.claude/skills/ (personal).
  • Progressive loading: only the name and description load up front. The content and supporting files load only when needed.
  • The description decides when Claude triggers it on its own. disable-model-invocation: true for anything with consequences.
  • Arguments with $ARGUMENTS and $0, and live data with !`command`.
  • Permissions: allowed-tools pre-approves, disallowed-tools blocks, and Skill(...) rules in settings.
  • Community skills save work, but read them before installing.

In the next chapter we'll meet skills' big siblings: subagents. We'll see how Claude splits big tasks among several helpers working in parallel, and also understand tokens, the context window and prompt caching in depth.

Check yourself

1. What's the difference between a skill and CLAUDE.md?

2. Which field prevents Claude from triggering /deploy on its own?

Answering every quiz question marks the chapter as done automatically.