Action-Oriented
/deploy-staging
/run-tests
/fix-lint
Slash commands transform Claude Code from a conversational assistant into a powerful automation platform. Master these commands to standardize workflows, eliminate repetitive tasks, and share best practices across your team.
Command | Purpose | Pro Tips |
---|---|---|
/clear | Reset conversation context | Use between unrelated tasks to save tokens |
/compact [instructions] | Compress conversation history | Add focus instructions: /compact Focus on test results |
/cost | View token usage and costs | Check regularly to optimize spending |
/resume | Resume previous conversation | Maintains full context from earlier sessions |
# Example: Compact with specific focus/compact Keep only code changes and error messages
# Check costs before expensive operations/cost
Command | Purpose | Pro Tips |
---|---|---|
/config | Modify settings interactively | Access model preferences, permissions |
/permissions | Manage tool permissions | Set up team-wide allowed tools |
/model | Switch AI models | Choose between Opus 4 and Sonnet 4 |
/hooks | Configure automation hooks | Set up event-driven workflows |
# Configure permissions for team/permissions# Navigate to: Add new permission → Edit → Always allow
# Switch to Opus for complex task/model# Select: claude-4-0-opus
Command | Purpose | Pro Tips |
---|---|---|
/init | Generate CLAUDE.md | Creates project-specific memory file |
/memory | Edit memory files | Update project documentation on the fly |
/add-dir | Add working directories | Expand workspace without restarting |
/review | Request code review | Get immediate feedback on changes |
# Initialize project with context/init
# Add related microservice/add-dir ../backend-api
# Quick code review/review
# Configure MCP servers/mcp
# Typical workflow:# 1. View configured servers# 2. Check connection status# 3. Authenticate OAuth servers# 4. Test available tools
# Install GitHub app for automated reviews/install-github-app
# View PR comments in current branch/pr_comments
# This enables @claude mentions in GitHub
Custom commands are Markdown files in specific directories:
/deploy
)/test
)/frontend:component
)/personal-workflow
)# Create New Feature
Please implement a new feature with the following specifications:
$ARGUMENTS
Requirements:- Follow our coding standards in CLAUDE.md- Include comprehensive tests- Update documentation- Create or update API endpoints as needed- Ensure backward compatibility
Steps:1. Analyze existing code structure2. Plan the implementation3. Write tests first (TDD)4. Implement the feature5. Update documentation6. Prepare commit with descriptive message
Usage: /feature User authentication with OAuth
---allowed-tools: Bash(gh:*), Edit, MultiEdit, WebSearchdescription: Fix GitHub issue with full workflowargument-hint: issue-number---
## Current Context- Git status: !`git status --short`- Current branch: !`git branch --show-current`- Recent commits: !`git log --oneline -5`
## Task
Fix GitHub issue #$ARGUMENTS by:
1. Fetching issue details with `gh issue view $ARGUMENTS`2. Understanding the problem and requirements3. Searching codebase for relevant files4. Implementing the fix with tests5. Creating descriptive commit referencing the issue6. Opening a PR with explanation
## Standards- All changes must pass: !`cat .github/pre-push-checks.sh`- Follow patterns in: @docs/coding-standards.md
---allowed-tools: Bash(npm:*), Bash(lighthouse:*), WebFetchdescription: Analyze and improve performance---
## Performance Analysis for: $ARGUMENTS
### Current Metrics!`npm run build -- --stats`
### Bundle Analysis!`npm run analyze`
### Lighthouse Scores (if URL provided)!`[[ "$ARGUMENTS" =~ ^https?:// ]] && lighthouse $ARGUMENTS --output=json --quiet | jq '.categories'`
## Your Task
Based on the above metrics:1. Identify performance bottlenecks2. Suggest specific optimizations3. Implement improvements4. Measure impact
Focus on:- Bundle size reduction- Load time optimization- Runtime performance- Memory usage
---allowed-tools: Bash(git:*), Bash(npm:*), Editdescription: Automated release workflowargument-hint: major|minor|patch---
# Release Workflow - $ARGUMENTS
## Pre-release Checks- Current version: !`node -p "require('./package.json').version"`- Uncommitted changes: !`git status --porcelain`- Current branch: !`git branch --show-current`- CI status: !`gh run list --limit 1`
## Release Tasks
Please execute the following release workflow:
1. Ensure we're on main branch and up to date2. Run all tests and ensure they pass3. Update version using `npm version $ARGUMENTS`4. Generate changelog from commits since last tag5. Update CHANGELOG.md with generated content6. Commit changes7. Create annotated tag8. Push changes and tags9. Create GitHub release with changelog
Abort if any step fails.
Action-Oriented
/deploy-staging
/run-tests
/fix-lint
Resource-Focused
/update-database
/clean-cache
/build-docker
Workflow-Based
/morning-routine
/pre-commit
/post-deploy
Use subdirectories for logical grouping:
<!-- Using split pattern --># Deploy to $ARGUMENTS
Parse arguments:- Environment: First word before space- Version: Everything after first space
Example: /deploy staging v2.1.0
<!-- Handling optional parameters --># Build project
Target: ${ARGUMENTS:-production}
This builds for production by default,or the specified target if provided.
MCP servers can expose their own slash commands:
# Format: /mcp__<server>__<command>
# Examples:/mcp__github__create_pr/mcp__database__run_migration/mcp__browser__take_screenshot
/mcp
to see connected servers/help
when server is activeCreate commands that call other commands:
# Comprehensive Test Suite
Please run the following test sequence:
1. First, run unit tests: `/test:unit all`2. If successful, run integration: `/test:integration`3. Finally, run E2E tests: `/test:e2e critical`4. Generate coverage report
Stop if any stage fails.
---allowed-tools: Bash(git:*), Read, Edit---
# Intelligent Fix Based on Context
## Determine Issue Type- Last commit: !`git log -1 --oneline`- Changed files: !`git diff --name-only HEAD~1`- CI status: !`[[ -f .github/workflows/ci.yml ]] && echo "CI configured"`
## Apply Appropriate Fix
Based on the context above:- If test files changed: Run affected tests- If source files changed: Run tests and lint- If CI files changed: Validate workflow syntax- If docs changed: Check markdown and links
$ARGUMENTS
Share commands via version control:
# In your repositorygit add .claude/commands/git commit -m "Add team Claude Code commands"git push
# Team members automatically get commands
Starting with a simple need:
<!-- Version 1: Basic -->Run our test suite
Evolving to production-ready:
<!-- Version 2: Robust -->---allowed-tools: Bash(npm:*), Readdescription: Run test suite with smart detectionargument-hint: [specific-test-file] [--watch]---
# Test Runner
## Environment Check- Node version: !`node --version`- Test framework: !`[[ -f jest.config.js ]] && echo "Jest" || echo "Unknown"`- Previous test results: !`[[ -f coverage/lcov-report/index.html ]] && echo "Coverage available"`
## Run Tests
Target: ${ARGUMENTS:-all tests}
Please:1. Clear test cache if needed2. Run tests matching: $ARGUMENTS3. If failures, analyze and suggest fixes4. Generate coverage report5. Highlight any new uncovered code
Use --watch flag if specified in arguments.
!
bash execution@
for consistent contexthead
, tail
, or jq
Now that you’ve mastered slash commands: