Automated summary
Explains how to build custom Claude Code slash commands with YAML frontmatter, tool permissions, and multi-step decision logic.
Strengths
- Clear file template with YAML frontmatter and the $ARGUMENTS input variable
- Precise permission patterns (Bash(gh issue view:*), Bash(git:*), Read, Edit) that keep scope tight
- Complete, realistic issue-triage example showing conditional branching and CLI integration
- Explicit best practices for structure, validation, and external tool usage
Limitations
- Tightly bound to Claude Code: .claude/commands files do not carry over to other agents
- Does not cover debugging failing commands or concrete error-handling implementations
- The skills-integration section is cut off and only sketched out
Use it when turning a repetitive process such as issue triage, PR review, or git scripting into a reusable slash command for a team.
Skip it if you need guidance for agents other than Claude Code, or if you are authoring skills rather than slash commands.
Security analysis
SafeThis is purely instructional content explaining how to author Claude Code slash command files with YAML frontmatter and tool permissions. It contains no executable payloads, no destructive commands (no rm -rf, curl|sh, or base64 decoding), and no attempts to exfiltrate secrets or disable safety mechanisms. The examples reference legitimate tools (git, gh) and even advocate for narrowly scoped allowed-tools, so listing it poses no meaningful execution risk.
No concerns found
How this analysis is madeExamples
Create a slash command /plan-issue in .claude/commands that fetches a GitHub issue, analyzes it, and posts a step-by-step plan as a comment. Restrict it to the gh issue view and gh issue comment tools.Write a project slash command that reviews the current branch's diff, checks it against our testing conventions, and posts review notes — use $ARGUMENTS for the PR number and only allow read-only git and gh tools.My custom command has allowed-tools: Bash(*). Rewrite its YAML frontmatter so it can only run git and pytest commands, and add decision logic for what to do when tests fail.name: Creating Slash Commands description: 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.
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
- Create command file in
.claude/commands/[name].md - Add YAML frontmatter with permissions and description
- Write command prompt with clear steps and decision logic
- Use $ARGUMENTS variable for dynamic input
- Test command with
/<command-name> [args]
Command Structure
Basic Template
# .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
- Examples:
description: One-line summary shown in command list
Permission Patterns
# 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:
# .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:
---
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
---
allowed-tools: Bash(gh:*)
---
1. Fetch PR: `gh pr view $ARGUMENTS`
2. Get diff: `gh pr diff $ARGUMENTS`
3. Review and comment
With Git
---
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
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/creating-slash-commands-mmh8qqwx/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/creating-slash-commands-mmh8qqwx' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/creating-slash-commands-mmh8qqwx/download' --output '.skill-downloads/creating-slash-commands-mmh8qqwx/SKILL.md.part' && mv '.skill-downloads/creating-slash-commands-mmh8qqwx/SKILL.md.part' '.skill-downloads/creating-slash-commands-mmh8qqwx/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/creating-slash-commands-mmh8qqwx/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.