With recent updates to Cursor IDE, many users have experienced their custom User Rules (personal context/instructions) disappearing from the interface. While the rules may appear to be lost, they’re actually still stored in Cursor’s internal database - they’re just not displaying in the UI.
This blog post shows you how to access and read your stored rules directly from Cursor’s SQLite database.
This is the easiest way to read your rules in a single command.
python3 -c "
import sqlite3, os, platform
db_path = os.path.expanduser('~/Library/Application Support/Cursor/User/globalStorage/state.vscdb') if platform.system() == 'Darwin' else os.path.expandvars(r'%APPDATA%\Cursor\User\globalStorage\state.vscdb')
conn = sqlite3.connect(db_path)
result = conn.execute(\"SELECT value FROM ItemTable WHERE key = 'aicontext.personalContext'\").fetchone()
if result:
data = result[0]
print(data.decode('utf-8') if isinstance(data, bytes) else data)
else:
print('No rules found')
conn.close()
"
You’ll need sqlite3
to access the database.
macOS:
brew install sqlite
Windows:
choco install sqlite
sqlite3 "/Users/$(whoami)/Library/Application Support/Cursor/User/globalStorage/state.vscdb" \
"SELECT value FROM ItemTable WHERE key = 'aicontext.personalContext';"
Now copy them to your clipboard and paste them in Cursor’s User Rules 😉
Cursor stores user rules (custom instructions/personal context) in a SQLite database located at:
macOS/Linux:
/Users/[username]/Library/Application Support/Cursor/User/globalStorage/state.vscdb
Windows:
%APPDATA%\Cursor\User\globalStorage\state.vscdb
The rules are stored in the ItemTable
with the key 'aicontext.personalContext'
.
The storage table has a simple structure:
CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB);
key
: Text identifier for the settingvalue
: BLOB containing the actual rules contentmacOS:
sqlite3 "/Users/$(whoami)/Library/Application Support/Cursor/User/globalStorage/state.vscdb" \
"SELECT value FROM ItemTable WHERE key = 'aicontext.personalContext';"
Windows:
sqlite3 "%APPDATA%\Cursor\User\globalStorage\state.vscdb" "SELECT value FROM ItemTable WHERE key = 'aicontext.personalContext';"
If you want to see the raw hex encoding:
sqlite3 "/Users/$(whoami)/Library/Application Support/Cursor/User/globalStorage/state.vscdb" \
"SELECT hex(value) FROM ItemTable WHERE key = 'aicontext.personalContext';"
To convert hex data to readable text:
sqlite3 "/Users/$(whoami)/Library/Application Support/Cursor/User/globalStorage/state.vscdb" \
"SELECT hex(value) FROM ItemTable WHERE key = 'aicontext.personalContext';" | \
python3 -c "import sys; data=sys.stdin.read().strip(); print(bytes.fromhex(data).decode('utf-8'))"
Cursor’s storage distinguishes between:
\n
strings: Stored as backslash + n characters (\
+ n
)0A
)If your rules contain: Hello World\nTest
\n
: Displays as Hello World\nTest
(one line with visible \n)Hello World
Test
\n
: 5C6E
in hex0A
in hexSolution: Check that Cursor is installed and has been run at least once
Solution: Make sure Cursor is not running when accessing the database
Solution: You may not have any custom rules set, or they’re stored under a different key
Created by analyzing Cursor’s SQLite storage mechanism.