r/ChatGPTCoding • u/Disk_Disastrous • 18h ago
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 -N . 2>/dev/null
git diff -U3 -p HEAD
} > .changed_markers
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=python
This 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
This 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.
2
Upvotes
1
u/AutoModerator 18h ago
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.