llm-codebase-context
v1.0.2
Published
A command-line tool to prepare your codebase for submission to Large Language Models (LLMs) like ChatGPT or Claude. It creates a formatted context file that includes your source code while intelligently filtering out binary files, large files, and commonl
Readme
LLM Codebase Context
A command-line tool to prepare your codebase for submission to Large Language Models (LLMs) like ChatGPT or Claude. It creates a formatted context file that includes your source code while intelligently filtering out binary files, large files, and commonly ignored directories.
Why Use This?
- Quickly create LLM-ready snapshots of your codebase
- Smart filtering removes irrelevant files (node_modules, binaries, build artifacts)
- Avoids common issues like token limits by excluding overly large files
- Structured XML output format is ideal for LLM context
Installation
# Install globally
npm install -g llm-codebase-context
# Or run with npx without installing
npx llm-codebase-context <project_root>Usage
Basic Usage
# Process the current directory and output to structure.txt
codebase-context .
# Process a specific project and specify output file
codebase-context /path/to/project output.txt
# Process only a subdirectory of your project
codebase-context /path/to/project output.txt srcAdvanced Usage
# Add custom ignore patterns
codebase-context . output.txt . "tests,fixtures,*.json"
# Process a specific subdirectory with custom ignores
codebase-context /path/to/project output.txt src "*.test.js,*.spec.js,__tests__"Configuration
The tool comes with sensible defaults that work for most projects:
Default Limits
- Maximum file size: 1MB
- Maximum line count: 5000 lines
Default Ignore Patterns
The tool automatically ignores common patterns including:
- Package management:
node_modules,package-lock.json, etc. - Version control:
.git,.gitignore - Build outputs:
dist,build,.next, etc. - System files:
.DS_Store,Thumbs.db - Environment/secrets:
.envfiles,.pem,.key - Logs and temp files:
logs,*.log,temp,tmp - Language-specific:
__pycache__,*.class, etc. - Binary files: Images, videos, archives, executables
Output Format
The tool produces an XML-formatted file with each source file enclosed in <file> tags:
<file path="src/index.js">
// File content goes here
</file>
<file path="src/utils/helpers.js">
// Another file's content
</file>This format is optimized for use with LLMs as it clearly delineates file boundaries and preserves path information.
Use Cases
- Get help with bugs by providing full context to an LLM
- Ask for architecture recommendations with full codebase knowledge
- Generate documentation based on your entire project
- Request refactoring suggestions with proper context
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
License
ISC
