Danny Willems -- Work In Progress

A mathematician fighting for privacy and security on the Internet, while dreaming about describing the Universe with equations and symbols.

Resume (PDF) Contributions Research Publications Public Talks Open source software contributions Experience Education Blog Recommended softwares
16 January 2026

Claude Code Slash Commands: A Comprehensive Guide

by Danny Willems

Claude Code provides a powerful set of slash commands that enhance your coding workflow. These commands allow you to configure the environment, manage tools, set up automation, and more. This article provides a comprehensive overview of all available slash commands.

What are Slash Commands?

Slash commands are special commands that start with / and provide access to Claude Code’s configuration and utility features. They can be invoked at any time during your conversation with Claude by simply typing the command.

Available Commands

/help - Display Available Commands

The /help command shows you all available slash commands and their descriptions. This is your starting point when you want to discover what Claude Code can do.

Usage:

/help

What it shows:

When to use it:

/config - Interactive Settings Configuration

The /config command launches an interactive configuration interface where you can adjust Claude Code’s behavior and preferences.

Usage:

/config

What you can configure:

Configuration hierarchy:

Claude Code uses a three-tier configuration system:

  1. User settings (~/.claude/settings.json) - Global settings for all projects
  2. Project settings (.claude/settings.json) - Team-wide settings (git tracked)
  3. Local settings (.claude/settings.local.json) - Personal overrides (git ignored)

Settings are merged in this order, with local settings taking precedence.

Example configuration options:

See the example configuration file:

{
  "model": "claude-3-5-sonnet-20241022",
  "maxTokens": 8192,
  "temperature": 0.7,
  "autoApproveTools": ["read", "grep", "view"],
  "hooks": {
    "enabled": true
  }
}

/allowed-tools - Manage Tool Permissions

The /allowed-tools command lets you control which tools Claude can use during your session. This is useful for security, limiting actions, or focusing on specific tasks.

Usage:

/allowed-tools

What it does:

Common tools you might want to control:

Example use cases:

Read-only mode: When you want Claude to analyze code without making changes:

Enable: view, grep, glob, read_bash
Disable: edit, create, bash (write mode)

Safe exploration: When exploring a new codebase:

Enable: view, grep, glob, search tools
Disable: edit, create, bash

Full automation: When you trust Claude to make changes:

Enable: all tools

/hooks - Set Up Automation Triggers

Hooks allow you to automate actions at specific points in your Claude Code workflow. They can run commands, format code, run linters, or integrate with external tools.

Usage:

/hooks

Available hook types:

  1. PreToolUse - Runs before a tool is executed
  2. PostToolUse - Runs after a tool completes
  3. UserPromptSubmit - Runs when you send a message
  4. SessionStart - Runs when a new session begins

Configuration:

Hooks are defined in your .claude/settings.json:

{
  "hooks": {
    "enabled": true,
    "PostToolUse": {
      "edit": "npm run format ${file}"
    }
  }
}

Common use cases:

Auto-format after editing:

{
  "hooks": {
    "PostToolUse": {
      "edit": "prettier --write ${file}"
    }
  }
}

Run tests after changes:

{
  "hooks": {
    "PostToolUse": {
      "edit": "npm test -- --findRelatedTests ${file}"
    }
  }
}

Lint on save:

{
  "hooks": {
    "PostToolUse": {
      "edit": "eslint --fix ${file}"
    }
  }
}

Session setup:

{
  "hooks": {
    "SessionStart": "git fetch origin && echo 'Ready to code!'"
  }
}

/mcp - Configure MCP Servers

Model Context Protocol (MCP) allows Claude Code to connect to external data sources and tools. This extends Claude’s capabilities beyond the local filesystem.

Usage:

/mcp

What is MCP?

MCP is a protocol that allows Claude to:

Common MCP integrations:

Configuration:

MCP servers are configured in .claude/mcp.json:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    "google-drive": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-gdrive"],
      "env": {
        "GDRIVE_CLIENT_ID": "${GDRIVE_CLIENT_ID}",
        "GDRIVE_CLIENT_SECRET": "${GDRIVE_CLIENT_SECRET}"
      }
    }
  }
}

Important considerations:

⚠️ Context consumption: MCP servers can consume significant context (40%+ in some cases). Use the /context command to monitor usage and disable unused servers.

Best practices:

  1. Only enable MCP servers you’re actively using
  2. Monitor context usage with /context
  3. Use environment variables for credentials (never hardcode)
  4. Disable servers between sessions if not needed

/agents - Create and Manage Subagents

