Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions docs/samples/claude-code/runcat-statusline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"title": "Claude Code",
"symbol": "staroflife",
"symbol": "circle.lefthalf.filled",
"metricsBarValue": "67%",
"metrics": [
{"title": "Model", "formattedValue": "Opus 4.7"},
Expand All @@ -16,6 +16,13 @@
],
"lastUpdatedDate": "2026-06-07T05:55:36Z"
}

This sample is limit-aware: the menu-bar value shows the 5h session limit %
(the number that tells you how close you are to being rate-limited), and the
card icon fills up as the 5h / 7d usage rises, turning into a warning triangle
near the cap. RunCat renders the menu-bar icon monochrome, so the level is
conveyed by SHAPE rather than colour. Both fall back gracefully (context % on
the bar, staroflife icon) when no rate-limit data is present.
"""

import json
Expand All @@ -34,6 +41,19 @@ def pct(title, value):
return {"title": title, "formattedValue": f"{value:g}%", "normalizedValue": round(value / 100, 4)}


def limit_symbol(value):
"""SF Symbol whose shape reflects how full the plan limit is."""
if value is None:
return "staroflife"
if value >= 85:
return "exclamationmark.triangle.fill"
if value >= 66:
return "circle.fill"
if value >= 33:
return "circle.lefthalf.filled"
return "circle"


try:
payload = json.load(sys.stdin)
if not isinstance(payload, dict):
Expand All @@ -47,9 +67,12 @@ def pct(title, value):
five = (rate_limits.get("five_hour") or {}).get("used_percentage")
seven = (rate_limits.get("seven_day") or {}).get("used_percentage")

# icon warns as you approach whichever plan limit is closest to its cap
limit_level = max([v for v in (five, seven) if v is not None], default=None)

snapshot = {
"title": "Claude Code",
"symbol": "staroflife",
"symbol": limit_symbol(limit_level),
"metrics": [m for m in [
{"title": "Model", "formattedValue": model},
pct("Context", ctx),
Expand All @@ -58,8 +81,10 @@ def pct(title, value):
] if m is not None],
"lastUpdatedDate": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
}
if ctx is not None:
snapshot["metricsBarValue"] = f"{ctx:g}%"
# menu-bar value: prefer the 5h session limit; fall back to context %
bar_value = five if five is not None else ctx
if bar_value is not None:
snapshot["metricsBarValue"] = f"{bar_value:g}%"

OUT.parent.mkdir(parents=True, exist_ok=True)
fd, tmp = tempfile.mkstemp(prefix=".runcat-", dir=str(OUT.parent))
Expand Down