A utility script that bundles a Git repository's state and non-binary source files into a single Markdown stream optimized for Large Language Model context windows.
git- Version control systemfile- File type detectionawk- Text processingxclip- Clipboard integration (optional, required for-cflag)
collect_context.sh [OPTIONS]-c, --copy- Copy output directly to the system clipboard-d <dir>, --directory <dir>- Target a specific repository directory (default: current directory)-h, --help- Display help message and exit
Basic execution:
collect_context.shCopy output to clipboard:
collect_context.sh -cTarget a specific directory:
collect_context.sh -d /path/to/projectCopy output from specific directory to clipboard:
collect_context.sh -d /path/to/project -cThe script collects:
- Git Information: Status, unstaged changes, staged changes, and recent commit history
- Source Files: Complete contents of all non-binary, text-based files in the repository
- Smart Filtering: Respects
.gitignorerules and excludes binary files automatically
All output is formatted as clean Markdown with syntax highlighting for easy consumption by LLMs.