DEV Community

Cover image for Claude Code forgets your sessions after 30 days. I found my year anyway.
Thi Ho
Thi Ho

Posted on AI-assisted

Claude Code forgets your sessions after 30 days. I found my year anyway.

I wanted to see my year with Claude Code the way Spotify shows me a year of music. So I built agent-wrapped:

npx github:openyard-cloud/agent-wrapped
Enter fullscreen mode Exit fullscreen mode

It reads the history Claude Code (and Codex) already keep on your computer and writes one HTML file: a short story you tap through, and a card you can save as an image. Here is mine.

My card: The Marathoner, 126 active days, 72M+ tokens, a 13-day streak, favourite model Opus 5.5

Nothing is uploaded. The page makes no network requests, and the card shows totals only.

The first version said I had 71 active days this year. The real number is 126. Finding the other 55 is most of this post.

Where Claude Code keeps your history

There are three places, and none is enough on its own.

Session transcripts, in ~/.claude/projects/**/*.jsonl. Every message, tool call, token count and model is there. They are detailed, but Claude Code deletes them after 30 days unless you change cleanupPeriodDays. On my machine they start on 12 October.

The /stats cache, in ~/.claude/stats-cache.json. Daily totals back to your first session: messages, sessions, tool calls, tokens per model. Mine goes back to January. But it only updates when you run /stats, and I last ran it on 13 August.

So from mid-August to mid-October I had nothing. Two months of work, gone from both sources.

Prompt history, in ~/.claude/history.jsonl. This is what the up arrow recalls. It keeps the time and project of every prompt you typed, and it is not cleaned up. It still knew the days the other two had lost: 55 of them.

Merging three sources without counting a day twice

  • The cache was built from the same transcripts, so on a day both cover, the larger count wins.
  • Prompt history only fills days neither of the others has. It has no tokens, models or tools, so those days count prompts only, and sessions are estimated: a new one starts after 30 quiet minutes in a project.
  • The prompt text is never read into the page. Only the timestamp and the project folder.

That left one honest problem. 55 of my days have no token count, so my token total is a floor. The card says 72M+, rounded down, and the tokens slide says "Counted on 71 of your 126 days". I could have estimated the rest, but my days range from a few thousand tokens to over 10 million, and a guessed number on a card you share is worse than a plus sign.

The 20-day session

The cache says my longest session lasted 1,770,352,869 milliseconds. That's 20.5 days, because I left it open.

So "longest session" is active time: agent-wrapped walks the timestamps and adds up gaps shorter than 30 minutes. My real longest was 56 hours of agent activity (a long-running loop), which is how I ended up as The Marathoner.

Four slides from my story: 126 days, my year as twelve month calendars, 55 Esc presses, The Marathoner

Small things I liked finding

  • 13 models came and went in my year, from Sonnet 4.5 in January to Fable 5.2 last week. The models slide is a little history of the year in AI.
  • 55 times I pressed Esc to stop the agent mid-reply. About once every 38 prompts. Claude Code writes those as [Request interrupted by user], and they were being counted as prompts until I noticed.
  • My agent re-read 36 billion tokens of context from cache. That gets its own line, because it would dwarf everything else.

Codex, and more than one computer

If you use Codex too, it reads ~/.codex and puts both agents on one card.

History lives per computer, not per account. If part of your year is on another laptop, run --export wrapped-laptop.json there and --add wrapped-laptop.json on your main machine. The file holds counts only.

Privacy, and the test that keeps it

The page is one file. The font, the numbers and the code are embedded, and nothing is fetched. The card shows totals only: no prompts, no file names, no project names.

That last promise is a test. It feeds prompts mentioning a secret project and an edit to a billing file through the whole pipeline, renders the page, and fails if any of those strings appear in it. The same test covers prompt history and the export file.

Try it

npx github:openyard-cloud/agent-wrapped          # your year
npx github:openyard-cloud/agent-wrapped --demo   # made-up data, to see what it looks like
Enter fullscreen mode Exit fullscreen mode

Two tips:

  • Run /stats in Claude Code once first.
  • Set "cleanupPeriodDays": 365 in ~/.claude/settings.json so next year's Wrapped has every day.

MIT, no dependencies, Node 18 or newer.
Site: wrapped.openyard.cloud ยท Code: github.com/openyard-cloud/agent-wrapped

What did you get? I'd love to see the Night Owls.

Top comments (0)