Skip to main content

LLM plugin for Claude Code integration

Project description

llm-claude-code

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

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
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.0.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llm_claude_code_plugin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4ea32679a8c206ae64fe76f5cdbd122939044e17b8377fafbc9f8dfa21b707e
MD5 853a762f030e2d6a42a06424cfac331f
BLAKE2b-256 9406a4e486424bede5ef5a0f6642327636c8edff59c2f94417f43a229ac34dcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_claude_code_plugin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78b7a0c86259c1863409801d5709e08ca0367d70e25538abee777b5a8884b3ff
MD5 caf4625abbd24ca84b823aed6c09e822
BLAKE2b-256 ed5d7b93fb9702e8830297929229602236788bf621278fd4dd161a608ba87be2

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