Skip to content
Source
Sign inSign up
pingdotgg/t3code

docs: seed worktrees with a copy of real userdata instead of banning it #4949

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/4949/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 1 changed file with 13 additions and 4 deletions.

x
0 of 1 viewed, 1 left
13 additions and 4 deletionsAGENTS.mdModified
View file
@@ -59,7 +59,7 @@
## The three ways to hurt yourself
​
1. **Killing by pattern.** Never `pkill -f`, `pgrep | kill`, or `kill` a PID you found by matching a name, path, or worktree string. Your own agent process has this worktree's path in its argv, and this machine runs several other dev servers at once. Kill only a PID you captured at spawn, or the owner of your port from `ss -H -ltnp` after confirming `/proc/<pid>/cwd` is your worktree.
-2. **Touching the live install.** `~/.t3/userdata` is the developer's real T3 Code database, in use while you work. Read-only inspection is fine. Never start a server against it, never open it read-write, never clean it up.
+2. **Writing to the live install.** `~/.t3/userdata` is the developer's real T3 Code database, in use while you work. Reading it and copying from it are fine, and a good way to get real test data (see Test data). Never start a server against it, never open it read-write, never clean it up.
3. **Baking in origins.** Never set `VITE_HTTP_URL` or `VITE_WS_URL` for dev. Dev is single-origin and Vite proxies `/api`, `/ws`, `/oauth`, and `/.well-known`. Setting them bakes localhost into the bundle and silently breaks every remote browser.
​
## Hit every surface
@@ -85,10 +85,19 @@
​
## Test data
​
-An empty database is a bad test. Seed your worktree's `.t3` instead of pointing at live state:
+An empty database is a bad test. Seed your worktree's `.t3` with a copy of real data instead of pointing at live state:
+​
+- Copy from `~/.t3/userdata` (the developer's real data, the most realistic test set) or `~/.t3/dev`. Worktree state lives at `<worktree>/.t3/userdata`.
+- Snapshot the database with `VACUUM INTO`, which is safe even while a server has the source open and yields one consistent file:
+​
+ ```bash
+ mkdir -p .t3/userdata
+ rm -f .t3/userdata/state.sqlite* # VACUUM INTO refuses to overwrite
+ bun -e "new (require('bun:sqlite').Database)(process.env.HOME + '/.t3/userdata/state.sqlite', { readonly: true }).run(\"VACUUM INTO '.t3/userdata/state.sqlite'\")"
Thread on line 96
cursor[bot](GitHub profile, opens in a new tab)commented

Re-seed while dev server runs

Medium Severity

The snapshot recipe removes and recreates .t3/userdata/state.sqlite* in the worktree but does not say to stop the worktree’s own vp run dev first. Re-running it while that server still has the destination database open can race or leave a corrupt or inconsistent sandbox copy, unlike the plain-cp warning about an open source.

Fix in Cursor Fix in Web
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 28852a40b35047bc166add9f0e60dac5083d5695. Configure [here](https://www.cursor.com/dashboard/bugbot).
+ ```
+​
+ A plain `cp` is only safe when no server has the source open, and must bring the `-wal` and `-shm` siblings along. A live file copy is a corrupt copy.
​
-- Copy from `~/.t3/dev`, never from `~/.t3/userdata`.