Slash Commands

User-invoked prompt templates for common workflows.

Slash commands are reusable prompt templates that users invoke by typing/command-name. They're ideal for standardizing repetitive workflows like code review, testing, and deployment.

How It Works

When a user types a slash command:

  1. The agent looks up the command in .claude/commands/
  2. The template is loaded and placeholders are replaced with arguments
  3. The expanded prompt is sent to the agent for processing

File Location

Commands are stored as markdown files in the .claude/commands/ directory:

.claude/
└── commands/
    ├── review-pr.md
    ├── test.md
    ├── deploy.md
    └── document.md

The filename (without .md) becomes the command name.

Command Structure

Each command file contains a prompt template:

.claude/commands/review-pr.md
1Review pull request #$1 for:
2
31. Code quality and best practices
42. Potential bugs or edge cases
53. Security vulnerabilities
64. Performance implications
75. Test coverage
8
9Provide specific, actionable feedback with line references.

Placeholders

Commands support two types of placeholders:

Positional Arguments ($1, $2, $3...)

Replace specific positions with user-provided values.

1# Usage: /deploy staging
2Deploy to the $1 environment.
3Run pre-deployment checks and notify the team.

All Arguments ($ARGUMENTS)

Replace with the entire argument string.

1# Usage: /search user authentication flow
2Search the codebase for: $ARGUMENTS
3Summarize relevant files and their relationships.

Built-in Templates

/review-pr

Review a pull request for quality and security.

1Review pull request #$1 for:
2
31. Code quality and best practices
42. Potential bugs or edge cases
53. Security vulnerabilities
64. Performance implications
75. Test coverage
8
9Provide specific, actionable feedback with line references.

/test

Run tests and fix failures.

1Run the test suite and handle any failures:
2
31. Execute: npm test
42. Analyze any failing tests
53. Identify root causes
64. Implement fixes
75. Re-run to verify
8
9Focus on: $ARGUMENTS

/deploy

Deploy to a specified environment.

1Deploy to the $1 environment:
2
31. Run pre-deployment checks
42. Build the production bundle
53. Execute deployment scripts
64. Verify deployment success
75. Run smoke tests
8
9Report any issues encountered.

/document

Generate documentation for code.

1Generate documentation for: $ARGUMENTS
2
3Include:
4- Purpose and functionality
5- Parameters and return values
6- Usage examples
7- Edge cases and limitations
8
9Format as JSDoc/TSDoc comments.

/refactor

Refactor code with specific goals.

1Refactor the following with these goals: $ARGUMENTS
2
31. Analyze current implementation
42. Identify improvement opportunities
53. Propose refactoring strategy
64. Implement changes incrementally
75. Verify behavior is preserved
8
9Explain each change and its benefits.

Creating Custom Commands

To create a custom command:

  1. Create a new .md file in .claude/commands/
  2. Write your prompt template using placeholders
  3. Save with the desired command name

Example: Custom /analyze Command

.claude/commands/analyze.md
1Analyze $1 for:
2
3## Performance
4- Time complexity
5- Space complexity
6- Bottlenecks
7
8## Maintainability
9- Code clarity
10- Documentation
11- Test coverage
12
13## Security
14- Input validation
15- Error handling
16- Sensitive data exposure
17
18Provide a summary with recommendations.

Command naming

Use lowercase names with hyphens for multi-word commands. Keep names short and descriptive: /review-pr, /run-tests, /gen-docs.

Configuration in Agent Workshop

In the Levers Configuration step, the Slash Commands tab lets you:

  • Add from templates - Use pre-built command templates
  • Create custom - Write your own commands
  • Configure placeholders - Define expected arguments
  • Enable/disable - Toggle individual commands

Best Practices

Be Specific

Vague commands produce vague results. Include specific steps, criteria, and expected outputs.

Use Numbered Steps

Breaking workflows into numbered steps helps the agent execute systematically.

Include Context Hints

Tell the agent what to focus on or ignore.

Test Your Commands

Try your commands with various arguments to ensure they work as expected.