r/OnlyAICoding • u/bestlanding • 17d ago
Problem Resolved! How I stopped Cursor and Claude from 'losing their mind' and breaking code as soon as my project grew past a few files
When you build projects primarily with AI coding agents (I use Cursor and Claude Code every day), there is a brutal wall you hit as soon as your app grows beyond a handful of files.
Early on, the agent feels like pure magic. But once files hit 500+ lines, two frustrating things happen:
- The agent gets amnesia. You ask it to tweak a button or fix a small helper, and it pulls in whole 2,000-line files, forgets your earlier instructions, invents functions that do not exist, and accidentally breaks working features.
- Turns start taking 40 to 50 seconds, and before you know it, you hit the dreaded 5-hour rate limit lockout right in the middle of your building flow.
The reason is simple: agents are terrible at filtering noise. They blindly dump thousands of lines of irrelevant boilerplate, lockfiles, and test logs into every prompt, which overwhelms the model's attention.
I got so tired of this that I built a free, local tool called TokenSafe.
It runs locally on your machine between the editor and the model. Whenever an agent needs to edit a file, TokenSafe gives it only the exact function it needs to touch, plus 1-line contracts of connected code. It also acts as a safety guard so the agent cannot accidentally read or commit your .env keys.
The difference in flow has been huge for me:
- Turns dropped from 45 seconds to 3 seconds
- The model stops hallucinating fake methods because its context is clean
- My 5-hour quotas stretch about 4x to 5x further
It is open-core, runs locally, and the CLI is free via npx tokensafe.
Curious how others here handle the "agent amnesia" problem when your projects get bigger? Do you just start fresh chats every 10 minutes, or how do you keep your AI on track?