Skip to content

Slash Commands

Reusable, parameterized prompts you trigger with /command.

Beginner9 min read

Slash commands are shortcuts you type in the Claude Code prompt to trigger built-in actions or your own reusable workflows — one short command instead of re-explaining the same thing every session.

How commands work

Type a forward slash at the start of any message to open the command menu. You can keep typing to filter the list. Whatever text you add after the command name is passed to it as arguments. Commands are only recognized at the very start of a message — mid-sentence slashes are treated as plain text.

text
/help
/clear
/compact focus on the auth changes only
/model opus

Built-in commands worth knowing

Claude Code ships with dozens of built-in commands. These are the ones you will reach for most often as you get started:

  • /help — list every available command with a short description
  • /clear — wipe the conversation and start fresh (your CLAUDE.md memory is kept)
  • /compact — summarize the conversation to free up context window space; pass optional focus instructions
  • /config — open the settings panel to change theme, model, and other preferences
  • /mcp — manage connected MCP server connections
  • /agents — configure subagents Claude can delegate tasks to
  • /init — generate a starter CLAUDE.md for a new project
  • /memory — edit your CLAUDE.md memory files
  • /model — switch the AI model mid-session
  • /skills — list all loaded skills and their token costs
Built-ins vs bundled skills
Some commands (like /code-review and /debug) are labeled 'Skill' in the docs. They work identically from your perspective, but under the hood they are prompt-based instructions rather than hard-coded logic — which also means Claude can invoke them automatically when relevant.

Creating your own command

Custom commands are just Markdown files saved in a special directory. Create a file and Claude Code immediately registers it as a slash command — no restart needed. There are two file layouts that both work:

  • ~/.claude/skills/<command-name>/SKILL.md — personal, available in every project
  • .claude/skills/<command-name>/SKILL.md — project-scoped, committed with the repo
  • .claude/commands/<name>.md — legacy path, still fully supported

The directory name (or file name for the legacy path) becomes the command you type. A file at .claude/skills/summarize-pr/SKILL.md is invoked with /summarize-pr.

Anatomy of a skill file

Every skill file has two parts: optional YAML frontmatter between --- markers that configures behavior, and plain Markdown content with the instructions Claude follows. Here is a minimal example that accepts an argument:

yaml
# .claude/skills/open-issue/SKILL.md
---
description: Open a GitHub issue for a bug. Use when the user wants to file a bug report.
argument-hint: <issue title>
---

Create a GitHub issue with the title: $ARGUMENTS

Before creating:
1. Check if a similar issue already exists with `gh issue list --search "$ARGUMENTS"`
2. Write a short description summarizing the bug and reproduction steps
3. Run: gh issue create --title "$ARGUMENTS" --body "<description>"

You can now type /open-issue login page throws 500 on empty password and Claude will run the full workflow. The $ARGUMENTS placeholder expands to everything you typed after the command name.

Inject live data with shell commands
Prefix a line with !`command` to run a shell command and inline its output before Claude sees the skill. This is useful for grounding Claude in real state — for example, !`git diff HEAD` pulls in your actual diff rather than relying on open files.

Controlling who invokes a skill

By default, Claude can invoke a skill automatically when it judges the skill is relevant. Add disable-model-invocation: true to the frontmatter to make a skill manual-only — useful for destructive or deployment workflows you only want to trigger yourself. Pair it with user-invocable: false to hide a skill from the / menu entirely, making it background knowledge Claude loads quietly.

yaml
---
description: Deploy the application to production
disable-model-invocation: true
---

1. Run the test suite: npm test
2. Build: npm run build
3. Push: git push origin main
Command name comes from the directory, not the frontmatter
The name: field in frontmatter sets the display label shown in skill listings — it does not change what you type to invoke the skill. The invocation name always comes from the directory name (or filename for .claude/commands/ files). Renaming the frontmatter name: field will not change /command-name.
Key takeaways
Type / to browse all commands; the most useful built-ins are /help, /clear, /compact, /config, and /mcp. Create custom commands by adding a SKILL.md file to .claude/skills/<name>/ — project-scoped or personal. Use $ARGUMENTS to pass input, !`shell command` to inject live context, and disable-model-invocation: true for workflows you want manual control over. Full reference: code.claude.com/docs/en/commands.