Agents (also called subagents or custom agents) are specialized AI assistants with specific instructions and tool access. They’re perfect for repetitive tasks or domain-specific work.

Usage:

/agents

What are agents?

Agents are configured AI helpers that:

Configuration:

Agents are defined in .claude/agents/ directory:

File: .claude/agents/code-reviewer.json

{
  "name": "code-reviewer",
  "description": "Reviews code for best practices and potential bugs",
  "systemPrompt": "You are an expert code reviewer. Focus on:\n- Security vulnerabilities\n- Performance issues\n- Code style and conventions\n- Potential bugs",
  "allowedTools": ["view", "grep", "search_code"],
  "model": "claude-3-5-sonnet-20241022"
}

File: .claude/agents/test-writer.json

{
  "name": "test-writer",
  "description": "Writes comprehensive unit tests",
  "systemPrompt": "You are a test-driven development expert. Write thorough, maintainable tests with good coverage.",
  "allowedTools": ["view", "create", "edit", "bash"],
  "model": "claude-3-5-sonnet-20241022"
}

Using agents:

Once configured, invoke an agent by mentioning it:

@code-reviewer review the authentication module
@test-writer create tests for user-service.js

Common agent types:

/vim - Enable Vim-Style Editing

The /vim command enables vim keybindings in the Claude Code interface for those who prefer modal editing.

Usage:

/vim

What it enables:

Common vim commands in Claude Code:

When to use it:

Disabling vim mode: Run /vim again to toggle it off.

/terminal-setup - Install Keyboard Shortcuts

The /terminal-setup command installs shell integration and keyboard shortcuts for your terminal.

Usage:

/terminal-setup

What it installs:

Shell shortcuts:

Integration features:

Supported shells:

Installation process:

The command will:

  1. Detect your shell
  2. Add configuration to your shell RC file (~/.bashrc, ~/.zshrc, etc.)
  3. Create necessary helper scripts
  4. Set up keyboard shortcuts

Example additions to ~/.zshrc:

# Claude Code shortcuts
export CLAUDE_CODE_PATH="$HOME/.claude/bin"
alias claude="claude-code"

# Quick launch with Ctrl+K
bindkey '^k' claude-quick-launch

After installation: Restart your shell or run:

source ~/.zshrc  # or ~/.bashrc, ~/.config/fish/config.fish

/bug - Report Issues

The /bug command helps you report bugs or issues with Claude Code directly to the development team.

Usage:

/bug

What it does:

  1. Opens an issue template
  2. Collects diagnostic information automatically
  3. Lets you describe the problem
  4. Submits to the Claude Code issue tracker

Information collected:

Before reporting a bug:

  1. Check existing issues - Search for similar reports
  2. Try to reproduce - Verify the issue happens consistently
  3. Collect details - Note what you were doing when it occurred
  4. Simplify - Try to find the minimal reproduction case

What to include:

Good bug report:

Title: "bash tool fails with 'permission denied' on macOS"

Description:
When running `claude` with a bash command that writes to /usr/local,
I get a permission denied error even though the command works in my
regular terminal.

Steps to reproduce:
1. Run `claude`
2. Ask: "create a test file in /usr/local/test"
3. Error occurs when bash tool tries to execute

Expected: Should ask for sudo password or show clear error
Actual: Shows generic permission denied

Version: Claude Code 1.2.3
OS: macOS 14.1
Shell: zsh 5.9

Less helpful report:

Title: "it doesn't work"
Description: claude is broken, fix it

Command Chaining and Workflows

You can combine multiple slash commands in your workflow:

Example workflow:

  1. Setup new project:
/config         # Configure for the project
/mcp            # Enable necessary MCP servers
/hooks          # Set up auto-formatting
/terminal-setup # Install shortcuts
  1. Security-focused session:
/allowed-tools  # Restrict to read-only tools
/agents         # Load security auditor agent
  1. Before ending session:
/context        # Check context usage

Best Practices

  1. Use /help regularly - Discover new features and refresh your memory
  2. Configure per-project - Use .claude/settings.json for team consistency
  3. Monitor with /context - Keep track of token usage (see Understanding the /context command)
  4. Start restrictive - Use /allowed-tools to limit permissions, expand as needed
  5. Automate repetitive tasks - Set up /hooks for formatting, linting, testing
  6. Create specialized agents - Use /agents for common workflows
  7. Report issues - Use /bug to help improve Claude Code

This article covers the main slash commands. For more on context management, see:

Resources


Part of the Claude Code article series

tags: claude-code - ai - productivity - tools