O jeito CERTO de gastar menos token no Claude Code — Transcript
Full transcript
- 0:00This video will show you how you can
- 0:02save and spend fewer tokens, instead of
- 0:04trying to find those wild tools all over
- 0:06the internet—the ones you see on
- 0:08Instagram where you comment just to get
- 0:10a message saying: "look, this tool will
- 0:12save you X%" to help you save and spend
- 0:14fewer tokens inside Cloud Code, Cursor,
- 0:16or any other one out there.
- 0:18So, I'm going to show you in practice
- 0:20what I'm testing, what I have tested,
- 0:22and what actually works for you. In
- 0:24other words, what is the right way for
- 0:26you to spend fewer tokens inside Cloud
- 0:28Code. Let's get to the video. Hey
- 0:29everyone, welcome to another video here
- 0:31on the channel. This video is almost
- 0:32like a vent, right? Basically, if you
- 0:34search for this today on the internet,
- 0:36on Instagram or even here, you'll start
- 0:38seeing a million tools that most people
- 0:39recommending them don't even use or
- 0:41don't actually work, right? "Install
- 0:43this skill,""install Graph File,""
- 0:45install graphs,""install this other
- 0:46thing because it saves tokens,""oh, get
- 0:48a second brain." And when you look,
- 0:50you've installed a bunch of things that
- 0:52really just bloated the context—no
- 0:54savings at all—or you don't even know
- 0:56how it works.
- 0:58I'm going to show you in practice what
- 0:59I'm applying, what actually produced
- 1:01results without having to install wild
- 1:03tools. If you want a miracle, well, this
- 1:05video is not for you. Now, if you want
- 1:07to understand behind the scenes how to
- 1:09actually save, what things you can use
- 1:10that I've tested and applied in projects
- 1:12and also with my clients, stay with me
- 1:14until the end of this video and you'll
- 1:16understand. So, leave a like and
- 1:17subscribe to the channel if you're not
- 1:19subscribed. Look, subscribe and leave
- 1:21your like down below. And also, the
- 1:23exclusive links are here for you to join
- 1:24the exclusive group, access the live
- 1:26streams, get access to the content, and
- 1:28Full Stack Pro still has lifetime access
- 1:30available for those who want to learn
- 1:32programming step-by-step. Deal? So let's
- 1:34go. The first thing, okay?
- 1:37Without further ado, how can we start
- 1:39saving tokens?
- 1:41And I'll talk specifically about Cloud
- 1:43Code here to demonstrate, but what I'm
- 1:45showing here works for the ChatGPT Codex
- 1:47, it works for Cursor, it works for—man
- 1:49, it will work for any harness or agent
- 1:51like that.
- 1:53The same thing, without having to
- 1:55install wild things inside your harness
- 1:57.
- 1:58So the first thing is managing context.
- 2:03If you don't know how to manage the
- 2:04context window, with Cloud Code, it's
- 2:06very, very easy to get penalized if you
- 2:08don't manage it correctly.
- 2:11I'm going to show you why.
- 2:13Basically, look, if you don't know how
- 2:15to manage this, you'll burn through your
- 2:17tokens very quickly.
- 2:19So, if you don't know what a context
- 2:20window is, let's understand it in
- 2:22practice here. Think of it like this,
- 2:24every model has its own context window
- 2:26of how many thousands of tokens it
- 2:28supports. It's kind of like its brain,
- 2:30so it can remember what's happening. So
- 2:32, let's assume here, let me open Cloud
- 2:34Code, look. I even opened a project here
- 2:36, and I just typed, look, a period. You
- 2:38can see that I sent it inside Cloud Code
- 2:39, I don't have any previous conversation
- 2:41, I just typed a period. I literally
- 2:43just typed a period.
- 2:46And here we can see, I have it on the
- 2:48side, look, basically this model I used
- 2:51here has a context window, meaning it
- 2:53has a 1 million token window, and my
- 2:55period consumed 77,000, that is, it used
- 2:588%, perfect, 8%of our context window,
- 3:00which is 1 million, and basically it
- 3:02consumed almost nothing.
- 3:06So, how did it consume 77,000? Because
- 3:09it loads the system prompt, it also
- 3:11loads the tools.
- 3:12If you have, for example, in this
- 3:14project I'm in, ah, if I have that agent
- 3:17MD, that cloud.md, it loads that into
- 3:19the session every time you send a prompt
- 3:21, plus some memory files you have. So,
- 3:23it's going to load all of this. So,
- 3:25that's basically why, because I only
- 3:27sent a period there. So, every time you
- 3:29keep chatting, if I send here, for
- 3:31example, I don't know, I'll send "
- 3:33everything okay" here, for example, look
- 3:35, notice I'm here, look, at my 5-hour
- 3:37window, 53%, right? I'll send "
- 3:38everything okay" here, I don't know what
- 3:40project is already open. There, "
- 3:41everything okay," you, uh, what are we
- 3:43going to do in the project I'm in? And
- 3:45it only spent 10,000 here, it was 77,
- 3:47right? If I look here at 53, it stayed
- 3:49at 53, it didn't consume anything, right
- 3:51? So, as you keep using it, it keeps
- 3:53growing this context window, you keep
- 3:55consuming it, and basically when you
- 3:57reach 1 million, right, which is a lot,
- 3:59it will reset that window, right? So,
- 4:02while it's in this 1 million window, it
- 4:04sort of remembers everything you're
- 4:05talking about.
- 4:07But every time this context window grows
- 4:09, if I send more things, keep
- 4:11implementing code, keep doing it, it
- 4:13grows, reaching 200, 300 thousand there
- 4:15, and basically every time you send a
- 4:17new prompt, it takes and injects, that
- 4:19is, all your history so it remembers, it
- 4:21injects everything you have there that
- 4:23was generated for it to remember, so it
- 4:25also has that as a base, that is, as its
- 4:28brain for it to know what to do, where
- 4:30to continue from. So, this is its memory
- 4:32, as if it were its memory, to make it
- 4:34easier to understand. So, the more, okay
- 4:37, let's suppose I have there, uh, 500
- 4:39here. Let's take another example here
- 4:41that I left here, for example, look,
- 4:42this context window here for this agent
- 4:44, look, I was already at 600 here, look
- 4:46. Pay attention here, look. I'll go down
- 4:47here, I don't even know what this was
- 4:49here. Look, I'm at 54, right? So, I'll
- 4:51send here, hi, how are you? I'll just
- 4:53send this. And pay attention, look, 600
- 4:55thousand. And look at how much it's
- 4:56going to use up of my context window
- 4:58here. Let it finish here. It went to 65
- 5:00. So, basically it consumed much more of
- 5:02the context window even though I sent
- 5:04the same thing, which was a hi, how are
- 5:06you. But how did it consume so much more
- 5:07now? Because it injected the nearly 600
- 5:10thousand it had already used.
- 5:12So, it injected all the history, all the
- 5:14codes, basically the things it already
- 5:16had there for it to have that fresh in
- 5:18its memory, to know how to continue from
- 5:20where we were.
- 5:22So, if you keep giving prompts in the
- 5:24same window, that is, in the same
- 5:26session, our dear Claude Code here, it
- 5:28keeps accumulating this and, suddenly,
- 5:30if I continue this same session here
- 5:32with 600 thousand, there are two
- 5:34problems.
- 5:36First, you saw that a hi, how are you,
- 5:38used a lot. If I had asked it to do
- 5:40something, it would have used much more
- 5:41, because it already has a lot consumed
- 5:43here. Second thing, when it reaches that
- 5:45point, I like to, you know? 400 is the
- 5:47maximum for me. Once it hits 400,000
- 5:49used, I like to either clear the context
- 5:51or start a new window. "Oh, Matheus, but
- 5:54it's a topic I want to continue here."
- 5:56Then I come here and type/compact, which
- 5:58means I condense the session so it still
- 6:00remembers the main points, but I don't
- 6:02create a new session. Or, "Oh, Matheus,
- 6:04I've reached 400, 400 and something, I
- 6:05want to do something different or
- 6:07implement something that doesn't need
- 6:09this history." Man, just come here and
- 6:11type/clear. If you type/clear here, for
- 6:13example, look, it will clear it, meaning
- 6:15it resets your session. Same thing as if
- 6:17you had come here. So it will lose all
- 6:19that history there.
- 6:20So that is one of the things we need to
- 6:22be careful to do.
- 6:24Or you can also ask Claude to configure
- 6:26auto-compact there. I don't like to keep
- 6:28it enabled, but you can say, "Hey,
- 6:30enable auto-compact there at 450,000."
- 6:32Then, when it reaches 450,000, it
- 6:34compacts it on its own. We can
- 6:36definitely do that. But if you don't pay
- 6:38attention to this, this is one of the
- 6:39biggest traps for those who are using it
- 6:41and aren't careful, as it spends a lot
- 6:42of tokens. But there's another thing,
- 6:44right?
- 6:45If you understand a bit more about the
- 6:47context window, you might say, "Well,
- 6:49Matheus, when it reaches 600,000, the
- 6:51cost is lower because it has the input
- 6:53cache inside the model."
- 6:55So it doesn't spend as much.
- 6:58In fact, when we send a prompt, there is
- 7:00a cache, but basically the resending is
- 7:02cheaper; reading the cache costs a bit
- 7:04less.
- 7:06However, depending on if you left it
- 7:08idle for too long, this cache expires.
- 7:10You will end up paying more for usage
- 7:11again. So knowing how to manage the
- 7:13context window is important.
- 7:15Once again, reached 400, 450, man,
- 7:17either you do a clear or you do a
- 7:20compact there or use the auto-compact.
- 7:23If you keep going at 500, 600, every
- 7:25little irrelevant prompt, every small
- 7:27thing you send, you'll see it will
- 7:29consume a lot.
- 7:33Another thing, when you're in a session
- 7:35of 600 or so messages, let's say, and
- 7:37you run a/compact command, it will also
- 7:39consume quite a few tokens, because your
- 7:41window is already heavily used, and it
- 7:43needs to understand—that is, read
- 7:45everything to know what to remember and
- 7:47what to condense.
- 7:49Now, if you run a/clear command, it
- 7:51wipes the history and won't consume any
- 7:53tokens, okay? So that's one of the
- 7:55things we should always keep in mind.
- 7:57So, the first thing to start saving
- 7:59tokens is knowing how to manage and
- 8:01track your context window, knowing when
- 8:03to compact, when it's important, or when
- 8:05you can just clear it. So, obviously, as
- 8:07I said, managing this will yield much
- 8:09better results than constantly
- 8:10installing new tools. The second thing
- 8:12is the Claude MD.
- 8:15There's a trend on the internet of
- 8:16downloading Claude or Agents MD files
- 8:18that are massive. So, I've left it here
- 8:20, look, the Agents MD or Claude MD,
- 8:22right? It is not a documentation file.
- 8:25Every time you enter a prompt in a
- 8:27project that has a Claude MD or Agents
- 8:29MD file, it injects that file as context
- 8:31so your agent has it in its memory—
- 8:33essentially providing some important
- 8:35instructions before it performs a task
- 8:37or starts reasoning through one.
- 8:40So, many people start putting all sorts
- 8:42of things in there, like tasks to be
- 8:44done, code examples, or design patterns
- 8:46.
- 8:47That's not the place to put code
- 8:49examples or design patterns, because
- 8:51basically—and I even left one open here
- 8:53for you—a horrible example you see a lot
- 8:55online is a bloated Claude file, right?
- 8:59A bloated Agents MD is basically where
- 9:01you describe your entire project
- 9:03documentation. Every prompt you send,
- 9:05you'll be sending all of that, and
- 9:07you'll end up handicapping the model
- 9:08because it contains certain patterns and
- 9:10things that are bad.
- 9:13So don't put that in your Claude MD; for
- 9:15example, I even left it here, don't
- 9:17include giant documentation, don't
- 9:19include the architecture, or code
- 9:21examples.
- 9:22Let me see if I put the one I created
- 9:24here, look, a code example of how you're
- 9:26going to do it. Let me see, I think I
- 9:28only left this here: how you are going
- 9:30to structure the project.
- 9:32You use skills for that, you use rules
- 9:34inside your Claude Code or your Codex,
- 9:36that's no problem.
- 9:38In here, man, 200 lines at most, at the
- 9:40absolute most, 200 lines max. This one,
- 9:43for example, has 288, which is still
- 9:45relatively low, but here's the thing:
- 9:46don't include these things like "final
- 9:48reminders." Don't be lazy, don't provide
- 9:51half-baked solutions, and don't say "
- 9:52think step by step." These are things
- 9:54that kind of degrade the result, because
- 9:57today, when you're using frontier models
- 9:59like Opus, Claude, or GPT, they already
- 10:01have that reasoning built in. So,
- 10:03telling it to "think step by step" or "
- 10:05think before you act" is redundant; it
- 10:07already has that reasoning. Doing this
- 10:09is redundant. The model's own
- 10:10documentation tells you not to do this.
- 10:13So, don't fall for the "guru" trap of
- 10:15adding this stuff or forcing it to work
- 10:17step by step; the way it ends up doing
- 10:19it will actually be worse. So, don't
- 10:21create a bloated .clinerules or
- 10:23.cursorrules file. Keep it short. And
- 10:25here is what I actually included. Things
- 10:26that I include, which are even
- 10:28recommended by Anthropic themselves.
- 10:29Include, for example, commands that are
- 10:31important for the agent to remember. So
- 10:33, if you have a test command, a build
- 10:35command, or some script to run tests,
- 10:37it's good to make sure it doesn't forget
- 10:39them. Or internal conventions for some
- 10:41script, or, for example, "I have a
- 10:42legacy project with a legacy structure"
- 10:44that it absolutely must follow,
- 10:46otherwise, it will break. So, that is
- 10:48something you can put in there, or also
- 10:49put into a skill. Patterns, as I
- 10:51mentioned, like legacy code here, right
- 10:53? And 200 lines is just...More than 200
- 10:55lines is...For instance, look here, I
- 10:57included an example of a project that is
- 10:59currently live and uses Supabase.
- 11:00Supabase is indeed live. So, I added a
- 11:03few things, like, "the app is already
- 11:04published." I put that in there, okay?
- 11:06And look at this, it's 24 lines. I also
- 11:09added some patterns here just so it
- 11:10doesn't modify certain tables.
- 11:13Obviously, there's no MCP to modify
- 11:15production, but I left this as a
- 11:16safeguard to prevent it from generating
- 11:18random things that could mess up
- 11:20production.
- 11:21And I also generated a doc that has a
- 11:23project overview. In this project
- 11:25overview, if I show it to you, it's very
- 11:27small. Where is it? Project overview. It
- 11:29has, it has here, look, 50 lines as well
- 11:31that are just about the project, just so
- 11:33it understands the overview of what the
- 11:35project is about. So, it's basically
- 11:37tiny, right? Let me grab another one
- 11:39here because I left two open. So, this
- 11:41one here too, look, some things it
- 11:42shouldn't do. I also put some tests here
- 11:44that it should run, deployment
- 11:46configurations. So, basically the
- 11:48simplest possible way to clarify some
- 11:50commands, type checks, some lints, test
- 11:53commands.
- 11:54And the third thing is basically
- 11:55switching models in the session.
- 11:57This is one of the things that makes you
- 11:59spend tokens from your context window
- 12:00that we talked about.
- 12:02In other words, if you are in here, for
- 12:04example, inside a session, I'm
- 12:06programming here inside a session, I'm
- 12:09using, look, Opus 3.5, I'm firing away
- 12:11here and it's great. After I sent two,
- 12:13three things there, it already did them
- 12:15, I come here, look, and I'll switch to
- 12:17Fable. I switched to Fable and there
- 12:20were already things it implemented, it
- 12:22will generate more tokens, you will
- 12:23spend more tokens. Why does this happen
- 12:25?
- 12:26Because from the moment we are talking
- 12:28to a model, this model already has its
- 12:30cache, it already has all of this inside
- 12:32its memory, inside its context.
- 12:35From the moment you switch models in the
- 12:37same session, this new model, when you
- 12:39give it a prompt to follow, it won't
- 12:41have the cache from the other one.
- 12:43What does it have to do? It has to read
- 12:44the history, see everything you've
- 12:46already done. So it consumes your entire
- 12:48context window instead of just
- 12:49continuing from the line where the
- 12:50previous one already had the context
- 12:52window. So it sort of has to reread
- 12:54everything, it doesn't have the cache,
- 12:55so you will spend more tokens at the
- 12:57start, so it will degrade a little at
- 12:59the beginning.
- 13:00But if for every prompt you make in the
- 13:02same session you keep switching, my
- 13:03friend, and I know there are people who
- 13:05recommend doing that, then you're going
- 13:07to waste tokens because it will clear
- 13:09your cache every time and that is
- 13:10horrible.
- 13:11So, basically, switching models will
- 13:13break the cache, okay? So each model has
- 13:16a separate cache, by running/model, that
- 13:18is, you switching, it will basically
- 13:20read the entire history, complete, it
- 13:22will keep resetting all the time. So
- 13:24don't do that. Now, if you switch the
- 13:26effort level, that's fine, no problem.
- 13:28So if I'm here in the model, see, I'm
- 13:30already using Opus on high, oh, I'm
- 13:32going to do another task that doesn't
- 13:34need high effort, you can come here and
- 13:36change it, for example, to medium effort
- 13:38, and it's fine, it won't degrade. The
- 13:40same model already has the cache, you're
- 13:42just changing its reasoning level, no
- 13:44problem.
- 13:45Another thing is switching models to
- 13:47generate a plan and to implement. That’s
- 13:49also not a problem. If I change here,
- 13:51for example, the slash planning, where
- 13:53is it, oh, planning, if I change the
- 13:55planning, execute, it will create the
- 13:57plan with one mode and then I will
- 13:59execute the plan with the automatic mode
- 14:01using another model, so that’s also fine
- 14:03, it won’t spend as much.
- 14:05So these are three little rules here
- 14:06that if you follow them you’ll already
- 14:08spend much fewer tokens.
- 14:10And the only tool I recommend that even
- 14:12had a cool impact, today I’m actually
- 14:14not using it and am doing these tests
- 14:15here to see without using and with using
- 14:17. So the Caveman here is basically
- 14:19really cool for you to install and you
- 14:21can install it, I even mentioned it,
- 14:23there's a video here on the channel, and
- 14:24you can set how you want it to respond,
- 14:26right? So it will respond directly,
- 14:28without explaining, without being like,
- 14:30so it saves some tokens because it sort
- 14:32of handles that, right? So here it shows
- 14:34, right? So look, a normal agent
- 14:36responding to you, it will explain, it
- 14:37will generate the things that were done
- 14:39. Now, depending on how you configure
- 14:41your Caveman to be direct, there's even
- 14:43the mega Cave here that responds in
- 14:45another language, I don't recommend it,
- 14:46but if you set it, right? So for example
- 14:48, it just responds directly without
- 14:50keeping on explaining. That will already
- 14:52save a lot of tokens.
- 14:55So this is one of the only tools I
- 14:57really liked using a lot, that really
- 14:58had a big, let's say, savings, but
- 15:00obviously there’s not much of a miracle
- 15:02, but knowing how to manage these three
- 15:04things here, you won’t fall into that
- 15:06trap that Harness sometimes has, right?
- 15:09So here it has a 1 million context
- 15:11window, you will always keep using up to
- 15:131 million, until it clears on its own.
- 15:16You will spend a lot of tokens, use up
- 15:17your session window here very quickly if
- 15:20you follow that path.
- 15:21So comment down below which tool you use
- 15:23, what you're working on, or if you've
- 15:25ever dealt with any of these mistakes
- 15:27regarding the three rules I mentioned.
- 15:29Post it in the comments so we can see
- 15:31and chat about it. Deal? So I'll see you
- 15:33in the next video, oh, I'll leave two
- 15:34videos playing right here over my face
- 15:36that I highly recommend you watch.
About this transcript
This page contains the full transcript of O jeito CERTO de gastar menos token no Claude Code by Sujeito programador, generated from the public captions YouTube serves with the video. The transcript has 3,245 words across 481 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.