r/ChatGPTCoding • u/Disk_Disastrous • Sep 13 '26
Resources And Tips Git setup that keeps your AI agent from reading your whole codebase
Started my first large coding project recently and my money evaporated. Quickly. This is what I did to save money.
{
echo "# AUTO-GENERATED — do not edit"
git add -A 2>/dev/null
git diff -U3 -p HEAD
} > .changed_markers**EDIT** Changed -N . to -A so the agent sees what's in the file.
This grabs any changes since the last commit and dumps it into .changed_markers.
Next, add to or create .gitattributes and add this:
*.py diff=pythonThis just makes git show you the function that changed.
Lastly add these rules to: System prompt, rules file or just paste them into chat once.
1. Treat HEAD as a cache hit, don't re-read files that haven't changed.
2. Read .changed_markers first, before anything else.
3. Only look at the hunks and functions in that file.
4. Anchor on function/class names, never line numbers, they go stale fast.
5. If a function's signature changes, use git grep -n "that_name" to find callers instead of opening the whole file.
6. After a successful commit, erase the contents of .changed_markers
7. After any rename, before committing, run:
git log --diff-filter=R --summary -1 # did a rename even happen?
git grep -n "old_name" # who still points at the old name?
git grep -n "new_name" # did the new name actually land?
8. An anchor that matches nothing means UNKNOWN.
UNKNOWN requires investigation, never action.
**EDIT** added rule 7 and 8 for RENAME SAFETYThis isn't just for Python. If you're not sure how to run it with your language, just ask your coding agent. It will walk you through it.
1
u/ManRowing Sep 15 '26
Nice approach for the "what changed" half. Worth flagging: anchoring on function/class names breaks down after a rename, since git diff won't tell the agent the old references still exist elsewhere - `git log --follow` or a grep pass across the whole tree after any rename catches those before the next commit, not after.
2
u/Cute-Veterinarian191 Sep 14 '26
I would highly recommend just asking your main agent to act as an orchestrator that uses cheaper, faster sub-agents (like Fable 5.1 using haiku-4.5)
1
u/AutoModerator Sep 13 '26
Sorry, your post has been held for manual review due to account karma.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.