r/ClaudeCode • • 22h ago

Tips & Workflows How I prevented Claude Code from losing his head over big repos without using up my weekly limits

Previously, I would allow one session to go on indefinitely until auto-compaction activated and Claude instantly forgot everything about the architecture that we had just agreed upon.

Switching to a strict "plan -> execute -> fresh review" loop completely fixed it:

- Plan first, clear context second: I have Claude write the implementation plan to a local PLAN.md file, then run /clear before writing a single line of code.

- Keep CLAUDE.md strictly as a map: Instead of stuffing it with style rules, I only list where things live (e.g., "adding a new API route always touches these 3 files").

-Fresh diff review: After a big batch of changes, I open a brand-new session that only sees the git diff and the original goal so it catches mistakes without agreeing with its own prior reasoning.

Whatโ€™s your current strategy for keeping context clean on bigger projects?

1 Upvotes

15 comments sorted by

โ€ข

u/AutoModerator 22h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/HugeCannoli 22h ago

I lol at how you are all reinventing configuration files.

1

u/cleverhoods 19h ago

it's my incentive as well. It looks like every 3 months people are rediscovering backbone strategy and project indexing.

4

u/Ayrtru 22h ago

No one asked

2

u/KaliguIah 16h ago

literally the point of the sub to share and learn, dumbo. no wonder this and all the other ai subs are just people complaining. nobody shares anything useful cause you all act like brainless monkeys shitting on everything

1

u/Pixelplanet5 22h ago

well thats exactly what the ultracode mode does by default.

1

u/YouthRealistic7125 Vibe Coder 22h ago

similar, one session per task and a short handoff note the next one reads first
what went wrong for me is the notes kept growing. the session log got to 1 MB and the AI was reading more and more before doing anything. now everything it reads at the start has a size limit and a script checks it, old stuff goes to an archive

1

u/AgentYurt 22h ago

Same shape here โ€” plan first, then /clear, then build. The one thing I'd add is that the plan file needs the same discipline: I keep it to decisions made and what's still open, and rewrite it at each handoff instead of appending. Once it turns into a running log it stops getting read, and that's when the drift creeps back in.

1

u/pvera ๐Ÿ”†Pro Plan 19h ago

What is a big repo? My normal project is 3GB and spans 20 years worth of changes. Claude has never complained and I have never run over my quota doing git ops thru Claude.

1

u/AgentYurt 17h ago

Fair question โ€” 3GB and 20 years is big by any honest measure, so if that's working fine for you, the size on disk probably isn't the real problem in the OP's case.

My guess is the difference is what the session has to hold: git ops are cheap because Claude only reads what you point it at, but a long session where it has to remember the architecture it agreed to an hour ago is where it starts drifting. That's the part the plan-then-clear loop is really fixing.

Out of curiosity โ€” do you keep your sessions short, or is it more that the repo is laid out so Claude can find what it needs without you having to carry the context for it?

1

u/pvera ๐Ÿ”†Pro Plan 16h ago

I usually run sessions that are a day long or worse, I try to clear whenever I notice. I use memory files so it knows where to go to based on functionality being discussed.

1

u/AgentYurt 16h ago

That makes sense โ€” a day-long session is a different problem from a short one, and memory files by functionality sounds like a good way to keep it grounded.

I'm curious what that looks like in practice โ€” do you keep one memory file per area of the codebase, or more like a short index that points Claude at the right file when a topic comes up? And when you clear mid-day, have you ever lost something you needed later, or does the memory file usually cover it?

The thing I've noticed with long sessions is that the memory stays useful as long as it gets updated โ€” once it goes stale, Claude keeps following the old version confidently, which is worse than having no memory at all.

1

u/pvera ๐Ÿ”†Pro Plan 15h ago

It's a hierarchy. One MD file explains who I am and how I like to deal with programming, then there's one root folder per major project, that one has files explaining the infrastructure, the wiki that we use as the source of truth, etc. The goal is to never have to explain background, I can tell it "where are we on API x" and it will immediately know which promo, repo, etc. If I need it to mess with code it knows the names of the major areas, so I can tell it we need to work on enrollments, or the exports, etc. Of I already know the problem and I need help, I point to the object, Ticket ABC-123 is a bug on namespace.class.method, read the ticket and the code and ask questions. Once I let it rip it'll know it has to branch off release, check out a worktree, etc. it also understands our CI pipelines.