Does Cursor Actually Track Your Token Usage? A Deep Dive Into state.vscdb

February 1, 2026

Does Cursor Actually Track Your Token Usage? A Deep Dive Into state.vscdb

I've been building cursor-history, a CLI tool that lets you browse and export your Cursor AI chat sessions. Think of it as a time machine for your AI conversations โ€” every question you asked, every code snippet it wrote, all searchable and exportable.

One evening, a thought hit me: does Cursor store token usage locally?

You know, the stuff that actually costs money โ€” input tokens, output tokens, cached tokens, reasoning tokens. If it's sitting right there in the local SQLite database, maybe I could surface it in my tool and give people visibility into their actual usage.

So I went digging.

The Setup

Cursor stores everything in SQLite databases called state.vscdb. There are two flavors:

  • Global storage: ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb โ€” full AI responses, bubble data
  • Workspace storage: ~/Library/Application Support/Cursor/User/workspaceStorage/*/state.vscdb โ€” per-project session metadata

Both share the same dead-simple schema:

CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB);
CREATE TABLE cursorDiskKV (key TEXT NOT NULL UNIQUE ON CONFLICT REPLACE, value BLOB);

Key-value stores all the way down. The interesting stuff lives in cursorDiskKV, where each message (or "bubble" in Cursor-speak) is stored as a JSON blob under keys like bubbleId:<composerId>:<bubbleId>.

My global database had 4,592 bubble entries. Let's see what's inside.

First Blood: tokenCount

A quick grep and... yes! There it is:

{
  "tokenCount": {
    "inputTokens": 131373,
    "outputTokens": 6493
  }
}

Input tokens, output tokens. Beautiful. Ship it. Done. Right?

Not so fast.

$ grep -oE '"tokenCount":\{[^}]*\}' all_bubbles.jsonl | sort -u
"tokenCount":{"inputTokens":0,"outputTokens":0}
"tokenCount":{"inputTokens":131373,"outputTokens":6493}
"tokenCount":{"inputTokens":17945,"outputTokens":1079}
"tokenCount":{"inputTokens":19097,"outputTokens":4827}
"tokenCount":{"inputTokens":23022,"outputTokens":2801}

Out of 4,592 bubbles, only 5 had non-zero token counts. The other 4,587? All zeros. That's a 99.9% empty rate.

So Cursor has the field, it just... rarely fills it in. Cool. Cool cool cool.

The Scavenger Hunt Begins

Knowing Cursor's tendency to be inconsistent with field names across versions (something I've learned the hard way building this tool), I decided to do a full audit of every token-related field in the entire database. No stone unturned.

$ grep -oiE '"[a-zA-Z_]*token[a-zA-Z_]*"\s*:\s*[0-9]+' all_values | sort | uniq -c | sort -rn

And the plot thickened. Turns out token data is scattered across five different locations with two different naming conventions.

The Full Map

Location 1: Bubble tokenCount (camelCase)

The one I already found. Lives directly on each bubble:

{
  "tokenCount": {
    "inputTokens": 131373,
    "outputTokens": 6493
  },
  "modelInfo": {
    "modelName": "claude-4.5-opus-high-thinking"
  },
  "usageUuid": "cc5b64e1-a2ef-4c6f-9777-b28a910ea041"
}

Mostly zeros. But when it's populated, it's the real deal โ€” actual server-reported token counts.

Location 2: contextWindowStatusAtCreation

This one surprised me. It's on user messages and tracks how full the context window was when you sent the message:

{
  "contextWindowStatusAtCreation": {
    "percentageRemaining": 80,
    "percentageRemainingFloat": 80.678,
    "tokensUsed": 52554,
    "tokenLimit": 272000
  }
}

Much more consistently populated than tokenCount โ€” found on ~60 bubbles. The tokenLimit values are interesting too: 176k, 200k, and 272k, mapping to different model tiers.

Location 3: promptDryRunInfo (the inception one)

This is JSON inside a string inside JSON. A matryoshka doll of data:

{
  "promptDryRunInfo": "{\"userMessageTokenLimit\":89760,\"userMessageTokenCount\":{\"numTokens\":488},\"fullConversationTokenCount\":{\"numTokens\":17862},\"barFraction\":0.005}"
}

Yes, that's a stringified JSON object. You have to JSON.parse() twice to get to the actual numbers. It's a client-side pre-send estimate โ€” Cursor calculates how many tokens your message will use before sending it. Not the actual API response, but still useful.

Location 4: Composer-Level (composerData:*)

Per-session aggregates in the composer metadata:

{
  "contextTokensUsed": 111068,
  "contextTokenLimit": 272000,
  "contextUsagePercent": 55,
  "usageData": {}
}

The contextUsagePercent is fun โ€” sometimes it's an integer like 55, sometimes a float like 57.731998443603516. Because why would Cursor be consistent?

And that usageData: {} field? Always empty. In every single session I checked. It's like a placeholder for a feature that never shipped. (Or maybe a future Cursor version will populate it. Who knows.)

Location 5: agentKv:blob:* (snake_case!)

And here's where it gets spicy. Deep in the agent key-value store:

{
  "usage": {
    "input_tokens": 2,
    "output_tokens": 3
  }
}

Snake case. Different parent key (usage instead of tokenCount). Different naming (input_tokens instead of inputTokens). Only 2 entries found. This appears to come from Cursor's agent system and mirrors the raw API response format more closely.

The Fields That Don't Exist

Here's what I was really hoping to find โ€” the extended usage breakdown from LLM APIs:

FieldExists?
inputTokens / input_tokensYes (two formats)
outputTokens / output_tokensYes (two formats)
cache_read_input_tokensNope
cache_creation_input_tokensNope
reasoning_tokens / output_reasoningNope
Any cost/pricing dataNope

Cursor proxies all API calls through their servers. The extended usage info that Claude/GPT APIs return (cached tokens, reasoning tokens) simply never makes it to local storage. It's either stripped out server-side or never forwarded to the client.

Bonus Finds

While rummaging through the database, I also found some gems:

Model usage breakdown:

ModelBubble Count
claude-4.5-opus-high-thinking205
composer-114
gpt-5-codex11
gpt-5.210
gpt-5.2-codex-xhigh6

Request timing data on each assistant bubble:

{
  "timingInfo": {
    "clientStartTime": 654927,
    "clientRpcSendTime": 1756201887204,
    "clientSettleTime": 1756201888091,
    "clientEndTime": 1756201888091
  }
}

AI code tracking stats (daily, in ItemTable):

{
  "date": "2026-01-29",
  "tabSuggestedLines": 0,
  "tabAcceptedLines": 0,
  "composerSuggestedLines": 158,
  "composerAcceptedLines": 158
}

And yes, your subscription status is also stored locally: cursorAuth/stripeMembershipType = "pro". Along with auth tokens in plaintext. But that's a story for another day.

The Naming Chaos Summary

If you ever need to extract token data from Cursor's databases, here's the compatibility matrix you'll need:

LocationKey PatternField NamesConvention
Bubble databubbleId:*tokenCount.inputTokenscamelCase
Bubble databubbleId:*contextWindowStatusAtCreation.tokensUsedcamelCase
Bubble databubbleId:*promptDryRunInfo (stringified JSON)camelCase
Composer datacomposerData:*contextTokensUsed, contextTokenLimitcamelCase
Agent dataagentKv:blob:*usage.input_tokenssnake_case

Two naming conventions. Five locations. Double-encoded JSON. And a 99.9% chance the main tokenCount field is just zeros.

Takeaways

  1. Cursor does store token usage locally โ€” but it's sparse, scattered, and inconsistent
  2. No extended usage data โ€” cached tokens and reasoning tokens are not stored
  3. Multiple naming conventions coexist in the same database (camelCase vs snake_case)
  4. promptDryRunInfo is your best bet for consistent token estimates, but it's client-side estimates, not server-reported actuals
  5. contextWindowStatusAtCreation is the most reliably populated field for understanding context usage
  6. The empty usageData: {} field hints that Cursor might plan to store more detailed usage data in the future

For now, if you want real token usage visibility, you'll need to piece together data from multiple locations and accept that most of it will be approximate at best.


4,592 bubbles explored. 5 had real token counts. The rest were zeros. At least I got a blog post out of it.

ยฉ 2026 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2026-02-01). Does Cursor Actually Track Your Token Usage? A Deep Dive Into state.vscdb. https://caiborui.com/blog/2026-02-01-en-cursor-token-usage-local-database-exploration

@misc{borui2026-50067aec,
  author = {borui},
  title = {{Does Cursor Actually Track Your Token Usage? A Deep Dive Into state.vscdb}},
  year = {2026},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2026-02-01-en-cursor-token-usage-local-database-exploration}
}