Create Custom Slash Commands with Markdown Files
Every team has prompts they run over and over — reviewing PRs, generating tests, checking conventions. Instead of retyping them, turn each one into a reusable slash command by dropping a Markdown file into .claude/commands/.
# Create a project-level command anyone on the team can use
mkdir -p .claude/commands
cat > .claude/commands/review.md << 'EOF'
Review the staged changes for:
- Security vulnerabilities
- Missing error handling
- Naming convention violations
Suggest fixes inline. Be concise.
EOF
Now type /review in any Claude Code session inside that project and the prompt fires immediately. The filename becomes the command name — review.md becomes /review, add-tests.md becomes /add-tests.
For commands you want across all projects, use the global directory instead:
# Global commands live in ~/.claude/commands/
mkdir -p ~/.claude/commands
cat > ~/.claude/commands/explain.md << 'EOF'
Explain this code like I'm reading it for the first time.
Walk through the logic step by step, note any non-obvious decisions,
and flag anything that looks fragile.
EOF
You can also use the $ARGUMENTS placeholder to pass dynamic input:
cat > .claude/commands/migrate.md << 'EOF'
Create a new migration for: $ARGUMENTS
Follow existing migration conventions in this project.
Run the migration and verify it works.
EOF
# Usage: /migrate "add status column to orders table"
Project commands (.claude/commands/) get committed to git so the whole team shares them. Global commands (~/.claude/commands/) are yours alone.
The best slash commands aren't clever — they're the prompts you were already typing every day, saved once and reused forever.
via Claude Code
Log in to leave a comment.
Turn your most common prompts into reusable slash commands — drop a markdown file into .claude/commands/ and it becomes a /command you and your team can invoke anytime, with consistent instructions every time.
Create reusable slash commands in your project so common prompts like "run tests and fix failures" or "review this file for security issues" become a single /command instead of typing the same instructions every time.
The $ARGUMENTS placeholder in custom slash command files turns a static prompt into a reusable tool — pass different values each time you invoke it, just like a function that takes arguments.