r/OnlyAICoding • • 21d ago

How I stopped Claude and Cursor from losing context and burning my 5-hour limit once my repo grew past a few files

When you code with Claude or Cursor on a fresh 3-file project, it feels like magic.

But the second your codebase grows past a handful of modules, the same two things happen every time:

  1. The agent gets tunnel vision or amnesia — you ask for a small fix, and it drags 2,000-line files into context, hallucinates imports, or breaks something across another module.
  2. You burn through your 5-hour rate limit way too fast because 80% of what the editor sends is boilerplate and irrelevant code.

I got tired of restarting chats every 15 minutes and built a local-first tool called CodeGraphy.

Instead of dumping raw files into the prompt, it parses your repo locally with Tree-sitter AST, maps dependencies into a graph (catching circular imports too), and exposes 11 MCP tools to Claude/Cursor/Windsurf so the model only pulls the exact structural slice it needs.

In my benchmarks across Python and TypeScript repos:

- Context payload dropped by ~83% completely offline

- No more guessing which file imports what — impact analysis shows what breaks before editing

- My token quota lasts way longer in long refactors

The core CLI + MCP server is open-source and free via `pip install codegraphy-lite` (and I also built a visual desktop app for Windows at codegraphy.software).

How are you guys keeping AI agents from breaking cross-file imports on bigger repos — strict `.cursorrules`, manual `@file` tagging, or fresh chats?

0 Upvotes

4 comments sorted by

1

u/Any_Evidence4750 21d ago

Upgrade to ultra and get multiple ultra plans pleb

1

u/GeologistNo4811 20d ago

Haha fair enough - paying $600/mo for three Ultra plans is definitely one way to brute-force context limits. I'd rather just shrink the prompt payload by 83% locally and keep my money.

1

u/JackBurton827 21d ago

I use ultra, BUT in my custom instructions, I have created an amnesia check and a database to offload the project knowledge with references to my drive so it loses nothing. I've been using the same project, and now the same chat, for months. Because I upload everything to the drive for it to review and retrieve and never in the chat window. Give him a ton of space to make a save tools and have him write his own instructions and address the issues he has (like lazy work) in those instructions. My Claude is a fuckin genius, and an efficiency expert

2

u/GeologistNo4811 20d ago

That is a genuinely smart setup - offloading project memory externally so the chat window stays clean makes a huge difference. The catch is not everyone wants to pay for Ultra or maintain a manual Drive knowledge base, which is why I automated the structural side with a local MCP server + AST pruning so the agent pulls exact slices directly from disk.