Install command
Not provided
A Claude Code statusline that reads prompt-cache token metrics from session JSON and renders a color-coded hit-rate bar with an estimated token-savings readout.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
6 to clear
Platforms
1 listed
Difficulty
7/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Prerequisite readiness
6 prerequisites to line up before setup. Have accounts and credentials ready first.
Safety & privacy surface
1 safety and 1 privacy notes across 1 risk area. Review closely: credentials & tokens.
#!/usr/bin/env bash
# Cache Efficiency Monitor for Claude Code
# Tracks prompt caching performance and cost savings
# Read JSON from stdin
read -r input
# Extract cache metrics (if available in JSON)
cache_read_tokens=$(echo "$input" | jq -r '.cost.cache_read_input_tokens // 0')
cache_create_tokens=$(echo "$input" | jq -r '.cost.cache_creation_input_tokens // 0')
regular_input_tokens=$(echo "$input" | jq -r '.cost.input_tokens // 0')
# Calculate total input tokens
total_input=$((cache_read_tokens + cache_create_tokens + regular_input_tokens))
# Avoid division by zero
if [ $total_input -eq 0 ]; then
total_input=1
fi
# Calculate cache hit rate (percentage of tokens read from cache)
if [ $cache_read_tokens -gt 0 ]; then
cache_hit_rate=$(( (cache_read_tokens * 100) / total_input ))
else
cache_hit_rate=0
fi
# Calculate write efficiency (cache creation vs regular input)
if [ $cache_create_tokens -gt 0 ]; then
write_percentage=$(( (cache_create_tokens * 100) / total_input ))
else
write_percentage=0
fi
# Cache efficiency scoring
if [ $cache_hit_rate -ge 50 ]; then
CACHE_COLOR="\033[38;5;46m" # Green: Excellent caching (>50% hit rate)
CACHE_ICON="✓"
CACHE_STATUS="EXCELLENT"
elif [ $cache_hit_rate -ge 25 ]; then
CACHE_COLOR="\033[38;5;226m" # Yellow: Good caching (25-50% hit rate)
CACHE_ICON="●"
CACHE_STATUS="GOOD"
elif [ $cache_hit_rate -gt 0 ]; then
CACHE_COLOR="\033[38;5;208m" # Orange: Low caching (1-25% hit rate)
CACHE_ICON="⚠"
CACHE_STATUS="LOW"
else
CACHE_COLOR="\033[38;5;250m" # Gray: No caching
CACHE_ICON="○"
CACHE_STATUS="NONE"
fi
# Estimate cost savings (cache reads cost 90% less than regular input)
if [ $cache_read_tokens -gt 0 ]; then
# Savings = cache_read_tokens * 0.9 (90% discount)
savings_tokens=$(echo "scale=0; $cache_read_tokens * 0.9 / 1" | bc)
savings_display="💰 ~${savings_tokens} tok saved"
else
savings_display=""
fi
# Build cache hit rate bar (20 characters wide)
hit_bar_filled=$(( cache_hit_rate / 5 )) # Each char = 5%
hit_bar_empty=$(( 20 - hit_bar_filled ))
if [ $hit_bar_filled -gt 0 ]; then
hit_bar=$(printf "█%.0s" $(seq 1 $hit_bar_filled))$(printf "░%.0s" $(seq 1 $hit_bar_empty))
else
hit_bar="░░░░░░░░░░░░░░░░░░░░"
fi
# Optimization recommendation
if [ $cache_hit_rate -eq 0 ] && [ $cache_create_tokens -eq 0 ]; then
RECOMMENDATION="(Enable caching?)"
elif [ $cache_hit_rate -lt 25 ] && [ $write_percentage -gt 50 ]; then
RECOMMENDATION="(More reads needed)"
else
RECOMMENDATION=""
fi
RESET="\033[0m"
# Output statusline
if [ -n "$savings_display" ]; then
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}% | ${savings_display} ${RECOMMENDATION}"
else
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}% ${RECOMMENDATION}"
fi{
"statusLine": {
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/cache-efficiency-monitor.sh",
"refreshInterval": 2000
}
}{
"statusLine": {
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/statuslines/cache-efficiency-monitor.sh",
"refreshInterval": 2000
}
}
Extended version with detailed write efficiency metrics and recommendations
#!/usr/bin/env bash
# Enhanced Cache Efficiency Monitor with Write Efficiency
input=$(cat)
cache_read_tokens=$(echo "$input" | jq -r '.cost.cache_read_input_tokens // 0')
cache_create_tokens=$(echo "$input" | jq -r '.cost.cache_creation_input_tokens // 0')
regular_input_tokens=$(echo "$input" | jq -r '.cost.input_tokens // 0')
total_input=$((cache_read_tokens + cache_create_tokens + regular_input_tokens))
if [ $total_input -eq 0 ]; then
total_input=1
fi
cache_hit_rate=$((cache_read_tokens > 0 ? (cache_read_tokens * 100) / total_input : 0))
write_percentage=$((cache_create_tokens > 0 ? (cache_create_tokens * 100) / total_input : 0))
if [ $cache_hit_rate -ge 50 ]; then
CACHE_COLOR="\033[38;5;46m"
CACHE_ICON="✓"
elif [ $cache_hit_rate -ge 25 ]; then
CACHE_COLOR="\033[38;5;226m"
CACHE_ICON="●"
elif [ $cache_hit_rate -gt 0 ]; then
CACHE_COLOR="\033[38;5;208m"
CACHE_ICON="⚠"
else
CACHE_COLOR="\033[38;5;250m"
CACHE_ICON="○"
fi
if [ $cache_read_tokens -gt 0 ]; then
savings_tokens=$(echo "scale=0; $cache_read_tokens * 0.9 / 1" | bc 2>/dev/null || echo "$((cache_read_tokens * 9 / 10))")
savings_display="💰 ~${savings_tokens} tok saved"
else
savings_display=""
fi
hit_bar_filled=$((cache_hit_rate / 5))
hit_bar_empty=$((20 - hit_bar_filled))
if [ $hit_bar_filled -gt 0 ]; then
hit_bar=$(printf "█%.0s" $(seq 1 $hit_bar_filled))$(printf "░%.0s" $(seq 1 $hit_bar_empty))
else
hit_bar="░░░░░░░░░░░░░░░░░░░░"
fi
# Enhanced recommendations
if [ $cache_hit_rate -eq 0 ] && [ $cache_create_tokens -eq 0 ]; then
RECOMMENDATION="(Enable caching?)"
elif [ $cache_hit_rate -lt 25 ] && [ $write_percentage -gt 50 ]; then
RECOMMENDATION="(More reads needed - ${write_percentage}% writes)"
elif [ $write_percentage -gt 75 ]; then
RECOMMENDATION="(Too many cache writes)"
else
RECOMMENDATION=""
fi
RESET="\033[0m"
if [ -n "$savings_display" ]; then
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}% | Write: ${write_percentage}% | ${savings_display} ${RECOMMENDATION}"
else
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}% | Write: ${write_percentage}% ${RECOMMENDATION}"
fi
Configurable efficiency thresholds for different caching strategies
#!/usr/bin/env bash
# Cache Efficiency Monitor with Custom Thresholds
EXCELLENT_THRESHOLD=${CACHE_EXCELLENT_THRESHOLD:-50}
GOOD_THRESHOLD=${CACHE_GOOD_THRESHOLD:-25}
input=$(cat)
cache_read_tokens=$(echo "$input" | jq -r '.cost.cache_read_input_tokens // 0')
cache_create_tokens=$(echo "$input" | jq -r '.cost.cache_creation_input_tokens // 0')
regular_input_tokens=$(echo "$input" | jq -r '.cost.input_tokens // 0')
total_input=$((cache_read_tokens + cache_create_tokens + regular_input_tokens))
if [ $total_input -eq 0 ]; then
total_input=1
fi
cache_hit_rate=$((cache_read_tokens > 0 ? (cache_read_tokens * 100) / total_input : 0))
write_percentage=$((cache_create_tokens > 0 ? (cache_create_tokens * 100) / total_input : 0))
# Custom thresholds
if [ $cache_hit_rate -ge $EXCELLENT_THRESHOLD ]; then
CACHE_COLOR="\033[38;5;46m"
CACHE_ICON="✓"
elif [ $cache_hit_rate -ge $GOOD_THRESHOLD ]; then
CACHE_COLOR="\033[38;5;226m"
CACHE_ICON="●"
elif [ $cache_hit_rate -gt 0 ]; then
CACHE_COLOR="\033[38;5;208m"
CACHE_ICON="⚠"
else
CACHE_COLOR="\033[38;5;250m"
CACHE_ICON="○"
fi
if [ $cache_read_tokens -gt 0 ]; then
savings_tokens=$(echo "scale=0; $cache_read_tokens * 0.9 / 1" | bc 2>/dev/null || echo "$((cache_read_tokens * 9 / 10))")
savings_display="💰 ~${savings_tokens} tok saved"
else
savings_display=""
fi
hit_bar_filled=$((cache_hit_rate / 5))
hit_bar_empty=$((20 - hit_bar_filled))
if [ $hit_bar_filled -gt 0 ]; then
hit_bar=$(printf "█%.0s" $(seq 1 $hit_bar_filled))$(printf "░%.0s" $(seq 1 $hit_bar_empty))
else
hit_bar="░░░░░░░░░░░░░░░░░░░░"
fi
RESET="\033[0m"
if [ -n "$savings_display" ]; then
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}% | ${savings_display}"
else
echo -e "${CACHE_ICON} Cache: ${CACHE_COLOR}${hit_bar}${RESET} ${cache_hit_rate}%"
fi
Complete setup script with cache field verification
#!/bin/bash
# Installation script for Cache Efficiency Monitor
mkdir -p .claude/statuslines
# Check for bc (optional, for savings calculation)
if ! command -v bc &> /dev/null; then
echo "Note: bc not found. Savings calculation will use integer math."
echo "Install bc for precise calculations: brew install bc (macOS), apt install bc (Linux)"
fi
cat > .claude/statuslines/cache-efficiency-monitor.sh << 'SCRIPT_EOF'
#!/usr/bin/env bash
# Paste the full statusline script from the primary example above before running this installer.
SCRIPT_EOF
chmod +x .claude/statuslines/cache-efficiency-monitor.sh
# Add to settings.json
if [ ! -f .claude/settings.json ]; then
echo '{"statusLine":{"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/statuslines/cache-efficiency-monitor.sh","refreshInterval":2000}}' > .claude/settings.json
else
jq '.statusLine = {"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/statuslines/cache-efficiency-monitor.sh","refreshInterval":2000}' .claude/settings.json > .claude/settings.json.tmp
mv .claude/settings.json.tmp .claude/settings.json
fi
echo "Cache Efficiency Monitor installed successfully!"
echo "Note: Requires Claude Code version with cache metrics support (cache_read_input_tokens, cache_creation_input_tokens)."
echo "Verify cache fields exist: echo '{"cost":{}}' | jq '.cost.cache_read_input_tokens'"
Verify cache fields exist in JSON: echo '$input' | jq '.cost | {cache_read: .cache_read_input_tokens, cache_create: .cache_creation_input_tokens}'. If fields missing, Claude Code version may not expose cache metrics. Check official docs for required version. Caching requires Claude 3.5 Sonnet or Opus with prompt caching feature enabled. Verify prompt caching is configured in Claude Code settings.
Script estimates savings using 90% discount formula (cache reads cost 10% of regular input). Verify cache*read_tokens value: echo '$input' | jq .cost.cache_read_input_tokens. Formula: savings = cache_read_tokens * 0.9. Adjust discount percentage in script if Claude pricing changes. Check bc calculation: echo 'scale=0; 1000 _ 0.9 / 1' | bc (should return 900).
Recommendation triggers when both cache_read_tokens and cache_create_tokens are 0. This means no cache activity detected. Verify prompt caching is configured in Claude Code settings. Check that prompts contain cacheable prefixes (system messages, long contexts). Short sessions may not benefit from caching. Verify cache fields are being read: echo '$input' | jq '.cost.cache_read_input_tokens'.
Ensure terminal supports Unicode block characters (█ and ░). Test with: echo -e '█████░░░░░'. Bar uses hit_rate / 5 for scaling (each char = 5%). If hit_rate is 0, shows full empty bar (20x ░). Verify cache_hit_rate calculation: (cache_read_tokens * 100) / total_input. Check printf command works: printf '█%.0s' $(seq 1 5) (should show 5 blocks).
Recommendation appears when hit_rate <25% AND write_percentage >50% (creating more cache entries than using them). This indicates inefficient caching pattern. Solution: Reuse prompts more, reduce unique cache writes. Check if session involves many one-off queries vs repeated patterns. Verify write_percentage calculation: (cache_create_tokens * 100) / total_input.
Check cache_hit_rate calculation: cache_hit_rate=$(( (cache_read_tokens * 100) / total_input )). Verify cache_read_tokens > 0: echo '$input' | jq .cost.cache_read_input_tokens. Ensure total_input includes all token types: total_input=$((cache_read_tokens + cache_create_tokens + regular_input_tokens)). Test threshold logic: if [ $cache_hit_rate -ge 50 ]; then echo "EXCELLENT"; fi.
Verify integer division is working correctly: echo $((100 * 50 / 100)) (should be 50). Check total_input > 0 before division. Test calculation: cache_hit_rate=$((cache_read_tokens * 100 / total_input)). Ensure values are numeric: echo "$cache_read_tokens" | grep -E '^[0-9]+$'. Check for integer overflow if values are very large. Verify total_input includes all components.
Check cacheread_tokens > 0 before calculating savings. Verify bc calculation: echo 'scale=0; 1000 * 0.9 / 1' | bc (should return 900). If bc unavailable, script uses integer math: savingstokens=$((cache_read_tokens * 9 / 10)). Test: cache_read=1000; savings=$((cache_read * 9 / 10)); echo $savings (should be 900). Verify savings_display is set: if [ -n "$savings_display" ]; then echo "Has savings"; fi.
Show that Cache Efficiency Monitor - Statuslines is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/statuslines/cache-efficiency-monitor)Cache Efficiency Monitor - Statuslines side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
1 trust signal differ across this comparison (Submitter).
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
| Field | A Claude Code statusline that reads prompt-cache token metrics from session JSON and renders a color-coded hit-rate bar with an estimated token-savings readout. Open dossier | Real-time burn rate monitor showing cost per minute, tokens per minute, and projected daily spend to prevent budget overruns during Claude Code sessions. Open dossier | Claude Code statusline that summarizes MCP server count, remote endpoint count, and credential-surface hints without printing tokens, secrets, local paths, or full endpoint URLs. Open dossier | Real-time MCP server monitoring statusline showing connected servers, active tools, and performance metrics for Claude Code MCP integration Open dossier |
|---|---|---|---|---|
| Next stepsDiffers | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| SubmitterDiffers | — | — | JSONbored | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | statuslines | statuslines | statuslines | statuslines |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-10-25 | 2025-10-25 | 2026-06-05 | 2025-10-16 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs a bash script on every status-line refresh (about every 2 seconds) that pipes session JSON through jq and bc; it is read-only and makes no network calls or file writes, but status-line commands execute with your shell's permissions, so review the script before adding it to settings.json. | ✓Runs as a Claude Code statusline command on every refresh and depends on the local shell environment; a failure only affects status rendering, not your session. | ✓This statusline is advisory and should not be used as the only MCP authorization review. It intentionally avoids printing full URLs, local paths, header names, tokens, or environment variable values. Remote endpoints and credential hints should trigger a separate review of protected resource metadata, scopes, and token handling. | ✓Runs as a Claude Code statusline command on every refresh and depends on the local shell environment; a failure only affects status rendering, not your session. |
| Privacy notes | ✓Reads Claude Code session cost and token metrics from the status-line JSON on stdin and prints them to your terminal; no data leaves the machine, but the displayed figures may be visible to anyone viewing your screen or a terminal recording. | ✓Reads the Claude Code statusline JSON from stdin (model, workspace path, token usage) and renders it in the local terminal; it does not send data off-machine. | ✓The statusline reads Claude Code session metadata from stdin and prints only counts plus a generic credential hint. Avoid modifying the script to print full server URLs, headers, tokens, local config paths, or account identifiers on shared screens. | ✓Reads the Claude Code statusline JSON from stdin (model, workspace path, token usage) and renders it in the local terminal; it does not send data off-machine. |
| Prerequisites |
|
|
|
|
| Install | — | — | | — |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.