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 modifiers (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 reads arguments sequentially from left to right. Flags aren't global, they act as modifiers for whatever files come
next, until you reset them.
- Modifiers: (
-n,--tail,-i) Apply to subsequent files. - Actions: (
file,dir/) Capture the current state. - Resets: (
-N,-E) Clear active modifiers.
Example: Grab the last 50 lines of a log file, then grab the entirety of main.go in one go.
lx --tail 50 app.log -N src/main.go| Argument | Type | Effect |
|---|---|---|
--tail 50 |
Modifier | Sets read strategy to the last 50 lines |
app.log |
Action | Gets processed using the tail strategy |
-N |
Reset | Clears the tail strategy back to full content |
src/main.go |
Action | Processed in full |
| 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
show_hidden: false
follow_symlinks: false
ignore: true # respects .gitignore| Feature | lx | repopack | files-to-prompt |
|---|---|---|---|
| Language | Go | Node.js | Python |
| Stream Processing | ✅ | ❌ | ❌ |
| Clipboard Copy | ✅ | ❌ | ❌ |
| XML Support | ✅ | ✅ | ✅ |
| Token Estimation | ✅ | ✅ | ❌ |
| Binary Detection | ✅ | ✅ | ✅ |