List and concatenate directory/file contents β built for humans and AI workflows.
lscat is a Bash utility that walks your directory tree, prints a structured overview, and concatenates file contents with customizable delimiters. It is especially useful for feeding entire codebases into AI prompts via the MCP (Model Context Protocol) standard.
- Features
- MCP Integration
- Installation
- Quick Start
- Usage
- Options Reference
- Header Styles
- Compression Modes
- Pattern Matching
- Filtering
- Output to File
- Examples
- Tips & Best Practices
- Issues
- Contributing
- License
- Recursive directory traversal with full tree or compact list display
- File content concatenation with configurable delimiters
- Four header styles β
tree,ls,ls-R,noneβ to balance verbosity and compactness - Two compression modes β strip whitespace (
-c) or flatten to a single line per file (-C) - Pattern-based filtering β skip directories and files matching glob patterns at any depth
- Hidden file support β include or exclude dotfiles and hidden directories
- Line numbers in output
- Multi-destination output β pipe to stdout or write to one or more files
- Color-coded terminal output β automatically disabled when writing to a file
- Built-in installer β one command to install system-wide or per-user
The Model Context Protocol (MCP) is an open standard that enables AI models to connect with external tools and data sources. It allows AI assistants (like Claude Desktop, Cursor, and other AI IDEs) to interact with your development environment in a structured way.
lscat is a natural companion to the MCP workflow. When you use an AI assistant in your browser or IDE:
- Copy your entire codebase using
lscatto generate a complete project snapshot - Paste it into the AI prompt β the AI now has full context of your project
- Ask questions, request refactoring, or generate code β the AI understands your codebase
This is especially powerful for:
- Codebase-wide refactoring β paste the whole project and ask for architectural changes
- Bug analysis across files β give the AI complete context to trace issues
- Documentation generation β generate docs based on your actual code structure
- Code reviews β get comprehensive feedback on your entire project
# Create a compressed, flat snapshot of your entire project
lscat -d "*" -sd node_modules -sd .git -sd dist -C -H none -D context.txtThen open your AI prompt, paste the contents of context.txt, and start coding with full context.
Note:
lscatis a standalone shell script. You can invoke it directly from any MCP-compatible environment (terminal, shell, CI/CD) and pipe the output into your AI workflow.
Run the built-in installer, which will guide you through per-user or system-wide placement:
chmod +x lscat
./lscat --installYou will be prompted to choose one of:
| Option | Path | Requires sudo |
|---|---|---|
| Current user | ~/.local/bin/lscat |
No |
| System-wide | /usr/local/bin/lscat |
Yes |
| System-wide (alt) | /usr/bin/lscat |
Yes |
| Custom + symlink | User-defined | Maybe |
The installer automatically adds ~/.local/bin to your $PATH in ~/.bashrc and ~/.zshrc if it is not already present.
chmod +x lscat
cp lscat ~/.local/bin/lscatMake sure ~/.local/bin is on your $PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc# Show a tree of the current directory
lscat
# Show and concatenate all files in the current directory
lscat -d .
# Recursively process all directories
lscat -d "*"
# Process only specific file types
lscat -f "*.md"
# Save a full project snapshot to a file for an AI prompt
lscat -d "*" -C -H none -D context.txtlscat [OPTIONS]
Files and directories must be specified with -f or -d flags. Positional arguments are not supported. When called with no arguments, lscat produces a non-recursive tree of the current directory.
| Flag | Long form | Description |
|---|---|---|
-d DIR [DIR...] |
--dir |
Directories to process. Supports patterns and multiple values. |
-f FILE [FILE...] |
--file |
Files to process (non-recursive, current directory by default). Supports glob patterns. |
-a |
--all |
Include hidden files and directories (dotfiles). |
Special values for -d:
| Value | Behaviour |
|---|---|
. |
Current directory only, non-recursive |
* |
All non-hidden directories, recursively |
.* |
All hidden directories, recursively |
migration*/ |
All directories whose name matches the glob |
Special values for -f:
| Value | Behaviour |
|---|---|
* |
All non-hidden files in the current directory |
.* |
All hidden files in the current directory |
*.md |
All Markdown files in the current directory |
client/src/*.js |
All .js files inside client/src/ |
| Flag | Long form | Description |
|---|---|---|
-D FILE |
--destination |
Write output to this file (creates if missing, overwrites if present). Can be specified multiple times for multiple output files. |
-de STR |
--delimiter |
String printed between file contents. Default: --- |
-l |
--line-numbers |
Prefix each line of file content with its line number. |
| Flag | Long form | Description |
|---|---|---|
-c |
--compress |
Remove leading/trailing whitespace and blank lines from file contents. |
-C |
--compress-hard |
Aggressive mode: also join all lines into a single line per file. Implies -c. Best used with -H none to minimise total token count. |
| Flag | Long form | Description |
|---|---|---|
-H TYPE |
--header-type |
Controls the directory listing format. Valid values: tree (default), ls, ls-R, none. |
| Flag | Long form | Description |
|---|---|---|
-sd PATTERN |
--skip-dir |
Skip any directory matching this pattern. Matches at any depth. Repeatable. |
-sf PATTERN |
--skip-file |
Skip any file matching this pattern. Matches at any depth. Repeatable. |
| Flag | Long form | Description |
|---|---|---|
-i |
--install |
Run the interactive installer. Must be used alone. |
-h |
--help |
Print the help message. |
-v |
--version |
Print version information. |
The -H / --header-type flag controls how the directory structure is displayed before file contents.
Full tree with branch connectors. Most informative, most verbose.
π .
βββ README.md
βββ lscat
βββ src/
βββ main.sh
βββ utils.sh
Flat list of files and folders. Compact, easy to scan.
π .
README.md
lscat
src/
Recursive listing with indented subdirectories, similar to ls -R.
π .
README.md
lscat
src/
src/
main.sh
utils.sh
No directory header printed at all. Combined with -C, this produces the most compact output possible β ideal for maximising the amount of code you can fit in an AI context window.
lscat -d "*" -C -H none -D context.txtStrips leading/trailing whitespace and removes blank lines from each file's content. Good for reducing noise while keeping code readable.
Strips all whitespace and collapses each file into a single continuous line. Intended for AI context packing where token count matters more than readability.
Tip: Combine
-C -H nonefor maximum density. You can always pair with-Dto save the result to a file before pasting into a prompt.
lscat supports glob patterns in -d, -f, -sd, and -sf flags. Because the shell expands unquoted globs before passing them to the script, always quote patterns:
# Good β lscat receives the literal pattern
lscat -f "*.md"
lscat -d "migration*/"
# Bad β the shell expands *.md before lscat sees it
lscat -f *.md-d "migration*/"matches any directory whose name starts withmigration, at any depth.-sf "*.log"skips any file ending in.log, anywhere in the tree.-sd node_modulesskips every directory namednode_modules, no matter how deeply nested.-sd ./client/node_modulesskips only that specific path.
Skip patterns apply to both the tree display and file content processing β a skipped directory or file will not appear in either section of the output.
lscat -d "*" -sd node_modules -sd .git -sd dist -sd __pycache__lscat -d "." -sf "*.log" -sf "*.lock"lscat -d "*" -sd node_modules -sd .git -sf "*.min.js" -sf "*.map"Use -D to write output to a file. Color codes are automatically stripped when writing to a file, making it safe to parse or share.
# Single output file
lscat -d "." -D snapshot.txt
# Multiple output files
lscat -d "." -D snapshot.txt -D backup.txt
# Custom delimiter
lscat -d "." -de "========" -D snapshot.txtThe output file is created if it does not exist and overwritten if it does. Combined with compression, this is the recommended workflow for preparing AI context:
lscat -d "*" -sd node_modules -sd .git -C -H none -D context.txtlscatNon-recursive tree of the current directory, including hidden files.
lscat -d "*"Recursively lists and concatenates all non-hidden files.
lscat -f "*.md"lscat -f "docs/*.md"lscat -d "*" -sd node_modules -sd .git -sd dist -sd buildlscat -d "*" -sd node_modules -sd .git -C -H none -D context.txtCreates a flat, compressed dump of your entire project with no directory headers β ready to paste into an AI prompt.
Include hidden files
lscat -d "." -aShow all hidden directories recursively
lscat -d ".*"Skip all hidden directories but include hidden files
lscat -d "*" -a -sd ".*"lscat -D output.txt -de "========" -d "."lscat -f ".gitignore" "README.md" -d src testsProcesses specific named files alongside full directory trees.
lscat -H ls -C -D output.txt -d "." -f "*.md"Flags can be in any order.
Always quote glob patterns to prevent premature shell expansion:
lscat -f "*.js" # correct
lscat -f *.js # may break depending on your shellUse -H none -C together when maximising token efficiency for AI prompts. The tree header adds substantial output that you often don't need when the AI only needs to read the code.
Use -sd for deep skip patterns. Because -sd node_modules matches at any depth, you do not need to specify the full path. A single flag handles all nested occurrences.
Use -l for debugging. Line numbers make it easy to reference specific positions when discussing code with an AI or in a code review.
Use -de to add visual separation when pasting multiple files into a document:
lscat -d "." -de "ββββββββββββββββββββββββββββββ"All bugs, feature requests, and technical issues must be reported in the original repository on GitHub: π https://github.com/lionel-hue/LSCAT/issues
Please do not open issues in forks.
Contributions are welcome! You are free to fork, modify, and redistribute this project for non-commercial use. If you have improvements or bug fixes, please submit a Pull Request to the original repository.
When contributing or redistributing:
- Do not modify the project author or claim ownership.
- Do not modify or falsify the commit history, authorship metadata, or project logs.
- Always clearly acknowledge the original owner ([LIONEL SISSO]).
- Ensure your changes follow the License.
Custom License β see LICENSE for details.
Key Terms:
- Non-Commercial Use Only: This software cannot be used or redistributed for profit.
- Attribution Required: You must credit the original author ([LIONEL SISSO]).
- Original Repo for Issues: All issues must be raised in the main repository.