Claude Code transforms repetitive development workflows into single-word commands. Slash commands are reusable prompt templates stored as Markdown files that execute with simple /command-name syntax, reducing token consumption by up to 20% while standardizing team processes. This agentic coding tool, released by Anthropic in February 2025 and reaching general availability in May 2025, operates primarily as a CLI interface that understands your codebase and executes routine tasks through natural language.
Claude Code is an agentic coding tool that lives in your terminal, available as a standalone CLI, VS Code extension, JetBrains IDE integration, and web interface. The tool uses advanced models (Claude Opus 4.1, Sonnet 4.5, or Haiku 3.5) to understand entire codebases through "agentic search," make multi-file edits, handle git workflows, and execute background tasks—all without manual context selection.
Slash commands function as custom prompts encapsulated in Markdown files placed in designated directories. The filename (without .md extension) becomes the command name. When invoked, Claude processes the command's content with any provided arguments, executing specified tools and operations. Commands reduce repetitive prompting, ensure consistency across teams, and enable complex workflows to be triggered with minimal typing.
Commands operate on a permission-based model where read-only access is default. Commands can specify allowed-tools to use specific Claude capabilities like Bash execution, file operations, or MCP integrations. The system supports two scopes: project commands shared via version control in .claude/commands/, and personal commands in ~/.claude/commands/ available across all projects. Commands support frontmatter metadata, dynamic arguments, bash command execution, and file references—creating a powerful automation framework.
The system addresses four critical developer needs: token efficiency (extracting fixed workflows from conversation context), workflow automation (encapsulating repetitive tasks), consistency (standardizing processes across teams), and reusability (defining once, using repeatedly). Commands can be invoked directly with /, through natural language triggers defined in CLAUDE.md files, or programmatically by Claude itself using the SlashCommand tool. The result is faster development, reduced cognitive load, and executable documentation that travels with the codebase.
Claude Code provides 26 built-in commands covering session management, configuration, project initialization, integrations, and development workflows. Users can create unlimited custom commands through Markdown files, and MCP (Model Context Protocol) servers expose dynamic commands for external tool integration.
Session Management: /clear resets conversation history while maintaining the session; /compact [instructions] summarizes conversation to free context window space with optional preservation instructions; /rewind restores code and conversation to previous automatic checkpoints (keyboard shortcut: Esc+Esc).
Configuration & Settings: /config opens an interactive configuration wizard for model preferences and permissions; /allowed-tools configures tool permissions interactively; /permissions displays active permission settings; /hooks sets up automated commands at lifecycle points; /model switches between Claude AI models (Opus for complex tasks, Sonnet for speed, Haiku for economy).
Project Initialization: /init creates CLAUDE.md file with project context by analyzing structure; /memory opens and modifies project memory files (shortcut: start any message with # to add immediately); /add-dir expands access beyond current project directory.
Information & Diagnostics: /help displays all available commands with descriptions and scope indicators; /status shows account and system information for current session; /usage displays token consumption statistics with percentages and reset timers; /cost shows detailed token usage data for API users; /doctor diagnoses installation and setup issues.
Development Workflow: /agents manages custom AI subagents for specialized tasks like code review or testing; /review triggers code review functionality; /pr_comments manages GitHub pull request comments; /bug reports bugs to Anthropic including session data.
Integrations: /mcp manages Model Context Protocol servers with subcommands for list, add, remove, and import from Claude Desktop; /install-github-app configures GitHub Actions integration for automatic PR reviews.
Terminal & Editor: /terminal-setup installs terminal shortcuts including Shift+Enter for newlines in iTerm2 and VS Code; /vim enables vim-style editing keybindings.
Account Management: /login switches or authenticates Anthropic accounts; /logout signs out of current session.
Users create commands by placing Markdown files in .claude/commands/ (project-specific, shared via git) or ~/.claude/commands/ (personal, available globally). Commands in subdirectories create namespaced commands—for example, .claude/commands/frontend/component.md becomes /component with a "(project:frontend)" label. This organizational structure helps manage large command collections while preventing naming conflicts.
Custom commands use optional YAML frontmatter to control behavior with these fields: description (brief text shown in /help), allowed-tools (list of tools the command can use like Bash with specific command patterns), argument-hint (expected argument format shown in autocomplete), model (specific Claude model to use), and disable-model-invocation (prevents automatic execution by Claude).
Common custom command patterns from the community include /optimize for performance analysis, /security-review for vulnerability assessment, /refactor for best practices application, /commit for conventional commit creation, /fix-issue [number] to resolve GitHub issues, and /deploy-check for deployment readiness verification. The community has created extensive collections—wshobson/commands offers 57 production-ready commands, while the Claude Command Suite provides 148+ specialized commands.
When MCP servers are installed, their tools become available as slash commands following the pattern /mcp__servername__toolname. The GitHub MCP server exposes 20+ commands including /mcp__github__list_issues, /mcp__github__create_pull_request, and /mcp__github__fork_repository. The Filesystem MCP server provides /mcp__filesystem__read_file, /mcp__filesystem__write_file, and /mcp__filesystem__list_directory. Other popular servers include SQLite (database queries), Puppeteer (web automation), Context7 (documentation management), and AWS Serverless (Lambda operations).
MCP commands require explicit permission configuration—approve all tools from a server with mcp__servername or approve specific tools individually. Rather than typing exact MCP syntax, users can leverage natural language: "Show me GitHub issue #123" automatically invokes GitHub MCP tools, while "List all database tables" triggers SQLite MCP functionality.
Claude Code slash commands fully support arguments and parameters through a flexible system supporting both catch-all and positional parameter syntax. Arguments enable dynamic command behavior while maintaining simplicity—all arguments are technically optional, with command prompts determining how to handle missing values.
Arguments follow the command name separated by spaces: /command-name [arguments]. Multiple arguments are space-delimited: /review-pr 456 high alice. For multi-word arguments, use quotes: /mcp__jira__create_issue "Bug title with spaces" high. All text after the command name becomes available to the command through placeholder variables.
$ARGUMENTS captures ALL text passed after the command as a single string. In the command file .claude/commands/fix-issue.md, the content Fix issue #$ARGUMENTS following our coding standards transforms /fix-issue 123 high-priority into the instruction "Fix issue #123 high-priority following our coding standards." This catch-all approach works well for commands that need flexible input or pass arguments to nested tools.
Positional arguments ($1, $2, $3) access specific arguments individually by position. A command with Review PR #$1 with priority $2 and assign to $3 transforms /review-pr 456 high alice into distinct values: $1 = "456", $2 = "high", $3 = "alice". Use positional arguments when you need to reference arguments separately in different contexts within the command, when argument order is fixed and meaningful, or when reusing the same argument multiple times.
The argument-hint frontmatter field documents expected parameters and appears in command autocomplete. Example:
---
argument-hint: [pr-number] [priority] [assignee]
description: Review pull request
---
Review PR #$1 with priority $2 and assign to $3.While Claude Code doesn't enforce argument requirements at the syntax level, well-documented hints improve usability. Structure commands to work gracefully without arguments when possible, providing sensible defaults or prompting for missing information.
String arguments (most common): /fix-issue 123 or /refactor UserComponent. File paths: /analyze src/components/Button.js or /security-review app/controllers/users_controller.rb. Numbers: /review-pr 456 or /fix-issue 789. Multiple words with quotes: /mcp__jira__create_issue "Bug title with spaces" high. Multiple space-delimited arguments: /review-pr 456 high alice or /tools:api-scaffold create user management endpoints with RBAC.
All arguments are treated as strings—there's no automatic type validation or conversion. Commands must handle parsing and validation within their prompt logic or bash execution steps.
File references with @: Include file contents directly in commands using the @ prefix. The command Compare @src/old-version.js with @src/new-version.js and summarize differences reads both files and inserts their contents into the prompt context.
Bash command execution with !: Execute bash commands and include output in the prompt using backtick notation preceded by !. Example:
---
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git log:*)
---
## Context
- Current git status: !`git status`
- Current git diff: !`git diff HEAD`
- Recent commits: !`git log --oneline -10`
Based on the above changes, explain the git diffCommands must specify allowed-tools in frontmatter with the Bash tool and specific command patterns (wildcards supported like git add:*). This powerful feature combines dynamic argument input with real-time system state, enabling sophisticated context-aware commands.
Combining all features: The most powerful commands combine arguments, file references, and bash execution:
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
argument-hint: [message]
---
## Context
- Status: !`git status`
- Diff: !`git diff HEAD`
- Branch: !`git branch --show-current`
Create conventional commit with message: $ARGUMENTS
Stage all changes and commit following Conventional Commits standards.Usage: /commit "feat: add user authentication" captures the argument, executes git commands to gather current state, then creates an appropriately formatted commit.
No built-in support exists for named parameters (like --flag=value)—all parsing must happen in command prompts. No automatic type validation or conversion occurs. Character limits exist on command descriptions shown to Claude via the SlashCommand tool to prevent token overflow. Built-in commands like /compact and /clear cannot be invoked programmatically—only user-defined custom commands support automatic execution by Claude.
Slash commands are accessible through multiple invocation methods, keyboard shortcuts, and context-dependent availability rules that determine when and where commands can be executed.
Direct typing: The primary method is typing / at the start of a line in Claude Code's chat interface. This immediately triggers command recognition and autocomplete showing available commands with descriptions. Syntax follows the pattern /command-name [arguments] with examples like /help to list commands, /commit to execute a custom commit workflow, or /fix-issue 123 to resolve a specific GitHub issue.
Natural language invocation: Commands can be triggered through natural language when referenced in CLAUDE.md files. Define keyword mappings like:
### Work Keywords
- **"commit my changes"**: Execute `/commit` command
- **"mid-checkpoint"**: Execute `/nakajime` commandWhen users say "commit my changes" in conversation, Claude automatically executes the appropriate slash command without requiring explicit / syntax.
Programmatic invocation: Claude can autonomously execute custom slash commands using the SlashCommand tool during conversations. This requires commands to be user-defined (not built-in), have a description field in frontmatter, and be referenced by name in instructions or CLAUDE.md. To prevent automatic execution, add disable-model-invocation: true to command frontmatter or deny the SlashCommand tool in /permissions.
MCP server prompts: MCP servers expose prompts as dynamically available slash commands following the format /mcp__<servername>__<promptname> [arguments]. Examples include /mcp__github__list_prs to view pull requests or /mcp__jira__create_issue "Bug title" high to create prioritized issues.
Commands work in the Claude Code terminal/CLI chat interface within standalone terminal sessions, VS Code integrated terminals, iTerm2, WezTerm, and other terminal emulators. Commands persist throughout conversations until the session ends.
Scope determines availability: Project commands from .claude/commands/ are available only within that specific project directory, automatically loaded when Claude Code starts, and shared with the team via git. User commands from ~/.claude/commands/ are available globally across all projects, personal to the user, and not shared in repositories.
Namespaced organization: Commands in subdirectories create logical groupings—.claude/commands/frontend/component.md becomes /component with "(project:frontend)" indicator, while ~/.claude/commands/security/audit.md becomes /security:audit. This structure prevents naming conflicts and helps manage large command collections.
Command navigation: Up/Down arrows navigate command history; Ctrl+R provides reverse search through command history with highlighted matches (press repeatedly to cycle through older matches); Tab autocompletes filenames and paths when typing arguments.
Session control: Ctrl+C cancels current operation; Ctrl+D exits Claude Code session; Ctrl+L clears terminal screen while keeping conversation history; Esc stops Claude's current action; Esc + Esc edits previous message or invokes /rewind.
Special input prefixes: / at start invokes slash commands; # at start adds to CLAUDE.md memory; @ prefix references files (e.g., @filename.js); ! at start executes direct bash commands without Claude interpretation.
Mode switching: Shift+Tab toggles between Auto-Accept Mode, Plan Mode, and normal mode; /vim enables vim-style editing keybindings; Shift+Enter creates line breaks (after running /terminal-setup).
The /help command is the primary discovery tool, listing all available commands with descriptions and scope indicators: "(project)", "(user)", "(project:namespace)", or server name for MCP commands. Type / to trigger autocomplete showing built-in commands with full tab completion support, though custom command autocomplete has known limitations—users must type full custom command names manually as of October 2025, with feature requests (#3094, #4171) tracking improvements.
Commands can define argument-hint in frontmatter for better UX—this text appears in autocomplete to guide argument usage. For example:
---
argument-hint: [issue-number] [priority]
description: Fix GitHub issue with priority
---Commands are not automatically chained but can be executed sequentially for complete workflows. Manual chaining involves running commands one after another: /dev:code-review to assess state, /project:create-feature user-dashboard to implement, then /security:security-audit to verify.
Individual commands can define internal multi-step workflows using numbered steps that execute bash commands, call MCP tools, and perform coordinated operations. Example:
## Steps
1. Run `git status` to see all changes
2. Run `git diff` to review changes
3. Stage all changes with `git add -A`
4. Create conventional commit
5. Push to current branchComplete feature development pipelines combine multiple specialized commands: /workflows:feature-development user authentication system, then /tools:security-scan authentication implementation, then /tools:test-harness authentication test suite, then /tools:docker-optimize authentication service.
Permission-based context: Commands respect project-level permissions through the allowed-tools frontmatter field specifying which tools the command can use (e.g., Bash(git add:*), Bash(git commit:*)). Commands inherit conversation permissions if not specified. Use /permissions to add SlashCommand to deny rules to prevent all programmatic command execution.
Model-specific commands: Commands can specify which model to use with the model frontmatter field (e.g., model: claude-3-5-sonnet-20240620), forcing the command to run with a specific model regardless of session defaults.
Scope-based availability: Project commands are only available when working in that project directory, automatically loaded on startup, and shared with the team. User commands are always available, loaded from ~/.claude/commands/, and personal to the individual.
MCP server dependencies: MCP commands are only available when the server is configured (claude mcp add <name>), running and connected, and has proper permissions granted to server tools.
Claude Code maintains command history for the current session only—history doesn't persist between separate sessions. Ctrl+R provides reverse search with highlighted matches, and users can press Ctrl+R repeatedly to cycle through older matches. Up/Down arrows navigate through previous commands, useful for recalling and editing similar commands with different arguments (e.g., /fix-issue 123 → Up arrow → edit to /fix-issue 124).
Session continuity is maintained through claude -c or --continue to resume the most recent conversation, or claude -r "abc123" to resume a specific session by ID. The /clear command wipes conversation history for a fresh start, while /compact [instructions] summarizes conversation to retain important parts while freeing context space. Commands themselves persist regardless of history management—they're defined by Markdown files, not session state.
The Claude Code community reports 20% token usage reduction when converting fixed workflows to slash commands. Commands serve as executable documentation that travels with the codebase, ensuring consistent processes across teams while dramatically reducing repetitive prompting.
Git workflow automation: The /commit command is among the most popular, automating conventional commit creation by analyzing current changes with git status and git diff, determining appropriate commit type (feat, fix, docs, style, refactor, test, chore), staging changes, and pushing to the remote branch—all in a single command invocation.
Issue management: Commands like /fix-issue [number] retrieve issue details using GitHub CLI, search the codebase for relevant files, implement necessary changes, write and run tests, create descriptive commit messages, and open pull requests—transforming multi-step manual workflows into single-command execution.
Code quality and security: Custom commands for /security-review examine code for SQL injection, XSS vulnerabilities, authentication issues, and cryptographic weaknesses. The /deploy-check command runs linters, executes test suites, performs production builds, checks for console.log statements, and verifies environment documentation before deployment.
Team standardization: Project commands in .claude/commands/ enable teams to codify best practices, enforce coding standards, and share organizational knowledge through version-controlled automation. Commands become onboarding tools, reducing the learning curve for new team members while ensuring consistency across contributors.
The system excels at workflow automation, token efficiency, and team standardization, though it requires technical comfort with CLI environments and Markdown files. Popular community collections like wshobson/commands (57 production-ready commands) and the Claude Command Suite (148+ specialized commands) provide starting points for teams building their automation libraries.