r/ClaudeCoding • • 18h ago

Idle Claude Code sessions silently re-pay their whole cache when you come back. A keep-warm hook cut that ~87% across my 53 sessions.

16 Upvotes

**TL;DR:** (but read if you like saving $ and maximizing your limits...) When a long Claude Code session sits idle past its cache lifetime (1 hour in my sessions) and you come back, your next message pays to rebuild the whole conversation's cache. A tiny automatic reply every ~50 minutes avoids that. Measured from my own session logs since I've been using this...I have a membership, and it still factors in for tokens not wasted, but for API-equivalent costs: across 53 sessions, 474 pings cost ~$67 vs. ~$520 of cold-cache rebuilds.

Eg. of long session alone: 35 pings, ~$3.50, avoided ~$25.
"One ping costs ~1/40th of a full cache rebuild."

**The problem many seem to miss...**

Claude Code caches your conversation so each message doesn't re-pay for everything before it. Reading that cache is cheap, but it expires. If you walk away longer than its lifetime (dinner, sleep, a long build or training run) and then reply, the entire conversation is written to the cache again at the expensive rate. On a big session that's a real hit every time you come back.

**What I set up (the gist)**

One Claude Code **Stop hook**, with no cron or external timer. Claude Code can run a Stop hook in the background and wake the session when the hook exits with code 2 (`asyncRewake`). Mine starts a small watcher at the end of every turn. It checks the session transcript once a minute, and after 50 idle minutes it exits with a short instruction: reply with exactly "warm · 9:16 AM" (the script stamps the time, since the model has no clock), no tools, no file changes. That ~15-token reply re-reads the cache, which resets its 1-hour timer, and the end of that turn starts the next watcher.

Safety rails:

- Stops after 20 consecutive pings (~17 hours) until I send a real message, so a forgotten session can't ping forever. (In practice it never triggered: I always came back or closed the session first.), just there in case you totally space out, go touch grass for a few days and forget about it...it's not pinging/costing you perpetually...

- One watcher per session, and it dies with the session, so closing a session ends the pings.

- Global and per-project off switches.

- Logs each ping's `cache_read` / `cache_creation`, which is how I know every ping was a cache hit.

**The numbers** (Based on Opus 5.5 pricing: cache read = 0.05x input, 1-hour cache write = 2x input)

- One ping costs ~1/40th of a full cache rebuild.

- One long session: 35 pings over 8 idle stretches (1 to 12 hours) = **$3.50**; rebuilds avoided = **$25.23**. Every ping was a cache hit (big read, ~335 new tokens written).

- All 53 sessions I have historically: pings **$67**, rebuilds avoided **$520**. Only ~$11 of the $67 went unused: $9 in sessions I never returned to, $2 where I came back within the hour anyway.

- Break-even is ~40 pings on Opus 5.5, so with the 20-ping cap, any return within ~17 hours is a win. On models where cache reads cost 0.1x, the cap sits right at break-even.

**When it does NOT help**

- **You leave a session open and never come back.** Those pings are wasted. Close sessions you're done with: a closed session never pings, and the cap limits any one you forget, but it's always better to start fresh in general, the problem is starting over it not always optimal for a given instance, hence this solution...

- **You come back within the hour.** The cache was still warm, so that ping wasn't needed. Unavoidable (the hook can't know when you'll return), but tiny: $2 across ALL my sessions.

- **You come back between 50 and 60 minutes.** A ping fired at the 50-minute mark, but the cache would still have been warm when you returned, so that one ping wasn't needed. Come back sooner and no ping fires at all ($0). The hook can't know when you'll return, so this can't be avoided, but it's tiny: 14 such pings, ~$2, across ALL my sessions.

- **Your session uses the 5-minute cache.** This relies on the 1-hour cache; a 50-minute ping does nothing for a 5-minute one. Check yours (below).

- **On a subscription,** the dollar figures are API-equivalent, not actual charges. The benefit there is stretching your usage limits. Anthropic doesn't publish exactly how cache reads and rebuilds count against plan limits, so read the numbers as ratios. The savings assume your plan weighs a cheap cache read far less than a full rebuild, as API pricing does, so your limits stretch further.

**The bigger lesson: session size**

My long session for eg. had grown to ~740K tokens. Every ordinary call re-reads the whole thing (on average ~386K tokens per call over 267 calls), and that re-reading cost ~$20, about as much as the keep-warm saved in that session. Keep-warm is great for an important session you can't restart yet. But when you can, start a fresh session (with good notes or a handoff summary) so each call re-reads far less.

