Best practices with state.vscdb and state.vscdb.backup in Cursor

Hi All,

In my Mac these 2 dbs are 20Gb each and it’s surprised me, because I didn’t notice it could be so big. So, I ask you what are the best practices to maintain those files in a good size, because I have just a 256 SSD and it’s ‘eating’ too much space?

TIA,

Kleyber Derick

Is there any reasonable answer?

Hey, this is a known issue. The cursorDiskKV table inside state.vscdb keeps storing data from chats and agent sessions with no limit or cleanup. The team is aware, but there’s no ETA yet.

Here’s what you can do right now:

  1. Try VACUUM, it helps if the DB is fragmented

Fully quit Cursor, then run in Terminal:

sqlite3 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb "VACUUM;"

If the size doesn’t change, it means the file is actually full of data, not just fragmented.

  1. Cleanup via SQL, if VACUUM didn’t help

Make a backup first:

cp ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb.manual-backup

Then run:

sqlite3 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb <<'SQL'
PRAGMA journal_mode=DELETE;
BEGIN IMMEDIATE;
DELETE FROM cursorDiskKV WHERE key LIKE 'agentKv:%';
DELETE FROM cursorDiskKV WHERE key LIKE 'bubbleId:%';
DELETE FROM cursorDiskKV WHERE key LIKE 'checkpointId:%';
COMMIT;
VACUUM;
SQL

This can shrink the file from 20 GB down to tens of MB. But note that chat history in the UI will disappear. Old chats may show an endless Loading Chat. The actual chat data isn’t deleted from workspaceStorage, the UI just won’t be able to find it. Agent transcripts will still be in ~/.cursor/projects/.

The state.vscdb.backup file is an automatic backup created by Cursor. It should shrink on its own after the main file gets smaller.

More details and workaround discussion:

Let me know if you have any questions about the process.

Thanks @deanrie, that helped. Now the db is only 725Mb.

So I have to do this at least one a month, right?

Glad it helped!

Yeah, there’s no automatic cleanup yet, so you’ll need to do it manually from time to time. How often depends on how actively you use Agent and chats. If you use it a lot, you might need to do it every couple of weeks. If you use it moderately, once a month should be enough.

The team is aware of the issue. There’s no exact ETA yet, but your report helps with prioritization. Once there’s a built-in retention policy, manual cleanup won’t be needed.

For now, just keep an eye on the file size and clean it up when it starts getting too big.

1 Like