Claude Code has three main ways to customize it. Slash commands are shortcuts you type, like /clear or /init. Skills are folders with a SKILL.md file that teach Claude a repeatable workflow, and each skill becomes its own /command. Hooks are shell commands that run automatically at set moments, such as after every file edit. Use skills when Claude should follow a procedure. Use hooks when something must happen every single time. This guide shows how each one works, with copy-paste examples taken from Anthropic's docs, as of October 2026.
What is the difference between skills, hooks and slash commands?
| Slash commands | Skills | Hooks | |
|---|---|---|---|
| What it is | A command you type at the start of a message | A SKILL.md file with instructions |
A shell command (or other handler) tied to an event |
| Who triggers it | You | You (/skill-name) or Claude, when relevant |
Claude Code, automatically |
| Reliable every time? | Yes, when you type it | Claude decides how to follow it | Yes, it always runs |
| Where it lives | Built in, or from your skills | .claude/skills/ or ~/.claude/skills/ |
Settings files such as .claude/settings.json |
| Best for | Controlling the session | Workflows, checklists, team know-how | Formatting, blocking risky actions, notifications |
One big change to know: custom slash commands have been merged into skills. Anthropic's docs say a file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Your old .claude/commands/ files still work. Skills just add more options.
Which built-in slash commands should I know?
Type / in a session to see everything available. A command only works at the start of your message. These are the ones most people use daily:
| Command | What it does |
|---|---|
/init |
Create a starting CLAUDE.md for your project |
/memory |
Edit CLAUDE.md files and turn auto memory on or off |
/clear |
Start a new conversation with empty context |
/compact [instructions] |
Summarize the conversation to free up context |
/context |
Show what is using your context window |
/model |
Switch the AI model |
/effort |
Set the effort level |
/usage |
Show session cost, plan limits and stats (/cost is an alias) |
/skills |
List available skills |
/hooks |
View your hook configurations |
/mcp |
Manage MCP server connections |
/plugin |
Manage plugins |
/rewind |
Roll back the conversation and code to an earlier point |
/resume |
Return to a previous conversation |
Some commands are actually bundled skills that ship with Claude Code. Examples include /code-review (alias /review), /simplify, /batch, /loop, /debug and /doctor.
For more on /init and /memory, see CLAUDE.md explained.
What are Claude Code skills?
Anthropic puts it simply: "Create a SKILL.md file with instructions, and Claude adds it to its toolkit. Claude uses skills when relevant, or you can invoke one directly with /skill-name."
Make a skill when you keep pasting the same instructions into chat, or when part of your CLAUDE.md has turned into a step-by-step procedure.
The big advantage over CLAUDE.md: a skill's body loads only when it is used. Long reference material costs almost nothing until you need it.
Where do Claude Code skills live?
| Location | Path | Applies to |
|---|---|---|
| Personal | ~/.claude/skills/<skill-name>/SKILL.md |
All your projects |
| Project | .claude/skills/<skill-name>/SKILL.md |
This repo (commit it to share with your team) |
| Plugin | <plugin>/skills/<skill-name>/SKILL.md |
Wherever the plugin is enabled |
| Enterprise | Managed settings directory | Your whole organization |
How do I create a Claude Code skill?
Here is Anthropic's own first example. It summarizes your uncommitted changes and flags risks.
- Create the folder:
mkdir -p ~/.claude/skills/summarize-changes
- Create
~/.claude/skills/summarize-changes/SKILL.mdwith this content:
---
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.
- Start Claude Code in a git project and type
/summarize-changes. Or just ask "what changed?" and Claude may load it on its own.
The !`git diff HEAD` line is dynamic context injection. Claude Code runs the command and puts its output into the skill before Claude reads it.
Which SKILL.md frontmatter fields matter?
All fields are optional. Anthropic recommends at least description, because Claude uses it to decide when to load the skill.
| Field | What it does |
|---|---|
name |
The command name. Defaults to the folder name. |
description |
What the skill does and when to use it |
disable-model-invocation |
true means only you can trigger it. Good for deploys. |
user-invocable |
false hides it from the / menu so only Claude uses it |
allowed-tools |
Tools Claude can use without asking during that turn |
context and agent |
context: fork runs the skill in a subagent |
How do I pass arguments to a skill?
Use $ARGUMENTS. Here is Anthropic's example:
---
name: fix-issue
description: Fix a GitHub issue
disable-model-invocation: true
---
Fix GitHub issue $ARGUMENTS following our coding standards.
Type /fix-issue 123 and Claude receives "Fix GitHub issue 123 following our coding standards." You can also pick single arguments with $ARGUMENTS[N] or the shorthand $N.
What are Claude Code hooks?
Hooks are "user-defined shell commands" that Claude Code runs at specific points in its lifecycle. The key word is deterministic. A CLAUDE.md line like "always run Prettier" depends on Claude remembering. A hook runs every time.
Here are the hook events beginners use most:
| Event | When it fires |
|---|---|
SessionStart |
When a session begins or resumes |
UserPromptSubmit |
When you submit a prompt, before Claude processes it |
PreToolUse |
Before a tool call runs. Can block it. |
PostToolUse |
After a tool call succeeds |
Notification |
When Claude Code sends a notification |
Stop |
When Claude finishes responding |
PreCompact |
Before context compaction |
SessionEnd |
When a session ends |
There are many more, including SubagentStop, InstructionsLoaded and FileChanged. Most hooks are "type": "command". Other types are http, mcp_tool, prompt (asks a model a yes or no question) and agent (experimental).
Where do I put hooks?
| Location | Scope | Shared? |
|---|---|---|
~/.claude/settings.json |
All your projects | No |
.claude/settings.json |
This project | Yes, commit it |
.claude/settings.local.json |
This project | No |
Plugin hooks/hooks.json |
When the plugin is on | Yes |
| Skill or subagent frontmatter | While that skill or subagent is active | Yes |
Run /hooks inside Claude Code to see every configured hook, grouped by event. You can also describe the hook you want and ask Claude to write it.
Example hook: get a notification when Claude needs you
Add this to ~/.claude/settings.json on a Mac:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
]
}
}
On Linux, Anthropic's docs use notify-send 'Claude Code' 'Claude Code needs your attention' as the command instead.
Example hook: auto-format every file Claude edits
Add this to .claude/settings.json in your project. It runs Prettier after each Edit or Write:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}
It needs jq. Install it with brew install jq on macOS or apt-get install jq on Debian and Ubuntu.
Example hook: block edits to protected files
A PreToolUse hook can stop an action. If the script exits with code 2, the action is blocked and the message you write to stderr goes back to Claude so it can adjust.
- Save this as
.claude/hooks/protect-files.sh:
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
PROTECTED_PATTERNS=(".env" "package-lock.json" ".git/")
for pattern in "${PROTECTED_PATTERNS[@]}"; do
if [[ "$FILE_PATH" == *"$pattern"* ]]; then
echo "Blocked: $FILE_PATH matches protected pattern '$pattern'" >&2
exit 2
fi
done
exit 0
- Make it executable:
chmod +x .claude/hooks/protect-files.sh
- Register it in
.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-files.sh"
}
]
}
]
}
}
- Test it by asking Claude to add a comment to your
.envfile. The edit is blocked.
When should I use a skill, a hook, or CLAUDE.md?
- CLAUDE.md: short facts Claude needs every session, like build commands and conventions.
- Skill: a multi-step procedure, or reference material only needed sometimes.
- Hook: anything that must happen every time, with no exceptions.
- Subagent: a side task you want done in a separate context, so its output does not fill your main conversation. Subagent files live in
.claude/agents/or~/.claude/agents/.
Skills and hooks also help you spend less on Claude Code. A skill keeps long instructions out of context until needed. A hook can filter a huge log down to the error lines before Claude reads it.
Where can I get ready-made skills, agents and prompts?
You do not have to write everything from scratch. Our Brain Lab is a free library of ready-to-download skills, agents and prompts. Grab one, drop it into ~/.claude/skills/ or .claude/skills/, and adapt the description to your project.
You can also install plugins with /plugin. Plugins package extensions, such as skills and hooks, so you can share them across projects.
Frequently asked questions
Are custom slash commands deprecated?
They were merged into skills. Files in .claude/commands/ keep working and still create a /command. New work should use .claude/skills/<name>/SKILL.md, which supports extra files and frontmatter options.
Can Claude use a skill without me typing the command?
Yes. Claude loads a skill when your request matches its description. To stop that, set disable-model-invocation: true.
How do I see which hooks are active?
Type /hooks inside Claude Code. It lists every configured hook by event.
How does a hook block an action?
Exit with code 2 from a PreToolUse hook and write the reason to stderr. Claude Code blocks the tool call. Exit 0 lets the normal permission flow continue.
Can I share skills and hooks with my team?
Yes. Commit .claude/skills/ and .claude/settings.json to your repo. For several repos, package them as a plugin.
Do skills cost tokens?
Very few until used. Only the description is needed for Claude to decide when to load a skill. The full body loads when the skill runs. Run /skills and press t to sort skills by token count.
Go deeper with a free course
Skills and hooks are where Claude Code starts to feel like your own tool. If you are new, begin with our guide to installing Claude Code and check how it stacks up in Claude Code vs Cursor vs GitHub Copilot. Then take the free course Claude Code from Zero to build your own skills and hooks step by step.
Sources
Did this land? Leave a reaction.
Discussion
0 commentsMembers can join the discussion
Become a member to comment and reply to other members.
Become a MemberNo comments yet
Be the first to start the discussion.