Command Line Interface
SwissArmyHammer provides a comprehensive command-line interface for managing prompts, running the MCP server, and integrating with your development workflow.
Installation
# Install from Git repository (requires Rust)
cargo install --git https://github.com/wballard/swissarmyhammer.git swissarmyhammer-cli
# Ensure ~/.cargo/bin is in your PATH
export PATH="$HOME/.cargo/bin:$PATH"
Basic Usage
swissarmyhammer [COMMAND] [OPTIONS]
Global Options
--help, -h
- Display help information--version, -V
- Display version information
Commands Overview
Command | Description |
---|---|
serve | Run as MCP server for Claude Code integration |
search | Search and discover prompts with powerful filtering |
test | Interactively test prompts with arguments |
doctor | Diagnose configuration and setup issues |
completion | Generate shell completion scripts |
Quick Examples
Start MCP Server
# Run as MCP server (for Claude Code)
swissarmyhammer serve
Search for Prompts
# Search for code-related prompts
swissarmyhammer search code
# Search with regex in descriptions
swissarmyhammer search --regex "test.*unit" --in description
Test a Prompt
# Interactively test a prompt
swissarmyhammer test code-review
# Test with predefined arguments
swissarmyhammer test code-review --arg code="fn main() { println!(\"Hello\"); }"
Check Setup
# Diagnose any configuration issues
swissarmyhammer doctor
Generate Shell Completions
# Generate Bash completions
swissarmyhammer completion bash > ~/.bash_completion.d/swissarmyhammer
# Generate Zsh completions
swissarmyhammer completion zsh > ~/.zfunc/_swissarmyhammer
Exit Codes
0
- Success1
- General error2
- Command line usage error3
- Configuration error4
- Prompt not found5
- Template rendering error
Configuration
SwissArmyHammer looks for prompts in these directories (in order):
- Built-in prompts (embedded in the binary)
- User prompts:
~/.swissarmyhammer/prompts/
- Local prompts:
./prompts/
(current directory)
For detailed command documentation, see the individual command pages linked in the table above.