writing-slash-commands

1
1
Source

Create and use custom slash commands to automate Claude Code workflows. Learn argument passing, frontmatter configuration, bash integration, and file references for building reusable prompts.

Install

mkdir -p .claude/skills/writing-slash-commands && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5615" && unzip -o skill.zip -d .claude/skills/writing-slash-commands && rm skill.zip

Installs to .claude/skills/writing-slash-commands

About this skill

Slash Commands Guide

Slash commands are reusable prompt templates that automate recurring tasks in Claude Code. Define them once, invoke them anytime with /command-name [args].

Quick Start

Create a Command

Project-scoped (shared with team):

mkdir -p .claude/commands
echo "Analyze this code for performance issues:" > .claude/commands/optimize.md

Personal (across all projects):

mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security-review.md

Invoke with /optimize or /security-review.


Custom Commands Architecture

ScopeLocationScopeShareable
Project.claude/commands/Repository-specificYes (team)
Personal~/.claude/commands/All projectsNo

Namespacing

Organize commands in subdirectories (no effect on invocation):

.claude/commands/
├── frontend/
│   └── component.md      # Invokes as `/component` (shows "project:frontend")
├── backend/
│   └── api.md           # Invokes as `/api` (shows "project:backend")
└── security-review.md   # Invokes as `/security-review`

Note: User-level and project-level commands with the same name conflict; only one is available.


Arguments & Placeholders

Capture All Arguments with $ARGUMENTS

Use $ARGUMENTS when you need all arguments as a single string:

---
description: Fix issue with optional priority
argument-hint: [issue-number] [optional-priority]
---

Fix issue #$ARGUMENTS following our coding standards.

Usage: /fix-issue 123$ARGUMENTS = "123" Usage: /fix-issue 123 high-priority$ARGUMENTS = "123 high-priority"

Access Individual Arguments with $1, $2, ...

Use positional parameters for structured commands:

---
description: Review pull request with priority and assignee
argument-hint: [pr-number] [priority] [assignee]
---

Review PR #$1 with priority $2 and assign to $3.
Focus on security, performance, and code style.

Usage: /review-pr 456 high alice$1="456", $2="high", $3="alice"

When to use positional:

  • Arguments have distinct roles (ID, priority, owner)
  • Need defaults: ${3:-unassigned}
  • Reference arguments separately throughout command

Frontmatter Configuration

All options are optional; commands work without frontmatter.

FieldPurposeExample
descriptionShown in /help (required for SlashCommand tool)"Fix security issues"
argument-hintArgument syntax hint for autocomplete"[issue] [priority]"
allowed-toolsTools this command can invokeBash(git add:*), Bash(git status:*)
modelOverride default model for this command"claude-3-5-haiku-20241022"
disable-model-invocationPrevent SlashCommand tool from triggeringtrue

Example with Full Frontmatter

---
description: Create a git commit with staged changes
argument-hint: [message]
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
model: claude-3-5-haiku-20241022
---

Create a git commit with message: $ARGUMENTS

Bash Execution & File References

Run Bash Commands with !

Prefix inline commands with ! to execute before the command runs. Requires allowed-tools with Bash:

---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*), Bash(git log:*)
description: Create a git commit
---

## Context

- Current status: !`git status`
- Staged changes: !`git diff --cached`
- Recent commits: !`git log --oneline -5`

## Your Task

Create a single commit summarizing the changes.

Output from bash commands is included in the prompt context.

Reference Files with @

Include file contents in commands:

Review the implementation in @src/utils/helpers.js

Compare @src/old-version.js with @src/new-version.js

Use standard file references (e.g., @docs/, @src/).


Pattern Examples

Example 1: Priority-Based Issue Fix

---
description: Fix issue with priority level
argument-hint: [issue-number] [priority-level]
---

Fix GitHub issue #$1 with priority "$2".

Steps:
1. Understand the issue context
2. Write minimal, focused fix
3. Consider edge cases
4. Ensure tests pass

Usage: /fix-issue 42 high


Example 2: Bash-Powered Code Review

---
allowed-tools: Bash(git diff:*), Bash(git log:*)
description: Review recent commits for code quality
argument-hint: "[number-of-commits]"
---

## Context

Recent changes:
!`git log --oneline -${1:-5}`

Full diff:
!`git diff HEAD~${1:-5}...HEAD`

## Your Task

Provide a code quality review focusing on readability, performance, and best practices.

