// guide · claude code weekly limit

Compact at 300k, and check your tempo every morning

Thursday night, 8:44, my Claude weekly limit was gone. Four days into a seven-day week. My first suspect was the swarm of helper sessions. I counted every Claude turn on my box for that week: 26,618 of them. The swarm cost 2.9 percent. Here is what actually ate the week, and the one line that aims at the biggest part of it.

The written version of the weekly-limit video. All numbers are my own counts from one box, weighted with API list prices as a proxy, which is a guess with a spreadsheet behind it, not an official unit. Sources and that caveat, at the bottom.

The suspects, and what they cost

I split the week by what kind of work it was. Thousands of small helper sessions: 2,451 of them, and together they cost 2.9 percent. Real subagents: twelve that week, 0.1 percent. So the swarm was innocent, which was bad news, because it meant the problem was something I do all day.

Then I split the cost by token type, and the week fell into place.

75.6%
Of the whole week was cache reads: Claude rereading the conversation so far before answering.
31%
Of turns had more than 300,000 tokens of context. Those turns cost 53.7 percent of the week.
8.8%
The single biggest session, one long conversation that never got smaller.

A cache read is Claude reading the conversation so far before it answers. Per token it is cheap, far cheaper than fresh input. But it happens on every single turn, and it is the whole conversation every time. Before every answer, Claude rereads the entire book you have written together, page one to now. The book only gets thicker.

Just the part above 300k, the pages Claude didn't really need anymore, was 22.8 percent of everything. About a fifth of my week, spent rereading old pages. By default Claude Code runs a conversation close to the model's context limit before it compacts, so a long session keeps paying for page one long after page one stopped mattering.

The one line: compact at 300k

Claude Code compacts a conversation when it grows past the auto-compact window. The window is a documented setting, CLAUDE_CODE_AUTO_COMPACT_WINDOW, and it accepts anything from 100,000 up to a million tokens, capped at the model's context window. Leave it unset and compaction waits until the conversation nears the model's limit, about 967k tokens on models with a native one-million window.

~/.claude/settings.json
{
  "env": {
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "300000"
  }
}

That is the whole fix, and it is aimed straight at the 22.8 percent. You can also set it per session with /autocompact 300k if you want to try it before you commit. New sessions pick the window up; the conversation you have open right now keeps its current window.

Pick your own number instead of copying mine. A lower window compacts more often and spends a little on summarizing; a higher one pays more rereading. Mine is 300,000 because that is where my own turns started costing real money.

Three more changes, one sentence each

Honest status: I don't know yet whether these fixes hold. The next weekly count answers that, and I'll say so either way, the same as I do in the videos.

The morning tempo check

The count has a blind spot, and Thursday proved it. On the day my limit ran out, this box used only 4.6 percent of the week. Something was burning the limit elsewhere, probably the work I can't see from here. Which is exactly why a small script checks the tempo every morning instead of me checking it on Thursdays, when it's too late.

It counts the tokens in your Claude Code transcripts over the last seven days, weights them with API list prices, and compares the pace against the week so far. To be clear about what this is: an approximation, not an official unit. Anthropic does not publish the unit the weekly limit is counted in, list prices are my stand-in, and the script only sees this one machine. It tells you your own pace against your own last week. It does not tell you Anthropic's meter.

~/.claude/hooks/tempo_check.py
#!/usr/bin/env python3
"""Daily tempo check for your Claude Code weekly limit.

Counts tokens in your own Claude Code transcripts (~/.claude/projects) over
the last seven days, weighted with API list prices. A proxy, not an official
usage unit: Anthropic does not publish the limit's unit, and this only sees
this machine. Fill PRICES from Anthropic's pricing page, and BASELINE with
last week's final count when your limit ran out.
"""
import datetime
import json
import pathlib

