Skip to content

Slash Commands

Slash commands are shortcuts that trigger specific behaviors. Some are built-in; you can create your own.

CommandDescription
/helpShow all available commands
/compactSummarize context to save tokens
/clearClear conversation history
/modelSwitch to a different model
/configView or modify settings
/contextShow context window usage
/mcpManage MCP server connections

For complex tasks, use plan mode by pressing Alt+M to cycle through modes:

> add a user notification system

Claude will:

  1. Ask clarifying questions using the AskUserQuestion tool
  2. Present options for you to choose
  3. Create a detailed implementation plan
  4. Wait for your approval before executing

When your conversation gets long:

> /compact

Claude summarizes the conversation, keeping important context while reducing token usage. Use this proactively—don’t wait until you hit limits.

Change models without restarting:

> /model haiku # Quick, cheap queries
> /model sonnet # Default, balanced
> /model opus # Complex reasoning

Create your own commands for repetitive workflows.

  1. Create the commands directory

    Terminal window
    mkdir -p .claude/commands
  2. Create a command file

    Each .md file becomes a command:

    Terminal window
    touch .claude/commands/review.md
  3. Write the command prompt

    Review my staged changes for:
    1. Code quality issues
    2. Potential bugs
    3. Security concerns
    4. Missing tests
    5. Documentation needs
    Be thorough but concise. Prioritize by severity.
  4. Use your command

    > /review
  • Directory.claude/
    • Directorycommands/
      • review.md
      • deploy.md
      • test.md
      • doc.md
Review the code changes I'm about to commit.
Check for:
1. **Bugs**: Logic errors, edge cases, null handling
2. **Security**: Input validation, SQL injection, XSS
3. **Performance**: N+1 queries, unnecessary loops, memory leaks
4. **Style**: Naming, formatting, consistency with codebase
5. **Tests**: Are changes tested? Should new tests be added?
Provide feedback in order of severity. Be specific about file
and line numbers.
Run through the deployment checklist:
1. [ ] All tests pass
2. [ ] No linting errors
3. [ ] Database migrations are ready
4. [ ] Environment variables documented
5. [ ] CHANGELOG updated
6. [ ] Version number bumped
For each item, check and report status. Flag any blockers.
Generate comprehensive tests for the current file or function.
Include:
- Happy path tests
- Edge cases (empty input, large input, null)
- Error conditions
- Boundary conditions
Use pytest with fixtures where appropriate.
Follow existing test patterns in the codebase.
Generate documentation for the specified code:
1. Module-level docstring explaining purpose
2. Function/method docstrings with:
- Description
- Args with types
- Returns with type
- Raises (if applicable)
- Example usage
3. Type hints if missing
Use Google-style docstrings. Be concise but complete.
Generate a pull request description based on my changes.
Include:
## Summary
Brief description of what changed and why.
## Changes
- Bullet list of specific changes
## Testing
How the changes were tested.
## Screenshots
(Note if UI changes need screenshots)
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] No breaking changes (or documented if yes)

Commands can use $ARGUMENTS to accept input:

.claude/commands/explain.md
Explain the following code in detail:
$ARGUMENTS
Focus on:
1. What it does
2. How it works
3. Why it's implemented this way
4. Any potential issues

Usage:

> /explain the authentication middleware in app/middleware.py

Commands can reference selected code:

.claude/commands/optimize.md
Optimize this code for performance:
$SELECTION
Consider:
- Time complexity
- Space complexity
- Database queries
- Memory allocations
Show before/after with benchmarks if possible.

Commands in .claude/commands/ are part of your repo. Share them with your team:

Terminal window
git add .claude/commands/
git commit -m "Add team slash commands"

For personal commands that shouldn’t be shared:

Terminal window
# Add to .gitignore
echo ".claude/commands/personal-*.md" >> .gitignore
# Good
Review code for SQL injection vulnerabilities.
Check all database queries for parameterized inputs.
# Bad
Review code for security.
# Good
Generate tests using pytest.
Follow patterns in tests/conftest.py.
Use fixtures from tests/fixtures/.
# Bad
Generate tests.
# Good
Provide 3-5 specific suggestions.
Prioritize by impact.
Include code examples.
# Bad
Give me feedback.