Version: 0.1.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
Follow these steps to install and run the Repository Context Packager on your system.
Make sure you have the following installed:
-
Python 3.6+
python --version
-
pip (Python package manager)
pip --version
-
Git (for Git metadata extraction)
git --version
git clone https://github.com/kphero/repository-context-packager.git
cd repo-context-packagerpip install -r requirements.txtOr manually:
pip install GitPythonpython repo-scan.py ./test-directoryOr display help:
python repo-scan.py --help- Permission Denied: Try running with elevated privileges or check file access rights.
- Missing GitPython: Run
pip install GitPython. - Script Not Executing: Ensure you're in the correct directory and using the right Python version.
| 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) |
python repo-scan.py [-h] [-v] [-r] [paths ...] [-o [OUTPUT]]-
Analyze current directory and display results:
python repo-scan.py . -
Analyze a folder and write results to
context-package.md:python repo-scan.py ./my_project -o context-package.md
-
Analyze multiple files:
python repo-scan.py file1.txt file2.md
-
Analyze recent files in current directory:
python repo-scan.py . -rNote:
repo-scan.pyonly detects files located in the same directory as the script. Ensure that all target files are placed in the script’s directory before execution, or thatrepo-scan.pyis placed in the directory where the files are located.
# 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>
MIT License. See LICENSE file for details.
All contributions welcome—whether it's fixing bugs, improving documentation, suggesting new features, or submitting code enhancements.