Custom slash commands and skills
What this covers
- Scope commands and skills to the team or to yourself deliberately
- Use
context: forkto keep verbose output out of the main conversation - Choose between a skill and CLAUDE.md for a given piece of guidance
- Give a portable skill an explicit
namethat matches its directory, while recognizing Claude Code's directory-name fallback - Write
descriptionandwhen_to_useas the situations that should trigger a skill, because that is what it is selected on - Treat a command file and a skill directory of the same name as a collision to resolve, not a fallback
- Treat
argument-hintas display metadata and validate required arguments in the skill or its script - Distinguish
allowed-tools, which pre-approves, fromdisallowed-tools, which removes
Scope first
Commands in .claude/commands/ are project-scoped and shared through version control. Commands in ~/.claude/commands/ are yours alone. Same split as CLAUDE.md, same failure mode when you pick the wrong one.
For a personal variant of a shared skill, create it in ~/.claude/skills/ under a different name. Editing the shared one to suit yourself changes it for everybody.
One namespace, two places to define things
Commands and skills feed the same slash-command surface, so the same name in either place produces the same command:
.claude/commands/review.md -> /review
.claude/skills/review/SKILL.md -> /reviewTwo definitions claiming one invocation name is a collision the team has to resolve rather than a fallback arrangement. Migrating a command into a skill means retiring the old file in the same change.
Skill frontmatter worth knowing
A portable skill at .claude/skills/database-migration/SKILL.md keeps its identity and configuration in frontmatter:
---
name: database-migration
description: Runs the team's database migration workflow.
when_to_use: When adding, altering, or rolling back a migration.
context: fork
allowed-tools: Read, Grep, Bash
argument-hint: "[migration-name]"
---nameis the skill's portable identifier. The open Agent Skills specification requires it, limits it to 1-64 lowercase letters, numbers, and hyphens, and requires it to match the parent directory. Agents loadnameanddescriptionduring discovery before opening the full instructions, so an explicit name gives tools a stable identity to index and validate. Claude Code can fall back to the directory name for a local or project skill, but relying on that fallback makes the file non-conformant with the portable standard. For these skills, the directory still determines the slash command.descriptionandwhen_to_usehelp Claude decide when to select a skill. Inwhen_to_use, list the situations that should trigger the skill instead of repeating what it does. Otherwise, the skill may be found only when someone already knows to request it. The directory name is the command you type.context: forkruns the skill in an isolated subagent context, so its intermediate work doesn't fill the main conversation. Use it for tasks such as codebase analysis or exploratory research when the main conversation needs the conclusion but not every step used to reach it.allowed-toolstemporarily pre-approves the listed tools for the turn that invokes the skill. It does not remove other tools. Usedisallowed-toolsor permission deny rules when a capability must be unavailable.argument-hintis autocomplete text showing the expected arguments. It neither validates them nor prompts interactively when one is missing. The skill body or its invoked script must validate required inputs and fail clearly.
A skill is invocable both by name and by Claude judging it relevant; user-invocable and disable-model-invocation turn one of those off, never on.
Skill or CLAUDE.md?
The distinction is when it applies.
CLAUDE.md is always loaded — it belongs to universal standards that should hold for every interaction. A skill is invoked on demand — it belongs to a task-specific workflow you want available but not always present.
Putting an occasional workflow in CLAUDE.md makes it load on every turn. Put that workflow in a skill so it loads only when it is needed.
.claude/commands/.claude/skills/SKILL.mdnamedescriptionwhen_to_usecontext: forkallowed-toolsdisallowed-toolsargument-hint
Field note — common misconceptions
- MythThat everything useful belongs in CLAUDE.md
- ActuallyCLAUDE.md loads every turn, so a task-specific workflow belongs in a skill invoked on demand.
- MythThat a personal customization can be made without affecting teammates by editing the shared file
- ActuallyCreate a variant in
~/.claude/skills/under a different name, leaving the shared one alone. - MythThat forking a skill is about speed rather than context hygiene
- Actually
context: forkkeeps a verbose skill's transcript out of the main conversation, not its runtime. - MythThat
allowed-toolsremoves every tool not listed - ActuallyIt pre-approves what it lists and removes nothing;
disallowed-toolsmakes a tool unavailable.
Guided review
Review this lesson as a study deck
Review the lesson's main ideas in five guided slides, then test yourself with three flashcards.
Open Task 3.2 study deckCross-domain reasoning
Connect this idea
Project settings control coding work
Sessions, built-in tools, project instructions, skills, path rules, and execution mode determine what Claude knows and what it can do during a code change.
- 1.7 · Manage session state, resumption, and forking
- 2.5 · Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob)
- 3.1 · Configure CLAUDE.md files with appropriate hierarchy, scoping, and organization
- 3.3 · Apply path-specific rules for conditional convention loading
- 3.4 · Determine when to use plan mode vs direct execution
Applied practice
Practice this lesson in a lab
Use a related lab to create a decision, implementation or diagram, evidence record, and review.
- Lab 6 · Claude Code configuration hierarchy
Place guidance, reusable procedures, scoped rules, and enforcement in the mechanism that fits each one.