---
title: "cache-timer"
url: "https://claudemods.dev/zh-tw/builds/cache-timer-36cdda"
source: "https://github.com/ildunari/kosta-plugins/tree/main/plugins/cache-timer"
source_type: "github"
repo: "https://github.com/ildunari/kosta-plugins/tree/main/plugins/cache-timer"
author: "ildunari"
author_handle: "ildunari"
stars: 0
category: "工作流程與 CI"
categories: ["workflow"]
tags: ["auto-compact", "claude-code", "context-management", "hooks", "plugin", "prompt-cache", "statusline"]
permission_level: 0
scan_complete: true
install: "claude plugin marketplace add ildunari/kosta-plugins\nclaude plugin install cache-timer@kosta-plugins"
added: "2026-10-05T20:13:22.766Z"
updated: "2026-10-10T04:05:50Z"
locale: "zh-tw"
content_locale: "zh-tw"
---

# cache-timer

一個 Claude Code mod（function-hook 外掛），用來追蹤主要對話的提示快取視窗。

## Description

# cache-timer

一個 Claude Code mod（function-hook 外掛），用來追蹤主要對話的提示快取視窗。

- **狀態列：**`🟢 ▰▰▰▰▰▰▰▰▱▱ 47:12`，顯示在模型名稱旁。視窗使用量超過一半時顯示 🟢，降到 15% 時變為 🟡，低於該值時變為 🔴，過期後顯示 ⚪ `cold`。視窗會從主要執行緒送出要求的時間開始重新計時，並在模型完成回應後結束（被中斷的回應也算）；子代理程式和壓縮要求使用各自的快取前綴，會被忽略。
- **警告：**剩下 12 分鐘時，提示訊息會說如果不傳送內容，2 分鐘後將進行自動壓縮。如果上下文太小而無法壓縮，或時鐘在休眠後已經跳過 10 分鐘的位置，就不會顯示警告。
- **自動壓縮，只執行一次：**剩下 10 分鐘時，只要快取仍然是暖的，就會執行與 `/compact` 相同的壓縮。每一代快取（以要求時間命名）只有一次機會：呼叫前就會消耗機會，跳過呼叫或在工作階段中途拒絕也會消耗機會；只有抵達模型的新要求，才會以新的機會啟動新一代。上下文少於 40k 權杖時會跳過；如果要求在準備期間重新預熱快取，也會關閉這次壓縮呼叫。📦 表示某一代確實執行過壓縮。

這裡假設視窗使用 1 小時 TTL（`TTL_MS`）。使用 5 分鐘 TTL 的工作階段（超額用量、某些 API key 設定）會看到錯誤的倒數。門檻是 `hooks/register.tsx` 頂端的常數。

安裝：`claude plugin install cache-timer@kosta-plugins`。檢查：`claude plugin validate plugins/cache-timer`。

## Install

```
claude plugin marketplace add ildunari/kosta-plugins
claude plugin install cache-timer@kosta-plugins
```

## Original README

# cache-timer

A Claude Code mod (function-hook plugin) that tracks the prompt-cache window of the main conversation.

- **Status line:** `🟢 ▰▰▰▰▰▰▰▰▱▱ 47:12` beside the model name. The dot goes 🟢 above half the window, 🟡 down to 15%, 🔴 below, ⚪ `cold` once it has expired. The window restarts from when a main-thread request is sent, once the model has answered it (an interrupted answer counts); subagent and compaction requests run on their own cache prefix and are ignored.
- **Warning:** at 12 minutes left, a toast says an auto-compact is coming in 2 minutes unless you send something. It's skipped when the context is too small to compact, or when the clock has already jumped past the 10-minute mark (after a sleep).
- **Auto-compact, once:** at 10 minutes left, while the cache is still warm, it runs the same compaction as `/compact`. Each cache generation (named by its request time) gets one shot: it's spent before the call, a skip or a mid-turn refusal leaves it spent, and only a new request that reaches the model starts a generation with a fresh shot. It skips contexts under 40k tokens and calls the compaction off if a request re-warmed the cache while it was getting ready. 📦 marks a generation where a compaction actually stood.

The window is assumed to be the 1-hour TTL (`TTL_MS`). Sessions on the 5-minute TTL (usage overage, some API-key setups) will see the wrong countdown. The thresholds are constants at the top of `hooks/register.tsx`.

Install: `claude plugin install cache-timer@kosta-plugins`. Check: `claude plugin validate plugins/cache-timer`.
