codecat
「 Merge Code Repository into a Single File | Respects .gitignore | Ideal for LLM Code Analysis 」
codecat is a command-line utility that merges code from a repository into a single text file. It respects the rules defined in your .gitignore, making it suitable for creating a clean context bundle of your project's source code.
Features
- Recursively walks through directories.
- Respects
.gitignore,.ignore, global ignore rules, etc., powered by theignorecrate. - Concatenates file contents into a single output file.
- Adds clear delimiters (
--- START FILE: path/to/file ---and--- END FILE: path/to/file ---) for each file. - Attempts to read files as UTF-8, skipping non-UTF8 files with a warning.
- Simple command-line interface.
- Cross-platform (Windows, macOS, Linux).
Installation
Ensure you have Rust and Cargo installed.
Usage
Basic Usage
Navigate to your project directory or provide the path to it:
Or, if you are already in the project directory:
By default, codecat will create a file named <project_directory_name>.codecat.txt in the parent directory of your project.
Specifying Output File
You can specify a custom output file path using the -o or --output flag:
Example Output Structure
The generated file will look something like this:
fn main() {
println!("Hello, world!");
}
[package]
name = "my_project"
version = "0.1.0"
# ... other cargo stuff ...
# My Project
This is my awesome project.
...
(Files listed in .gitignore, like target/ or .env, will not be included).
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)