Create custom slash commands for Claude Code plugins
Slash commands are frequently-used prompts defined as Markdown files that Claude executes during interactive sessions. They provide reusability, consistency, and efficiency for common workflows.
Commands are written for agent consumption, not human consumption. Write commands as directives TO Claude about what to do, not as messages TO the user.
Correct approach (instructions for Claude):
Review this code for security vulnerabilities including:- SQL injection- XSS attacks- Authentication issuesProvide specific line numbers and severity ratings.
Incorrect approach (messages to user):
This command will review your code for security issues.You'll receive a report with vulnerability details.
The first example tells Claude what to do. The second tells the user what will happen but doesn’t instruct Claude.
Simple command without frontmatter:commands/review.md:
Review this code for security vulnerabilities including:- SQL injection- XSS attacks- Authentication bypass- Insecure data handlingProvide specific file:line references for each issue.
---description: Review code for security vulnerabilitiesargument-hint: [file-path]allowed-tools: ["Read", "Grep", "TodoWrite"]---Review the code for security vulnerabilities.If $ARGUMENTS is provided, focus on that file.Otherwise, review recent changes.
---argument-hint: [file-path]---If $ARGUMENTS is provided:1. Read that specific file2. Analyze just that fileIf $ARGUMENTS is empty:1. List all changed files with git status2. Ask which file to analyze3. Proceed with user's choice
---description: Create new feature with guided setup---Follow these steps:1. Ask for feature name using AskUserQuestion2. Create feature branch: feature/[name]3. Create directory structure4. Generate boilerplate files5. Show summary of what was created
---description: Review recent git changes---1. Run `git log --oneline -10` to see recent commits2. Run `git diff HEAD~1` to see latest changes3. Analyze the changes for: - Code quality issues - Potential bugs - Best practice violations
---description: Run tests with optional filtersargument-hint: [test-pattern]---Run the project's test suite.Steps:1. Determine test framework (Jest, pytest, etc.)2. If $ARGUMENTS provided, filter tests by pattern3. Run tests with appropriate command4. Analyze failures if any5. Suggest fixes for failing tests
---description: Deploy application to specified environment---Deploy the application using interactive environment selection.1. Use AskUserQuestion to select environment: - Production (requires confirmation) - Staging - Development2. If Production selected, ask for additional confirmation3. Run pre-deployment checks: - Tests passing - No uncommitted changes - On correct branch4. Execute deployment: - Build application - Run deployment script - Verify deployment5. Show deployment summary with URLs