A CLI tool to accelerate LLM usage by copying codebase snapshots (lc) or generating commands from prompts (lc -e). Additional QoL features planned as I find the uses for them.
lc creates a structured XML-like document of codebases for LLMs, respecting .gitignore and supporting multiple codebases.
- 🌳 Use with multiple codebases easily
- 🚫 Respects
.gitignoreand.repoignorepatterns - 📊 Token counting and warnings to keep within token limits
- 📋 Automatic clipboard integration
- 🛡️ Binary file detection and handling
- 💾 Preserves existing codebase contexts in clipboard
- 🖥️ Command generation with
lc -e
- Python 3.7+
- uv package manager
- Required Python packages (automatically installed by uv):
- pyperclip
- lxml
- colorama
- tiktoken
- pathspec
- openai
-
Install uv if you haven't already.
-
Clone this repository:
git clone https://github.com/TwoAbove/lc
cd lc- Add the following function to your shell configuration file (
.bashrc,.zshrc, etc.):
lc() {
local script_path="<PATH>/<TO>/lc.py"
if [ -x "$script_path" ]; then
"$script_path" "$@"
else
echo "Error: lc.py not found or not executable at $script_path"
return 1
fi
}- Reload your shell configuration:
source ~/.bashrc # or ~/.zshrc- Use it in your codebase!
lc# Process current directory
lc
# Process specific subdirectory
lc path/to/directory
# Directory-only mode (no file contents)
lc -d
# Set custom token limit warning
lc -t 5000
# Generate command from prompt
lc -e "list all python files"The tool outputs colored statistics in the terminal:
f: Number of filesl: Total lines of codet: Total tokens
Files exceeding the token limit are listed separately in red.
The tool preserves existing context in your clipboard, allowing you to build up context from multiple codebases:
- Run
lcin first project directory - Change to another project directory
- Run
lcagain - The clipboard now contains both codebases in a single XML document
-
Use
.repoignore- Create a
.repoignorefile in your repository root - Add patterns for files you don't want to include in the context
- Similar syntax to
.gitignore - Useful for excluding large generated files, logs, etc.
- Add a global
.repoignorein your home directory to ignore common patterns
- Create a
-
Token Management
- Default token limit is 10,000 per file - mostly a sanity check
- Adjust using
-tflag based on your LLM's context window - Monitor the token count in the output
-
Directory Structure
- Use directory-only mode (
-d) for initial exploration of large codebases - Helps manage token usage while providing structural context
- Use directory-only mode (
-
Binary Files
- Automatically detected and marked as
[Binary file] - Common binary extensions are pre-configured
- If some common binary extensions are missing, please send a PR!
- Helps prevent clipboard overuse and saves tokens
- Automatically detected and marked as
-
Clipboard Behavior
- Always reads existing clipboard content
- Updates existing codebase context if path matches
- Adds new codebase context if path is different
-
File Size
- Large files are reported but still included
- Consider using
.repoignorefor consistently large files or files that are not useful for LLMs
-
Git Integration
- Automatically finds Git root directory
- Respects
.gitignorepatterns from repository root - Works in non-Git directories too
Contributions are welcome! Please feel free to submit a Pull Request.