slash-commands
npx machina-cli add skill parcadei/Continuous-Claude-v3/slash-commands --openclawSlash Commands Reference
Create and use user-triggered prompts with /command-name syntax.
When to Use
- "How do I create a slash command?"
- "What slash commands are available?"
- "Add bash to my command"
- "Use file references in commands"
- "Slash commands vs skills"
Built-in Commands
| Command | Purpose |
|---|---|
/clear | Clear conversation history |
/compact | Compact conversation with focus |
/config | Open settings interface |
/cost | Show token usage |
/agents | Manage sub-agents |
/mcp | Manage MCP servers |
/memory | Edit CLAUDE.md files |
/model | Select AI model |
/review | Request code review |
/resume | Resume session |
/help | Get usage help |
Creating Commands
Project Commands
mkdir -p .claude/commands
cat > .claude/commands/optimize.md << 'EOF'
---
description: Analyze code for performance issues
---
Review this code for:
- Performance bottlenecks
- Memory leaks
- Caching opportunities
EOF
Personal Commands
mkdir -p ~/.claude/commands
cat > ~/.claude/commands/review.md << 'EOF'
---
description: Security-focused code review
---
Check for vulnerabilities:
- Input validation
- SQL injection
- XSS risks
EOF
Command File Format
---
description: Brief description for /help
allowed-tools: [Bash, Read, Write] # Optional
argument-hint: "[file] [type]" # Optional
---
Your markdown instructions here.
Use $1, $2 for arguments or $ARGUMENTS for all.
Bash Execution
Run bash before loading prompt with ! prefix:
---
allowed-tools: Bash(git:*), Bash(grep:*)
description: Git commit helper
---
Current status: !`git status`
Staged changes: !`git diff --staged`
Recent commits: !`git log --oneline -5`
Based on these changes, suggest a commit message.
Rules:
- Must declare
allowed-tools: Bash(...)in frontmatter - Use backticks:
!`command` - Output is included in Claude's context
File References
Include files with @ prefix:
Review against @.claude/STYLE_GUIDE.md
Compare:
- @src/old.js
- @src/new.js
Refactor files matching @src/**/*.util.ts
Arguments
---
argument-hint: "[pr-number] [priority]"
---
Review PR #$1 with priority: $2
# Or use all arguments:
Fix issue #$ARGUMENTS
Usage:
/review-pr 456 high
# $1 = "456", $2 = "high"
Namespacing
Organize with subdirectories:
.claude/commands/
├── frontend/
│ └── component.md → /component (project:frontend)
└── backend/
└── endpoint.md → /endpoint (project:backend)
MCP Slash Commands
MCP servers expose prompts as commands:
/mcp__github__list_prs
/mcp__github__pr_review 456
/mcp__jira__create_issue "Bug" high
Slash Commands vs Skills
| Aspect | Slash Commands | Skills |
|---|---|---|
| Invocation | Explicit: /command | Auto-discovered |
| Files | Single .md file | Directory with SKILL.md |
| Use Case | Quick prompts | Complex workflows |
Use slash commands for: Frequently typed prompts, simple templates Use skills for: Complex workflows, multiple files, auto-discovery
Example: Complete Git Commit Command
---
description: Generate semantic commit message
allowed-tools: Bash(git:*), Read
argument-hint: "[type]"
---
# Semantic Commit Generator
Staged files: !`git diff --name-only --cached`
Diff preview:
!`git diff --cached | head -100`
Generate a conventional commit message.
Type: $1 (feat/fix/docs/style/refactor/perf/test/chore)
Format: `<type>(<scope>): <subject>`
Usage: /commit feat
Source
git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/slash-commands/SKILL.mdView on GitHub Overview
Slash Commands let you trigger prompts with /command-name for fast, repeatable tasks. They support quick prompts, Bash execution, and file references within commands. You can organize commands as project- or personal-level files under .claude/commands or ~/.claude/commands and use MCP slash commands for management and namespacing.
How This Skill Works
Each command is a Markdown file with a YAML frontmatter that declares allowed-tools and an optional argument-hint; the body provides the prompt logic. Bash can be executed in the command body using the !`command` syntax, and files can be referenced with @ prefixes. Arguments are passed as $1, $2 or $ARGUMENTS.
When to Use It
- When you need a quick, repeatable prompt (e.g., common tasks).
- When you want to run shell commands inside a prompt using Bash.
- When you want to reference project or source files with @ references.
- When you want to organize prompts by project or user with subdirectories.
- When you compare Slash Commands to Skills for lightweight prompts and quick templates.
Quick Start
- Step 1: Create a command file under .claude/commands or ~/.claude/commands.
- Step 2: Add YAML frontmatter with description and allowed-tools (and optional argument-hint).
- Step 3: Write the prompt body and use $1, $ARGUMENTS and !`command` references as needed.
Best Practices
- Declare allowed-tools in the frontmatter (e.g., allowed-tools: [Bash, Read, Write]).
- Provide an argument-hint to guide usage and input expectations.
- Name and place commands in the correct directory (.claude/commands or ~/.claude/commands).
- Use clear, concise Markdown bodies and document behavior with /help.
- Test prompts with example inputs and verify the corresponding /help output.
Example Use Cases
- Built-in command: /clear clears conversation history.
- Project command: optimize.md analyzes code for performance issues.
- Personal command: review.md performs a security-focused code review.
- Bash execution: Git commit helper uses !`git status`, !`git diff --staged`, !`git log --oneline -5` to craft a commit message.
- File references: review against @.claude/STYLE_GUIDE.md and compare @src/old.js vs @src/new.js.