**How to check your own sessions**

Claude Code keeps transcripts as JSONL under `~/.claude/projects/<project>/`. Each assistant entry has `message.usage`:

- `cache_read_input_tokens` / `cache_creation_input_tokens`: a healthy resume shows a big read and a tiny write. A large `cache_creation_input_tokens` on the first message after a break is the expensive rebuild this avoids.

- `cache_creation.ephemeral_1h_input_tokens` vs `ephemeral_5m_input_tokens`: tells you whether your session uses the 1-hour or the 5-minute cache.

As with most stuff, have Claude Code set this up for you and ask me anything you want. Happy Coding!


r/ClaudeCoding • • 11h ago

r/Claude [TLDR] Claude Code gave me my afternoons back. I keep thinking about the developer I might never hire. [via r/claude]

5 Upvotes

OP : u/Automatic-Duck-2827

Some afternoons my wife and I go mushroom picking while Claude does my client work. We can stay out as long as we like. I love that. I also get home sometimes, open my laptop, and realize I could’ve stayed in the woods.

I’m a freelance dev running several projects. On one of them alone, I had six Claude Code agents working on separate tickets. Claude reads the issue in Jira, writes the fix, runs the tests, opens a merge request, and puts screenshots in it. One client replies to Claude in Jira thinking they’re talking to me. If something’s off, their feedback is usually enough for Claude to fix it.

The part that scares me a little is how boringly well it works. Give it the repo and a clear description of what the client needs, and most tickets go through on the first try. I can still read the code and explain what it does. I still check changes to the data model myself, especially the Prisma schema. But on an ordinary ticket? There’s rarely much I would’ve changed.

I thought having more clients would eventually mean hiring another dev. Now I can start another Claude session and still go for that walk. I happen to be the person who has the clients, so I get a free afternoon. If I were a developer looking for work, that same afternoon might look like a job opening that never got posted.

I don’t know what we do with that. Maybe someday we’ll talk seriously about taxing the income those agents generate, or limiting how many one company can run. Even on my little setup, I wouldn’t know what to count. Is one Claude session that spins up six agents one worker or six?

I’m curious about something more immediate, though. Has anyone here reached the point where you would’ve hired someone, but opened another Claude session instead? I’d love to hear about that decision. It feels like one of those small things that could add up to a very different economy.


r/ClaudeCoding • • 18h ago

I’m building an open-source intelligent LLM router that runs inside AI coding agents

2 Upvotes

I’m developing AutoRouter, an open-source routing and optimization layer for AI coding agents.
The goal is to make coding agents more efficient by automatically selecting the appropriate model and reasoning effort for different types of work, instead of relying on one fixed model for everything.
The architecture is designed to integrate with existing agent harnesses rather than replace them.
The current native Codex integration supports Luna-first stage classification and model switching, subject to the available model catalog and host controls. The portable integrations currently provide routing recommendations and shared tools.
I’m working toward more advanced routing, including adaptive escalation, subagent delegation, performance-aware model selection and local progress estimation.
I want AutoRouter to become a configurable optimization layer for Codex, Claude Code and other coding agents.
GitHub: https://github.com/Z440-prod/autorouter
I’d especially appreciate feedback from people who understand coding-agent internals, model routing and harness architecture.
What capabilities would make something like this genuinely useful in your daily workflow?


r/ClaudeCoding • • 5h ago

r/ClaudeAI [TLDR] I vibecoded a flyable Atlantis in one 96 KB HTML file with Fable 5.2 [via r/ClaudeAI]

1 Upvotes

OP : u/Any-Reputation8118

Try it in your browser · Source on GitHub

Best experienced in Chrome. Free to try, open source under the MIT license.

Atlantis is a garden city you can fly through in the browser: rings of turquoise canals around a stepped podium, a 105 m crystal rising from a crystal lotus, spiral towers, glass domes and villas half hidden in flowering trees, with farmland and limestone mountains behind. The look is based on how people describe Atlantis under regression hypnosis. Everything is generated by code on load, so the project is one 96 KB HTML file with no images, 3D models, sound files or libraries.

I wrote the brief and Claude Code (Fable 5.2) wrote all the code. The prompt is public in the repo as prompt.txt, next to the two inputs it uses: artstyle.md, an art bible with the city plan, materials and lighting, and eight concept images I made with ChatGPT as visual reference. The prompt sets the constraints (WebGPU, no engine, everything procedural) and a frame-time target for my PC. It also tells Claude how to check its own work: a subagent that sees only the art bible, the concept art and the renders reports visual defects, while GPU timing measures a 60-second fly-through. Claude wrote the WGSL shaders (sky, crystal refraction, water reflections and caustics), the generators for every building and tree, the collision and the chiptune music in Web Audio.

