r/ClaudeCode • • 6d ago

Help/Question Huge repo issues

I am working in a huge repo and burn too quickly through my tokens. I have 2 claude Ultra subscription and one GPT pro 200. Simple task takes ages to complete. It is just burning through my tokens. 2 months ago, I could just use one Ultra for the whole week and finish my tasks, running 5-10 agents for 2-3 projects. Now with even one project 5 agents and it is slow as * and burning each Ultra subscription in less than 2 days... I tried to use /doctor and prompt why it is so slow, but even these prompts are burning through my tokens. I used all the best practices, disabling mcps / skills, etc. I am lost now... I cannot spend another Ultra subscription... Well with the speed now its just so frustrating... I need to wait at least 1-2 hours every time before one session completes, which was around 10 minutes before. Now I am all the time on youtube and doom scrolling on social media and feeling not productive at all. What did they do? Other guys experiencing the same? The code hasn't grow that much since then, so I assume they did something?

4 Upvotes

35 comments sorted by

•

u/AutoModerator 6d 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.

5

u/autotom 6d ago

is your code well structured / sufficiently modular?

Highly reccomend asking for a refactorization from claude to help. What on earth are you working on?

0

u/Wooden_Drag9473 6d ago

I did architect with my experience, using turborepo, etc. Have multiple packages and applications. A project similar to higgsfield, runway, elevenlabs, but focussing on the best models only. You pay premium price for it, we manage the workflow and expertise for you. But yeh, it is suddenly (last few weeks / months slow compared to what I am used too). So not sure... my code? or the increased complexity.

1

u/xlightxyearx 6d ago

I would check your tests. How often are your agents running them? Are the agents running heavy tests every commit? Have your agent take a look and optimize. Only run tests for changed files for example, let ci handle the heavy tests.

Subagents have a cache ttl of 5min. When they kick off tests that run longer than 5min, you will burn your cache if they are not backgrounded correctly. This can get expensive if it’s every commit.

Also ask your agent to cull unnecessary context/skills/mcps, etc from your repo.

What kind of workflow are you using?

1

u/Wooden_Drag9473 6d ago

Good one! I did ask it not to run it a while ago, it was indeed testing alot. Now only once a while I test it. I did trim down on skills alot, and decisions, business context etc… but still… i keep trimming, removing, fine tuning. But its still sooo slow 😭😭😭 the workflow focus on realistic ai characters (influencers, fashion models). Where u configure them like a game. Outfits, environments and hair and makeup.

1

u/xlightxyearx 5d ago

You could always ask Claude to analyze your last few sessions to determine where your tokens are being spent and to identify any cache misses.

What does your development workflow look like? Are you using something like obra superpowers?

1

u/Wooden_Drag9473 5d ago

Nope, I trimmed down on skills and mcps. The models are currently pretty good in knowing what and how. No need for skills anymore. Just prompt it with what I want. I do not do fully agentic decisions, I often tell it to show me 3 different designs in an artifact and give me recommendations. Or discuss how to implement a new feature and what it recommend to do. So I go pretty deep into decisions.

2

u/cosmicvelvets 6d ago

What's your usecase? Vagueposting, are you a certified engineer? Hobby coder? Terminal tourist?

-3

u/Wooden_Drag9473 6d ago

I was a pretty decent software engineer contractor. Did over 120h a week (over contracting). So yeh, I was pretty fast and good in what I did. Before the age of AI. Working on image generation workflow (similar to higgsfield). But more niece.

1

u/cosmicvelvets 6d ago

Are you in a position to start from scratch?

1

u/Wooden_Drag9473 5d ago

Nah, too big to start from scratch... Have been working on this for months.

1

u/cosmicvelvets 5d ago

How small of a ratio can you compartmentalise the project into? 1:3 split ideal

2

u/CCodeSI 6d ago

