A tool to easily gather code context to give to an AI like ChatGPT or Claude.
Pacont (short for Path and Content) is a simple and efficient CLI tool designed to recursively print file paths and their contents within specified directories or files. This tool is particularly useful for gathering code context to provide to AI models like ChatGPT or Claude, making it easier to analyze and understand large codebases.
- Recursively traverse directories and subdirectories.
- Print file paths relative to the input directory.
- Output the contents of each file.
- Accept multiple directories and files as input, concatenating their contents with a separator.
- Control maximum recursion depth.
- Include error messages in the output for files that cannot be read.
- Rust and Cargo installed. If you haven't installed Rust yet, you can do so by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Clone the repository:
git clone https://github.com/Tmpecho/pacont.git
cd pacont
- Build the project:
cargo build --release
- Move the executable to a directory in your PATH:
sudo cp target/release/pacont /usr/local/bin/pacont
brew tap Tmpecho/pacont
brew install pacont
pacont [OPTIONS] <PATH>...
-m, --max-depth <MAX_DEPTH>
: Maximum recursion depth for directories (0 means no recursion) [default: usize::MAX]-i, --include-errors
: Include error messages in the output-o, --output-information
: Display the number of characters and words of the output without printing the contents-h, --help
: Print help information-V, --version
: Print version information
Given a directory structure:
src/
├── div
│ └── test.kt
└── main.kt
README.md
misc/
├── notes.txt
Running pacont src README.md misc/
will output:
**div/test.kt**
//comment
**main.kt**
println("hello")
--------------------------------------------------------------------------------
**README.md**
# Pacont
A very simple CLI tool to recursively print file paths and contents in a directory.
--------------------------------------------------------------------------------
**notes.txt**
Some notes here...
Running pacont -o src README.md misc/
will output:
Total Characters: 1234
Total Words: 234
Contributions are welcome! Feel free to open an issue or submit a pull request if you have any improvements or new features to add.