Skip to content
prompt cachingClaude Codehow to reduce Claude Code tokewhat is prompt caching in LLMsClaude Opus 5Anthropic API

Claude Code Prompt Caching: The 20x Rule That Decides Your Bill

Claude Code prompt caching decides if your next message costs cents or dollars. Here's the 20x math, the one-hour clock, and three ways to reset clean.

The AI University1 min read
Claude Code Prompt Caching: The 20x Rule That Decides Your Bill

𝗠𝗼𝘀𝘁 𝗽𝗲𝗼𝗽𝗹𝗲 𝘂𝘀𝗶𝗻𝗴 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗱𝗲 𝗮𝗿𝗲 𝗼𝘃𝗲𝗿𝗽𝗮𝘆𝗶𝗻𝗴. 𝗛𝗲𝗿𝗲'𝘀 𝘄𝗵𝘆.

Your last Claude Code message may have cost 20x more.

Not because of what you typed, but because of what expired while you stepped away.

𝗛𝗲𝗿𝗲'𝘀 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝗯𝗿𝗲𝗮𝗸𝗱𝗼𝘄𝗻, 𝗰𝗼𝗻𝗰𝗲𝗽𝘁 𝗯𝘆 𝗰𝗼𝗻𝗰𝗲𝗽𝘁.

𝟭. 𝗧𝗢𝗞𝗘𝗡𝗦 𝗔𝗥𝗘 𝗧𝗛𝗘 𝗖𝗨𝗥𝗥𝗘𝗡𝗖𝗬

→ One word is roughly one token. Nothing you send is free.

→ Output costs 5x input. On Opus that is $5 in, $25 out per million.

𝟮. 𝗘𝗩𝗘𝗥𝗬 𝗥𝗘𝗣𝗟𝗬 𝗥𝗘𝗦𝗘𝗡𝗗𝗦 𝗧𝗛𝗘 𝗪𝗛𝗢𝗟𝗘 𝗧𝗛𝗥𝗘𝗔𝗗

→ The API is stateless. It remembers nothing between messages.

→ Your 200th message re-sends messages 1 through 199 as fresh input.

𝟯. 𝗣𝗥𝗢𝗠𝗣𝗧 𝗖𝗔𝗖𝗛𝗜𝗡𝗚 𝗜𝗦 𝗧𝗛𝗘 𝗗𝗜𝗦𝗖𝗢𝗨𝗡𝗧

→ Claude reads a held copy of your thread at one tenth the input price.

→ Writing that copy costs 1.25x, or 2x for the one-hour version.

𝟰. 𝗧𝗛𝗘 𝗖𝗔𝗖𝗛𝗘 𝗛𝗔𝗦 𝗔 𝗖𝗟𝗢𝗖𝗞

→ Claude Code holds a one-hour cache. Go quiet longer and it dies.

→ Switching your model, your tools, or your settings kills it instantly.

𝟱. 𝗪𝗛𝗬 𝗜𝗧 𝗜𝗦 𝗘𝗫𝗔𝗖𝗧𝗟𝗬 𝟮𝟬𝗫

→ Cache alive, you pay 0.1x to read it.

→ Cache dead, you pay 2x to write it again. That gap is 20x.

→ A 500K-token thread: 50 cents to read, 10 dollars to rebuild.

𝟲. 𝗧𝗛𝗥𝗘𝗘 𝗪𝗔𝗬𝗦 𝗧𝗢 𝗥𝗘𝗦𝗘𝗧 𝗖𝗟𝗘𝗔𝗡

→ /clear wipes the thread. Best when your files already hold the context.

→ /compact writes a summary and restarts you from it.

→ A handoff file parks context outside the chat, reloaded on demand.

𝟳. 𝗥𝗢𝗨𝗧𝗘 𝗧𝗛𝗘 𝗪𝗢𝗥𝗞, 𝗧𝗛𝗘𝗡 𝗠𝗔𝗜𝗡𝗧𝗔𝗜𝗡 𝗜𝗧

→ Let a cheap model execute and a smarter one advise. Each keeps its own cache.

→ Run /doctor to trim a bloated CLAUDE.md, plus stale skills and memory files.

𝗧𝗛𝗘 𝗠𝗔𝗦𝗧𝗘𝗥 𝗙𝗢𝗥𝗠𝗨𝗟𝗔

Tokens are the bill.

Every reply resends the thread.

The cache is the discount.

The clock is the only real risk.

Build it yourself

Every build on the store ships with its complete source code and the exact Claude prompts that produced it.

Browse the store

Keep reading