An RTX 5070 Ti draws a frame in about 2.5 ms at 1440p High, and a low-end phone runs it on Low at about 28 fps.


Original link/media URL : https://v.redd.it/mvdvmg4w6z2i1


r/ClaudeCoding • • 5h ago

r/ClaudeAI [TLDR] I built a musical instrument you play in thin air (Try it yourself) [via r/ClaudeAI]

1 Upvotes

OP : u/Sourcecode12

I used Claude Fable 5.2 to build a musical instrument you play in thin air. It's called Music Maker. Open it in your browser, turn on your webcam.

How it works:

You turn on your webcam, pinch with both hands and pull them apart. A string stays in the air where you left it. Sweep a fingertip across it and it plays.

  • Strings and notes: each string gets its own instrument and its own scale (major, minor, pentatonic, blues, Dorian, Hijaz). Where you cross the string decides the note, and longer strings hold more notes. A string can also play chords instead of single notes.
  • 24 instruments: guitar, electric guitar, harp, oud, qanun, sitar, piano, electric piano, organ, marimba, kalimba, steel pan, violin, cello, strings, flute, trumpet, voices, bells, synth, bass, 808 bass, drums and hand drums. All of them are played the same way, drums included.
  • Expression: rest a finger on a string to sustain a note or roll a drum. Pinch a string and pull it sideways to bend the pitch, then let go to snap it. Pinch empty air and drag to sweep a filter and echo over the whole mix.
  • Building a track: there are six pre-made beats you switch on one part at a time (kick, snare, hats, bass, chords). A looper records what you play and keeps it going while you add the next layer. A "follow chords" mode retunes every string to the current bar, so whatever you play fits.
  • Recording: you can record video with sound or sound only, in landscape or vertical, and save MP4/WebM, MP3 or WAV. You can also export each beat part and each layer as separate stems.
  • Setups: you can save a whole stage (strings, instruments, beat, key, layers) and load it back in one click, or start from a ready-made layout.
  • Changing the loop Style: You can record your loop, export it as WAV or MP3, import it to Suno AI and turn it into any style you want.

How it was built:

  • Hand tracking: MediaPipe's hand landmarker runs in the browser and gives 21 points per hand. A pinch is measured as the gap between thumb and index fingertip relative to hand size, so it works at any distance from the camera. The camera picture never leaves your machine.
  • Gestures: this took the most iteration. A pluck is a fingertip crossing from one side of a string to the other, with a small dead zone so tracking jitter doesn't trigger notes. A finger that settles on the string is a hold. A pinch on the string is a pull.
  • Sound: every sound is synthesised live with the Web Audio API, with no samples. Plucked strings use Karplus-Strong. The rest are built from oscillators, FM and filtered noise, with a generated reverb.
  • Timing: the beats and loops run on a look-ahead scheduler tied to the audio clock, and loop layers can snap to the grid.
  • Export: video uses MediaRecorder on the canvas. MP3 is encoded in the page, and stems are rendered offline, faster than real time.
  • Packaging: the whole thing is one HTML file, with no build step, backend or account.
  • Process: I made it with Claude over one long session. I described what I wanted, tested each version, and fed back what was wrong or missing.

Why:

I wanted to experiment with AI tools and motion tracking, and see what happens when you combine them with music. The result is an instrument you play with nothing but your hands and a webcam.

Limits:

It needs Chrome or Edge on a computer, decent light, and your hands about 40 to 80 cm from the camera. The instruments are synthesised, so the violin won't fool anyone.

Try it: https://hashem-al-ghaili.github.io/music-maker/
Code: https://github.com/Hashem-Al-Ghaili/music-maker

What it cost to build:

  • Tokens: about 31 million in total across 83 requests. Roughly 30 million of those were cached re-reads of the same context, which are billed at a fraction of the normal rate. The model wrote about 286,000 tokens of output, which is the code, the tests and the replies.
  • Where it went: about 44% on writing code and running tests, about 43% on the model re-reading its standing instructions at every step, and the rest on conversation and research.
  • Money: it was built inside my Claude MAX subscription, with no API bill and no other paid services. Hosting is free on GitHub Pages.
  • Time: Around 2 hours from start to finish.

Feedback welcome. Feel free to download the code and build on it.


Original link/media URL : https://v.redd.it/ldzxawwi0z2i1


