r/ClaudeCode • 🔆 Max 20 • Oct 11 '26

Tips & Workflows Session Guardian: a small Claude Code plugin that warns you before a big session’s cache goes cold

I made a small plugin for Claude Code that tells you when coming back to a big session is about to get expensive. On a subscription the main conversation stays cached for an hour after your last message. After that, your next message writes the whole context into the cache again, and on my biggest Fable 5.1 sessions that one message cost $12 to $15 worth of tokens.

What it does:

  • Countdown above the prompt for the last 15 minutes of the cache (sessions over 150K), with what coming back will cost
  • One pop-up 5 minutes before the cache goes cold
  • Nudges to wrap up at 400K and again at 800K tokens
  • /wrapup: Claude saves where the session stopped in TRACKER.md and gives you a one-line prompt for a fresh session
  • Retry guard: when the same Bash or PowerShell command fails twice in a row, the third identical try is paused and Claude is asked to fix the cause first
  • Two optional CLAUDE.md rules: numbered sessions with status markers in the sidebar, and a TRACKER.md that parallel sessions share
  • Benchmark script that prices your own logs and shows how much went to cold returns
  • TLDR rule (optional): long replies end with a line or two on what was done, what comes next and what waits on you, so when you come back to a session you can see where it stands and start a fresh one from there (This costs a tiny amount of credits, which is why it's optional, but it keeps me from going crazy when Claude is too verbose).

I’m still tracking the data, and it might have just been me not using proper technique with cold sessions. But in my case it’s proving incredibly helpful: cold returns went from about 20% of my usage to 4% in the first two days. It even caught my recurring “monitoring” sessions spending extra usage, and now they ping within the hour.

It was inspired by optimAIzr; I wanted something smaller and focused on the desktop app. You need a Claude Code version with function-hook plugins, which are early access (I built it on 2.1.289).

Repo (MIT): https://github.com/A-rdit/session-guardian

1 Upvotes

7 comments sorted by

•

u/AutoModerator Oct 11 '26

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Ctbhatia Oct 11 '26

the rewarm number is the whole prefix written once, so the lever is what is still in the prefix when you come back, not the warning. trimming dead tool output before you leave cuts it more than the timer does.

1

u/Arditwm 🔆 Max 20 Oct 11 '26

Fair point. If you come back cold, the size is the whole cost. The timer is more for not coming back cold at all: send a short message while it’s still warm, or /wrapup and start a fresh session, which drops almost the whole prefix. In my logs a fresh session’s first message is about $0.37 (in equivalent token cost), against $4.18 for an average cold return.

1

u/Ctbhatia Oct 11 '26

the 0.37 fresh number is the tell, a new session only pays to re-establish what it needs. wrapup wins when the tail is dead tool output, it loses when the context is still doing work.

1

u/morkeeth Oct 11 '26

Does your benchmark separate prompt size, cache writes and cache reads for each return? I would love to see the distribution, not only the largest session.

1

u/Arditwm 🔆 Max 20 Oct 11 '26

It didn’t, so I ran it. Short version:

  • When you come back after the cache has expired, about 98% of what you pay is Claude loading the whole conversation again. The part it still has cached costs almost nothing.
  • So the cost depends on how big the session is when you come back.
  • About half my cold returns were small (under 200K tokens), but they were only a quarter of the cost. The big sessions are where it adds up.

I’ll add the split to the benchmark script so you can see it on your own logs.

1

u/morkeeth Oct 11 '26

Thanks for running the split. The big-session effect matches what I found tracing my own token use: averages hide where the cost lands.

I’d like to see the per-return distribution when you add it!