Skip to main content

LLM plugin for Claude Code integration

Project description

llm-claude-code-plugin

PyPI Changelog License

Plugin for LLM adding support for Claude Code models (Sonnet and Opus) via the Claude Code CLI.

Installation

Install this plugin in the same environment as LLM:

uv add llm-claude-code-plugin

Prerequisites

This plugin requires the Claude Code CLI to be installed and available. The plugin looks for the Claude Code executable at:

  • ~/.claude/local/claude (default)
  • Custom path specified via the claude_path option

Make sure you have Claude Code installed and configured before using this plugin.

Usage

Available Models

This plugin provides five models:

  • code/sonnet - Claude Code with latest Sonnet model (default)
  • code/opus - Claude Code with latest Opus model
  • code/sonnet-4 - Claude Code with Sonnet 4 (claude-sonnet-4-20250514)
  • code/opus-4 - Claude Code with Opus 4 (claude-opus-4-20250514)
  • code/opus-4.1 - Claude Code with Opus 4.1 (claude-opus-4-1-20250805)

List available models:

llm models list

Basic Usage

Execute a prompt using Claude Code Sonnet:

llm -m code/sonnet "Explain how to use Python decorators"

Execute a prompt using Claude Code Opus:

llm -m code/opus "Write a Python function to calculate fibonacci numbers"

Execute a prompt using Claude Code Sonnet 4:

llm -m code/sonnet-4 "Review this code for best practices"

Model Options

The plugin supports the following options:

  • claude_path: Custom path to the Claude Code CLI executable

Example using a custom Claude Code path:

llm -m code/sonnet -o claude_path /usr/local/bin/claude "Your prompt here"

File Attachments

This plugin supports attaching various file types to your prompts, including:

  • Text files (.txt, .py, .js, .html, .css, .md, etc.)
  • Code files (Python, JavaScript, C, Java, Shell scripts)
  • Data files (JSON, XML, YAML)
  • Images (PNG, JPEG, GIF, WebP)

Attach files using the -a flag:

llm -m code/sonnet -a myfile.py "Explain this Python code"

Attach multiple files:

llm -m code/sonnet -a file1.py -a file2.js "Compare these two implementations"

URL Support

When URLs are included in prompts or attachments, the plugin automatically enables the WebFetch tool for Claude Code:

llm -m code/sonnet "Analyze the content at https://example.com"

Interactive Chat

Start an interactive chat session:

llm chat -m code/sonnet

Or with Opus:

llm chat -m code/opus

Or with Sonnet 4:

llm chat -m code/sonnet-4

Configuration

You can set the Claude Code path permanently using LLM's configuration:

llm logs path  # Find your logs directory
# Edit the config file to set default claude_path

Features

  • Five Model Support: Access latest Sonnet/Opus and specific versioned models (Sonnet 4, Opus 4, Opus 4.1)
  • File Attachments: Support for text, code, data, and image files
  • URL Processing: Automatic WebFetch tool enablement for URL analysis
  • Streaming Support: Real-time response streaming
  • Error Handling: Comprehensive error reporting and timeout management
  • Flexible Path Configuration: Custom Claude Code executable paths

Technical Details

  • Timeout: Commands timeout after 5 minutes to prevent hanging
  • Temporary Files: Attachment content is safely handled via temporary files
  • Error Recovery: Graceful handling of missing executables and other errors
  • Content Types: Extensive MIME type support for attachments

Troubleshooting

Claude Code CLI Not Found

If you see an error about the Claude Code CLI not being found:

  1. Ensure Claude Code is installed and accessible
  2. Check that the executable is at ~/.claude/local/claude or specify a custom path
  3. Verify the executable has proper permissions

Example with custom path:

llm -m code/sonnet -o claude_path /path/to/your/claude "Your prompt"

Timeout Issues

If commands are timing out:

  • Complex prompts may take longer to process
  • Large file attachments can increase processing time
  • The default timeout is 5 minutes

File Attachment Issues

If file attachments aren't working:

  • Ensure files exist and are readable
  • Check that file types are supported
  • Large files may cause performance issues

Development

To set up this plugin for development:

git clone https://github.com/edwardchampion/llm-claude-code.git
cd llm-claude-code-plugin
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

The plugin uses Python's subprocess module to execute the Claude Code CLI and supports:

  • Multiple attachment types through MIME type detection
  • Streaming responses via generator functions
  • Configurable command paths and options
  • Robust error handling and cleanup

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

See CHANGELOG.md for version history and changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_claude_code_plugin-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_claude_code_plugin-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file llm_claude_code_plugin-0.1.1.tar.gz.

File metadata

File hashes

Hashes for llm_claude_code_plugin-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1177379d7e1c79043e2286630132da04b7cd2d45e5347393dffc3f1dbf0b3352
MD5 b0e0e64dd934327729e2f2b2932f4ce8
BLAKE2b-256 290a70d0188c8980aa33dc406c9a98dcbdcb1af0240c32d054cf1f07731e3bf4

See more details on using hashes here.

File details

Details for the file llm_claude_code_plugin-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_claude_code_plugin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 817fd118e0dad88ef2d8e406c86da1ea6fe41907c8c8d585ff7575cf5c2bd497
MD5 aa68cdb3fe7bbc5ba27a0d05f846bf33
BLAKE2b-256 89128b52ed01d10dd2e3ed052844acfb409dad76e3174d96b5c404426c391b81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page