Skip to content
RCreddit.com·

Git setup that keeps your AI agent from reading your whole codebase

AI summary

A developer shares a Git setup to optimize AI agent interaction with large codebases, aiming to reduce costs. Key strategies include treating HEAD as a cache, prioritizing .changed_markers, focusing on changed hunks and functions, and anchoring on function/class names instead of line numbers. For signature changes, git grep -n is used to find callers. After a successful commit, .changed_markers are cleared. This method is applicable across various programming languages.

Time & source

Times shown in UTC

Display time zone: UTC

Local time zone unavailable; showing UTC.

PublishedOffset at this time: UTC+0Sep 13, 2026, 05:30 UTC

IngestedOffset at this time: UTC+0Sep 13, 2026, 14:01 UTC

Published
Sep 13, 2026, 05:30
Ingested
Sep 13, 2026, 14:01
Source type
Dev community
Tier
Community
Source status
Healthy

Tier is a per-source editorial setting, not a per-item score.

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.

Source·reddit.com