YouTube2Text

O jeito CERTO de gastar menos token no Claude Code — Transcript

by Sujeito programador · 3,245 words · 481 segments · language en · Watch on YouTube

Full transcript

  1. 0:00This video will show you how you can
  2. 0:02save and spend fewer tokens, instead of
  3. 0:04trying to find those wild tools all over
  4. 0:06the internet—the ones you see on
  5. 0:08Instagram where you comment just to get
  6. 0:10a message saying: "look, this tool will
  7. 0:12save you X%" to help you save and spend
  8. 0:14fewer tokens inside Cloud Code, Cursor,
  9. 0:16or any other one out there.
  10. 0:18So, I'm going to show you in practice
  11. 0:20what I'm testing, what I have tested,
  12. 0:22and what actually works for you. In
  13. 0:24other words, what is the right way for
  14. 0:26you to spend fewer tokens inside Cloud
  15. 0:28Code. Let's get to the video. Hey
  16. 0:29everyone, welcome to another video here
  17. 0:31on the channel. This video is almost
  18. 0:32like a vent, right? Basically, if you
  19. 0:34search for this today on the internet,
  20. 0:36on Instagram or even here, you'll start
  21. 0:38seeing a million tools that most people
  22. 0:39recommending them don't even use or
  23. 0:41don't actually work, right? "Install
  24. 0:43this skill,""install Graph File,""
  25. 0:45install graphs,""install this other
  26. 0:46thing because it saves tokens,""oh, get
  27. 0:48a second brain." And when you look,
  28. 0:50you've installed a bunch of things that
  29. 0:52really just bloated the context—no
  30. 0:54savings at all—or you don't even know
  31. 0:56how it works.
  32. 0:58I'm going to show you in practice what
  33. 0:59I'm applying, what actually produced
  34. 1:01results without having to install wild
  35. 1:03tools. If you want a miracle, well, this
  36. 1:05video is not for you. Now, if you want
  37. 1:07to understand behind the scenes how to
  38. 1:09actually save, what things you can use
  39. 1:10that I've tested and applied in projects
  40. 1:12and also with my clients, stay with me
  41. 1:14until the end of this video and you'll
  42. 1:16understand. So, leave a like and
  43. 1:17subscribe to the channel if you're not
  44. 1:19subscribed. Look, subscribe and leave
  45. 1:21your like down below. And also, the
  46. 1:23exclusive links are here for you to join
  47. 1:24the exclusive group, access the live
  48. 1:26streams, get access to the content, and
  49. 1:28Full Stack Pro still has lifetime access
  50. 1:30available for those who want to learn
  51. 1:32programming step-by-step. Deal? So let's
  52. 1:34go. The first thing, okay?
  53. 1:37Without further ado, how can we start
  54. 1:39saving tokens?
  55. 1:41And I'll talk specifically about Cloud
  56. 1:43Code here to demonstrate, but what I'm
  57. 1:45showing here works for the ChatGPT Codex
  58. 1:47, it works for Cursor, it works for—man
  59. 1:49, it will work for any harness or agent
  60. 1:51like that.
  61. 1:53The same thing, without having to
  62. 1:55install wild things inside your harness
  63. 1:57.
  64. 1:58So the first thing is managing context.
  65. 2:03If you don't know how to manage the
  66. 2:04context window, with Cloud Code, it's
  67. 2:06very, very easy to get penalized if you
  68. 2:08don't manage it correctly.
  69. 2:11I'm going to show you why.
  70. 2:13Basically, look, if you don't know how
  71. 2:15to manage this, you'll burn through your
  72. 2:17tokens very quickly.
  73. 2:19So, if you don't know what a context
  74. 2:20window is, let's understand it in
  75. 2:22practice here. Think of it like this,
  76. 2:24every model has its own context window
  77. 2:26of how many thousands of tokens it
  78. 2:28supports. It's kind of like its brain,
  79. 2:30so it can remember what's happening. So
  80. 2:32, let's assume here, let me open Cloud
  81. 2:34Code, look. I even opened a project here
  82. 2:36, and I just typed, look, a period. You
  83. 2:38can see that I sent it inside Cloud Code
  84. 2:39, I don't have any previous conversation
  85. 2:41, I just typed a period. I literally
  86. 2:43just typed a period.
  87. 2:46And here we can see, I have it on the
  88. 2:48side, look, basically this model I used
  89. 2:51here has a context window, meaning it
  90. 2:53has a 1 million token window, and my
  91. 2:55period consumed 77,000, that is, it used
  92. 2:588%, perfect, 8%of our context window,
  93. 3:00which is 1 million, and basically it
  94. 3:02consumed almost nothing.
  95. 3:06So, how did it consume 77,000? Because
  96. 3:09it loads the system prompt, it also
  97. 3:11loads the tools.
  98. 3:12If you have, for example, in this
  99. 3:14project I'm in, ah, if I have that agent
  100. 3:17MD, that cloud.md, it loads that into
  101. 3:19the session every time you send a prompt
  102. 3:21, plus some memory files you have. So,
  103. 3:23it's going to load all of this. So,
  104. 3:25that's basically why, because I only
  105. 3:27sent a period there. So, every time you
  106. 3:29keep chatting, if I send here, for
  107. 3:31example, I don't know, I'll send "
  108. 3:33everything okay" here, for example, look
  109. 3:35, notice I'm here, look, at my 5-hour
  110. 3:37window, 53%, right? I'll send "
  111. 3:38everything okay" here, I don't know what
  112. 3:40project is already open. There, "
  113. 3:41everything okay," you, uh, what are we
  114. 3:43going to do in the project I'm in? And
  115. 3:45it only spent 10,000 here, it was 77,
  116. 3:47right? If I look here at 53, it stayed
  117. 3:49at 53, it didn't consume anything, right
  118. 3:51? So, as you keep using it, it keeps
  119. 3:53growing this context window, you keep
  120. 3:55consuming it, and basically when you
  121. 3:57reach 1 million, right, which is a lot,
  122. 3:59it will reset that window, right? So,
  123. 4:02while it's in this 1 million window, it
  124. 4:04sort of remembers everything you're
  125. 4:05talking about.
  126. 4:07But every time this context window grows
  127. 4:09, if I send more things, keep
  128. 4:11implementing code, keep doing it, it
  129. 4:13grows, reaching 200, 300 thousand there
  130. 4:15, and basically every time you send a
  131. 4:17new prompt, it takes and injects, that
  132. 4:19is, all your history so it remembers, it
  133. 4:21injects everything you have there that
  134. 4:23was generated for it to remember, so it
  135. 4:25also has that as a base, that is, as its
  136. 4:28brain for it to know what to do, where
  137. 4:30to continue from. So, this is its memory
  138. 4:32, as if it were its memory, to make it
  139. 4:34easier to understand. So, the more, okay
  140. 4:37, let's suppose I have there, uh, 500
  141. 4:39here. Let's take another example here
  142. 4:41that I left here, for example, look,
  143. 4:42this context window here for this agent
  144. 4:44, look, I was already at 600 here, look
  145. 4:46. Pay attention here, look. I'll go down
  146. 4:47here, I don't even know what this was
  147. 4:49here. Look, I'm at 54, right? So, I'll
  148. 4:51send here, hi, how are you? I'll just
  149. 4:53send this. And pay attention, look, 600
  150. 4:55thousand. And look at how much it's
  151. 4:56going to use up of my context window
  152. 4:58here. Let it finish here. It went to 65
  153. 5:00. So, basically it consumed much more of
  154. 5:02the context window even though I sent
  155. 5:04the same thing, which was a hi, how are
  156. 5:06you. But how did it consume so much more
  157. 5:07now? Because it injected the nearly 600
  158. 5:10thousand it had already used.
  159. 5:12So, it injected all the history, all the
  160. 5:14codes, basically the things it already
  161. 5:16had there for it to have that fresh in
  162. 5:18its memory, to know how to continue from
  163. 5:20where we were.
  164. 5:22So, if you keep giving prompts in the
  165. 5:24same window, that is, in the same
  166. 5:26session, our dear Claude Code here, it
  167. 5:28keeps accumulating this and, suddenly,
  168. 5:30if I continue this same session here
  169. 5:32with 600 thousand, there are two
  170. 5:34problems.
  171. 5:36First, you saw that a hi, how are you,
  172. 5:38used a lot. If I had asked it to do
  173. 5:40something, it would have used much more
  174. 5:41, because it already has a lot consumed
  175. 5:43here. Second thing, when it reaches that
  176. 5:45point, I like to, you know? 400 is the
  177. 5:47maximum for me. Once it hits 400,000
  178. 5:49used, I like to either clear the context
  179. 5:51or start a new window. "Oh, Matheus, but
  180. 5:54it's a topic I want to continue here."
  181. 5:56Then I come here and type/compact, which
  182. 5:58means I condense the session so it still
  183. 6:00remembers the main points, but I don't
  184. 6:02create a new session. Or, "Oh, Matheus,
  185. 6:04I've reached 400, 400 and something, I
  186. 6:05want to do something different or
  187. 6:07implement something that doesn't need
  188. 6:09this history." Man, just come here and
  189. 6:11type/clear. If you type/clear here, for
  190. 6:13example, look, it will clear it, meaning
  191. 6:15it resets your session. Same thing as if
  192. 6:17you had come here. So it will lose all
  193. 6:19that history there.
  194. 6:20So that is one of the things we need to
  195. 6:22be careful to do.
  196. 6:24Or you can also ask Claude to configure
  197. 6:26auto-compact there. I don't like to keep
  198. 6:28it enabled, but you can say, "Hey,
  199. 6:30enable auto-compact there at 450,000."
  200. 6:32Then, when it reaches 450,000, it
  201. 6:34compacts it on its own. We can
  202. 6:36definitely do that. But if you don't pay
  203. 6:38attention to this, this is one of the
  204. 6:39biggest traps for those who are using it
  205. 6:41and aren't careful, as it spends a lot
  206. 6:42of tokens. But there's another thing,
  207. 6:44right?
  208. 6:45If you understand a bit more about the
  209. 6:47context window, you might say, "Well,
  210. 6:49Matheus, when it reaches 600,000, the
  211. 6:51cost is lower because it has the input
  212. 6:53cache inside the model."
  213. 6:55So it doesn't spend as much.
  214. 6:58In fact, when we send a prompt, there is
  215. 7:00a cache, but basically the resending is
  216. 7:02cheaper; reading the cache costs a bit
  217. 7:04less.
  218. 7:06However, depending on if you left it
  219. 7:08idle for too long, this cache expires.
  220. 7:10You will end up paying more for usage
  221. 7:11again. So knowing how to manage the
  222. 7:13context window is important.
  223. 7:15Once again, reached 400, 450, man,
  224. 7:17either you do a clear or you do a
  225. 7:20compact there or use the auto-compact.
  226. 7:23If you keep going at 500, 600, every
  227. 7:25little irrelevant prompt, every small
  228. 7:27thing you send, you'll see it will
  229. 7:29consume a lot.
  230. 7:33Another thing, when you're in a session
  231. 7:35of 600 or so messages, let's say, and
  232. 7:37you run a/compact command, it will also
  233. 7:39consume quite a few tokens, because your
  234. 7:41window is already heavily used, and it
  235. 7:43needs to understand—that is, read
  236. 7:45everything to know what to remember and
  237. 7:47what to condense.
  238. 7:49Now, if you run a/clear command, it
  239. 7:51wipes the history and won't consume any
  240. 7:53tokens, okay? So that's one of the
  241. 7:55things we should always keep in mind.
  242. 7:57So, the first thing to start saving
  243. 7:59tokens is knowing how to manage and
  244. 8:01track your context window, knowing when
  245. 8:03to compact, when it's important, or when
  246. 8:05you can just clear it. So, obviously, as
  247. 8:07I said, managing this will yield much
  248. 8:09better results than constantly
  249. 8:10installing new tools. The second thing
  250. 8:12is the Claude MD.
  251. 8:15There's a trend on the internet of
  252. 8:16downloading Claude or Agents MD files
  253. 8:18that are massive. So, I've left it here
  254. 8:20, look, the Agents MD or Claude MD,
  255. 8:22right? It is not a documentation file.
  256. 8:25Every time you enter a prompt in a
  257. 8:27project that has a Claude MD or Agents
  258. 8:29MD file, it injects that file as context
  259. 8:31so your agent has it in its memory—
  260. 8:33essentially providing some important
  261. 8:35instructions before it performs a task
  262. 8:37or starts reasoning through one.
  263. 8:40So, many people start putting all sorts
  264. 8:42of things in there, like tasks to be
  265. 8:44done, code examples, or design patterns
  266. 8:46.
  267. 8:47That's not the place to put code
  268. 8:49examples or design patterns, because
  269. 8:51basically—and I even left one open here
  270. 8:53for you—a horrible example you see a lot
  271. 8:55online is a bloated Claude file, right?
  272. 8:59A bloated Agents MD is basically where
  273. 9:01you describe your entire project
  274. 9:03documentation. Every prompt you send,
  275. 9:05you'll be sending all of that, and
  276. 9:07you'll end up handicapping the model
  277. 9:08because it contains certain patterns and
  278. 9:10things that are bad.
  279. 9:13So don't put that in your Claude MD; for
  280. 9:15example, I even left it here, don't
  281. 9:17include giant documentation, don't
  282. 9:19include the architecture, or code
  283. 9:21examples.
  284. 9:22Let me see if I put the one I created
  285. 9:24here, look, a code example of how you're
  286. 9:26going to do it. Let me see, I think I
  287. 9:28only left this here: how you are going
  288. 9:30to structure the project.
  289. 9:32You use skills for that, you use rules
  290. 9:34inside your Claude Code or your Codex,
  291. 9:36that's no problem.
  292. 9:38In here, man, 200 lines at most, at the
  293. 9:40absolute most, 200 lines max. This one,
  294. 9:43for example, has 288, which is still
  295. 9:45relatively low, but here's the thing:
  296. 9:46don't include these things like "final
  297. 9:48reminders." Don't be lazy, don't provide
  298. 9:51half-baked solutions, and don't say "
  299. 9:52think step by step." These are things
  300. 9:54that kind of degrade the result, because
  301. 9:57today, when you're using frontier models
  302. 9:59like Opus, Claude, or GPT, they already
  303. 10:01have that reasoning built in. So,
  304. 10:03telling it to "think step by step" or "
  305. 10:05think before you act" is redundant; it
  306. 10:07already has that reasoning. Doing this
  307. 10:09is redundant. The model's own
  308. 10:10documentation tells you not to do this.
  309. 10:13So, don't fall for the "guru" trap of
  310. 10:15adding this stuff or forcing it to work
  311. 10:17step by step; the way it ends up doing
  312. 10:19it will actually be worse. So, don't
  313. 10:21create a bloated .clinerules or
  314. 10:23.cursorrules file. Keep it short. And
  315. 10:25here is what I actually included. Things
  316. 10:26that I include, which are even
  317. 10:28recommended by Anthropic themselves.
  318. 10:29Include, for example, commands that are
  319. 10:31important for the agent to remember. So
  320. 10:33, if you have a test command, a build
  321. 10:35command, or some script to run tests,
  322. 10:37it's good to make sure it doesn't forget
  323. 10:39them. Or internal conventions for some
  324. 10:41script, or, for example, "I have a
  325. 10:42legacy project with a legacy structure"
  326. 10:44that it absolutely must follow,
  327. 10:46otherwise, it will break. So, that is
  328. 10:48something you can put in there, or also
  329. 10:49put into a skill. Patterns, as I
  330. 10:51mentioned, like legacy code here, right
  331. 10:53? And 200 lines is just...More than 200
  332. 10:55lines is...For instance, look here, I
  333. 10:57included an example of a project that is
  334. 10:59currently live and uses Supabase.
  335. 11:00Supabase is indeed live. So, I added a
  336. 11:03few things, like, "the app is already
  337. 11:04published." I put that in there, okay?
  338. 11:06And look at this, it's 24 lines. I also
  339. 11:09added some patterns here just so it
  340. 11:10doesn't modify certain tables.
  341. 11:13Obviously, there's no MCP to modify
  342. 11:15production, but I left this as a
  343. 11:16safeguard to prevent it from generating
  344. 11:18random things that could mess up
  345. 11:20production.
  346. 11:21And I also generated a doc that has a
  347. 11:23project overview. In this project
  348. 11:25overview, if I show it to you, it's very
  349. 11:27small. Where is it? Project overview. It
  350. 11:29has, it has here, look, 50 lines as well
  351. 11:31that are just about the project, just so
  352. 11:33it understands the overview of what the
  353. 11:35project is about. So, it's basically
  354. 11:37tiny, right? Let me grab another one
  355. 11:39here because I left two open. So, this
  356. 11:41one here too, look, some things it
  357. 11:42shouldn't do. I also put some tests here
  358. 11:44that it should run, deployment
  359. 11:46configurations. So, basically the
  360. 11:48simplest possible way to clarify some
  361. 11:50commands, type checks, some lints, test
  362. 11:53commands.
  363. 11:54And the third thing is basically
  364. 11:55switching models in the session.
  365. 11:57This is one of the things that makes you
  366. 11:59spend tokens from your context window
  367. 12:00that we talked about.
  368. 12:02In other words, if you are in here, for
  369. 12:04example, inside a session, I'm
  370. 12:06programming here inside a session, I'm
  371. 12:09using, look, Opus 3.5, I'm firing away
  372. 12:11here and it's great. After I sent two,
  373. 12:13three things there, it already did them
  374. 12:15, I come here, look, and I'll switch to
  375. 12:17Fable. I switched to Fable and there
  376. 12:20were already things it implemented, it
  377. 12:22will generate more tokens, you will
  378. 12:23spend more tokens. Why does this happen
  379. 12:25?
  380. 12:26Because from the moment we are talking
  381. 12:28to a model, this model already has its
  382. 12:30cache, it already has all of this inside
  383. 12:32its memory, inside its context.
  384. 12:35From the moment you switch models in the
  385. 12:37same session, this new model, when you
  386. 12:39give it a prompt to follow, it won't
  387. 12:41have the cache from the other one.
  388. 12:43What does it have to do? It has to read
  389. 12:44the history, see everything you've
  390. 12:46already done. So it consumes your entire
  391. 12:48context window instead of just
  392. 12:49continuing from the line where the
  393. 12:50previous one already had the context
  394. 12:52window. So it sort of has to reread
  395. 12:54everything, it doesn't have the cache,
  396. 12:55so you will spend more tokens at the
  397. 12:57start, so it will degrade a little at
  398. 12:59the beginning.
  399. 13:00But if for every prompt you make in the
  400. 13:02same session you keep switching, my
  401. 13:03friend, and I know there are people who
  402. 13:05recommend doing that, then you're going
  403. 13:07to waste tokens because it will clear
  404. 13:09your cache every time and that is
  405. 13:10horrible.
  406. 13:11So, basically, switching models will
  407. 13:13break the cache, okay? So each model has
  408. 13:16a separate cache, by running/model, that
  409. 13:18is, you switching, it will basically
  410. 13:20read the entire history, complete, it
  411. 13:22will keep resetting all the time. So
  412. 13:24don't do that. Now, if you switch the
  413. 13:26effort level, that's fine, no problem.
  414. 13:28So if I'm here in the model, see, I'm
  415. 13:30already using Opus on high, oh, I'm
  416. 13:32going to do another task that doesn't
  417. 13:34need high effort, you can come here and
  418. 13:36change it, for example, to medium effort
  419. 13:38, and it's fine, it won't degrade. The
  420. 13:40same model already has the cache, you're
  421. 13:42just changing its reasoning level, no
  422. 13:44problem.
  423. 13:45Another thing is switching models to
  424. 13:47generate a plan and to implement. That’s
  425. 13:49also not a problem. If I change here,
  426. 13:51for example, the slash planning, where
  427. 13:53is it, oh, planning, if I change the
  428. 13:55planning, execute, it will create the
  429. 13:57plan with one mode and then I will
  430. 13:59execute the plan with the automatic mode
  431. 14:01using another model, so that’s also fine
  432. 14:03, it won’t spend as much.
  433. 14:05So these are three little rules here
  434. 14:06that if you follow them you’ll already
  435. 14:08spend much fewer tokens.
  436. 14:10And the only tool I recommend that even
  437. 14:12had a cool impact, today I’m actually
  438. 14:14not using it and am doing these tests
  439. 14:15here to see without using and with using
  440. 14:17. So the Caveman here is basically
  441. 14:19really cool for you to install and you
  442. 14:21can install it, I even mentioned it,
  443. 14:23there's a video here on the channel, and
  444. 14:24you can set how you want it to respond,
  445. 14:26right? So it will respond directly,
  446. 14:28without explaining, without being like,
  447. 14:30so it saves some tokens because it sort
  448. 14:32of handles that, right? So here it shows
  449. 14:34, right? So look, a normal agent
  450. 14:36responding to you, it will explain, it
  451. 14:37will generate the things that were done
  452. 14:39. Now, depending on how you configure
  453. 14:41your Caveman to be direct, there's even
  454. 14:43the mega Cave here that responds in
  455. 14:45another language, I don't recommend it,
  456. 14:46but if you set it, right? So for example
  457. 14:48, it just responds directly without
  458. 14:50keeping on explaining. That will already
  459. 14:52save a lot of tokens.
  460. 14:55So this is one of the only tools I
  461. 14:57really liked using a lot, that really
  462. 14:58had a big, let's say, savings, but
  463. 15:00obviously there’s not much of a miracle
  464. 15:02, but knowing how to manage these three
  465. 15:04things here, you won’t fall into that
  466. 15:06trap that Harness sometimes has, right?
  467. 15:09So here it has a 1 million context
  468. 15:11window, you will always keep using up to
  469. 15:131 million, until it clears on its own.
  470. 15:16You will spend a lot of tokens, use up
  471. 15:17your session window here very quickly if
  472. 15:20you follow that path.
  473. 15:21So comment down below which tool you use
  474. 15:23, what you're working on, or if you've
  475. 15:25ever dealt with any of these mistakes
  476. 15:27regarding the three rules I mentioned.
  477. 15:29Post it in the comments so we can see
  478. 15:31and chat about it. Deal? So I'll see you
  479. 15:33in the next video, oh, I'll leave two
  480. 15:34videos playing right here over my face
  481. 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.