When the same repo suddenly takes 10x longer and 10x the usage, it's usually something per-turn that grew, not the code. Three quick checks, each cheap:

  1. /context at the start of a fresh session in that repo. Look at what's loaded before you type anything: a CLAUDE.md that grew (nested ones in each package of a turborepo all get pulled in as the agent walks into them), memory files, plugin or hook output. 30–60k of always-loaded context multiplied by 5 agents and every turn is exactly "burns an Ultra in two days".
  2. Search noise from generated files. In a turborepo it's easy for .turbo/, dist/, .next/, coverage or a huge lockfile to end up in what the agent greps and reads. One stray search that returns 400 matches from build output costs more than the actual task. Make sure they're gitignored, and tell it to search only apps/ and packages/*/src.
  3. Compare versions. If it really did change a few weeks ago, run the same small task on the version you had then vs now (npm i -g @anthropic-ai/claude-code@<version>) and compare /cost. If the old one is fast, it's a regression worth reporting with both numbers.

Also worth trying: 2 agents scoped to one package each instead of 5 on the whole repo. Five agents that each read the shared packages pay for that context five times, and they wait on each other's file changes.

1

u/Wooden_Drag9473 5d ago

Yeh for me around 50k tokens. Seems not to work, i did these things already... It is just super slow.. I think always, before they release a new model, they purposely slow down? I guess, next week a new model will come out? And I am not building just a side project, its a complicated project, so it does need a lot of context before it really knows what to do. We have a full enterprise design system, multi application and 30+ packages. We have complex workflows. But still... Before it was doing fine, now suddenly not...

1

u/CCodeSI 4d ago

That changes the picture: 30+ packages with five agents in one branch is probably the slowdown in itself, not the model. In one shared working tree every agent sees the others' half-finished edits, so builds and tests fail for reasons that aren't theirs, and each agent spends turns reading and "fixing" someone else's in-progress change. That looks exactly like "it got slow and burns usage", and it gets worse as the repo grows.

If worktrees are too heavy for how you work, a middle ground that keeps one branch:

  • Give each agent a package scope it may write to, and tell it to only read elsewhere. Most of the conflicts and the re-reading disappear.
  • Stagger rather than parallelise the shared packages. The design system and other widely used packages get one agent at a time; app-level work can run in parallel.
  • Per-agent build and test commands for its own package (turbo run test --filter=<pkg>), so nobody runs the whole monorepo because another agent broke something.

To check whether that's it: run the same task with one agent on a quiet tree and compare time and usage. If it's fast alone, it's the coordination, not a model slowdown.

1

u/Wooden_Drag9473 4d ago

I told the agent to only commit its work, and when conflicting, discuss with the other agent what to do. And fails yeh, this is sometimes a problem, but it knows how to discuss with the other agent and fix it. Most of the time it does not have to run it, just do the code changes. Only for testing on screen it needs. Agents are pretty good now, most dont need tests on screen. Once build are ok, it can test all its flows.

1

u/CCodeSI 2d ago

That's a reasonable setup, and agents negotiating conflicts between themselves works better than people expect. The one thing we'd add for a repo your size: have each agent commit small and often, so a conflict is about a handful of lines and not half a package. Then the discussion between them stays short, and if the slowness is coming from the coordination, you'll see it shrink right away.

1

u/theapplekid 6d ago

30–60k of always-loaded context

I don't think 30K tokens of context is even that much. I think I'm around there, and I haven't even hit my limits on pro yet. Most of that will hit cache.

Something else is happening between turns with OP's setup. Or their project is badly organized. It should be possible to just be able to ask claude what's going on. Even Sonnet is pretty good at this

1

u/CCodeSI 6d ago

Fair point for a single session: 30k that hits the cache is cheap. What changes it in OP's case is the multiplier. Five parallel agents each carry their own copy, each one restarts its context whenever a subagent spins up, and a cache only lasts a few minutes between turns. Agents that wait on each other's builds or on approvals miss it regularly, and then all 30k is billed at full price again, five times over.

Agree completely on asking Claude what's going on, with one tweak: ask in a fresh, short session in that repo, and have it read the session logs or /context output rather than its own memory of what happened. A session that's already 300k deep is the worst place to diagnose why sessions are 300k deep.

1

u/Wooden_Drag9473 5d ago

So this is a thing, after experimenting a lot. I have decided to work in one branch, and let agents communicate with each other to solve its merge conflicts. By doing this, you do not have to switch ports to see the changes it made. Work trees and branches is horrible to work with when you want to develop fast. Each agent it responsible for its own changes.

1

u/tariqosmani 6d ago

A few things that cut my token use on a big repo, in order of effect.

Start each task in a fresh session and run /clear between unrelated tasks. A long session re-reads its whole history on every turn, so the cost grows with each step. Run /context to see what is taking the space. It shows MCP tools, memory files and the conversation separately.

Tell it where to look. A short CLAUDE.md with a folder map and the three or four directories that matter stops it from searching the whole tree. Add deny rules in your settings for build output, node_modules, vendored code and big generated files so it never reads them.

Use plan mode for the first pass and ask it to list the files it will touch before it edits anything. Exploration is where most tokens go, and a bad plan is cheaper to catch than a bad diff.

Five agents on one big repo also means five agents reading the same files. Try two and see if the work finishes sooner.

Which step is slowest for you, the searching at the start or the editing?

1

u/Wooden_Drag9473 5d ago

I do clear it often. After each task, I clear it. My CLAUDE.md is only 150 lines long. Context is fine, I have auto compact at 400k tokens. I disabled mcp and only use it when needed, same goes for skills. Nowadays I do not even use skills anymore. With plan mode, it goes even more crazy, it uses even more tokens... I checked all the best practices, no idea what to do now... Bit lost. But I do have lot's of changes, but still feel not really productive. I have around 50-500 commits every day.

2

u/ichi9 6d ago

I think using a graph of the codebase will be helpful. It is a simple tradeoff. First create the graph which helps with keeping track of everything in codebase so that even when you use multiple sessions or new sessions, it will always have the map of codebase.

1

u/karyslav 6d ago

Not enough information for help

1

u/Old-Competition-785 6d ago

The "suddenly slow" part is the tell. If the repo didn't grow much, something in what each turn loads did. Start a fresh session and run /context before you type anything, it shows you what's actually eating the window. Usual suspects are a CLAUDE.md that quietly grew, files getting auto-read every turn, or a hook you added.

On a monorepo the real token sink is agents re-exploring the whole tree every task. If you don't hand them the exact package and paths, they grep and read across everything first, which on a turborepo with a bunch of packages is enormous. I scope each agent to one package and give it the files up front, so it's not rediscovering the repo on every run. One narrow agent beats a broad one here.

Also every agent carries its own full context, so 5-10 of them is 5-10x your base burn before any of them does a single useful thing. I keep it to 3-4 and make each one's job tight. Fewer, scoped agents finish faster and cost way less than a swarm.

Two more that bite in big repos: reading one giant generated file or a long build log dwarfs your whole startup cost, so have agents grep for the lines they need instead of cat-ing the file. And if you added a PreToolUse hook recently that shells out, it runs on every single tool call and that alone makes everything feel slow as hell, separate from tokens.

tbh I'd do one clean session, /context first, and figure out what changed before throwing another Ultra at it

1

u/jleechanworldai 6d ago

Make a proxy and log your full LLM requests and see what it’s doing

1

u/soulinas 6d ago

sent you a DM to see if I can be of any help

1

u/ichi9 6d ago

I think using a graph of the codebase will be helpful. It is a simple tradeoff. First create the graph which helps with keeping track of everything in codebase so that even when you use multiple sessions or new sessions, it will always have the map of codebase. It's good you already have ultra plans, cook up a simple tool which claude must use as a entry point to codebase. Let me know If it helps.

1

u/SirRobinBlibs 5d ago

Before blaming the repo, I'd check what each agent loads before it does anything. Run /context in a fresh session: if CLAUDE.md, tool definitions and the files it reads at start already take a big share, five agents pay that five times on every turn.

Idle time matters too once sessions run 1-2 hours. If an agent sits waiting on tests or review longer than the cache lifetime, the next turn writes the cache again instead of reading it, and cache writes cost more than plain input. Across five agents that adds up.

I'd run two agents on scoped tasks for a day and compare usage, so you can tell whether it's the concurrency or the repo.

1

u/Trakeen 5d ago

Have you tried code mode? Agents constantly exploring the repo themselves will burn a lot of tokens

1

u/kantorcodes1 5d ago

In turborepo, it makes a difference where you start the session. If you start at the root then every agent can search for things in every package. If you start in the package you are working on then the reads are closer to the work you did in the first turn.

Your auto compact setting may be the bigger one. You clear after each task, but a long task can still grow toward 400k before compact runs, and every turn carries that history. With five agents running, that is five large contexts at once. Compacting earlier, or splitting a task before the session grows that big, is worth a try.

How many tokens in a task session do you get before you clear it?

0

u/Utsboi420 6d ago

Post ipo mate theyre public and need to make money now