📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

24 способа сэкономить токены Claude Code — от простых до экспертных

Эдвард Гришин | AI и автоматизация бизнеса19:40

Transcription

Hello everyone. Let's imagine a situation. It's 3 PM, you're in the middle of a project. And then Claude writes: "Limit exhausted." You think, what to do? Buy extra usage to continue your project with real dollars, or lose half a day and wait for tomorrow, because limits will only update in a few hours, or in the worst case, even tomorrow. In reality, you might not know what 98.5% of the tokens you pay for are used for. In reality, they are not used for code. Claude simply rereads your entire correspondence and with each new message, from the very beginning, and does so again and again. And even if you have a $200 subscription, tokens can burn like in an API for $5,000. And out of them, 98.5% are only for chat history, not for your work. And this is actually not a subscription problem, but how you work with this subscription. Today I will show you 24 ways to save tokens and how to fix the situation with running out of limits. After them, the $20 Pro tariff will be enough for those who use it for a much larger number of tasks. And for those who used the $100 subscription and also didn't have enough of it, or the $200 one, they can also save a huge number of tokens. Everything here will be with real examples, with real commands, so watch on. Let's go. If you are here for the first time, then a little about myself. My name is Edward Grishin, 12 years in IT and e-commerce. I worked at Yandex Market, Cooper Technopark, now at Sunlite. I manage teams of up to 200 people in companies with a turnover of up to 200 billion rubles per year. A couple of years ago, like everyone else, I think, I actively started delving into AI, created my company Futur AI, which is engaged in business automation through voice bots, websites, and integrations. Everything I show here, I have gone through myself personally on my live projects, which I did either on order or implemented for myself. Therefore, only the truth. So, before we start, let me explain to you what a token is. A token is depicted here as coins. This seems to be the most understandable visual. It is the minimal unit. So, roughly speaking, a word equals a token, but this is very rough. And this is what many people don't explain. Every time you send a message, Claude rereads your entire conversation from scratch. The first message- response, the second- response. Everything up to your last word. And this is done every time. And it turns out that you pay 500 tokens for the first message, 5,000 for the tenth, 250,000 total tokens for the thirtieth. This is in one ordinary session. Plus, there is invisible consumption. Each message carries its Claude Markdown, connected MCP servers, system prompts, skills. You may not think about it, but it just drips and accumulates and is spent. Often this is not configurable, and these can be some architectural decisions. For example, Anthropic's initial context is always 51,000 tokens before the first message. The cache lives exactly 5 minutes. Auto-compact always triggers at 95%. And this is not a bug, this is how Anthropic's Claude system is designed. And we will learn to work with this, and so that you understand the scale. The $200 per month Max subscription actually costs Anthropic $3,000 to $5,000 in API equivalent. That's why many people on X, formerly Twitter, are whining, crying, and writing that limits are running out, and this will continue. Anthropic counts money, and it's not a profitable company, unlike OpenAI, and limits will be reduced, even on a $200 per month subscription. And the last thing that's important, the thicker your context, the worse its quality. The model remembers the beginning and the end well, but everything in the middle always gets blurred. And usually everyone complains about this and says that Claude starts to get stupid. No, in fact, this is a feature of its operation. There is even such a term, "loss in the middle," which is known in the West. Therefore, you can pay a lot but get less. And it's important to know how to work with this too. So, we've finished with the theory. Next are only hacks. Let's go. So, the first is basic hacks. Nine hacks. Basic level doesn't mean it's not significant. It just means you should know it by default. And the first three save you, believe me, more than everything that follows. The first hack is the `/clear` command. Between tasks, it's the most important on the list. `/clear` actually resets the session history. The next message is treated as the first: no accumulated load. Switch from one project to another. `/clear`. Finished a task, `/clear`. Sounds banal, but most people don't do it. They just continue the same session for hours and end up spending a huge number of tokens. Here it is shown that you could have spent 140,000 if you hadn't used this command. Another life hack. If you watched my video about plugins, I talked about the GSD Get Shit Done plugin. It's an excellent plugin for large projects that I use. And it always writes to use the `/clear` command before each major start of any part of the project. But this plugin can do it, while Claude by default cannot. So remember, the `/clear` command is mandatory. Next hack: disable unnecessary MCP servers. One connected MCP server loads the entire description of its tools with each message. One server up to 18,000 tokens, three servers up to 590,000. And this is before the first word "hello." It's important for you to open the list of your MCP servers and leave only those that you need right now. Turn off the rest. If you can, use CLA instead of MCP, because CLA uses even fewer tokens. It's a better way to connect with Claude than MCP. I also talked about this in one of my videos. How to disable unnecessary MCP servers in the terminal, you can see on your screen now, and you see that removing unnecessary servers will save you a large number of tokens. Next hack: combine prompts into one message. Three separate messages, three rounds with full history. One message with three tasks, one round. An excellent example of how many people write, for example, in Telegram: "Hello, separate message. How are you? Separate message, what are you doing, separate message." If this is still possible in correspondence, although it annoys many, then within the framework of working with Claude, it's better not to do so. Therefore, it's always better to write in one long sentence: "Analyze something, find errors there, suggest corrections." One message. And you can clearly see here that three separate messages are 3,000 extra tokens. And when everything is in one context, you can save 60-70% of these tokens. How to use `plan_mode` before a complex task. The most expensive thing in Claude is when it goes the wrong way, writes some code for you, and then you just delete it all. Therefore, always enable `plan_mode`. First, a plan, you say "ok" or refine it, and only then it starts writing code. I added to my Claude Markdown in all my projects the following phrase: "Do not make changes until there is 95% confidence in the task." Ask questions until then. This really works, especially on tasks where you yourself don't fully understand what you want. The next hack is the `/context` and `/cost` commands. `/context` shows what exactly is consuming tokens right now: chat history, MCP overhead, uploaded files. `/cost` is the actual consumption and estimate for the session. I or you will run the `/context` command in an empty session. And you won't have a single message. You will see that 51,000 tokens are already occupied by system prompts, tools, agents. This is before the first word. So, the next hack is the status line in the terminal. All you need to enable it is to use the `status_line` command, which you see on the screen now, and then a permanent line will appear at the bottom of the screen showing your model, its context window, a visual bar, a counter, and you will see how quickly it can fill up over time. So, the next hack is to keep the dashboard open if you are working on the same desktop and always check it. If you are working in Claude Code on the desktop, then by going to usage settings, you can see the remaining limit and the time until reset for each model. All this can also be automated through N8N or a simple script so that you receive notifications in Telegram when, for example, less than 20% remains. I did this myself. Why? Because I once had a situation where I ran out of limits on a project that I didn't have time to publish, and my previous commit broke the production. And it was a big mistake that I allowed such carelessness. But, honestly, I admit it. And I had to buy additional limits here in Extra Usage to use them and fix the project. And after I fixed production, everything became good, and I went to sleep peacefully at 12:00 AM. Don't make my mistakes. Always use control of your limits if you are not working in the terminal. Eighth hack: provide only the necessary context. Before uploading a file or document, think for a second, does Claude really need the whole file? Because if you have a bug in one function, then give him the text about that one function. Need a paragraph of context, give only a paragraph. Futur AI has a very large knowledge base, because it's not just a website, it also has a voice and text agent. And I, of course, never give the entire catalog, only specific departments. It turns out cheaper and much better. And you can understand this from the example that you can save up to 96% on this hack alone. Next hack. Watch how Claude works and stop it in time. Don't send it any command and leave. Watch for the first couple of minutes. Sometimes it goes completely the wrong way, gets stuck in some infinite loop, recalculates the same files. It does this again and again. If you see this, stop it and correct it. The same idea, in principle, as in `plan_mode`, but here, in real-time, where you monitor Claude's work. So, nine hacks. They will make your life noticeably better right now. Next is the second level of advanced hacks. It's about Claude Markdown and Compacting. And one of these hacks, at one time, saved me more than everything that came before, because I didn't understand, for example, how the cache works specifically in Claude, but now I know. There will be five hacks. They require a one-time setup, then they work on their own without you. Hack 10 is Claude Markdown. Use it as an index and give it instructions in English. Claude Markdown is read with every message, with every one. Even if you just wrote "hello." If you have 1,000 lines, 1,000 lines of context for each message, and this is a big mistake, there should be no more than 200 lines in Claude Markdown. Only text, code agreement, build commands, 95% rules, which I mentioned earlier. And a shift in thinking that I didn't understand for a long time. Claude Markdown is not documentation, it's an index. The architecture should be in the Architecture Markdown file. Knowledge base. It knows where to look and doesn't load extra. It is Claude Markdown. And one more thing that few people apply. Write instructions in English. And ideally, if you know English, communicate with Claude in English, because Cyrillic is tokenized worse. For the same thought, it takes one and a half to two times more tokens. Save a note in Obsidian and add tags, 15 tokens. Save note to Obsidian and add tags, 15 tokens. For 1,000 calls per month, the difference will be noticeable in 6,000 tokens. Claude can respond to users in Russian, but internally try to keep everything in instructions in English. As the eleventh hack. Precise file links. Don't write "look in the repository, find some problem," but "look at a specific function in such-and-such a file." Make direct links to files using the "@" symbol and the file name. This stops Claude from wandering around the entire project. And thus you will save a huge number of tokens, because instead of reading thirty files, Claude will only read one file and spend a maximum of 2,000 tokens. The next hack is the `/compact` command, run at 60%, not 95%. Automatic compact triggers at 95%. By this point, the context has finally degraded. The middle of the story is blurred, which I talked about at the beginning. Therefore, run the `/compact` command manually at 60% and specify what to save. Save architectural decisions, current task, file structure. Just the `/compact` command without instructions will give a blurred result. The next hack is that a five-minute break costs money. Only a few people know this, and it took me some time to notice and understand how it works. The prompt cache in Claude is exactly 5 minutes. If you return after six minutes, the next message will be recalculated from scratch at full token cost. And this is where unexplained cost spikes usually arise. If you leave for a long time, use the `/compact` or `/clear` command before you get up, or just know that the first message after a pause will cost more than usual. The next hack is that command output inflates the context. When Claude executes shell commands, the entire output goes into the context. For example, `git log` without limits, 200 commits, `npm install`, hundreds of lines of logs. All this accumulates unnoticed. Therefore, write a prohibition in Claude for commands that are not needed in this project, or add a limit to `git log` and all commands, as is written here, in principle. We have finished with the previous level of hacks, we are moving on to expert hacks that completely change the system, not individual things in your project. So, the next hack is to choose the right model. Sonnet should be used by default in 80% or more of all development tasks. Haiku is better used for sub-agents, formatting simple tasks, or research. And Opus should be used for deep architecture, complex planning. Try to keep its usage around 15-20%. More means the budget will be spent faster. This is important to remember. A separate tip: when you need to review a large codebase, connect Codex, the official plugin for Claude Code, to your project. Many of you have ChatGPT, a paid subscription, and for $20 you get an excellent code reviewer, absolutely free. And version 5.4 is perfect for this and will save you tokens where they are most expensive. So, the sixteenth hack. Sub-agents cost 7-10 times more. Agent processes consume approximately seven, or even 10 times more tokens than a single session. You ask why? Because each sub-agent wakes up with its full context. It reloads system tools, code, Markdown, and everything you have. A separate counter from scratch. Therefore, delegate one-off tasks to sub-agents using the Haiku model. Research, processing large amounts of data, summarization. If 80% of tokens are spent on Haiku instead of Opus, the difference in tokens and, naturally, in final money will be significantly more noticeable. Many agents are, of course, powerful, but very expensive and consume a huge number of tokens. I use them infrequently. And you know, when I see these videos about CLIP or about me running 10 sessions simultaneously, the question is: are you the conductor of this system? And how do you manage to maintain deep context everywhere? Our human memory cannot hold everything in memory simultaneously. Our memory doesn't work like agents' memory. Therefore, all this is hype bullshit that I see, it doesn't really affect the business. You can, at best, run two sessions simultaneously and switch between them. But if more, well, God, you're just a genius. But this whole system has one huge drawback. It's the human, the one who manages it from above. Therefore, let's use everything correctly here and still be more in context and focus. Because as long as a person manages it, the key word is "as long as," it's important to do projects qualitatively, and then not be surprised why something turns out to be unrecognizable. The next hack is understanding peak hours. The time from 3 PM to 9 PM Moscow time on weekdays is the peak load on Claude. The limit is consumed faster at this time. Large refactorings, multi-agent sessions, complex tasks. Plan better for the evening, night, or morning, or weekends. The same limit, but in principle, will last longer. So, the next hack is Claude Markdown. Like a living constitution. Claude doesn't remember the previous session. Every time it starts from scratch. Everything you explained yesterday, you'll have to explain today. And spend tokens on it again and again. Claude Markdown is automatically loaded at the beginning of each session. What does this mean? That what is written there, Claude knows for free, without your explanations. Be sure to add a section to Claude Markdown that says not to explain twice. Only rules that have already cost you an error or repeated explanation. One rule, one line, maximum 15 words. In Futur, I have a line "Knowledge" that you cannot touch without synchronizing with bot.ru. I explained it manually several times until I wrote it down. And since then, I haven't touched it again. This is not documentation. Documentation says how the project is structured. This is a constitution, the foundation, rules that cannot be broken. Claude reads them, remembers them, and doesn't break them anymore. One condition: don't let sections grow. A long list, and this is already hack 10, but in reverse. And now for bonuses. Six bonus hacks that are not in any guides, and I think they will help you save even more on tokens. Bonus one. Claude Ignore. Works like Gitignore. I list what Claude should not read when researching a project. Node modules, files with the .env format, log files, build files - all this can go into context and quietly consume your tokens. If you create one `cloud_ignore` file in the root, this will no longer happen. The next bonus is Claude Markdown hierarchy. Claude recognizes three levels: global, project, and files in subdirectories. Global is personal coding style, what is the same everywhere. Project is your project's architecture. Directory code is the rules of a specific module. It's important not to have any duplication here. Each file should be small, and everything should be read automatically. The next bonus is controlling extended thinking. By default, extended thinking allocates 31,999 tokens for thinking about each request. Unnoticeably, and this happens every time. For most tasks, 10,000 is enough - 70% of hidden thinking tokens per request. Configured in the request configuration. If you use Claude via API, this is direct savings on each call. How this is configured, you can see on your screen now. Take a screenshot. And the next bonus is a memory session. After resetting the session, Claude forgets everything you explained to him each time, who you are, how the system is structured, what you have already tried. This is thousands of tokens in each new session just for context. And the solution here is actually simple. It's a `memory.md` file in the project root with sections: architecture, system, patterns that work, patterns that don't work, links to key files. A new session starts by reading this file, not by explanations. For more complex systems, use SQL Lite for short facts, Obsidian, which I've already mentioned, or Agent Memory Markdown for long-term context. The essence is the same: knowledge is stored outside the chat, not in it. Fifth bonus is to delegate routine to an external service, in this case, N8N. Claude should not wait for you. For example, to analyze a YouTube video. What does Claude do? Downloads, transcribes, analyzes, saves. The session takes 5-10 minutes. Tokens are spent, including while it's just waiting for a response from an external API. Linear tasks are better outsourced to N8N or any other automation. Claude gives a command via webhook. The service executes, returns the result. Session closed, tokens are not dripping. I have a dialogue with Claude where it formulates what to analyze. Nos pulls the conversation, processes it, puts the result in files. Claude considers it ready. Waiting costs are absolutely zero. I found this hack on X. This is the sixth bonus hack. Claude output. Minimal output. The idea here is to turn Claude into a caveman who answers in one word. And all the hacks before this were about input tokens, about what you send to Claude, but it also responds, and these responses are also read by the next messages. By default, Claude responds very lengthily, like, "I would be happy to answer you, let me please search for you on the network, and so on." That is, it spends many tokens on this narrative, not on the result. But if you add just one line to Claude Markdown, where you write `output_style` and say: "No preamble, tool result first, no explanation of action, stop," after this, it will start speaking as concisely as possible. And in real tests, a person wrote that it saves 50-75 output tokens per use of such messages. And it's important that this only works on outgoing messages, when Claude describes what it's doing. For tasks where it writes a large piece of code or analyzes, the savings will be more modest, of course. But if you work with agents and have many outgoing calls, it will be noticeably felt. And this is probably the most unusual hack imaginable. Well, the finale. Most people actually don't need a more expensive plan. They just need to send the correspondence history 30 times where it could have been sent five times. And this is not a problem of limits, it's simply a problem of contextual hygiene and rules. If you do everything correctly, then right now, just open any active session and run the `/context` command. See what's there, and it will show where your tokens are going and what can be improved. That's all. Write in the comments which hack was most non-obvious to you, what you are already using, what is already working. Like, subscribe to the channel, and see you in the next video. Goodbye everyone.