cache-keepalive

A Claude Code plugin that sends inexpensive keepalive turns during idle pauses to keep the five-minute prompt cache available.

In plain words
What is it for?
Keeping Claude Code's prompt cache warm through a Stop hook, with settings for the wait interval and the keepalive message.
Why use it?
It helps avoid losing cached prompt data during normal thinking gaps, which can reduce costs in API-billed sessions.

Plugin for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Claude Code
/plugin marketplace add yujiachen-y/claude-code-cache-keepalive
agentmods
npx agentmods add plugins/yujiachen-y/claude-code-cache-keepalive/cache-keepalive
Clone the repo
git clone --depth 1 https://github.com/yujiachen-y/claude-code-cache-keepalive

Made for: Claude Code.

Per session not measured What this adds to a session before it is invoked.
When invoked not measured Not applicable: nothing here is loaded into a session.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Security

Grade A, and why

cache-keepalive scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cache-keepalive/.claude-plugin/plugin.json · 50 lines

What it actually says

{
  "name": "cache-keepalive",
  "version": "0.1.1",
  "description": "Keep Claude Code's 5-minute prompt cache warm across idle pauses by injecting cheap keepalive turns from a Stop hook. Saves real money on API-billed sessions with normal thinking gaps.",
  "author": {
    "name": "yujiachen-y"
  },
  "homepage": "https://github.com/yujiachen-y/claude-code-cache-keepalive",
  "repository": "https://github.com/yujiachen-y/claude-code-cache-keepalive",
  "license": "MIT",
  "keywords": [
    "cache",
    "prompt-cache",
    "keepalive",
    "ttl",
    "cost-optimization",
    "hooks"
  ],
  "userConfig": {
    "interval_seconds": {
      "type": "number",
      "title": "Keepalive interval (seconds)",
      "description": "Seconds the Stop hook sleeps before injecting a keepalive ping. Claude Code's prompt cache TTL is 300s (5 min); 240 leaves a 60s safety margin.",
      "default": 240,
      "min": 30,
      "max": 290,
      "required": false,
      "sensitive": false
    },
    "keepalive_message": {
      "type": "string",
      "title": "Keepalive message",
      "description": "Text injected as a user-side keepalive turn. Keep it bland so Claude replies cheaply without starting tools or generating long output.",
      "default": "got it, i need some time to think about the next move",
      "required": false,
      "sensitive": false
    },
    "max_loops_per_turn": {
      "type": "number",
      "title": "Max keepalive loops per turn",
      "description": "Max consecutive keepalive cycles per idle turn before giving up. At interval=240 and max=7, one idle turn keeps the cache warm for ~28 minutes.",
      "default": 7,
      "min": 1,
      "max": 60,
      "required": false,
      "sensitive": false
    }
  }
}
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 50 lines scan A e566fbb211f6

Subscribe to this mod's changes

cache-keepalive is a plugin published in the GitHub repository yujiachen-y/claude-code-cache-keepalive (16 stars, last pushed 4mo ago), licensed MIT. Its token cost is not measured: this kind of file is read by the harness, not the model. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.