How To Restore Cursor User Rules

3 mins
Published on 31 May 2025

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.

TL;DR - Quick Command to Read Your Rules

Using Python

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()
"

Using sqlite3 Binary Package

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';"

Example Output

2025-05-31-how-to-restore-cursor-user-rules-example

Now copy them to your clipboard and paste them in Cursor’s User Rules 😉

Cursor Rules Storage Guide

Overview

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'.

Database Schema

The storage table has a simple structure:

CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB);
  • key: Text identifier for the setting
  • value: BLOB containing the actual rules content

Reading Your Rules

Basic Read

macOS:

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';"

Examine Raw Hex Data

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';"

Decode Hex to Readable Text

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'))"

Understanding Newline Encoding

The Technical Detail

Cursor’s storage distinguishes between:

  • Literal \n strings: Stored as backslash + n characters (\ + n)
  • Actual newlines: Stored as newline bytes (hex 0A)

Example

If your rules contain: Hello World\nTest

  • Literal \n: Displays as Hello World\nTest (one line with visible \n)
  • Actual newline: Displays as:
    Hello World
    Test
    

Hex Analysis

  • Literal \n: 5C6E in hex
  • Actual newline: 0A in hex

Troubleshooting

Issue: Database not found

Solution: Check that Cursor is installed and has been run at least once

Issue: Permission denied

Solution: Make sure Cursor is not running when accessing the database

Issue: Empty result

Solution: You may not have any custom rules set, or they’re stored under a different key

Security Notes

  • The database contains your custom instructions in plain text
  • Consider the security implications of your custom rules
  • The database is not encrypted

Created by analyzing Cursor’s SQLite storage mechanism.