nuke-cursor-app
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNuke Cursor App
Nuke Cursor App
Why this exists
为什么开发这个工具
Cursor (the AI IDE) is an Electron-based VS Code fork. It has a known,
Cursor-acknowledged memory leak: the renderer process accumulates tool-call
state (diffs, file contexts) during long agent sessions and never frees it,
especially in the Agents window. The UI gets laggy, then freezes. The only
reliable recovery is a full restart — that is what this skill does, end to
end: snapshot → kill → relaunch → before/after report.
Cursor(一款AI IDE)是基于Electron的VS Code分支版本。它存在一个官方已确认的内存泄漏问题:在长时间的Agent会话期间,渲染器进程会不断累积工具调用状态(差异、文件上下文),且永远不会释放这些内存,尤其是在Agents窗口中。UI会逐渐卡顿,最终冻结。唯一可靠的恢复方法是完全重启——这正是本工具的功能,端到端完成:快照→终止进程→重新启动→报告前后状态。
How Cursor runs
Cursor的运行方式
One main process at plus
helper processes (Renderer, GPU, extension host, network service, crashpad)
that all live under the bundle path.
/Applications/Cursor.app/Contents/MacOS/Cursor/Applications/Cursor.app一个主进程位于,加上辅助进程(Renderer、GPU、扩展宿主、网络服务、crashpad),所有进程都属于包路径。
/Applications/Cursor.app/Contents/MacOS/Cursor/Applications/Cursor.appSafety rules
安全规则
- Match processes ONLY by the bundle path — never by the bare word "cursor".
/Applications/Cursor.app - Do NOT touch — despite the name it is a macOS system text-input service, not part of the Cursor app.
CursorUIViewService - Warn the user first if you have reason to think an important agent run is in flight; killing Cursor kills its local agent sessions.
- The metrics collector OWNS . Read it ONLY with
cursor-metrics.sqlite3. Never write to it.sqlite3 -readonly - The snapshot is best-effort: if the DB is missing or a query fails, note that in the log and continue — never block the nuke on it.
- 仅通过包路径匹配进程——绝不要仅通过“cursor”这个词匹配。
/Applications/Cursor.app - 不要触碰——尽管名称相似,但它是macOS系统文本输入服务,不属于Cursor应用。
CursorUIViewService - 如果有理由认为正在运行重要的Agent任务,需先警告用户;终止Cursor会同时终止其本地Agent会话。
- 指标收集器拥有文件。仅以
cursor-metrics.sqlite3模式读取它,绝不要写入。sqlite3 -readonly - 快照为尽力而为:如果数据库缺失或查询失败,在日志中记录该情况并继续——绝不要因快照问题阻止终止操作。
Procedure
操作流程
1. Snapshot BEFORE killing
1. 终止前的快照
bash
DB="$HOME/Library/Application Support/<metrics-collector>/cursor-metrics.sqlite3"
LOG_DIR="$HOME/Library/Application Support/<metrics-collector>/nuke-logs"
mkdir -p "$LOG_DIR"
LOG="$LOG_DIR/$(date +%Y-%m-%d-%H%M).md"bash
DB="$HOME/Library/Application Support/<metrics-collector>/cursor-metrics.sqlite3"
LOG_DIR="$HOME/Library/Application Support/<metrics-collector>/nuke-logs"
mkdir -p "$LOG_DIR"
LOG="$LOG_DIR/$(date +%Y-%m-%d-%H%M).md"Live per-process readout — these are the "before" numbers
实时进程读取——这些是“重启前”的数据
ps -axo pid,rss,comm | grep "/Applications/Cursor.app" | grep -v grep
ps -axo pid,rss,comm | grep "/Applications/Cursor.app" | grep -v grep
Totals for the summary line (rss is in KB on macOS)
摘要行的总计数据(macOS上rss单位为KB)
ps -axo rss,comm | awk 'index($0, "/Applications/Cursor.app") {n++; s+=$1} END {printf "%d processes, %.1f GB", n, s/1048576; print ""}'
ps -axo rss,comm | awk 'index($0, "/Applications/Cursor.app") {n++; s+=$1} END {printf "%d processes, %.1f GB", n, s/1048576; print ""}'
Last 30 min from the collector (read-only)
收集器中最近30分钟的数据(只读)
sqlite3 -readonly "$DB" "SELECT datetime(timestamp,'unixepoch','localtime'), role, process_count, ROUND(cpu_percent,1), ROUND(resident_bytes/1073741824.0,2) || ' GB' FROM raw_samples WHERE timestamp > strftime('%s','now') - 1800 ORDER BY timestamp;"
sqlite3 -readonly "$DB" "SELECT datetime(timestamp,'unixepoch','localtime'), kind, role, reason, memory_pressure FROM events WHERE timestamp > strftime('%s','now') - 1800 ORDER BY timestamp;"
Write all four outputs into `$LOG` with headings: process list, totals,
metrics (last 30 min), events (last 30 min). The after-restart reading is
appended in step 4 — so one file tells the whole story of this nuke.sqlite3 -readonly "$DB" "SELECT datetime(timestamp,'unixepoch','localtime'), role, process_count, ROUND(cpu_percent,1), ROUND(resident_bytes/1073741824.0,2) || ' GB' FROM raw_samples WHERE timestamp > strftime('%s','now') - 1800 ORDER BY timestamp;"
sqlite3 -readonly "$DB" "SELECT datetime(timestamp,'unixepoch','localtime'), kind, role, reason, memory_pressure FROM events WHERE timestamp > strftime('%s','now') - 1800 ORDER BY timestamp;"
将以上四个输出内容写入`$LOG`文件,并添加标题:进程列表、总计数据、指标(最近30分钟)、事件(最近30分钟)。重启后的读取数据会在步骤4中追加到该文件——因此一个文件即可记录本次终止操作的完整过程。2. Kill every Cursor process
2. 终止所有Cursor进程
bash
undefinedbash
undefinedGraceful quit first — lets Cursor save session state
先尝试优雅退出——让Cursor保存会话状态
osascript -e 'tell application "Cursor" to quit' 2>/dev/null
sleep 3
osascript -e 'tell application "Cursor" to quit' 2>/dev/null
sleep 3
Kill anything still alive under the bundle path
终止所有仍在运行的包路径下的进程
pkill -f "/Applications/Cursor.app" 2>/dev/null
sleep 1
pkill -f "/Applications/Cursor.app" 2>/dev/null
sleep 1
Verify; force-kill leftovers by PID if needed
验证;如有残留则通过PID强制终止
ps -axo pid,comm | grep "/Applications/Cursor.app" | grep -v grep
ps -axo pid,comm | grep "/Applications/Cursor.app" | grep -v grep
if any remain: kill -9 <pid> ...
如果有残留: kill -9 <pid> ...
Final check — must print "all Cursor processes gone"
最终检查——必须输出“all Cursor processes gone”
ps -axo pid,comm | grep "/Applications/Cursor.app" | grep -v grep && echo "STILL RUNNING" || echo "all Cursor processes gone"
The graceful quit often fails exactly when this skill is needed — a leaked
renderer blocks the main thread — which is why the pkill/kill steps exist.
Note in the log whether graceful quit worked or force-kill was needed.ps -axo pid,comm | grep "/Applications/Cursor.app" | grep -v grep && echo "STILL RUNNING" || echo "all Cursor processes gone"
当本工具需要运行时,优雅退出往往会失败——泄漏的渲染器会阻塞主线程——这就是为什么需要pkill/kill步骤。在日志中记录优雅退出是否成功,或者是否需要强制终止。3. Relaunch and verify
3. 重新启动并验证
Skip this step only if the user asked to keep Cursor closed
("nuke cursor and keep it closed").
bash
sleep 2
open -a Cursor仅当用户要求保持Cursor关闭("nuke cursor and keep it closed")时,才跳过此步骤。
bash
sleep 2
open -a CursorWait up to 15 s for the main process to come back
等待最多15秒,直到主进程恢复
for i in $(seq 1 15); do
ps -axo comm | grep -q "/Applications/Cursor.app/Contents/MacOS/Cursor" && break
sleep 1
done
ps -axo pid,comm | grep "/Applications/Cursor.app/Contents/MacOS/Cursor" | grep -v grep
If the poll times out, report that — never claim Cursor is back without
seeing the main process.for i in $(seq 1 15); do
ps -axo comm | grep -q "/Applications/Cursor.app/Contents/MacOS/Cursor" && break
sleep 1
done
ps -axo pid,comm | grep "/Applications/Cursor.app/Contents/MacOS/Cursor" | grep -v grep
如果轮询超时,需报告该情况——在未检测到主进程的情况下,绝不要声称Cursor已恢复。4. After-restart reading
4. 重启后的读取数据
bash
sleep 10 # let Cursor settle and restore windows
ps -axo pid,rss,comm | grep "/Applications/Cursor.app" | grep -v grep
ps -axo rss,comm | awk 'index($0, "/Applications/Cursor.app") {n++; s+=$1} END {printf "%d processes, %.1f GB", n, s/1048576; print ""}'Append both outputs to under an "after restart" heading.
$LOGbash
sleep 10 # 让Cursor稳定并恢复窗口
ps -axo pid,rss,comm | grep "/Applications/Cursor.app" | grep -v grep
ps -axo rss,comm | awk 'index($0, "/Applications/Cursor.app") {n++; s+=$1} END {printf "%d processes, %.1f GB", n, s/1048576; print ""}'将这两个输出内容追加到文件的“重启后”标题下。
$LOG5. Report to the user
5. 向用户报告
End with one plain-English summary line, for example:
Killed 14 processes using 21.3 GB. Cursor is back with 9 processes using 2.1 GB. Snapshot saved to nuke-logs/2026-08-14-1832.md.
Never claim success without the step 2 final check and (unless skipped)
the step 3 relaunch check.
最后输出一条简洁的英文总结,例如:
Killed 14 processes using 21.3 GB. Cursor is back with 9 processes using 2.1 GB. Snapshot saved to nuke-logs/2026-08-14-1832.md.
在未完成步骤2的最终检查和(除非跳过)步骤3的重启检查的情况下,绝不要声称操作成功。
Known failure modes
已知失败模式
- After a force-kill, Cursor may show a "restore windows?" dialog on relaunch. That is expected — tell the user to click Restore.
- If the metrics DB has no recent rows (collector stalled), say so in the
log and the report; the readouts still give valid before/after.
ps
- 强制终止后,Cursor在重启时可能会显示“是否恢复窗口?”的对话框。这是预期情况——告知用户点击“恢复”即可。
- 如果指标数据库没有最近的记录(收集器停滞),需在日志和报告中说明;读取的数据仍能提供有效的重启前后对比。
ps