一、有彩蛋!
二、10分钟环境魔改清单
2.1 第一步:关闭隐私模式
下载完第一件事:
sql
Settings → AI → Cursor Settings → 把 "Privacy mode" 关掉
为什么? 否则模型永远给你"官方话术",不会真正理解你的代码风格。
2.2 必装3个插件
| 插件名称 | 作用 | 为什么必须装 |
|---|---|---|
| Continue | 本地模型桥接 | 可以接入 Claude、GPT-4 等多种模型 |
| Thunder Client | 一键跑通 API | 不用离开编辑器就能测试接口 |
| Error Lens | 把报错甩到脸上 | 实时高亮错误,不用等 Hover 才看到 |
2.3 配置 .cursorignore
把 .cursorignore 写成 .gitignore 的孪生兄弟,关键是别让 AI 读到日志/密钥,否则 Token 烧得比房租还快。
bash
# .cursorignore 示例
node_modules/
dist/
build/
.env
.env.local
*.log
.DS_Store
coverage/
三、Token 获取
- 干货: 本次送出50个号, trial + pro, 可使用Claude 4.5、Gemini 2.5 Pro、o3 等模型
- 获取方式: 搜索"cursor-code" 关注+评论, 先到先得
- 真实有效, 如有虚假直接举报!

四 机器码重置大法
Mac:
bash
rm ~/Library/Application\ Support/Cursor/machineid
ruby
curl -fsSL https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_mac_id_modifier.sh | sudo bash
Windows:
powershell
del %APPDATA%\Cursor\machineid
ruby
irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
ruby
irm https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
选择上面的一种命令即可,管理员运行powerShell。
⚠️ 关键:24小时内别登录原账号,否则触发风控。
五、让 AI 记得你长什么样
4.1 创建专属系统提示词
在仓库根目录新建 .cursor/system-prompt.md,写入:
markdown
You are my senior TypeScript mentor.
- Always return runnable code
- No yarn, use pnpm
- Prefer arrow function + functional component
- Write Chinese comment for business logic
- Follow Airbnb style guide
- Use meaningful variable names
4.2 立即生效
保存后,按 Ctrl+Shift+P(Mac: Cmd+Shift+P) → 输入 Reload Window
效果 :从此 AI 不再给你 class Foo extends React.Component 的古董代码。
六、70% 自动生成工作流(实测可复现)
场景1:需求 → 代码
你的操作:
arduino
需求用英文一句话:
"Add a retry wrapper for fetch with exponential backoff"
在文件头打:
typescript
// cursor:retry.ts
结果:立刻弹出完整实现 + 单测,直接可用。
场景2:自动补全类型和文档
操作步骤:
- 光标移到函数名
- 按
Ctrl+K→Ctrl+T - 自动生成 JSDoc + 类型守卫
前后对比:
❌ 优化前:
typescript
function retry(fn, times) {
// ...
}
✅ 优化后:
typescript
/**
* 为函数添加重试机制(指数退避)
* @param fn - 需要重试的异步函数
* @param times - 最大重试次数
* @returns 包装后的函数
*/
function retry<T extends (...args: any[]) => Promise<any>>(
fn: T,
times: number
): T {
// ...
}
场景3:自动生成 Git 提交信息
bash
git diff | cursor commit-msg
自动生成:
sql
feat(api): add retry mechanism with exponential backoff
- Implement retry wrapper for fetch requests
- Add configurable max retries and backoff factor
- Include comprehensive error handling
七、常见翻车与解药
| 翻车现场 | 根本原因 | 解药 |
|---|---|---|
| AI 突然中文答非所问 | 系统提示词优先级被覆盖 | 把系统提示第一句改成 "Reply in English" |
| 补全停滞在 50% | AI 在帮你读 node_modules |
.cursorignore 里把 node_modules 加上(检查拼写) |
| 提示 "Request too large" | 单个文件上下文超限 | 把文件拆成 <300行 ,或用 // cursor:ignore 注释掉大 JSON |
| 代码风格混乱 | 没有统一的 system prompt | 在 .cursor/system-prompt.md 中明确代码规范 |
| Token 消耗过快 | 读取了日志/依赖文件 | 检查 .cursorignore 配置是否完善 |
| 生成的代码无法运行 | 提示词不够具体 | 加上"runnable"、"with test case"等关键词 |
八、进阶技巧:让 Cursor 更懂你
7.1 自定义快捷键
json
// keybindings.json
[
{
"key": "cmd+shift+g",
"command": "cursor.generateDocstring"
},
{
"key": "cmd+shift+r",
"command": "cursor.refactorCode"
}
]
7.2 项目级配置
在项目根目录创建 .cursor/rules.md:
markdown
## 项目规范
### 命名规范
- 组件:PascalCase
- 函数:camelCase
- 常量:UPPER_SNAKE_CASE
### 文件结构
- components/ - 公共组件
- hooks/ - 自定义 Hooks
- utils/ - 工具函数
- types/ - TypeScript 类型定义
### 代码风格
- 优先使用 const
- 避免 any,必要时用 unknown
- 所有 Promise 必须有错误处理
7.3 Context 上下文管理
技巧 :在提问时使用 @filename 指定上下文
ruby
@utils/retry.ts 帮我优化这个重试函数的性能
AI 只会读取指定文件,避免干扰。
九、终极心法
哪天它罢工了,先别骂软件------
90% 是你没把需求讲成人话。
好的提示词示例:
bash
在 utils/format.ts 中添加一个函数,
将秒数转换为 "1h 30m 45s" 格式,
需要处理负数和边界情况,
用 TypeScript 严格模式,
包含 Jest 测试用例
差的提示词示例:
写个时间格式化
附录:常用快捷键速查
| 快捷键 | 功能 | 使用场景 |
|---|---|---|
Ctrl/Cmd + K |
打开 AI 对话 | 询问代码问题 |
Ctrl/Cmd + L |
添加到上下文 | 让 AI 记住当前文件 |
Ctrl/Cmd + Shift + P |
命令面板 | 执行 Cursor 命令 |
Tab |
接受建议 | 应用 AI 补全 |
Esc |
拒绝建议 | 忽略 AI 补全 |
最后一句话:
工具只是杠杆,你的思维才是支点。
Cursor 能让优秀程序员效率翻倍,
但救不了不会提问的人。
本文持续更新,欢迎关注获取最新技巧 🚀