A tool to generate comprehensive context for LLMs from any codebase.
Project description
LLM Code Context Generator
A powerful command-line tool that scans any project, intelligently filters files, and combines all relevant source code into a single, clean file perfectly formatted for Large Language Models (LLMs).
The Problem
AI models like GPT-4, Claude, and Gemini are powerful, but they can't see your entire project. When you ask for help, you often get generic answers because the AI lacks the full context. Manually copying and pasting code is slow, messy, and nearly impossible for large projects.
The Solution
LLM Code Context Generator fixes this. It walks through your project directory, uses your .gitignore file and a custom config to skip irrelevant files, and creates one
single, organized Markdown file.
You can paste this file into your favorite AI chat to give it the deep understanding it needs to provide truly helpful, project-aware answers.
Key Features
- 🚀 Fast and Local: Runs entirely on your machine, ensuring your code stays private and the process is quick.
- 🧠 Smart Filtering: Automatically understands and uses the rules from your project's
.gitignorefile. - ⚙️ Standardized Configuration: Configure the tool using the standard
pyproject.tomlfile, keeping your project root clean. - 🤖 AI-Friendly Format: The output is clean Markdown with language-specific code blocks, making it easy for LLMs to parse.
- ✅ Easy to Use: Install with a single command and run it from anywhere on your system.
Installation
You can install the tool directly from PyPI:
pip install llm-code-context-generator
After installation, the llmcontext command will be available in your terminal. You may need to restart your terminal for the command to be recognized the first time.
You can verify the installation by checking the help message:
llmcontext --help
How to Use
Using the tool is simple and straightforward.
Basic Usage
- Open your terminal and navigate to your project's main folder:
cd /path/to/your/project
- Run the command:
llmcontext
This will scan the current directory and create a context file named [your-project-name]_context.md.
Advanced Usage
Scanning a Different Directory
You can scan any project folder without cd-ing into it first:
llmcontext /path/to/another/project
Specifying an Output File
Use the -o or --output flag to set a custom name and location for the context file:
llmcontext . -o my-api-context.md
Configuration (via pyproject.toml)
For precise control, you can add a dedicated section to your project's pyproject.toml file. The tool will automatically find and use it. This is the recommended way to handle
project-specific configurations, as it keeps your project directory clean and follows modern Python standards.
Sample Configuration
Add a [tool.llmcontext] section to your pyproject.toml file like this:
# In your pyproject.toml file
[tool.llmcontext]
# A list of top-level directories to exclusively include.
# If not empty, only these directories will be scanned.
allowed_dirs = ["src", "app", "core"]
# A list of directory names to ignore everywhere.
ignored_dirs = [
"tests",
"docs",
"assets",
"migrations"
]
# A list of exact filenames to ignore.
ignored_files = [
"config.js",
"docker-compose.yml",
"manage.py"
]
# A list of file extensions to ignore.
ignored_extensions = [
".log",
".tmp",
".md",
".bak"
]
Configuration Keys Explained
allowed_dirs: (Whitelist) An array of strings. If you add folders here (e.g.,"src"), the tool will only look inside those folders at the top level. This is great for focusing on just your source code.ignored_dirs: (Blacklist) An array of strings. The tool will completely skip any folder with these names (e.g.,"tests").ignored_files: (Blacklist) An array of strings. The tool will skip any file that has one of these exact names (e.g.,"docker-compose.yml").ignored_extensions: (Blacklist) An array of strings. The tool will skip any file ending with one of these extensions (e.g.,".log",".md").
Note: The tool applies ignore rules from .gitignore first, then applies the rules from your pyproject.toml file for even more control.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
This project is licensed under the MIT License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_code_context_generator-0.1.6.tar.gz.
File metadata
- Download URL: llm_code_context_generator-0.1.6.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afea42f613474473e779cd623d63fe7ab99640ba04b8340ce56cedc773e8f793
|
|
| MD5 |
74e2d3b3121ce23b64c0ddb3402f4703
|
|
| BLAKE2b-256 |
e472548efc186dcf503a76da1078aaa7ca2ade4cd67a3fede872ce35af9bf2bd
|
File details
Details for the file llm_code_context_generator-0.1.6-py3-none-any.whl.
File metadata
- Download URL: llm_code_context_generator-0.1.6-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58be7106b45e1aec69ac93c44c56fa8e3935e9e7ebdba25c47f3eba7c3cb6769
|
|
| MD5 |
2d0ec8ca397c155da5116eb448d41850
|
|
| BLAKE2b-256 |
c646f87ee8e10935bb1ee2532023f145cd8269ecbb6469144c5c1b05f9c79599
|