Skip to main content

Share code with LLMs via Model Context Protocol or clipboard. Rule-based customization enables easy switching between different tasks (like code review and documentation). Code outlining support is included as a standard feature.

Project description

LLM Context

License PyPI version Downloads

LLM Context is a tool that helps developers quickly inject relevant content from code/text projects into Large Language Model chat interfaces. It leverages .gitignore patterns for smart file selection and provides both a streamlined clipboard workflow using the command line and direct LLM integration through the Model Context Protocol (MCP).

Note: This project was developed in collaboration with several Claude Sonnets - 3.5, 3.6 and 3.7 (and more recently Grok-3 as well), using LLM Context itself to share code during development. All code in the repository is human-curated (by me 😇, @restlessronin).

Breaking Changes in v0.3.0

We've switched to a Markdown-based rules system replacing the previous TOML/YAML-based profiles. This is a breaking change that affects configuration. See the User Guide for details on the new rule format and how to use it.

Why LLM Context?

For an in-depth exploration of the reasoning behind LLM Context and its approach to AI-assisted development, check out our article: LLM Context: Harnessing Vanilla AI Chats for Development

Current Usage Patterns

  • Direct LLM Integration: Native integration with Claude Desktop via MCP protocol
  • Chat Interface Support: Works with any LLM chat interface via CLI/clipboard
    • Optimized for interfaces with persistent context like Claude Projects and Custom GPTs
    • Works equally well with standard chat interfaces
  • Project Types: Suitable for code repositories and collections of text/markdown/html documents
  • Project Size: Optimized for projects that fit within an LLM's context window. Large project support is in development

Installation

Install LLM Context using uv:

uv tool install "llm-context>=0.3.0"

To upgrade to the latest version:

uv tool upgrade llm-context

Warning: LLM Context is under active development. Updates may overwrite configuration files prefixed with lc-. We recommend all configuration files be version controlled for this reason.

Quickstart

MCP with Claude Desktop

Add to 'claude_desktop_config.json':

{
  "mcpServers": {
    "CyberChitta": {
      "command": "uvx",
      "args": ["--from", "llm-context", "lc-mcp"]
    }
  }
}

Once configured, you can start working with your project in two simple ways:

  1. Say: "I would like to work with my project" Claude will ask you for the project root path.

  2. Or directly specify: "I would like to work with my project /path/to/your/project" Claude will automatically load the project context.

CLI Quick Start and Typical Workflow

  1. Navigate to your project's root directory
  2. Initialize repository: lc-init (only needed once)
  3. Select files: lc-sel-files
  4. (Optional) Review selected files in .llm-context/curr_ctx.yaml
  5. Generate context: lc-context (with optional flags: -p for prompt, -u for user notes)
  6. Use with your preferred interface:
  • Project Knowledge (Claude Pro): Paste into knowledge section
  • GPT Knowledge (Custom GPTs): Paste into knowledge section
  • Regular chats: Use lc-context -p to include instructions
  1. When the LLM requests additional files:
    • Copy the file list from the LLM
    • Run lc-clip-files
    • Paste the contents back to the LLM

Core Commands

  • lc-init: Initialize project configuration
  • lc-set-rule <n>: Switch rules (system rules are prefixed with "lc-")
  • lc-sel-files: Select files for inclusion
  • lc-sel-outlines: Select files for outline generation
  • lc-context [-p] [-u] [-f FILE]: Generate and copy context
    • -p: Include prompt instructions
    • -u: Include user notes
    • -f FILE: Write to output file
  • lc-prompt: Generate project instructions for LLMs
  • lc-clip-files: Process LLM file requests
  • lc-changed: List files modified since last context generation
  • lc-outlines: Generate outlines for code files
  • lc-clip-implementations: Extract code implementations requested by LLMs (doesn't support C/C++)

Features & Advanced Usage

LLM Context provides advanced features for customizing how project content is captured and presented:

  • Smart file selection using .gitignore patterns
  • Multiple rule-based profiles for different use cases
    • System rules (prefixed with "lc-") provide default functionality
    • User-defined rules can be created independently or extend existing rules
  • Code Navigation Features:
    1. Smart Code Outlines: Allows LLMs to view the high-level structure of your codebase with automatically generated outlines highlighting important definitions
    2. Definition Implementation Extraction: Paste full implementations of specific definitions that are requested by LLMs after they review the code outlines, using the lc-clip-implementations command
  • Customizable templates and prompts

See our User Guide for detailed documentation of these features.

Similar Tools

Check out our comprehensive list of alternatives - the sheer number of tools tackling this problem demonstrates its importance to the developer community.

Acknowledgments

LLM Context evolves from a lineage of AI-assisted development tools:

  • This project succeeds LLM Code Highlighter, a TypeScript library I developed for IDE integration.
  • The concept originated from my work on RubberDuck and continued with later contributions to Continue.
  • LLM Code Highlighter was heavily inspired by Aider Chat. I worked with GPT-4 to translate several Aider Chat Python modules into TypeScript, maintaining functionality while restructuring the code.
  • This project uses tree-sitter tag query files from Aider Chat.
  • LLM Context exemplifies the power of AI-assisted development, transitioning from Python to TypeScript and back to Python with the help of GPT-4 and Claude-3.5-Sonnet.

I am grateful for the open-source community's innovations and the AI assistance that have shaped this project's evolution.

I am grateful for the help of Claude-3.5-Sonnet in the development of this project.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

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_context-0.3.2.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

llm_context-0.3.2-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file llm_context-0.3.2.tar.gz.

File metadata

  • Download URL: llm_context-0.3.2.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for llm_context-0.3.2.tar.gz
Algorithm Hash digest
SHA256 32e1b0b54bfdd0728302b6bb9c0b3a2004f84e7aa90a15ce3ddb30779431059f
MD5 073c531334ec2b8304076b8e3d15fde7
BLAKE2b-256 597bf63abf9e6796c18c4635dae8cddbb552cb3d09566e26d8f4f915ff3d4483

See more details on using hashes here.

File details

Details for the file llm_context-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_context-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3dde03863b129bc65f64a7d4a86403ffd1bacc56eedfb24eaa208e2114501969
MD5 2db862660334328754acf8a4e9b8d7c6
BLAKE2b-256 bdbaa635385df6c8061d64f2f673381d24e2419a5b80b7f44644085008a22519

See more details on using hashes here.

Supported by

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