← Back to all tutorials
Claude CodeEpisode 6

Slash Commands

Master Claude Code's built-in slash commands and create your own custom slash commands for repetitive workflows.

What Are Slash Commands?

Slash commands are built-in shortcuts that control Claude Code's behavior. They start with a forward slash (/) and give you quick access to session management, configuration, and utility functions without typing full natural language prompts.

Essential Built-in Commands

/help — Show All Commands

> /help

Displays a list of all available slash commands with brief descriptions.

/compact — Compress Context

> /compact

Summarizes the current conversation to free up context window space. Essential for long sessions. You can also provide a focus for the summary:

> /compact focus on the database migration changes

/clear — Reset Conversation

> /clear

Clears the conversation history entirely and starts fresh. Use this when switching to a completely different task within the same project.

/cost — Check Token Usage

> /cost

Shows the current session's token usage and estimated cost. Useful for monitoring your API spending.

/init — Generate CLAUDE.md

> /init

Analyzes your project and generates a CLAUDE.md file (covered in Episode 2).

/doctor — Diagnose Issues

> /doctor

Runs diagnostics to check your Claude Code installation, API key configuration, and connectivity. Use this when things aren't working as expected.

/config — View and Set Configuration

> /config

View all current configuration settings. You can also modify the configuration through this command.

Custom Slash Commands

You can create your own project-specific slash commands by adding Markdown files to the .claude/commands/ directory in your project:

my-project/
├── .claude/
│   └── commands/
│       ├── deploy.md
│       ├── test-all.md
│       └── review.md

Creating a Custom Command

Each command is a Markdown file. The filename becomes the command name, and the file content becomes the prompt sent to Claude:

# .claude/commands/deploy.md
Run the following deployment steps in order:
1. Run npm run lint and fix any errors
2. Run npm run test and ensure all tests pass
3. Run npm run build to create the production build
4. Show me the build output summary

Now you can run:

> /project:deploy

Using Arguments with $ARGUMENTS

Custom commands can accept arguments using the $ARGUMENTS placeholder:

# .claude/commands/create-component.md
Create a new React component called $ARGUMENTS with:
- TypeScript strict types
- A corresponding test file
- TailwindCSS styling
- Proper exports in the components/index.ts barrel file

Usage:

> /project:create-component UserProfile

Personal vs Project Commands

  • Project commands — Stored in .claude/commands/ in your repo root. These are shared with your team via Git.
  • Personal commands — Stored in ~/.claude/commands/. These are private to you and available across all projects.

What's Next

In the next episode, we'll explore MCP Servers — the Model Context Protocol that lets Claude Code connect to databases, APIs, and external services.

Claude CodeAICoding AgentCLIAnthropic