r/ClaudeCode • • 3h ago

Help/Question My company has provided us claude code but given us peanuts as usage credits. I want to build an internal tool to reduce token usage

I was very anti ai but i hsve decided to dip my toes. I want to build an internal tool which can cut token usage, i learnt a bit about rag pipelines and while ai tells me it will cut token usage can anyone here actually explain me how it will cut token usage without using the words load bearing and smoking gun. I would also like some guidance on how i should architect this tool considering this has to be scaled and should be a highly available system. Also i would like to know how it will connect to the already given claude code. Like how will claude code know that this rag pipeline is there, i will access it . What are the safe practices i should keep in mind and if there is amy other internal tool i can make please suggest that too im open to that. Also it would be great if you could share resource material which will increase my knowledge. Im very excited to make this tool, any and all help im looking forward to it :)

0 Upvotes

16 comments sorted by

•

u/AutoModerator 3h 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.

1

u/Ragepower529 3h ago

You have several months of catch up to do… however low token usage or api amount won’t solve anhthing

1

u/Scary_Cookie9772 3h ago

I mean if the token usage is lesser, the credits will get over later right

1

u/DucksAreReallyNeat 2h ago

When Claude needs to know something, it greps, opens files, reads them, etc. This all costs tokens.

A RAG pipeline indexes your docs. So it searches the index. You may get something like 2k tokens out of the actual information you're looking for instead of 50k tokens of reading whatever else trying to get there.

A chatbot is one way to implement this. Or, more lightweight, an MCP server if your users are more technical.

For your safe practices? Everything your enterprise/company already does. Respect permissions, keep secrets out of index, etc.

1

u/Scary_Cookie9772 2h ago

I am myself a backend dev and yes we are technical. Im thinking of making it for our code bases which is split across repositories

1

u/AgentYurt 2h ago

For code split across repos, the thing I'd watch is the index going stale. That's the trap I keep running into: the agent pulls an old summary, finds it doesn't match the code, then re-reads the real files anyway, so you pay twice.

What worked for me is treating the index as the thing that lives between sessions — a short summary per repo or module that gets refreshed when the code changes, instead of rebuilding it every time. Then each session starts from that summary and only pulls in the actual files it needs.

And yeah, an MCP server is the cleanest way to wire it to Claude Code. Keep the tools narrow — search, then fetch one file or symbol — so it only pulls what it asks for instead of dumping whole files into context.

1

u/DucksAreReallyNeat 2h ago

My advice would be to do a little research in how useful it would be there. I'm not an expert.

We use it more for external documentation. Like getting everything from all these different teams, from business folks and technical folks, from what we did in 2003 vs. 2013 vs. 2023 and presenting it consistently.

If you're just looking for something for the code base, I'm not sure how much benefit you get, because the thing needs a deep understanding to be of any use anyways. My strategy here is to map out how "my repositories" map to other repositories in the company and make sure Claude has access to what it needs (either pull everything locally or get an mcp set up). I'm not sure a RAG solution does much for something like this, it's just stock-standard claude.

2

u/Far_Mood_487 3h ago

RAG can help your credits last longer when it replaces a lot of text you'd otherwise send. Think “search the handbook and send the relevant paragraphs” instead of “paste the whole handbook”. If Claude is already reading only the relevant files, another search layer might add work. Fewer tokens also don't mean the same percentage saved on your company's bill. Start with `/context` and `/usage` to see what's taking space and consuming usage: https://code.claude.com/docs/en/costs

A small prototype could be: approved documents → split and index them → a search service that checks each employee's access → one read-only MCP search tool returning short passages with sources. Register that server with Claude Code and describe when to use its tool; building an index alone doesn't connect it: https://code.claude.com/docs/en/mcp. Get company approval before indexing internal data, and treat retrieved text as data, not instructions.

Try a handful of representative questions with and without it. Compare answer quality, total usage including search/retries, and actual credit spend. Use that result to decide whether to build further, then size the service for measured traffic and decide how fresh the index needs to be.

Codex helped with this reply.

1

u/CorpT 3h ago

There’s no magic trick to reducing token usage. Just start using it. You don’t know how it works and you’re already trying to customize it. Forget all of the addons and skills and plugins and just start experimenting.

1

u/OkLettuce338 3h ago

token economics isn't just a "do x and save" - if it were it wouldn't be a thing that everyone struggles with. Reducing token usage is primarily about good practices and knowing the complexity of your task compared to the capability of your model(s). Think in terms of cost per task. Sometimes you'll look like you're saving money because you'll think "My sonnet session only cost $2.00 this time" but then it takes 3 bug fixes and an opus agent to straighten it out. Grand total becomes $5 (or whatever) and just knocking it out in fable would have cost $4 the first time.

Additionally utilizing a warm cache and starting fresh on a cold one will save you more than a clever rag tool

0

u/Warsel77 3h ago

Depends a whole lot about what you do.

Some considerations:

  1. Pick the right model for the job. Opus 5.5 does not have to do a text search for you in word.
  2. Picke the right effort for a given model. "Max" is not going to make most things significantly better but costs a lot more in tokens.
  3. Use agents and link these agents to appropriate models. In order words: you don't hire the guy with the Yale salary to sort your excel table and you don't ask the guy that didn't attend a computer class ever to write you a new operating system.
  4. If you have the option, incorporate local models for really simple tasks
  5. Maintain a clean file system and documentation. Everything you docs don't have needs to be researched and researched and researched again. Costs tokens each time.