Usage: /review-commits 3 → Reviews last 3 commits


Example 3: Multi-Argument Configuration Command

---
description: Set up feature flags for testing
argument-hint: feature [enable|disable] [environment]
---

Configure feature "$1" to be $2 in the $3 environment.

Verify:
- Feature flag exists in @src/config/features.ts
- Environment is valid (dev, staging, production)
- Changes are tested before deployment

Usage: /feature dark-mode enable staging


SlashCommand Tool Integration

The SlashCommand tool allows Claude to invoke your custom commands programmatically.

Enable Auto-Invocation

Add to CLAUDE.md or project instructions:

When appropriate, use /optimize to analyze code performance.
When fixing bugs, use /fix-issue with the issue number.

Requirements for Tool Access

  1. Command must have description frontmatter
  2. Command must NOT have disable-model-invocation: true
  3. User must allow SlashCommand tool in permissions

Disable Specific Commands

Prevent Claude from auto-invoking a command:

---
disable-model-invocation: true
description: Manual review only
---

Your command content...

Permission Rules

Fine-grained control via /permissions:

SlashCommand:/commit         # Exact match: /commit only
SlashCommand:/review-pr:*    # Prefix match: /review-pr with any args

Deny SlashCommand entirely to disable all auto-invocation.


Best Practices

Do:

  • Use descriptive names matching functionality (e.g., /optimize, /security-review)
  • Include description for discoverability via /help and SlashCommand tool
  • Add argument-hint for clear usage patterns
  • Keep commands focused on a single responsibility
  • Use bash execution for context that changes (git status, timestamps)

Don't:

  • Embed static content that belongs in code (use file references instead)
  • Create commands without descriptions (breaks tool integration)
  • Overload with too many positional arguments (>3 becomes hard to remember)
  • Assume tools are available without declaring allowed-tools

Built-in Slash Commands (Reference)

Essential commands you get for free:

CommandPurpose
/helpList all commands (built-in + custom)
/configOpen Settings interface
/statusShow version, model, account
/costToken usage statistics
/modelSwitch AI model
/memoryEdit CLAUDE.md
/rewindRewind conversation or code
/clearClear history
/agentsManage custom AI subagents
/mcpManage MCP server connections

Workflow Integration

In CLAUDE.md or project instructions:

## Custom Commands

Use these commands to accelerate development:

- `/optimize [file]` — Analyze code performance
- `/security-review [file]` — Check for vulnerabilities
- `/commit [message]` — Create atomic commits
- `/test [suite]` — Run tests with focus

In conversations:

> I'll use /optimize to check this function for performance issues.

Claude recognizes the slash and may auto-invoke if SlashCommand tool is enabled.


See Also

  • MCP Slash Commands: Commands exposed by MCP servers (pattern: /mcp__server__prompt)
  • Plugin Commands: Commands from installed plugins (pattern: /plugin-name:command or just /command)
  • Interactive Mode: Keyboard shortcuts and input modes
  • Permissions: Fine-grained tool and command access control

reviewing-code

CaptainCrouton89

Systematically evaluate code changes for security, correctness, performance, and spec alignment. Use when reviewing PRs, assessing code quality, or verifying implementation against requirements.

10017

railway-cli-management

CaptainCrouton89

Deploy, manage services, view logs, and configure Railway infrastructure. Use when deploying to Railway, managing environment variables, viewing deployment logs, scaling services, or managing volumes.

1388

writing-like-user

CaptainCrouton89

Emulate the user's personal writing voice and style patterns. Use when the user asks to write content in their voice, draft documents, compose messages, or requests "write this like me" or "in my style."

815

gathering-requirements

CaptainCrouton89

Systematically clarify user needs, preferences, and constraints before planning or implementation. Classifies work type, investigates existing systems, discovers edge cases and integration points, resolves assumptions, and creates detailed specifications. Use when building features, enhancements, or integrations where requirements need clarification.

13

fixing-bugs-systematically

CaptainCrouton89

Diagnose and fix bugs through systematic investigation, root cause analysis, and targeted validation. Use when something is broken, errors occur, performance degrades, or unexpected behavior manifests.

21

investigating-code-patterns

CaptainCrouton89

Systematically trace code flows, locate implementations, diagnose performance issues, and map system architecture. Use when understanding how existing systems work, researching concepts, exploring code structure, or answering "how/where/why is X implemented?" questions.

61

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,6851,428

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,2641,326

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,5331,147

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,355809

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,264727

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,486684