Creating Slash Commands

Build custom slash commands in Claude Code with YAML frontmatter, permissions, and best practices. Use when creating automation workflows, project-specific commands, or standardizing repetitive tasks.

7 stars

Best use case

Creating Slash Commands is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Build custom slash commands in Claude Code with YAML frontmatter, permissions, and best practices. Use when creating automation workflows, project-specific commands, or standardizing repetitive tasks.

Teams using Creating Slash Commands should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/creating-slash-commands/SKILL.md --create-dirs "https://raw.githubusercontent.com/jack-michaud/faire/main/jack-software/skills/creating-slash-commands/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/creating-slash-commands/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Creating Slash Commands Compares

Feature / AgentCreating Slash CommandsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Build custom slash commands in Claude Code with YAML frontmatter, permissions, and best practices. Use when creating automation workflows, project-specific commands, or standardizing repetitive tasks.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Creating Slash Commands

## Overview

Slash commands automate workflows by encapsulating multi-step processes into reusable commands. They support YAML frontmatter for permissions, can integrate with CLI tools, and enable sophisticated decision logic.

## When to Use

- Automate repetitive multi-step workflows
- Standardize team processes (issue triage, PR reviews, etc.)
- Integrate external tools (GitHub CLI, git, custom scripts)
- Create project-specific automation patterns

## Process

1. **Create command file** in `.claude/commands/[name].md`
2. **Add YAML frontmatter** with permissions and description
3. **Write command prompt** with clear steps and decision logic
4. **Use $ARGUMENTS** variable for dynamic input
5. **Test command** with `/<command-name> [args]`

## Command Structure

### Basic Template

```markdown
# .claude/commands/my-command.md
---
allowed-tools: Bash(git:*),Read,Edit
description: Brief description of what this command does
---

Command instructions here. Use $ARGUMENTS to reference user input.

Steps:
1. First action
2. Second action
3. Final action
```

### YAML Frontmatter Fields

- `allowed-tools`: Restrict which tools the command can use
  - Examples: `Bash(gh:*)`, `Bash(git:*)`, `Read`, `Edit`, `Write`
  - Use wildcards: `Bash(pytest:*)` allows any pytest command
- `description`: One-line summary shown in command list

### Permission Patterns

```yaml
# Specific command only
allowed-tools: Bash(gh issue view:*)

# Multiple related commands
allowed-tools: Bash(gh issue view:*),Bash(gh issue comment:*)

# Tool categories
allowed-tools: Read,Edit,Grep,Glob

# Combined patterns
allowed-tools: Bash(git:*),Bash(gh:*),Read,Write
```

## Reference Example: Issue Triage Command

This project's `/plan-issue` demonstrates sophisticated automation:

```markdown
# .claude/commands/plan-issue.md
---
allowed-tools: Bash(gh issue view:*),Bash(gh issue comment:*)
description: Respond to a github issue with a plan of action
---

You are an expert software developer and project manager. Respond to GitHub issue $ARGUMENTS with a detailed plan. Steps:
1. Fetch issue: `gh issue view <issue-number>`
2. Analyze description and comments
3. Comment you're working on a plan: `gh issue comment <issue-number> --body "<your-comment>"`
4. Review codebase for context
5. Assess clarity: Need more info?
  - Yes: Comment clarifying questions, stop and wait
  - No: Proceed to step 6
6. Break down into smaller tasks
7. Comment detailed plan: `gh issue comment <issue-number> --body "<your-plan>"` with:
  - Issue summary
  - Resolution steps
  - Dependencies and considerations
```

**Key strengths:**
- Specific tool permissions (only issue view/comment)
- Multi-step workflow with decision branching
- GitHub CLI integration
- Context-aware (reads codebase before planning)
- Conditional logic (asks questions when unclear)

## Best Practices

### Permissions
- ✅ **Do**: Use specific tool permissions to limit scope
- ✅ **Do**: Use wildcards for command families (`Bash(git:*)`)
- ❌ **Don't**: Grant broad permissions without reason

### Command Design
- ✅ **Do**: Include decision logic for complex workflows
- ✅ **Do**: Read relevant context before taking action
- ✅ **Do**: Use CLI tool integration (gh, git, etc.)
- ❌ **Don't**: Assume context without verification
- ❌ **Don't**: Skip validation steps

