Cursor Agent Skill
Two ways to use Cursor Agent from OpenClaw, for different scenarios.
Related
Path Selection
| Scenario | Path | Why |
|---|
| Quick coding task, bug fix, refactor | CLI | Fast, no setup, works anywhere |
| Generate code, review PR, write tests |
CLI | Non-interactive
-p mode is perfect |
| Fix type errors using real diagnostics |
Node |
diagnostics.get shows actual TS/lint errors |
| Navigate definitions/references first |
Node |
lang.definition,
lang.references |
| Run project tests and iterate |
Node |
test.run +
test.results loop |
| Debug with breakpoints |
Node | Full debug protocol |
| Targeted changes to a specific project |
Node | IDE workspace context is precise |
Default: CLI. Use Node only when you specifically need IDE intelligence.
Path 1: CLI (Local Cursor Agent)
Prerequisites
CODEBLOCK0
Modes
| Mode | Flag | Use Case |
|---|
| Agent | (default) | Full coding — reads, writes, runs commands |
| Plan |
--plan or
--mode=plan | Design approach first, then choose local or cloud execution |
|
Ask |
--mode=ask | Read-only codebase exploration, no edits |
Interactive Mode
CODEBLOCK1
Non-Interactive Mode (Automation)
CODEBLOCK2
Cloud Agent Handoff
Push work to Cursor's cloud to continue running while you're away:
CODEBLOCK3
Pick up at cursor.com/agents.
Session Management
CODEBLOCK4
Slash Commands (Interactive)
| Command | Action |
|---|
| INLINECODE9 | Switch to Plan mode / view current plan |
| INLINECODE10 |
Switch to Ask mode |
|
/models | Switch AI model |
|
/compress | Summarize conversation, free context |
|
/rules | Create/edit rules |
|
/commands | Create/edit custom commands |
|
/mcp enable <name> | Enable MCP server |
|
/mcp disable <name> | Disable MCP server |
|
/sandbox | Configure sandbox mode |
|
/max-mode [on\|off] | Toggle Max Mode |
|
/resume | Resume previous conversation |
Keyboard Shortcuts
| Shortcut | Action |
|---|
| INLINECODE20 | Rotate modes (Agent → Plan → Ask) |
| INLINECODE21 |
Insert newline (multi-line prompt) |
|
Ctrl+R | Review changes (
i for instructions, arrows to navigate) |
|
Ctrl+D | Exit (double-press for safety) |
|
ArrowUp | Cycle previous messages |
Context & Rules
The CLI automatically loads:
- -
.cursor/rules directory - INLINECODE27 at project root
- INLINECODE28 at project root
- MCP servers from INLINECODE29
Use @filename or @directory/ in interactive mode to include context.
⚠️ Using CLI from OpenClaw (PTY Required)
Cursor CLI is an interactive TUI — it needs a real terminal. Use pty:true:
CODEBLOCK5
For long tasks, use background + poll:
CODEBLOCK6
Sandbox Controls
CODEBLOCK7
Sandbox supports granular network access controls — define which domains the agent can reach.
Path 2: VS Code / Cursor Node
Remote-control a Cursor/VS Code IDE through the OpenClaw Node protocol. The IDE must have the openclaw-node-vscode extension installed and connected.
Prerequisites
- - Extension installed: VS Code Marketplace
- Node visible in INLINECODE34
- Extension status bar shows 🟢
Invocation Pattern
CODEBLOCK8
Timeout Guide
| Operation | invokeTimeoutMs | Notes |
|---|
| File/editor/lang | 15000 | Fast IDE operations |
| Git |
30000 | May involve disk I/O |
| Test | 60000 | Depends on test suite |
| Agent plan/ask | 180000 | AI thinking time |
| Agent run | 300000 | Full coding task |
Command Reference
| Category | Prefix | Key Commands |
|---|
| File | INLINECODE35 | read, write, edit, delete |
| Directory |
vscode.dir.* | list |
|
Language |
vscode.lang.* | definition, references, hover, symbols, rename, codeActions, format |
|
Editor |
vscode.editor.* | context, openFiles, selections |
|
Diagnostics |
vscode.diagnostics.* | get (errors/warnings) |
|
Git |
vscode.git.* | status, diff, log, blame, stage, unstage, commit, stash |
|
Test |
vscode.test.* | list, run, results |
|
Debug |
vscode.debug.* | launch, stop, breakpoint, evaluate, stackTrace, variables, status |
|
Agent |
vscode.agent.* | status, run, setup |
|
Workspace |
vscode.workspace.* | info |
Quick Examples
CODEBLOCK9
Node Workflow: Fix → Verify → Commit
The real power of Node path — a closed loop with IDE intelligence:
CODEBLOCK10
No tmux, no TTY hacks — all through VS Code API.
Combined Workflow Example
Use CLI for broad tasks, switch to Node for precision:
CODEBLOCK11
Error Handling
| Error | Cause | Fix |
|---|
| CLI hangs | No PTY | Add pty:true to exec |
| INLINECODE46 |
Extension disconnected | Check VS Code status bar |
|
command not allowed | Gateway whitelist | Add to
gateway.nodes.allowCommands |
|
timeout | Operation too long | Increase
invokeTimeoutMs |
|
path traversal blocked | Absolute path used | Use relative paths for Node |
Security
- - CLI: Respects sandbox mode, command approval, rules
- Node: All paths relative to workspace, Ed25519 device identity, Gateway approval required
- Both: No raw shell access by default
Cursor Agent 技能
两种通过 OpenClaw 使用 Cursor Agent 的方式,适用于不同场景。
相关资源
路径选择
| 场景 | 路径 | 原因 |
|---|
| 快速编码任务、修复 Bug、重构 | CLI | 快速,无需配置,随处可用 |
| 生成代码、审查 PR、编写测试 |
CLI | 非交互式 -p 模式完美适用 |
| 使用真实诊断信息修复类型错误 |
Node | diagnostics.get 显示实际的 TS/代码检查错误 |
| 先导航定义/引用 |
Node | lang.definition、lang.references |
| 运行项目测试并迭代 |
Node | test.run + test.results 循环 |
| 使用断点调试 |
Node | 完整的调试协议 |
| 对特定项目进行针对性更改 |
Node | IDE 工作区上下文精确 |
默认:CLI。 仅在需要 IDE 智能功能时使用 Node。
路径 1:CLI(本地 Cursor Agent)
前提条件
bash
安装
curl https://cursor.com/install -fsS | bash
登录
agent login
验证
agent --version
模式
| 模式 | 标志 | 使用场景 |
|---|
| Agent | (默认) | 完整编码 — 读取、写入、运行命令 |
| Plan |
--plan 或 --mode=plan | 先设计方案,然后选择本地或云端执行 |
|
Ask | --mode=ask | 只读代码库探索,不进行编辑 |
交互模式
bash
启动交互会话
agent
使用提示启动
agent 将认证模块重构为使用 JWT 令牌
以计划模式启动
agent --plan 为 API 设计缓存层
以询问模式启动
agent --mode=ask 解释认证中间件的工作原理
非交互模式(自动化)
bash
一次性任务(打印结果后退出)
agent -p 查找并修复 src/ 中所有未使用的导入
使用特定模型
agent -p 审查此代码是否存在安全问题 --model gpt-5.2
JSON 格式输出以便解析
agent -p 列出所有 TODO 注释 --output-format json
流式 JSON(实时)
agent -p 运行测试并报告 --output-format stream-json --stream-partial-output
强制模式(自动应用更改,无需确认)
agent -p 修复所有代码检查错误 --force
云端 Agent 交接
将工作推送到 Cursor 云端,以便在您离开时继续运行:
bash
直接在云端启动
agent -c 重构认证模块并添加全面测试
对话中:添加 & 前缀发送到云端
& 重构认证模块并添加全面测试
在 cursor.com/agents 继续。
会话管理
bash
agent ls # 列出之前的对话
agent resume # 恢复最近的会话
agent --continue # 继续之前的会话
agent --resume=id # 恢复特定对话
斜杠命令(交互模式)
| 命令 | 操作 |
|---|
| /plan | 切换到计划模式 / 查看当前计划 |
| /ask |
切换到询问模式 |
| /models | 切换 AI 模型 |
| /compress | 总结对话,释放上下文 |
| /rules | 创建/编辑规则 |
| /commands | 创建/编辑自定义命令 |
| /mcp enable
| 启用 MCP 服务器 |
| /mcp disable | 禁用 MCP 服务器 |
| /sandbox | 配置沙箱模式 |
| /max-mode [on\|off] | 切换最大模式 |
| /resume | 恢复之前的对话 |
键盘快捷键
| 快捷键 | 操作 |
|---|
| Shift+Tab | 循环切换模式(Agent → Plan → Ask) |
| Shift+Enter |
插入换行(多行提示) |
| Ctrl+R | 审查更改(i 查看说明,方向键导航) |
| Ctrl+D | 退出(双击确保安全) |
| ArrowUp | 循环浏览上一条消息 |
上下文和规则
CLI 自动加载:
- - .cursor/rules 目录
- 项目根目录下的 AGENTS.md
- 项目根目录下的 CLAUDE.md
- mcp.json 中的 MCP 服务器
在交互模式下使用 @filename 或 @directory/ 包含上下文。
⚠️ 从 OpenClaw 使用 CLI(需要 PTY)
Cursor CLI 是交互式 TUI — 需要真实终端。使用 pty:true:
bash
✅ 正确 — 使用 PTY
exec pty:true command:agent -p 你的任务 workdir:/path/to/project
✅ 后台运行较长时间的任务
exec pty:true background:true command:agent -p 构建 REST API workdir:/path/to/project
❌ 错误 — 会挂起
exec command:agent -p 你的任务
对于长时间任务,使用后台 + 轮询:
bash
启动
exec pty:true background:true workdir:~/project command:agent -p 为认证模块添加全面测试 --force
检查进度
process action:log sessionId:XXX
检查是否完成
process action:poll sessionId:XXX
沙箱控制
bash
启用沙箱启动
agent --sandbox enabled
禁用沙箱启动
agent --sandbox disabled
交互式配置
/sandbox
沙箱支持精细的网络访问控制 — 定义 Agent 可以访问的域名。
路径 2:VS Code / Cursor Node
通过 OpenClaw Node 协议远程控制 Cursor/VS Code IDE。IDE 必须安装并连接 openclaw-node-vscode 扩展。
前提条件
调用模式
nodes invoke --node <名称> --invokeCommand <命令> --invokeParamsJson {key:val}
超时指南
| 操作 | invokeTimeoutMs | 说明 |
|---|
| 文件/编辑器/语言 | 15000 | 快速 IDE 操作 |
| Git |
30000 | 可能涉及磁盘 I/O |
| 测试 | 60000 | 取决于测试套件 |
| Agent 计划/询问 | 180000 | AI 思考时间 |
| Agent 运行 | 300000 | 完整编码任务 |
命令参考
| 类别 | 前缀 | 关键命令 |
|---|
| 文件 | vscode.file. | read、write、edit、delete |
| 目录 |
vscode.dir. | list |
| 语言 | vscode.lang.* | definition、references、hover、symbols、rename、codeActions、format |
| 编辑器 | vscode.editor.* | context、openFiles、selections |
| 诊断 | vscode.diagnostics.* | get(错误/警告) |
| Git | vscode.git.* | status、diff、log、blame、stage、unstage、commit、stash |
| 测试 | vscode.test.* | list、run、results |
| 调试 | vscode.debug.* | launch、stop、breakpoint、evaluate、stackTrace、variables、status |
| Agent | vscode.agent.* | status、run、setup |
| 工作区 | vscode.workspace.* | info |
快速示例
bash
读取文件