5.7 KiB
argument-hint, description, allowed-tools
| argument-hint | description | allowed-tools | ||||||
|---|---|---|---|---|---|---|---|---|
| [category/name] [--update] or leave empty for interactive creation | Extract and save current session workflow as a reusable slash command |
|
Extract and save the current or most recent session workflow as a reusable slash command file. Supports creating new commands, updating existing ones, and interactive guided creation.
Usage Examples
git/draft-pr- Create new command from recent workflowgit/commit-push --update- Update existing command with improvements- Leave empty - Interactive mode with guided questions
Command Creation Process
-
Determine Mode:
- If
--updateflag: Update existing command - If command name provided: Auto mode - analyze recent workflow
- If no arguments: Interactive mode - ask guided questions
- If
-
Analyze Workflow: Extract recent session patterns, tool usage, and command sequences
-
Generate Command File:
- Create at
~/.claude/commands/category/name.md - Add YAML frontmatter with argument-hint, description, allowed-tools
- Write implementation steps consolidating workflow actions
- Include usage examples and notes
- Create at
-
Update Mode (when using
--update):- Read existing command file
- Preserve metadata unless workflow significantly changed
- Merge or enhance implementation steps
- Add newly used tools to allowed-tools list
Naming & Location
Format: category/name → command file path
Personal Commands: ~/.claude/commands/category/name.md
- Available across all projects
- For individual workflows
Project Commands: ./.claude/commands/category/name.md
- Shared with team via git
- For project-specific workflows
Examples:
git/draft-pr→~/.claude/commands/git/draft-pr.md(personal)docker/build→./.claude/commands/docker/build.md(project)jira/clone-issue→~/.claude/commands/jira/clone-issue.md(personal)
Auto-detection (interactive mode with no name):
- Git operations →
git/workflow - Node/npm →
node/workflow - Docker →
docker/workflow - Test operations →
test/workflow - Jira →
jira/workflow - AWS →
aws/workflow
Command File Structure
---
argument-hint: [describe expected arguments and defaults]
description: Brief action-oriented description
allowed-tools: [Bash, Read, Write, Edit, etc.]
---
Brief description of command purpose and when to use it.
## Implementation Steps
1. **Major Action**: Description of what to do (consolidate related actions)
2. **Next Step**: Clear actionable instruction
3. **Final Step**: Verification or cleanup
## Usage Examples
- `/category/name arg1` - Example scenario
- `/category/name --flag` - Another scenario
## Notes
- Prerequisites or dependencies
- Related commands
- Important considerations
Interactive Questions
When in interactive mode, ask:
-
Purpose: What should this command do?
- Automate git operations
- Run tests or builds
- Manage external services (Jira, AWS, Docker)
- Code generation or scaffolding
-
Scope: Where should this command be available?
- Personal use only (save to ~/.claude/commands/)
- Share with team (save to ./.claude/commands/ for git tracking)
-
Tools: Which tools are needed? (multi-select)
- File operations (Read, Write, Edit, Glob)
- Shell commands (Bash)
- User interaction (AskUserQuestion)
- All tools (no restrictions)
-
Arguments: How should arguments be handled?
- All as single value
- Multiple positional arguments
- With default values
- No arguments needed
Workflow Extraction
When analyzing recent workflow:
- Track Tool Usage: Identify frequently used tools
- Find Patterns: Detect repeated action sequences
- Extract Commands: Capture successful bash commands and operations
- Consolidate Steps: Group micro-actions into major steps (avoid excessive detail)
- Infer Metadata: Set appropriate allowed-tools based on actual usage
Update Mode Details
When updating with --update flag:
- Preserve original description and argument-hint unless workflow changed significantly
- Merge new steps with existing implementation steps
- Add new tools to allowed-tools if used in recent workflow
- Enhance usage examples with recent successful executions
- Update notes with lessons learned or edge cases discovered
Output Format
After creation:
✅ Command created: /category/name
Location: ~/.claude/commands/category/name.md
Tools: [list of allowed-tools]
🔍 Usage: /category/name [arguments]
After update:
✅ Command updated: /category/name
Location: ~/.claude/commands/category/name.md
🔄 Changes:
- [Summary of what changed]
Best Practices
Description:
- Start with action verb (e.g., "Create", "Run", "Update")
- Keep under 100 characters
- Be specific and clear
Implementation Steps:
- Consolidate related actions (avoid micro-steps)
- Use descriptive step names
- Mention argument usage naturally in descriptions
- Include verification or error handling
Allowed Tools:
- Only list tools actually needed
- Omit for unrestricted access
- Use minimal set for security
Examples
# Interactive creation
/claude:create-command
# Create from recent git workflow
/claude:create-command git/sync-upstream
# Update existing command with improvements
/claude:create-command git/commit-push --update
# Create project-specific test command
/claude:create-command test/e2e-debug
Notes
- Commands expand to full prompts when invoked
- Keep focused on one specific workflow
- Test thoroughly before sharing with team
- Use
--updateto refine based on real usage - Commands run in current working directory context