Custom Skills & Slash Commands
CoreCreate and configure custom slash commands and skills · Difficulty 2/5
Explanation
Skills and slash commands are how you give Claude Code reusable, on-demand instructions. A skill is a markdown file (SKILL.md) with YAML frontmatter that Claude invokes when a task matches its description; a slash command is a prompt template you trigger explicitly by typing /name. Both turn a repeated workflow ("review this diff", "write a migration", "audit for security") into one invocation instead of a re-typed paragraph.
Where they live (scope & precedence)
Location determines who gets the skill or command and whether it is shared:
| Path | Scope | Shared via |
|---|---|---|
.claude/skills/ | Project | Version control (team-wide) |
~/.claude/skills/ | Personal | Per-developer, all projects |
.claude/commands/ | Project | Version control (team-wide) |
~/.claude/commands/ | Personal | Per-developer, all projects |
When a project skill and a personal skill share a name, the project skill wins. So to keep a personal variant without overriding the team's, give it a distinct name (e.g. /review-fast rather than redefining /review).
SKILL.md frontmatter reference
A skill is a folder under .claude/skills/<name>/ containing SKILL.md. The YAML frontmatter controls when and how it runs:
| Key | Purpose |
|---|---|
description | Natural-language trigger. Claude reads this to decide when the skill is relevant, so write it for matching — name the task and the cues that should activate it. |
allowed-tools | Whitelist of tools the skill may use (e.g. Read, Edit, mcp__github__*). Enforces least privilege — the skill can't reach beyond what you list. |
context | Execution context: fork runs the skill in an isolated sub-agent context that is discarded on completion; current runs inline in the main conversation. |
A minimal skill:
---
description: Review the current git diff for bugs and security issues. Use when the user asks for a code review or before a commit.
allowed-tools: Read, Grep, Bash
context: fork
---
Run `git diff --staged`, then review each change for correctness bugs,
missing error handling, and security issues. Report findings grouped by
severity. Do not modify files.When to fork the context
Set `context: fork for skills that do exploratory or verbose work — brainstorming, large-codebase analysis, research. Forking keeps all that intermediate output out of the main conversation so abandoned approaches don't bias later implementation, and only the skill's conclusion returns. Run inline (current`) when the skill needs the surrounding conversation or its step-by-step output is what you want to see.
Skills vs commands vs CLAUDE.md vs hooks
These four configuration surfaces are constantly confused; the exam tests telling them apart by *when each loads*:
| Surface | Loaded when | Best for |
|---|---|---|
CLAUDE.md | Every conversation, always | Universal standards and project context |
| Skills | On-demand, when the description matches the task | Task-specific workflows Claude chooses to apply |
| Slash commands | On-demand, when you type /name | Workflows you trigger explicitly |
| Hooks | Automatically, on a lifecycle event (e.g. PostToolUse) | Deterministic actions the harness runs, not Claude |
The key distinction: CLAUDE.md is always-on context; skills/commands are pulled in only when relevant (progressive disclosure, keeping the base context small); hooks are executed by the harness, not decided by Claude.
Common setup mistakes
- Vague
description— if the description doesn't name the task and its cues, Claude won't trigger the skill when you expect. Be specific about *when* it applies. - Forgetting
allowed-tools— omitting it can leave a skill with more access than it needs; list the minimum. - Editing the file but not seeing changes — confirm the skill is in the right scope (
.claude/skills/for project,~/.claude/skills/for personal) and that a same-named project skill isn't shadowing your personal one. - Using a skill where a hook belongs — if you want something to run automatically on every tool use, that's a hook, not a skill.
Key Takeaways
- Project skills/commands live in .claude/ (version-controlled, team-wide); personal ones in ~/.claude/
- SKILL.md frontmatter: description (trigger), allowed-tools (least privilege), context (fork vs current)
- Use context: fork for exploratory skills so verbose output never pollutes the main conversation
- CLAUDE.md is always loaded; skills/commands load on-demand; hooks run automatically via the harness
- Project skills override personal skills of the same name — use distinct names for personal variants
Glossary Terms
Related Concepts
Test Yourself
1 / 3Your team created an /analyze-codebase skill that performs comprehensive code analysis. After running this command, team members report that Claude becomes less responsive and loses track of their original task. What's the most effective way to address this?