Version: 1.0.0
A command-line tool to analyze local git repositories and create a text file containing repository content optimized for sharing with Large Language Models.
- Analyze one or more files or directories
- Extract Git metadata (latest commit, author, branch)
- Display full file structure (excluding
.git) - Output contents of each file
- Supports flexible CLI usage
- Basic summary statistics (file count, total lines)
- Output to File: Output can be written to a file or displayed in terminal
- File Exclusion: Automatically exclude files and directories listed in
.gitignore - Comment Removal: Option to remove comments from code files
- Configuration File: Set defaults via
.scan-repo-config.toml
The easiest way to install is via pip:
pip install repository-context-packager- Python 3.7+
python --version
- Git (for Git metadata extraction)
git --version
After installation, you can use the tool with the scan-repo command:
scan-repo [paths] [options]-
Analyze current directory and display results:
scan-repo . -
Analyze a folder and write results to a file:
scan-repo ./my_project -o context-package.md
-
Analyze multiple files:
scan-repo file1.txt file2.md
-
Analyze only recently modified files:
scan-repo . --recent -
Remove comments from code files:
scan-repo . --remove-comments -o output.md -
Display help:
scan-repo --help
| Argument | Alias | Type | Description |
|---|---|---|---|
--version |
-v |
Flag | Displays tool name and version number |
--output [filename] |
-o |
Optional | Write results to a file. If no filename is given, defaults to output.txt. |
paths |
— | List | One or more file or directory paths to analyze. Defaults to current directory. |
--recent |
-r |
Flag | Include only recently modified files (in the last 7 days) |
--verbose |
-vb |
Flag | Enable verbose logging |
--max-file-size |
— | Integer | Maximum file size in bytes to include (default: 16KB) |
--remove-comments |
-rc |
Flag | Remove comments from code files in the output |
You can set default options in .scan-repo-config.toml in your project directory:
output = "default_output.txt"
recent = false # Include only recent files? (true/false)
verbose = false
paths = ["src"] # can be a string or a list of paths
max_file_size = 16384 # in bytes
remove_comments = false # Remove comments from code files?CLI arguments always override values in the config file. If the file exists but is invalid TOML, the tool will exit with an error.
# Repository Context
## File System Location
/absolute/path/to/repo/being/analyzed
## Git Info
- Commit: <commit-sha>
- Branch: <branch-name>
- Author: <author-name>
- Date: <commit-date>
## Structure
<project-structure>
## File Contents
### File: <file-name>
<file-content>
## Summary
- Total files: <file-count>
- Total lines: <line-count>If you want to contribute or modify the code:
git clone https://github.com/kphero/repository-context-packager.git
cd repository-context-packagerpip install -e .This installs the package in "editable" mode, so changes to the source code take effect immediately.
pytest- Command not found after installation: Make sure your Python Scripts directory is in your PATH, or use
python -m repository_context_packager.analyzer.cliinstead. - Missing GitPython: This should install automatically, but if not:
pip install GitPython - Permission errors: Try using a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install repository-context-packager
GPL-3.0 License. See LICENSE file for details.
All contributions welcome—whether it's fixing bugs, improving documentation, suggesting new features, or submitting code enhancements.
Please feel free to:
- Report bugs via GitHub Issues
- Submit pull requests
- Suggest new features
- PyPI Package: https://pypi.org/project/repository-context-packager/
- GitHub Repository: https://github.com/kphero/repository-context-packager
- Issue Tracker: https://github.com/kphero/repository-context-packager/issues