← ContentsClaude Code · intermediate

Slash commands

Slash commands are special directives typed directly into the Claude Code terminal interface, each prefixed with a forward slash (/). They give developers a fast, deterministic way to control session behavior — things like compressing context, switching models, clearing history, or running diagnostic checks — without needing to phrase requests in natural language. Built-in slash commands come bundled with Claude Code and cover common session management tasks. Custom slash commands let you encode repeatable workflows (code reviews, security scans, refactors) as Markdown files that Claude follows like a playbook. Custom commands can be created in two ways. The newer approach uses Skills: you create a directory with a SKILL.md file containing YAML frontmatter (which sets the command name, description, and allowed tools) plus Markdown instructions. Skills support extra features like bundled supporting files, automatic invocation by Claude when relevant, and the $ARGUMENTS placeholder for passing parameters at invocation time. The legacy approach stores plain Markdown files in .claude/commands/ (project scope) or ~/.claude/commands/ (personal scope); these still work and the filename becomes the command name. Typing / in a Claude Code session opens an autocomplete menu showing all available built-in and custom commands. Commands can also be exposed programmatically through the Claude Agent SDK, where available slash commands are listed in the system initialization message. A character budget controls how much description text Claude loads — by default 1% of the context window (fallback 8,000 characters) — so description text should front-load the most important keywords.

When you’d use it

  • Context compression mid-sessionAfter a long coding session with many file reads and edits, the context window is nearly full. Using /compact summarizes the conversation history while preserving key decisions, freeing up token space without losing important context.
  • Repeatable security auditsA team creates a project-level /security-scan command stored in .claude/commands/. Any developer can run it pre-commit to check for SQL injection, exposed credentials, and insecure configs without remembering the full prompt each time.
  • Automated refactoring workflowA personal /refactor skill reads a file, applies clean-code principles, runs the test suite, and reports results. A developer invokes /refactor src/auth/login.ts to get a consistent, tested refactor without crafting a long instruction prompt.
  • Batch test execution with pattern filteringA /batch-test skill accepts $ARGUMENTS to filter which tests to run. Running /batch-test auth detects the test framework, runs only auth-related tests, summarizes pass/fail counts, and optionally auto-fixes common failures.
  • Session diagnostics and environment verificationWhen MCP server connections or external tool integrations fail unexpectedly, running /doctor instantly checks the environment setup, surfaces misconfigured paths or missing dependencies, and reports what is and isn't working.

What changed recently

  • 2026-05Plugins launched in public beta. Claude Code now supports plugins — installable bundles of slash commands, subagents, MCP servers, and hooks. Install with a single /plugin command inside Claude Code, eliminating manual filesystem setup for shared command collections.
  • 2026-06-15Agent SDK access added to Pro, Max, Team, and Enterprise plans. Developers on these plans can use the Agent SDK (and programmatic slash command invocation) within their subscription usage starting this date. Credits are per-user and cannot be pooled or transferred.
  • 2025-11-03The claude_code.skill_activated OpenTelemetry event was updated to fire for user-typed slash commands in addition to Claude-proactive invocations. A new invocation_trigger attribute carries one of three values: 'user-slash', 'claude-proactive', or 'nested-skill', enabling teams to track how each command is being triggered.
This is the short version

The full chapter has three worked examples, the common pitfalls, and the workflow that makes it pay — plus the other 84 features, kept current.

Get Claude Master — $97
CLAUDEMASTER
An independent publication.
Independent product. Not affiliated with or endorsed by Anthropic. “Claude” is a trademark of Anthropic, used here only to describe the subject of this manual.
© 2026 Claude Master — All rights reserved.