Skip to content

Claude usage

Your Claude plan's 5-hour and weekly limits, plus tokens and an estimated API cost by day, project and model, from Claude Code on your Mac. Syncs only these numbers to your iPhone.

by MArk · Version 1 · Updated 14 hours ago

Price
Free
Works on
Mac · iPhone (as a card)
Permissions
2

What it does

  • Lives where you glance

    Menu bar, TailApps Dock, Dashboard, a floating window, and a card on your iPhone.

  • Stays up to date

    Runs its script usage.sh on your Mac every 5 minutes

  • Stays up to date

    Updates when something is sent to its inbox limits

What it may do

TailApps shows this list before installing and asks you once. The card can do nothing else.

  • Run its script usage.sh

    script:usage.sh

  • Receive events sent to its inbox limits (from your hooks, webhooks or other devices)

    inbox:limits

Scripts

Everything it runs is here to read before you install.

usage.sh
#!/bin/sh
# Claude Code's token use for the last 7 days, read from its own logs (~/.claude/projects/**/*.jsonl).
# Reads only, sends nothing. Prints one JSON object: today, week, days (for a chart), top projects and models.
# Cost is an estimate at Anthropic API list prices (input, output, cache write = 1.25 x input, cache read);
# on a Pro or Max plan nobody pays it, but it shows how much work the sessions did.
dir="$HOME/.claude/projects"
if [ ! -d "$dir" ]; then
  echo "{\"found\":false,\"day\":\"$(date +%Y-%m-%d)\",\"today\":{\"tokens\":0,\"cost\":0},\"week\":{\"tokens\":0,\"cost\":0},\"days\":[],\"projects\":[],\"models\":[]}"
  exit 0
fi
# Files touched in the last 8 days; only lines that carry token counts go on to jq.
find "$dir" -type f -name '*.jsonl' -mtime -8 2>/dev/null | while IFS= read -r file; do
  grep -F -h '"output_tokens"' "$file" 2>/dev/null
done | jq -R -c '
  fromjson? | select(type == "object" and .type == "assistant" and (.message.usage | type) == "object")
  | select((.message.model // "") != "<synthetic>")
  | .message.usage as $u
  | {
      k: (if .message.id and .requestId then .message.id + ":" + .requestId else "line" + (input_line_number | tostring) end),
      t: ((.timestamp // "") | sub("\\.[0-9]+"; "") | try fromdateiso8601 catch 0),
      m: ((.message.model // "unknown") | sub("^claude-"; "")),
      p: ((.cwd // "") | split("/") | map(select(. != "")) | last // "unknown"),
      i: ($u.input_tokens // 0), o: ($u.output_tokens // 0),
      w: ($u.cache_creation_input_tokens // 0), r: ($u.cache_read_input_tokens // 0)
    }
' | jq -s -c '
  # $ per million tokens: [input, output, cache read]. Cache writes are 1.25 x input.
  def price:
    if test("fable-5-2|mythos-5-2") then [8, 40, 0.2]
    elif test("fable|mythos") then [10, 50, 1]
    elif test("opus-5-5") then [4, 20, 0.2]
    elif test("opus-5|opus-4-[5-9]") then [5, 25, 0.5]
    elif test("opus") then [15, 75, 1.5]
    elif test("sonnet-5-5") then [2, 10, 0.1]
    elif test("sonnet-5") then [2, 10, 0.2]
    elif test("haiku-5") then [0.1, 0.5, 0.01]
    elif test("haiku-4") then [1, 5, 0.1]
    elif test("haiku") then [0.8, 4, 0.08]
    else [3, 15, 0.3] end;
  def cost: (.m | price) as $p | (.i * $p[0] + .w * $p[0] * 1.25 + .o * $p[1] + .r * $p[2]) / 1000000;
  def tokens: .i + .o + .w + .r;
  def total: { tokens: (map(tokens) | add // 0), cost: ((map(cost) | add // 0) * 10000 | round / 10000),
               input: (map(.i) | add // 0), output: (map(.o) | add // 0), cache: (map(.w + .r) | add // 0), messages: length };
  # The last 7 calendar days, counted from noon UTC on the local date of today, so a 23- or 25-hour day skips none.
  ((now | strflocaltime("%Y-%m-%d") | strptime("%Y-%m-%d") | mktime) + 43200) as $noon
  | [range(6; -1; -1) | ($noon - . * 86400)] as $stamps
  | ($stamps | map(strftime("%Y-%m-%d"))) as $week
  | map(select(.t > 0) | . + { d: (.t | strflocaltime("%Y-%m-%d")) } | select(.d as $d | $week | index($d)))
  # Claude Code writes a line per content block of a reply, each with the usage so far: keep the fullest one.
  | group_by(.k) | map(max_by(.o))
  | . as $all
  | ($week | last) as $today
  | {
      found: true,
      day: $today,
      today: ($all | map(select(.d == $today)) | total),
      week: ($all | total),
      days: [range(0; 7) as $n | { label: ($stamps[$n] | strftime("%a")), value: ($all | map(select(.d == $week[$n]) | tokens) | add // 0) }],
      projects: ($all | group_by(.p) | map({ name: .[0].p } + total | del(.input, .output, .cache, .messages)) | sort_by(-.cost) | .[0:5]),
      models: ($all | group_by(.m) | map({ name: .[0].m } + total | del(.input, .output, .cache, .messages)) | sort_by(-.cost) | .[0:4])
    }
'