explaingit

51enuxu/cc-cache-playbook

Analysis updated 2026-05-18

25Audience · developerComplexity · 3/5Setup · hard

TLDR

A practical writeup on cutting repeated context and raising cache hit rates for a chat gateway running on top of a subscription based Claude Code upstream.

Mindmap

mindmap
  root((CC Cache Playbook))
    What it does
      Cuts repeated context
      Raises cache hit rate
      Session continuity via hashing
    Techniques
      Content hash anchors
      Segment level diffs
      Static system prompt
    Use cases
      Chat gateways
      Long running personas
      Subscription billed upstreams
    Audience
      Developers
      Gateway builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Reduce repeated context sent on every turn in a long running chat gateway

USE CASE 2

Raise prompt cache hit rates for a subscription billed LLM upstream

USE CASE 3

Detect and log when a conversation's context has quietly broken down

What is it built with?

Claude Code

How does it compare?

51enuxu/cc-cache-playbook0xpira/sskills8thpark/geode
Stars252525
LanguageJavaScriptTypeScript
Setup difficultyhardeasymoderate
Complexity3/52/52/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1day+

This is a technique writeup to apply to your own gateway code, not a ready to run project.

The explanation does not state a license for this content.

In plain English

This repository is a written playbook, not a piece of software you install. It documents lessons learned from running a self built chat gateway (for example a Telegram bot or web chat) that sits in front of Claude Code as a subscription based upstream, where usage is billed by request count rather than by the amount of text sent. The author explains how they cut the extra context sent on every turn from twenty to thirty thousand characters down to about two thousand, while raising their cache hit rate to ninety six percent. The core idea is that with a subscription plan, a long running conversation costs nothing extra to keep alive, but recalculating a conversation from scratch after a cache miss is expensive in wasted requests. So the advice is to keep sessions continuous whenever possible, and only start a fresh one when the conversation has genuinely broken off, saving heavy summarization for when a hard context limit is close. To decide whether a new message continues an old session, the playbook recommends hashing the content of the last user message as an anchor, rather than counting messages, since message counts can shift for unrelated reasons. For information that changes each turn, such as memory notes or status updates, it suggests sending only the parts that changed, marking removed sections clearly, and occasionally resending everything in full as a safety check. Content that never changes, like a persona's core instructions, is placed in a cached system prompt section instead of being repeated. The author also stresses logging context size, cache hit rate, and how many segments changed on every turn, since without this visibility a system can quietly get worse until it is obviously broken. A closing section on fallback summarization covers batch limits, backup upstream providers, and a check for a broken provider that returns an identical response no matter what is sent in.

Copy-paste prompts

Prompt 1
Help me implement content hash anchoring to detect if a new message continues my last chat session
Prompt 2
Show me how to send only changed context segments to my LLM gateway instead of the full context every turn
Prompt 3
Design a logging line for my chat gateway that tracks context size, cache hit rate, and changed segments per turn
Prompt 4
Write a fallback check that detects when a summarization upstream returns an identical response regardless of input

Frequently asked questions

What is cc-cache-playbook?

A practical writeup on cutting repeated context and raising cache hit rates for a chat gateway running on top of a subscription based Claude Code upstream.

What license does cc-cache-playbook use?

The explanation does not state a license for this content.

How hard is cc-cache-playbook to set up?

Setup difficulty is rated hard, with roughly 1day+ to a first successful run.

Who is cc-cache-playbook for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.