Debug Mode:让AI助手在运行时收集证据

TL;DR · AI 摘要
Debug Mode 是一种用于解决代码调试问题的工具,它允许AI助手在运行时收集证据,而不是仅仅依赖于代码阅读。
核心要点
- Debug Mode 是一种用于解决代码调试问题的工具,它允许AI助手在运行时收集证据,而不是仅仅依赖于代码阅读。
- 通过在代码中添加日志,运行程序并收集日志,然后分析日志以找到问题并进行修复,Debug Mode 可以帮助解决各种问题。
- Debug Mode 已经帮助解决了一些内部问题,包括竞态条件、内存泄漏、C++崩溃和SSR闪烁。
结构提纲
按章节快速跳转。
- §引言
Debug Mode 是一种用于解决代码调试问题的工具,它允许AI助手在运行时收集证据,而不是仅仅依赖于代码阅读。
Debug Mode 允许AI助手在运行时收集证据,而不是仅仅依赖于代码阅读。
通过在代码中添加日志,运行程序并收集日志,然后分析日志以找到问题并进行修复,Debug Mode 可以帮助解决各种问题。
Debug Mode 已经帮助解决了一些内部问题,包括竞态条件、内存泄漏、C++崩溃和SSR闪烁。
思维导图
用一张图看清主题之间的关系。
查看大纲文本(无障碍 / 无 JS 友好)
- Debug Mode
- 工作原理
- 在代码中添加日志
- 运行程序并收集日志
- 分析日志以找到问题并进行修复
- 应用
- 竞态条件
- 内存泄漏
- C++崩溃
- SSR闪烁
金句 / Highlights
值得收藏与分享的关键句。
Debug Mode 是一种用于解决代码调试问题的工具,它允许AI助手在运行时收集证据,而不是仅仅依赖于代码阅读。
通过在代码中添加日志,运行程序并收集日志,然后分析日志以找到问题并进行修复,Debug Mode 可以帮助解决各种问题。
Debug Mode 已经帮助解决了一些内部问题,包括竞态条件、内存泄漏、C++崩溃和SSR闪烁。
If you've ever watched an agent try to fix a bug, you've watched it guess. It reads the code, comes up with a theory, makes an edit, and hopes. Sometimes it's right. A lot of the time you get a fix that looks confident and quietly hides the real bug.
Debug Mode is what we built for that. Instead of sitting there reasoning about the code, the agent goes and gets evidence about what the code does when it runs.
Here's the loop
- Agent comes up with multiple hypotheses, and starts to work on the most plausible first
- Then, logging is added to test one hypothesis (without touching implementation)
- A little debug server collects the runtime output to .cursor/debug.log while your program runs.
- You reproduce the bug, and agent can now read the logs and understand what happened instead of having to guess
- Cursor finds the root cause in the logs, makes the fix, and pulls out the logging it added.
Here it is on a real bug, sped up to about a minute:
eric zakariasson

@ericzakariasson
here's me using debug mode to fix a small bug in an swift app i just built issue was the initial characters were cut off when typing it out, so i had cursor 1. instrument the code 2. ask me to reproduce the issue 3. read the debug logs 4. implement the fix 5. ask me to reproduce

Some interesting things that we've solved internally with debug mode:
- A race condition that hit 1 in 20 runs. It was corrupting git metadata in our best-of-N runs. Debug Mode pinned it down in under an hour
- A memory leak, traced in one pass. It came down to a misuse of our frontend framework. The fix was a single line.
- A native crash deep in C++. An Electron crash people would normally route around. The logs made it findable.
- An SSR flicker that had been given up on. A rendering bug nobody wanted to touch, fixed once the agent could see what the page was doing at runtime.
Try it with Shift+Tab (it's in the CLI too, via /debug).
I'm sure people are using it in ways I haven't thought of, so let me know!