### Structure
- ✅ **Do**: Number steps clearly
- ✅ **Do**: Use $ARGUMENTS for user input
- ✅ **Do**: Include clear success criteria
- ❌ **Don't**: Write vague instructions
- ❌ **Don't**: Omit error handling guidance

## Integration Patterns

### With Skills
Reference skill files in commands:

```markdown
---
description: Review code using TDD skill
---

1. Read skill: .claude/skills/testing/test-driven-development.md
2. Apply skill to files: $ARGUMENTS
3. Report findings
```

### With GitHub CLI
```markdown
---
allowed-tools: Bash(gh:*)
---

1. Fetch PR: `gh pr view $ARGUMENTS`
2. Get diff: `gh pr diff $ARGUMENTS`
3. Review and comment
```

### With Git
```markdown
---
allowed-tools: Bash(git:*)
---

1. Check status: `git status`
2. Stage changes: `git add $ARGUMENTS`
3. Commit with message
```

## Common Use Cases

### Workflow Automation
- Issue triage and planning
- PR review orchestration
- Release preparation
- Testing workflows

### Code Operations
- Batch refactoring
- Migration scripts
- Code generation
- Style enforcement

### Project Management
- Status reporting
- Documentation generation
- Dependency updates
- Configuration management

## Anti-patterns

- ❌ **Don't**: Create commands for single-step tasks
  - ✅ **Do**: Reserve commands for multi-step workflows

- ❌ **Don't**: Grant unlimited tool access
  - ✅ **Do**: Use specific allowed-tools restrictions

- ❌ **Don't**: Skip context gathering
  - ✅ **Do**: Read relevant files before action

- ❌ **Don't**: Write commands without decision logic
  - ✅ **Do**: Include conditional workflows for edge cases

- ❌ **Don't**: Ignore error scenarios
  - ✅ **Do**: Specify what to do when things fail

## Resources

- **Official Docs**: https://docs.claude.com/en/docs/claude-code/slash-commands
- **Settings Reference**: https://docs.claude.com/en/docs/claude-code/settings
- **Permissions Guide**: https://docs.claude.com/en/docs/claude-code/iam

Related Skills

Creating Hooks

7
from jack-michaud/faire

Build event-driven hooks in Claude Code for validation, setup, and automation. Use when you need to validate inputs, check environment state, or automate tasks at specific lifecycle events.

Creating New Plugins

7
from jack-michaud/faire

Follow a structured approach to create new Claude Code plugins and register them in your marketplace. Use when building plugins for commands, skills, hooks, or MCP servers.

Creating Skills

7
from jack-michaud/faire

A meta-skill for documenting and creating reusable skills for Claude Code agents. Use when you discover a technique, pattern, or workflow worth documenting for reuse across projects.

Ticket Workflow

7
from jack-michaud/faire

Autonomous ticket-to-production lifecycle with promptlet-driven phases. Use when executing /ticket commands or working on ticket-driven development.

setup-sprite

7
from jack-michaud/faire

Set up a reproducible remote dev environment using sprites with credential-free git sync. Use when user asks to "set up a sprite", "create a remote dev environment", "use sprites", or mentions wanting a reproducible remote environment for a project.

Writing python services

7
from jack-michaud/faire

Writing a class with encapsulated logic that interfaces with an external system. Logging, APIs, etc.

stacked-pr-review

7
from jack-michaud/faire

Use when addressing PR review comments on stacked jj branches. Triggered by phrases like "address review comments", "fix PR feedback", "respond to review on stacked branch", or "update the PR with reviewer suggestions".

Python Code Style

7
from jack-michaud/faire

Use when writing python code. Can be used for code review.

Plan

7
from jack-michaud/faire

My planning skill that has additional instructions. Always use when entering plan mode.

Modal

7
from jack-michaud/faire

No description provided.

merging-pr-stack

7
from jack-michaud/faire

Use when merging a stack of stacked PRs with jj. Triggered by phrases like "merge the PR stack", "merge the stacked PRs", "land these PRs", or "merge the stack into main".

Create Claude Channel

7
from jack-michaud/faire

Step-by-step procedure for building a Claude Code channel integration. Use when creating a new channel plugin that connects Claude Code to external systems via MCP, named pipes, webhooks, or chat platforms.