slash-command-builder
Create custom slash commands for Claude Code including syntax, arguments, bash execution, file references, and frontmatter configuration. Use when creating slash commands, custom commands, .md command files, or when asked about command creation, /command syntax, or command best practices.
What this skill does
# Slash Command Builder Create effective custom slash commands for Claude Code with proper structure, dynamic features, and best practices. ## Quick Reference **Command File Location**: - Project (shared): `.claude/commands/name.md` - Personal (individual): `~/.claude/commands/name.md` **Dynamic Features**: - Arguments: `$ARGUMENTS` (all) or `$1`, `$2`, `$3` (positional) - Bash execution: [execute: command] (requires `allowed-tools: Bash(...)`) - File references: `@path/to/file` **Frontmatter**: Optional YAML with `description`, `allowed-tools`, `argument-hint`, `model` ## The Slash Command Creation Workflow ### Phase 1: Requirements Gathering Use AskUserQuestion to understand what they need: 1. **What should the command do?** - What task or prompt does it automate? - What's the expected outcome? 2. **Who will use it?** - Just you (personal command) - Your team (project command) 3. **Does it need dynamic inputs?** - Fixed prompt (no arguments) - User-provided values (arguments needed) - Context from system (bash execution) - File contents (file references) 4. **What tools should it access?** - Read-only analysis (Read, Grep, Glob) - Git operations (Bash(git:*)) - Full access (default, no restrictions) ### Phase 2: Choose Scope **Personal Command** (`~/.claude/commands/`): - Your individual shortcuts - Experimental commands - Personal workflow automation - Not shared with team **Project Command** (`.claude/commands/`): - Team-shared commands - Standardized workflows - Committed to git - Available to all team members ### Phase 3: Design the Structure Basic command structure: ```markdown --- description: Brief description for /help allowed-tools: Optional tool restrictions argument-hint: Optional argument guidance --- [Your prompt here] ``` **Decision tree**: 1. Start with basic prompt 2. Add arguments if needed ($ARGUMENTS or $1/$2) 3. Add bash execution if context needed ([execute: command]) 4. Add file references if analyzing files (@path) 5. Add frontmatter for description and restrictions ### Phase 4: Implementation #### Step 1: Create the file ```bash # For project commands touch .claude/commands/your-command.md # For personal commands touch ~/.claude/commands/your-command.md ``` The filename (without .md) becomes the command name. #### Step 2: Write the command Use templates from [templates/](templates/) directory: - [basic-command.md](templates/basic-command.md) - Simple prompt - [with-arguments.md](templates/with-arguments.md) - With dynamic inputs - [with-bash.md](templates/with-bash.md) - With bash execution - [with-files.md](templates/with-files.md) - With file references - [complex-command.md](templates/complex-command.md) - All features combined #### Step 3: Add frontmatter (recommended) ```yaml --- description: What this command does (appears in /help) allowed-tools: Read, Grep, Glob # Optional restrictions argument-hint: [arg1] [arg2] # Optional user guidance --- ``` ### Phase 5: Testing 1. **Verify command appears**: ``` /help ``` Look for your command in the list. 2. **Test basic invocation**: ``` /your-command ``` 3. **Test with arguments** (if applicable): ``` /your-command arg1 arg2 ``` 4. **Test bash execution** (if applicable): - Verify commands execute - Check output appears in prompt 5. **Test file references** (if applicable): - Verify files load correctly - Check paths resolve 6. **Team testing** (for project commands): - Have teammates try it - Gather feedback - Iterate based on usage ### Phase 6: Iteration Start simple, add complexity incrementally: 1. **First**: Basic prompt without dynamic features 2. **Test**: Verify it works 3. **Add**: One feature (arguments OR bash OR files) 4. **Test**: Verify new feature works 5. **Repeat**: Add next feature if needed Don't try to add all features at once. Build incrementally. ## Common Command Patterns ### Pattern 1: Code Analysis ```markdown --- description: Analyze code for [specific criteria] allowed-tools: Read, Grep, Glob argument-hint: [file-or-directory] --- Analyze @$1 for: 1. [Criterion 1] 2. [Criterion 2] 3. [Criterion 3] Provide specific findings with examples. ``` ### Pattern 2: Git Workflow ```markdown --- description: [Git operation] with context allowed-tools: Bash(git:*) --- ## Current State Branch: [execute: git branch --show-current] Status: [execute: git status --short] ## Task [What to do with this context] ``` ### Pattern 3: Code Generation ```markdown --- description: Generate [artifact] following patterns allowed-tools: Read, Grep, Glob, Write argument-hint: [what-to-generate] --- ## Existing Patterns @[relevant examples] ## Task Generate $ARGUMENTS following the patterns above. ``` ### Pattern 4: Deep Analysis ```markdown --- description: Deep analysis of [topic] --- Think deeply about $ARGUMENTS considering: 1. [Aspect 1] 2. [Aspect 2] 3. [Aspect 3] [Extended thinking triggered by keywords] ``` ## Real-World Examples See [examples/](examples/) for complete working examples: - [git-workflows.md](examples/git-workflows.md) - Commit, PR, branch commands - [code-analysis.md](examples/code-analysis.md) - Review, security, performance - [code-generation.md](examples/code-generation.md) - Tests, docs, boilerplate ## Advanced Features ### Arguments: $ARGUMENTS vs $1/$2 **Use `$ARGUMENTS`** when: - You want all input as a single block - Free-form text (messages, descriptions) - Don't need to reference parts separately **Use `$1`, `$2`, `$3`** when: - You need structured parameters - Different parts used in different places - Want to provide defaults for missing args Example: ```markdown # $ARGUMENTS approach Explain $ARGUMENTS in detail. # Positional approach Review PR #$1 with priority $2 assigned to $3. ``` ### Bash Execution Execute commands BEFORE the prompt runs: ```markdown --- allowed-tools: Bash(git:*) --- Current branch: [execute: git branch --show-current] Recent commits: [execute: git log --oneline -5] ``` **Requirements**: 1. Must include `allowed-tools: Bash(...)` 2. Use [execute: command] syntax (backticks required) 3. Output is captured and included in prompt **Security**: Limit bash access with specific tool patterns: ```yaml allowed-tools: Bash(git:*) # Git only allowed-tools: Bash(npm:*), Bash(git:*) # npm and git ``` ### File References Include file contents with `@` prefix: ```markdown Review @src/auth/login.js for security issues. ``` **Features**: - Automatic CLAUDE.md inclusion from file's directory hierarchy - Works with relative or absolute paths - Directories show listing (not contents) ### Frontmatter Configuration Complete frontmatter options: ```yaml --- description: Brief description (required for /help and SlashCommand tool) allowed-tools: Read, Grep, Glob, Bash(git:*) # Optional restrictions argument-hint: [file] [priority] # Optional guidance model: claude-3-5-haiku-20241022 # Optional model override disable-model-invocation: false # Optional, prevent auto-calling --- ``` ## Best Practices 1. **Always include description** - Helps team understand command purpose - Required for SlashCommand tool - Appears in `/help` 2. **Use argument-hint for clarity** - Shows expected inputs - Self-documenting commands - Reduces user confusion 3. **Limit allowed-tools when appropriate** - Read-only commands: `Read, Grep, Glob` - Git-only: `Bash(git:*)` - Enhances security and safety 4. **Structure complex commands** - Use sections (Context, Task, Constraints) - Makes prompts easier to understand - Follows clear flow 5. **Reference project conventions** - Include `@CLAUDE.md` for standards - Reference example files - Ensures consistency 6. **Test incrementally** - Start simple, add features one at a time - Test each addition before next - Don't debug multiple features sim
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.