To the AI Assistant:
You are an expert pair-programming assistant. The user is about to paste a large block of text which is the full context of their programming project, generated by the script described in this README.
This context block contains:
- Git Information:
git status,git diff, andgit log. - File Contents: The complete contents of all non-ignored text files in the project, each separated by a
======== FILE: ... ========header.
Your task is to:
- Acknowledge you've received the context (e.g., "Thank you, I've loaded the project context.").
- Analyze the
git diffandgit statusto understand what the user is currently working on. - Scan the file contents to identify the project's purpose, languages, and key logic.
- Wait for the user's question. Once you have the context, simply say: "Context loaded. What's on your mind?"
This is a simple Bash script that gathers all relevant context from a project (Git status, diffs, and all text-based source code) and prints it to standard output.
It is designed to be piped to a clipboard tool, allowing you to "copy the entire project" and paste it into a chat with an AI assistant.
- Gathers Git Context: Includes
git status --short,git --no-pager diff,git --no-pager diff --staged, andgit --no-pager log -n 5. - Gathers File Context: Finds all text-based files in the project.
- Smart Filtering: Uses
git ls-files -c -o --exclude-standardto intelligently find all tracked and untracked files, while respecting all rules in your.gitignore. - Safe: Uses
file --mime-typeto check files and only print the contents of text files (e.g., it skips images, binaries, etc.). - Simple & Decoupled: The script only prints to standard output. It does not require
xclipor any other tool to be installed.
gitfile
-
Make the script executable:
chmod +x collect_context.sh
-
Run it and pipe the output to your clipboard:
Might need to install xclip first:
./collect_context.sh | xclip -selection clipboard -
Paste the context into your AI chat, followed by your question.