4.5 KiB
4.5 KiB
Troubleshooting Slash Commands
Common problems and solutions.
Command Not Found
Symptoms: /mycommand shows "Command not found"
Solutions:
- Verify file exists in
.claude/commands/directory - Check filename ends with
.mdextension - Ensure filename matches command name (dash-separated)
- Restart Claude Code to reload commands
Example:
# Wrong location
./commands/review.md
# Correct location
./.claude/commands/review.md
# Usage
/review @file.js
Arguments Not Working
Symptoms: Variables like $ARGUMENTS appear literally in output
Solutions:
- Use correct syntax:
$ARGUMENTS,$1,$2(not${ARGUMENTS}) - Don't escape dollar signs in command files
- Verify arguments are passed when invoking command
Example:
# ❌ Wrong
Review these files: ${ARGUMENTS}
# ✓ Correct
Review these files: $ARGUMENTS
Bash Commands Not Executing
Symptoms: !git status appears as text instead of executing
Solutions:
- Add
allowed-toolsfrontmatter with Bash specification - Use specific patterns, not wildcard
*unless necessary - Ensure bash command is valid and available
Example:
---
description: Git workflow
allowed-tools: Bash(git status:*), Bash(git diff:*)
---
!git status
!git diff --stat
File References Not Loading
Symptoms: @file.js doesn't load file content
Solutions:
- Use
@prefix before file path - Verify file path is correct (relative to project root)
- Check file exists and is readable
- Combine with positional arguments:
@$1
Example:
# Direct reference
Review @src/main.js for issues
# With argument
Review @$1 for issues
# Usage: /review src/main.js
Permission Errors
Symptoms: "Tool not allowed" or permission denied errors
Solutions:
- Add required tools to
allowed-toolsfrontmatter - Use specific patterns instead of broad permissions
- Separate file paths from command patterns
Example:
# ✓ Good - specific permissions
allowed-tools: Read(src/**), Bash(git status:*), Bash(git diff:*)
# ⚠️ Risky - too permissive
allowed-tools: *
Command Timeout
Symptoms: Command hangs or times out
Solutions:
- Avoid long-running processes in
!commands - Use background processes if needed
- Break into smaller commands
- Consider using subagents for complex workflows
Model Not Respecting Instructions
Symptoms: Claude doesn't follow command template
Solutions:
- Use clear, imperative language
- Number steps explicitly
- Add constraints section
- Use
model: claude-sonnet-4for complex commands
Example:
Review $ARGUMENTS
YOU MUST:
1. Check for X
2. Verify Y
3. Report Z
DO NOT:
- Skip any files
- Suggest changes without explanation
Description Not Showing in /help
Symptoms: Command appears but no description
Solutions:
- Verify frontmatter has
descriptionfield - Check YAML syntax (no tabs, proper spacing)
- Keep description under 100 characters for /help display
Example:
---
description: Review code for security issues
---
Argument Hints Not Working
Symptoms: Autocomplete doesn't show expected arguments
Solutions:
- Add
argument-hintto frontmatter - Use standard format:
<arg1> <arg2> - Use descriptive names
Example:
---
description: Generate tests
argument-hint: <file-path> <function-name>
---
Commands Conflict with Built-ins
Symptoms: Custom command doesn't run, built-in does instead
Solutions:
- Use different command name
- Avoid names like
/help,/clear,/init - Use descriptive, unique names
Debugging Tips
Test Basic Structure
# Create minimal test command
cat > .claude/commands/test.md << 'EOF'
---
description: Test command
---
Echo test: $ARGUMENTS
EOF
# Try it
/test hello world
# Should output: Echo test: hello world
Test Bash Execution
---
description: Test bash
allowed-tools: Bash(echo:*)
---
!echo "Bash works"
Result above should show "Bash works"
Test File Loading
---
description: Test file loading
---
Content from @package.json
Above should show package.json content
Verify Command Registration
# List all commands
/help
# Look for your command in the list
Getting Help
If problems persist:
- Check Official Documentation
- Review command file syntax carefully
- Test with minimal example first
- Verify Claude Code version supports features