r/ClaudeCoding • • 5h ago

r/ClaudeCode [TLDR] Multiple llm providers compromised [via r/ClaudeCode]

1 Upvotes

r/ClaudeCoding • • 17h ago

r/ClaudeAI [TLDR] Half a year of AI coding got me nowhere [via r/ClaudeAI]

1 Upvotes

OP : u/strongmstone

I've started several projects with Claude, Codex and Gemini, and it all ended the same way.

Planning goes great. Architecture, reviews with multiple agents, tests, all that. I'm excited, AI is cheering me on, first build looks promising, I am pumped and going all in

Then we start fixing bugs. Fix one, find more, break something else, repeat. Both Claude and Codex weekly limits gone within a few days.

AI says everything is done. I open the app and immediately find obvious bugs in basic functionality. And yes, I have automated UI and backend tests.

A few months later it's spaghetti code, every small fix becomes another endless loop, and I give up.

I do have a software development background. So I honestly don't understand how people with no coding experience are building working apps while I'm stuck here.

Basically, lots of time and money spent, and the excitement is wearing off.

Is this common, or am I just doing it wrong?


r/ClaudeCoding • • 17h ago

r/ClaudeAI [TLDR] I wanted to see how good Claude is at sizecoding. 5 days later: a 14 KB HTTPS server OS in assembly, with a $200 bounty on its key [via r/ClaudeAI]

1 Upvotes

OP : u/JaguarMoe

The result is a static web server that is its own operating system: 14 KB of x86-64 assembly with a boot sector, network driver, TCP, TLS 1.3 and HTTP. It takes a folder of files and outputs a bootable image. On a 2-vCPU cloud server it does two to three times nginx's new TLS connections and small pages per second.

Claude Code wrote all of it, mostly with Fable 5.2. I decided what it should do and what to leave out. What kept it honest was tests: every change was booted in QEMU, and the TLS code was checked with Wycheproof's test vectors, tlsfuzzer and Valgrind.

To find out whether it is secure too, I put money on it. The server's TLS key is the same number as the private key of a Bitcoin address holding $200. Get the key out of the server and the coins are yours. It runs at https://15kb.org until 18 February 2027.

Code, proof and benchmarks: https://github.com/FileSherlock/k15

If nobody gets in, I get to keep $200 in bitcoin :)


r/ClaudeCoding • • 22h ago

Help me to find the best

1 Upvotes

Yo, so I just snagged $30 for winning a comp, and I’m at a crossroads. Do I drop it on Claude Pro ‘cause I need Claude code for hackathons( till now i haven’t purchased any paid plans ) , or do I just YOLO it and splurge on random stuff I vibe with? This cash is like my precious, and I wanna use it like a boss. What do you think? Worth the pro life or just let it ride on some fun buys?


r/ClaudeCoding • • 5h ago

r/ClaudeCode [TLDR] Thoughts? Gemini Neon vs Opus 5.5 [via r/ClaudeCode]

0 Upvotes

OP : u/actualhabibi

What do you think about Gemini Neon vs Opus 5.5?

This is for those who used both.

Benchmarks don't tell the whole story. Tell us how you felt using it, the capabilities, speed, understanding, personality, if you had to hand-hold more or less, etc.

Share anything you want to benefit others to better understand the differences.

Gemini Neon vs Opus 5.5


r/ClaudeCoding • • 17h ago

r/ClaudeAI [TLDR] How to stop Claude from self crediting itself EVERYWHERE? [via r/ClaudeAI]

0 Upvotes

OP : u/standbyandroid

Recently, like a month ago, Claude started to push hard on crediting itself:

  • Adding "Generated by Claude Code 🤖" at the end of PR descriptions
  • Setting claude as committer or co-author of commits

It's impossible to stop it from doing so. It can't help it.

I have tried adding to my global/project rules, sometimes it will rewrite a commit after it notices it violated them but I couldn't find a way to reliably have Claude to respect the commit author/pr description rules.

Most of the projects I use Claude I'm the only dev so this is not a big issue, more like an annoyance, has anyone found a way to prevent this?


r/ClaudeCoding • • 10h ago

Anyone have a spare Claude Pro pass?

0 Upvotes

Hi everyone! 👋

I'm thinking about upgrading to Claude Pro, but I'd like to try it first to see if it's worth it for me. If anyone has a spare guest pass, I'd really appreciate it if you could share one.

I plan to use it for video editing work, mainly things like writing scripts, planning edits, and generating captions and descriptions.

Thanks so much! 🙏