lx is a CLI tool that bundles your codebase into a single context string for LLMs.
It crawls directories, respects your gitignores, skips binaries, and outputs Markdown, XML, or HTML directly to clipboard along with an estimated token count.
Instead of blindly concatenating files together, lx processes arguments as a stream. This means you can apply
different rules (like line limits or filters) to specific files on the fly within a single command.
Installation • Usage • Stream Processing • Configuration
- Token estimation for individual files and the final output.
- Smart traversal that respects
.gitignore,.ignore, and.lxignore. - Stream processing to apply interleaved options (like
--tail 50) mid-command. - Outputs standard Markdown, XML (ideal for Claude), or HTML.
- Copies directly to your system clipboard on Linux, macOS, and Windows.
- Plays nice with Unix pipelines (
find,fd,git, etc.).
go install github.com/rasros/lx/cmd/lx@latestcurl -fsSL https://raw.github.com/rasros/lx/main/install.sh | bashClipboard support (-c) requires xclip on X11 Linux or wl-clipboard on Wayland. macOS and Windows work out of the
box.
Grab everything in the current directory (ignoring hidden files) and copy to clipboard:
lx -cGet all Python files, but skip the tests:
lx -i "*.py" -e "*test*" src/Dump the directory as structured XML (Claude prefers this):
lx --xml .Prepend a custom instruction before the code context:
lx -p "Refactor the following code to use contexts:" main.goAdd custom headers to group specific files (also adjusts XML output):
lx -s "Code under test" src/database/users -s "Test fixtures" src/tests/fixturesUse fd to find files, preview them with lx, and bundle the final selection:
fd -t f | fzf -m --preview 'lx -n 20 {}' | lx -cSend context directly into llm tool:
lx -p "Explain this project structure" src/ | llmOnly bundle the files that changed in your current branch:
git diff --name-only main | lx -clx processes arguments left to right as a stream of sections - consecutive file/directory arguments with
no interleaved options between them. Interleaved options (like -n, --tail, -l, -i) are scoped to the section
they precede. When an interleaved option appears after files, it creates a section boundary: all interleaved
options reset to defaults before the new option takes effect.
Example: Grab the last 50 lines of a log file, then src/ with line numbers enabled:
lx --tail 50 app.log -l src/| Argument | Effect |
|---|---|
--tail 50 |
Sets tail for the next section |
app.log |
Gets the last 50 lines |
-l |
Section boundary: state resets to defaults, then line numbers enabled |
src/ |
Gets full content with line numbers |
| Flag | Format | Best For |
|---|---|---|
| (default) | Markdown | ChatGPT, GitHub Copilot, DeepSeek |
--xml |
XML | Claude (uses <document> and <source> tags) |
--html |
HTML | Archiving or visual debugging |
You can set your defaults in ~/.config/lx/config.yaml:
output_mode: "stdout" # stdout, copy
output_format: "xml" # markdown, xml, html| Feature | lx | repopack | files-to-prompt |
|---|---|---|---|
| Language | Go | Node.js | Python |
| Stream Processing | ✅ | ❌ | ❌ |
| Clipboard Copy | ✅ | ❌ | ❌ |
| XML Support | ✅ | ✅ | ✅ |
| Token Estimation | ✅ | ✅ | ❌ |
| Binary Detection | ✅ | ✅ | ✅ |