Don't Use /compact Until You See This $1.22 Test

DIY Smart Code
3,073 views •

Claude Code sends your entire conversation history with every request. See how this affects your token usage and session costs. The video investigates why simple interactions in Claude Code can spiral into massive token counts. Because the tool sends the full chat history with every message, a single OK command 15 minutes into a session can consume 306,000 tokens, compared to just 27,000 in a fresh session. Understanding how the context window behaves is essential for managing your AI agent costs effectively. While the price difference is not always as extreme as the token inflation might suggest, recognizing this behavior helps you decide when to restart a session to keep billing predictable. ---- Higgsfield AI — Create AI Videos & Visuals Get 10% OFF here: https://higgsfield.ai?fpr=thomas-dccf7e šŸš€ DYNAMOUS AI COMMUNITY Want to learn agentic coding with live daily events and workshops? Check out Dynamous AI: https://dynamous.ai/?code=646a60 Get 10% off here šŸ‘‰ https://shorturl.smartcode.diy/dynamous_ai_10_percent_discount ⚔ HOSTINGER — RELIABLE HOSTING FOR YOUR PROJECTS (10% OFF) Whether you're shipping a portfolio, a side project, n8n flows, or AI agents — I use Hostinger for fast, affordable VPS + web hosting. Get 10% off here šŸ‘‰ https://hostinger.com/DIYSMARTCODE n8n: https://n8n.partnerlinks.io/diysmartcode (Affiliate links — costs you nothing, supports the channel.) ---- Chapters 0:00 Claude Code Context Window: Same "ok", 11x the Tokens 1:13 What /context Shows Before You Type (MCP, CLAUDE.md, @file) 2:42 Prompt Caching: Every Message Resends the Session (967K Auto-Compact) 4:03 /compact Explained: What Survives Compaction and What Gets Lost 6:03 /clear Explained: Can You Undo It? (Rewind + Mid-Session CLAUDE.md) 7:31 Compact vs Handoff File: Same Trap, $0.49 vs $0.37 9:55 How to Save Tokens in Claude Code: Subagents, /btw, Hooks, Status Line 11:00 Context Rot Verdict: When to Compact, When to Clear What you will see in this 12-minute breakdown: → /context on a fresh session: 27.3K tokens before you type, 16.2K of them tool definitions → MCP tools at 0 tokens until Claude uses one, and why the "auto-compact at 80%" rule from a viral reel isn't in the docs → @file vs a plain path for the same question: 18.4K vs 6.5K tokens of messages → 15 minutes, 12 prompts, 42 requests: 6.9 million tokens sent, 6.6 million of them from the prompt cache → Auto-compact at about 967K on the 1M window, and what /autocompact 500k changes → /compact on a 306K session: down to 4.9K in 32 seconds, what comes back from disk, what gets summarized away → A rule from prompt one kept by the summary, plus /compact with a focus line and Compact Instructions in CLAUDE.md → /clear costs nothing, the next message carries the startup load: 27,401 tokens → The help center says /clear can't be undone; the rewind menu's "previous session" entry brought 284.5K tokens back → A CLAUDE.md edit applied mid-session on Claude Code 2.1.296 → Compact vs handoff file vs compact with focus: same trap, all three kept the rule, $0.49 vs $0.37 (Claude Code's cost estimate on a Max plan, one run) → Summarize from here, subagents, /btw, filtering hooks, the status line and Headroom → The cold-cache compact: 3.7x the price for the same command Claude Code docs, costs and managing context: https://code.claude.com/docs/en/costs Claude Code context window: https://code.claude.com/docs/en/context-window Prompt caching in Claude Code: https://code.claude.com/docs/en/prompt-caching Checkpointing and the rewind menu: https://code.claude.com/docs/en/checkpointing Status line setup: https://code.claude.com/docs/en/statusline Subagents: https://code.claude.com/docs/en/sub-agents Help center, models, usage and limits in Claude Code: https://support.claude.com/en/articles/14552983-models-usage-and-limits-in-claude-code Anthropic API pricing (cache reads): https://platform.claude.com/docs/en/about-claude/pricing Headroom on GitHub (open source): https://github.com/chopratejas/headroom Our Headroom test: https://youtu.be/7PMvZQjuuFk The 60-second version (Short): https://www.youtube.com/shorts/eIt4C-PATmE Compact or a handoff file: which one are you running tomorrow? Drop your pick below. #ClaudeCode #ContextWindow #Claude #Anthropic #ClaudeCodeTips #AICoding #AgenticCoding #PromptCaching #ContextEngineering #ContextRot #TokenOptimization #SaveTokens #ClaudeCodeCompact #ClaudeOpus #AIDeveloperTools #CodingAgent #DevTools #VSCode #LLM #AIAgents

Keyboard shortcuts

On. Switch them off if they collide with your assistive tools; ? still opens this sheet.

Go to

Press g then the letter.

  • gh Latest
  • gs Sources
  • gm Media
  • gv Videos
  • gp Podcasts
  • gc Calendar
  • gd Decoder
  • gz Dataviz
  • ga Datasets
  • gb Blog
  • gk Markets
  • gj Careers
  • gn Prompt Notebook

On this page

  • / Focus search, where there is one
  • t Back to top
  • ? This list
  • Esc Close