Skip to main content

LLM plugin for Claude Code SDK integration

Project description

llm-claude-code

PyPI Changelog Tests License

LLM plugin for Claude Code SDK integration

Overview

llm-claude-code is a plugin for Simon Willison's LLM tool that enables you to use Claude Code through the LLM command-line interface. This plugin leverages the Claude Code CLI to provide AI assistance with coding tasks.

Prerequisites

Before using this plugin, ensure you have:

  • Claude Code CLI installed: Install with npm install -g @anthropic-ai/claude-code
  • Node.js: Required for Claude Code CLI
  • Anthropic API Key configured: Set up through environment variables or Claude Code settings
  • Python 3.10 or higher

To install Claude Code, visit the official documentation.

Installation

Install this plugin in the same environment as LLM:

llm install llm-claude-code

Usage

Basic Usage

Use the claude-code model with the LLM command:

# Basic usage
llm -m claude-code "Write a Python function to calculate fibonacci numbers"

# Using the alias 'cc'
llm -m cc "Create a hello world script"

Features

  • Streaming Support: Real-time output display during generation
  • Color-coded Output: Different message types are displayed with distinct colors:
    • Tool messages: Blue
    • Error messages: Red
    • Success messages: Green
    • Regular messages: Default color
  • Error Handling: Comprehensive error reporting for CLI issues

Model Aliases

The plugin provides the following model identifiers:

  • Primary: claude-code
  • Alias: cc

Tool Usage

The initial implementation disables tool usage (--no-tools flag) to focus on text generation. Future versions may include configurable tool support.

Error Handling

The plugin includes comprehensive error handling for common issues:

  • CLINotFoundError: Raised when Claude Code CLI is not installed or not found in PATH
  • CLIConnectionError: Raised when there are connection issues with the Claude Code service
  • ProcessError: Raised when there are errors during command execution

Troubleshooting

SDK Import Errors

If you encounter import errors with the Claude Code SDK:

  1. Ensure you have Python 3.10 or higher
  2. Install the plugin with llm install llm-claude-code
  3. Verify that claude-code-sdk is properly installed

Connection Issues

If you experience connection timeouts:

  1. Check your internet connection
  2. Verify your Anthropic API key is valid
  3. Ensure you're not hitting rate limits

Development

To set up this plugin locally, first checkout the code:

cd llm-claude-code

Then create a new virtual environment and install the dependencies and test dependencies:

uv sync --extra test

To run the tests:

uv run pytest

Future Enhancements

The plugin is designed with extensibility in mind. Planned future features include:

  • Tool Usage Configuration: Enable specific tools via command-line options
  • Advanced Options: Custom system prompts, max turns, working directory settings
  • Session Management: Conversation continuity and state preservation

License

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

Contributing

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

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-0.0.1.tar.gz (9.4 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-0.0.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file llm_claude_code-0.0.1.tar.gz.

File metadata

  • Download URL: llm_claude_code-0.0.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for llm_claude_code-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c37d952a4912704614c50f509ed84a15eafe6d569e0bd4ec05e88dfcb49f7e3b
MD5 ac0472525dd62f656045550c658e0204
BLAKE2b-256 5457c9a63ba7ab6398bea16a23db723585b4da7c8048f1a40e00d9e72944419f

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_claude_code-0.0.1.tar.gz:

Publisher: publish.yml on ftnext/llm-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_claude_code-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_claude_code-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a88634ed04dbc5f3f59ff4850d6e07317070fefe5e1bbd179976056f18ceca3a
MD5 eab353a75f57ad885c865c9b1024b24e
BLAKE2b-256 67b6532cdd250b65745b64ee753b6f72c601d22ff2e7191a0b2b5633dcc5aa5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_claude_code-0.0.1-py3-none-any.whl:

Publisher: publish.yml on ftnext/llm-claude-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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