mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
feat(claudecode): update completion actions and clean up README
- Added new actions for `claude-quick` including 'optimize', 'refactor', 'test', and 'docs'. - Removed redundant code from the `_claude_quick` function to streamline the completion process. - Cleaned up the README by removing outdated usage examples for `claude-quick` to reflect the latest features.
This commit is contained in:
parent
f02139ac12
commit
6e2c0e721e
2 changed files with 4 additions and 232 deletions
|
|
@ -44,217 +44,3 @@ This plugin provides autocompletion and useful aliases for the [Claude Code CLI]
|
||||||
|
|
||||||
#### `claude-quick`
|
#### `claude-quick`
|
||||||
Quick access to common Claude Code patterns:
|
Quick access to common Claude Code patterns:
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
```bash
|
|
||||||
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`:
|
|
||||||
```bash
|
|
||||||
plugins=(... claudecode)
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Restart your terminal or run:
|
|
||||||
```bash
|
|
||||||
source ~/.zshrc
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Installation
|
|
||||||
|
|
||||||
1. Download the `claudecode.plugin.zsh` file
|
|
||||||
2. Source it in your `~/.zshrc`:
|
|
||||||
```bash
|
|
||||||
source /path/to/claudecode.plugin.zsh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- [Claude Code CLI](https://claude.ai/code) 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
|
|
||||||
```bash
|
|
||||||
# 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
|
|
||||||
```bash
|
|
||||||
# Quick print mode
|
|
||||||
ccp "explain this function"
|
|
||||||
|
|
||||||
# Continue previous conversation
|
|
||||||
ccc
|
|
||||||
|
|
||||||
# Verbose mode
|
|
||||||
ccv "debug this issue"
|
|
||||||
|
|
||||||
# Update Claude Code
|
|
||||||
ccu
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using Helper Functions
|
|
||||||
```bash
|
|
||||||
# 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:
|
|
||||||
```bash
|
|
||||||
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:
|
|
||||||
```bash
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Related
|
|
||||||
|
|
||||||
- [Claude Code Documentation](https://claude.ai/code)
|
|
||||||
- [Oh My Zsh](https://ohmyz.sh/)
|
|
||||||
- [Zsh Completion System](http://zsh.sourceforge.net/Doc/Release/Completion-System.html)
|
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,6 @@ _claude_tools() {
|
||||||
_describe 'tools' tools
|
_describe 'tools' tools
|
||||||
}
|
}
|
||||||
|
|
||||||
_claude "$@"
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Save current version to cache
|
# Save current version to cache
|
||||||
|
|
@ -241,6 +240,10 @@ _claude_quick() {
|
||||||
'debug:Debug the given code or error'
|
'debug:Debug the given code or error'
|
||||||
'review:Review the given code'
|
'review:Review the given code'
|
||||||
'fix:Fix the given issue'
|
'fix:Fix the given issue'
|
||||||
|
'optimize:Optimize the given code'
|
||||||
|
'refactor:Refactor the given code'
|
||||||
|
'test:Write tests for the given code'
|
||||||
|
'docs:Write documentation for the given code'
|
||||||
)
|
)
|
||||||
|
|
||||||
_describe 'actions' actions
|
_describe 'actions' actions
|
||||||
|
|
@ -441,23 +444,6 @@ _claude_pipe_enhanced() {
|
||||||
_describe 'input formats' formats
|
_describe 'input formats' formats
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update claude-quick completion
|
|
||||||
_claude_quick() {
|
|
||||||
local -a actions
|
|
||||||
actions=(
|
|
||||||
'explain:Explain the given content'
|
|
||||||
'debug:Debug the given code or error'
|
|
||||||
'review:Review the given code'
|
|
||||||
'fix:Fix the given issue'
|
|
||||||
'optimize:Optimize the given code'
|
|
||||||
'refactor:Refactor the given code'
|
|
||||||
'test:Write tests for the given code'
|
|
||||||
'docs:Write documentation for the given code'
|
|
||||||
)
|
|
||||||
|
|
||||||
_describe 'actions' actions
|
|
||||||
}
|
|
||||||
|
|
||||||
compdef _claude_quick claude-quick
|
compdef _claude_quick claude-quick
|
||||||
compdef _claude_git claude-git
|
compdef _claude_git claude-git
|
||||||
compdef _claude_project claude-project
|
compdef _claude_project claude-project
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue