llm context.py
Share code context with LLMs via MCP or clipboard
Share code context with LLMs via MCP or clipboard
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).
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.
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
Install LLM Context using uv:
uv tool install llm-context
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.
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:
Say: "I would like to work with my project" Claude will ask you for the project root path.
Or directly specify: "I would like to work with my project /path/to/your/project" Claude will automatically load the project context.
lc-init
(only needed once)lc-sel-files
.llm-context/curr_ctx.yaml
lc-context
(with optional flags: -p
for prompt, -u
for user notes)Use with your preferred interface:
Project Knowledge (Claude Pro): Paste into knowledge section
Regular chats: Use lc-context -p
to include instructions
When the LLM requests additional files:
lc-clip-files
lc-init
: Initialize project configurationlc-set-rule <n>
: Switch rules (system rules are prefixed with "lc-")lc-sel-files
: Select files for inclusionlc-sel-outlines
: Select files for outline generationlc-context [-p] [-u] [-f FILE]
: Generate and copy context-p
: Include prompt instructions-u
: Include user notes-f FILE
: Write to output filelc-prompt
: Generate project instructions for LLMslc-clip-files
: Process LLM file requestslc-changed
: List files modified since last context generationlc-outlines
: Generate outlines for code fileslc-clip-implementations
: Extract code implementations requested by LLMs (doesn't support C/C++)LLM Context provides advanced features for customizing how project content is captured and presented:
.gitignore
patternslc-clip-implementations
commandSee our User Guide for detailed documentation of these features.
Check out our comprehensive list of alternatives - the sheer number of tools tackling this problem demonstrates its importance to the developer community.
LLM Context evolves from a lineage of AI-assisted development tools:
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.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
[
{
"description": "IMPORTANT: First check if project context is already available in the conversation before making any new requests. Use lc-get-files for retrieving specific files, and only use this tool when a broad repository overview is needed.nnGenerates a structured repository overview including: 1) Directory tree with file status (â full, â outline, â excluded) 2) Complete contents of key files 3) Smart outlines highlighting important definitions in supported languages. The output is customizable via profiles that control file inclusion rules and presentation format. The assistant tracks previously retrieved project context in the conversation and checks this history before making new requests.",
"inputSchema": {
"properties": {
"profile_name": {
"default": "code",
"description": "Profile to use (e.g. 'code', 'copy', 'full') - defines file inclusion and presentation rules",
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Profile Name",
"type": "string"
},
"root_path": {
"description": "Root directory path (e.g. '/home/user/projects/myproject')",
"format": "path",
"title": "Root Path",
"type": "string"
}
},
"required": [
"root_path"
],
"title": "ContextRequest",
"type": "object"
},
"name": "lc-project-context"
},
{
"description": "IMPORTANT: Check previously retrieved file contents before making new requests. Retrieves (read-only) complete contents of specified files from the project. For this project, this is the preferred method for all file content analysis and text searches - simply retrieve the relevant files and examine their contents. The assistant cannot modify files with this tool - it only reads their contents.",
"inputSchema": {
"properties": {
"paths": {
"description": "File paths relative to root_path, starting with a forward slash and including the root directory name. For example, if root_path is '/home/user/projects/myproject', then a valid path would be '/myproject/src/main.py",
"items": {
"type": "string"
},
"title": "Paths",
"type": "array"
},
"root_path": {
"description": "Root directory path (e.g. '/home/user/projects/myproject')",
"format": "path",
"title": "Root Path",
"type": "string"
}
},
"required": [
"root_path",
"paths"
],
"title": "FilesRequest",
"type": "object"
},
"name": "lc-get-files"
},
{
"description": "IMPORTANT: First get the generation timestamp from the project context. Returns a list of paths to files that have been modified since a given timestamp. This is typically used to track which files have changed during the conversation. After getting the list, use lc-get-files to examine the contents of any modified files of interest.",
"inputSchema": {
"properties": {
"profile_name": {
"default": "code",
"description": "Profile to use (e.g. 'code', 'copy', 'full') - defines file inclusion and presentation rules",
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Profile Name",
"type": "string"
},
"root_path": {
"description": "Root directory path (e.g. '/home/user/projects/myproject')",
"format": "path",
"title": "Root Path",
"type": "string"
},
"timestamp": {
"description": "Unix timestamp to check modifications since",
"title": "Timestamp",
"type": "number"
}
},
"required": [
"root_path",
"timestamp"
],
"title": "ListModifiedFilesRequest",
"type": "object"
},
"name": "lc-list-modified-files"
}
]