ohmyzsh/plugins/claudecode/README.md
ClearClown 4830a615a2 feat(claudecode): add ClaudeCode CLI plugin with autocompletion and aliases
- Introduced a new plugin for the Claude Code CLI, providing autocompletion for commands and flags.
- Added useful aliases for quick access to common commands and functionalities.
- Implemented helper functions for session management, project analysis, and enhanced piping capabilities.
- Included a README file detailing features, installation instructions, and usage examples.
2025-06-15 17:07:17 +09:00

7.6 KiB

ClaudeCode Plugin for Oh My Zsh

This plugin provides autocompletion and useful aliases for the Claude Code CLI, making it easier to interact with Claude from the command line.

Features

Autocompletion

  • Complete all Claude Code CLI commands and flags
  • Smart completion for subcommands (update, mcp, commit, pr, review, test, lint, docs)
  • Model name completion (sonnet, opus, claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-haiku-20240307)
  • Output format completion (text, json, stream-json)
  • Directory completion for --add-dir flag
  • Session ID completion for --resume flag
  • Tool completion for --allowedTools and --disallowedTools
  • Enhanced flag completion with short forms (-h, -v, -p, -c, -r)

Aliases

Basic Aliases

  • ccclaude (short alias for quick access)
  • ccpclaude -p (print mode)
  • cccclaude -c (continue conversation)
  • ccrclaude -r (resume session)
  • ccvclaude --verbose (verbose mode)
  • ccuclaude update (update Claude Code)
  • ccmclaude mcp (MCP configuration)

Git Integration Aliases

  • cccommitclaude commit (AI-assisted commits)
  • ccprclaude pr (AI-assisted pull requests)
  • ccreviewclaude review (code review)

Development Aliases

  • cctestclaude test (test-related tasks)
  • cclintclaude lint (linting tasks)
  • ccdocsclaude docs (documentation tasks)

Model-Specific Aliases

  • ccsonnetclaude --model sonnet (use Sonnet model)
  • ccopusclaude --model opus (use Opus model)
  • cchaikuclaude --model claude-3-haiku-20240307 (use Haiku model)

Helper Functions

claude-quick

Quick access to common Claude Code patterns:

claude-quick explain "function definition"
claude-quick debug "error message"
claude-quick review "code snippet"
claude-quick fix "bug description"
claude-quick optimize "slow function"
claude-quick refactor "legacy code"
claude-quick test "new feature"
claude-quick docs "API endpoint"

claude-pipe

Pipe content directly to Claude:

cat file.js | claude-pipe "explain this code"
git log --oneline | claude-pipe "summarize these commits"

claude-pipe-enhanced

Enhanced pipe function with format-specific preprocessing:

cat app.js | claude-pipe-enhanced code "explain this function"
tail -f error.log | claude-pipe-enhanced log "find issues"
npm test 2>&1 | claude-pipe-enhanced error "fix failing tests"
curl api/data | claude-pipe-enhanced json "summarize this data"

claude-git

Git integration functions:

claude-git commit "added new feature"    # Create commit with AI
claude-git pr "bug fix description"      # Create PR description
claude-git diff HEAD~1                   # Explain git diff
claude-git log --author="john"           # Summarize commits
claude-git conflicts                     # Help resolve conflicts

claude-project

Project analysis functions:

claude-project analyze        # Analyze project structure
claude-project deps          # Analyze dependencies
claude-project security      # Security audit
claude-project performance   # Performance analysis
claude-project architecture  # Architecture review

claude-session

Session management functions:

claude-session list                    # List available sessions
claude-session save my_project_session # Save current session
claude-session load abc123            # Load specific session
claude-session clean                  # Clean old sessions

Installation

Using Oh My Zsh

  1. Clone this repository into your Oh My Zsh custom plugins directory:

    git clone https://github.com/your-username/ohmyzsh-claudecode-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/claudecode
    
  2. Add claudecode to your plugins array in ~/.zshrc:

    plugins=(... claudecode)
    
  3. Restart your terminal or run:

    source ~/.zshrc
    

Manual Installation

  1. Download the claudecode.plugin.zsh file
  2. Source it in your ~/.zshrc:
    source /path/to/claudecode.plugin.zsh
    

Requirements

  • Claude Code CLI must be installed and available in your PATH
  • Oh My Zsh (for plugin installation method)
  • Zsh with completion support

Usage Examples

Basic Commands with Completion

# Start interactive session (press Tab for completion)
claude <Tab>

# Print mode with flags (press Tab after --)
claude -p --<Tab>

# Continue with model selection
claude -c --model <Tab>

# Resume specific session
claude -r <session-id> <Tab>

Using Aliases

# Quick print mode
ccp "explain this function"

# Continue previous conversation
ccc

# Verbose mode
ccv "debug this issue"

# Update Claude Code
ccu

Using Helper Functions

# Quick patterns
claude-quick explain "async/await in JavaScript"
claude-quick debug "TypeError: Cannot read property"
claude-quick review "this React component"
claude-quick fix "memory leak in my application"
claude-quick optimize "database query performance"
claude-quick refactor "legacy authentication code"
claude-quick test "user registration flow"
claude-quick docs "REST API endpoints"

# Pipe content
cat error.log | claude-pipe "what's causing this error?"
ps aux | claude-pipe "which processes are using too much memory?"

# Enhanced pipe with format detection
cat app.js | claude-pipe-enhanced code "find potential bugs"
tail -100 /var/log/nginx/error.log | claude-pipe-enhanced log "analyze errors"
npm test 2>&1 | claude-pipe-enhanced error "fix these test failures"

# Git integration
claude-git commit                    # AI-assisted commit
claude-git pr "fixes authentication bug"
claude-git diff --cached            # Explain staged changes
claude-git log --since="1 week ago" # Summarize recent work
claude-git conflicts                # Help with merge conflicts

# Project analysis
claude-project analyze              # Full project analysis
claude-project deps                # Dependency analysis
claude-project security            # Security audit
claude-project performance         # Performance review

# Session management
claude-session list                 # Show available sessions
claude-session save feature_work    # Save current session
claude-session load abc123          # Resume specific session

Cache Management

The plugin automatically caches completion data for better performance:

  • Cache location: $ZSH_CACHE_DIR/completions/_claude
  • Version tracking: $ZSH_CACHE_DIR/claudecode_version
  • Automatic cache invalidation when Claude Code is updated

Troubleshooting

Completion not working

  1. Ensure Claude Code CLI is installed: which claude
  2. Verify the plugin is loaded: which cc (should show the alias)
  3. Reload completions: compinit

Cache issues

  1. Clear the cache:
    rm -f "$ZSH_CACHE_DIR/completions/_claude"
    rm -f "$ZSH_CACHE_DIR/claudecode_version"
    
  2. Restart your terminal

Permission issues

If you encounter permission prompts frequently, consider using:

claude --dangerously-skip-permissions -p "your query"

Note: Use with caution as this bypasses security prompts.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test with different Claude Code versions
  5. Submit a pull request

License

This plugin is released under the MIT License.