PRICES = {  # dollars per 1M tokens: (input, cache_write, cache_read, output)
    "opus":   (0, 0, 0, 0),  # fill from Anthropic's pricing page
    "sonnet": (0, 0, 0, 0),  # fill from Anthropic's pricing page
    "haiku":  (0, 0, 0, 0),  # fill from Anthropic's pricing page
}
BASELINE = 0.0  # last week's final weighted count, 0 = just show the count
TRANSCRIPTS = pathlib.Path.home() / ".claude" / "projects"
DAYS = 7


def model_kind(name):
    name = (name or "").lower()
    for kind in PRICES:
        if kind in name:
            return kind
    return "sonnet"  # unknown model: assume the middle price


def main():
    since = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=DAYS)
    total = 0.0
    per_project = {}
    for path in TRANSCRIPTS.glob("*/*.jsonl"):
        with path.open(encoding="utf-8", errors="replace") as fh:
            for line in fh:
                try:
                    row = json.loads(line)
                except json.JSONDecodeError:
                    continue
                if row.get("type") != "assistant" or not row.get("timestamp"):
                    continue
                when = datetime.datetime.fromisoformat(
                    row["timestamp"].replace("Z", "+00:00")
                )
                if when < since:
                    continue
                message = row.get("message") or {}
                usage = message.get("usage") or {}
                price = PRICES[model_kind(message.get("model"))]
                cost = (
                    usage.get("input_tokens", 0) / 1e6 * price[0]
                    + (usage.get("cache_creation_input_tokens") or 0) / 1e6 * price[1]
                    + (usage.get("cache_read_input_tokens") or 0) / 1e6 * price[2]
                    + usage.get("output_tokens", 0) / 1e6 * price[3]
                )
                total += cost
                per_project[path.parent.name] = per_project.get(path.parent.name, 0.0) + cost

    print(f"weighted units, last {DAYS} days: {total:,.0f}")
    elapsed = (datetime.datetime.now(datetime.timezone.utc) - since) / datetime.timedelta(days=DAYS)
    print(f"week elapsed: {elapsed * 100:.0f}%")
    if BASELINE and elapsed:
        used = total / BASELINE * 100
        print(f"of your baseline: {used:.0f}%  (pace {used / (elapsed * 100):.1f}x)")
    for name, cost in sorted(per_project.items(), key=lambda kv: -kv[1])[:3]:
        if total:
            print(f"top spender: {cost / total * 100:.1f}%  {name}")


if __name__ == "__main__":
    main()

Run it once by hand, then let cron do the mornings. Mine runs at a quarter past nine and messages me when the pace is running hot, with the three biggest spenders, which is usually the part that changes my day.

crontab -e
15 9 * * * /usr/bin/python3 $HOME/.claude/hooks/tempo_check.py >> $HOME/.claude/tempo.log 2>&1

Two blind spots stay, and I'm not going to pretend otherwise. The count only sees this machine, so a Mac or the web app burns the same limit invisibly. And one calibration week is one data point, not a law. The value is the pace, every morning, against your own last week.

Three things to steal

// the video

Watch the weekly-limit episode

This guide is the written version of the week-44 episode. It wasn't live yet when I wrote this page; my channel has the Stop hook and Search Console episodes now, and this one lands there the day it's up.

Sources, checked 27 October 2026

  • Anthropic, Claude Code docs, "Model configuration", code.claude.com/docs/en/model-config: CLAUDE_CODE_AUTO_COMPACT_WINDOW accepts 100,000 to 1,000,000 tokens (plain count, k or M form), is capped at the model's context window, and without it Claude Code compacts near the model's context limit, about 967k tokens on native one-million-context models; /autocompact sets it for one session.
  • My own numbers: every Claude turn on one box, 18 to 22 October 2026, 26,618 turns, weighted with API list prices as a proxy. One machine, one week, an approximation and not an official usage unit. Anthropic does not publish the unit the weekly limit is counted in.

Want the limit guard running for you?

The compact window, the morning tempo check and the rest of the agent setup, installed on your own server, with the settings I actually run.