当前位置: 首页 > Skill >

Use Cursor

Use Cursor

Use Cursor

使用 tmux 管理 Cursor CLI 任务并强化安全

1.0.11 2026.11.26 341
获取Skill文件查看使用说明
作 者:林言 许可证: 更新时间:2026.11.26
本文目录展开

Use Cursor - OpenClaw + Cursor CLI Integration

Enable OpenClaw to execute Cursor CLI for various software engineering tasks, supporting interactive mode, background tasks, CI/CD, and more.

🔒 Security Notes

Before installing, understand these security implications:

What This Skill Does

  • ✅ Manages Cursor CLI tasks via tmux (stated purpose)
  • ✅ Reads ~/.cursor/cli-config.json to check auth status (email redacted in output)
  • ✅ Captures tmux pane output (may contain workspace code/data)
  • ✅ All shell arguments are escaped to prevent injection
  • ✅ Does not download remote code at install time

Privacy Considerations

Data Access Purpose Protection
~/.cursor/cli-config.json Check auth status Email redacted (shows ***@domain.com)
~/.cursor/credentials Check auth status Not read, only existence checked
$CURSOR_API_KEY Optional auth Not logged or stored
$PATH, $HOME, etc. Inherited by child processes Not modified or logged
tmux output Return task results May contain workspace data

⚠️ Critical: tmux Pane Execution Risk

This skill sends user-provided strings into tmux panes via tmux send-keys.

How it works:

  1. Script creates tmux session
  2. Runs agent --print --trust 'TASK' in the pane
  3. Captures pane output and returns to agent

Risk: If the pane is running a shell, any text sent via send-keys will be executed. While we escape arguments at the JavaScript level, special characters/control sequences could still affect the shell.

Mitigation:

  • Use in isolated environments (container/VM) for untrusted tasks
  • Don't run on production machines with live secrets
  • Review task strings before sending

Recommendations

Environment Recommendation
Personal dev machine ✅ Safe for normal projects
Open source work ✅ Safe
Corporate environment ⚠️ Review with security team first
Production server ❌ Not recommended
Machine with high-value secrets ❌ Use isolated container/VM

Security Features (v1.0.0+)

  • ✓ Shell argument escaping via single-quote method (prevents injection)
  • ✓ tmux literal mode (-l flag) for all send-keys commands
  • ✓ Email redaction (***@domain.com)
  • ✓ API key/token redaction in output
  • ✓ No autonomous execution (always: false)
  • ✓ No remote code download
  • ✓ Explicit permissions declared in manifest
  • ✓ Isolated mode with minimal environment (hardcoded PATH)

🎯 Use Cases

Scenario Recommended Mode Description
Quick tasks Interactive Direct agent "task description"
Long-running coding Background tmux-managed, no timeout
CI/CD automation Non-interactive agent -p + JSON output
Code review Interactive/Background With context analysis
Large refactoring Background Interruptible, resumable

📦 Installation

1. Install Cursor CLI

⚠️ Security Note: The following install commands use remote scripts. Review them first or use your package manager when possible.

macOS:

# Recommended: use Homebrew (review formula first)
brew install --cask cursor-cli

# Alternative: official installer (review at https://cursor.com/install)
# curl https://cursor.com/install -fsS | bash

Linux/WSL:

# Download and inspect the installer first
curl -fsS https://cursor.com/install -o cursor-install.sh
less cursor-install.sh  # Review before running
bash cursor-install.sh

# Or check if available via your package manager

Verify installation:

agent --version
# or
cursor-agent --version

Required Dependencies:

  • tmux - Terminal multiplexer (required for background tasks)
  • agent or cursor-agent - Cursor CLI (required)
  • CURSOR_API_KEY - Optional, or use agent login for browser auth

2. Authentication

agent login
# or set API key
export CURSOR_API_KEY=your_api_key_here

3. Install tmux (Required for background tasks)

# Ubuntu/Debian
sudo apt install tmux

# macOS
brew install tmux

# CentOS/RHEL
sudo yum install tmux

🛠️ OpenClaw Tools

Tool List

Tool Description Example
use_cursor_spawn Start background Cursor task (standard mode) use_cursor_spawn "refactor this module"
use_cursor_spawn_isolated Start task with minimal environment use_cursor_spawn_isolated "task"
use_cursor_check Check task status use_cursor_check session-name
use_cursor_send Send additional instructions use_cursor_send session-name "make it async"
use_cursor_kill End task use_cursor_kill session-name
use_cursor_list List all tasks use_cursor_list
use_cursor_doctor Diagnose environment use_cursor_doctor

Execution Modes

Mode Script Use Case
Standard spawn.sh Normal development, trusted tasks
Isolated spawn-isolated.sh Untrusted inputs, shared machines
Container Docker/Podman Maximum isolation (manual setup)

🚀 Usage

Method 1: Background Task Mode (Recommended for large jobs)

User: Help me refactor this module using Cursor in background
→ Call: use_cursor_spawn "refactor src/ directory for better performance"
→ Returns: Task ID + tmux session name

Follow-up operations:

User: Check the progress of that task
→ Call: use_cursor_check <session-name>

User: Tell that task: change to TypeScript
→ Call: use_cursor_send <session-name> "implement in TypeScript"

User: Stop that Cursor task
→ Call: use_cursor_kill <session-name>

Method 2: Direct Run Mode (Small tasks)

User: Write a unit test for me
→ Call: use_cursor_run "write unit tests for src/utils.ts"
→ Wait for completion, return result

Method 3: Interactive Mode (Local debugging)

# Start interactive session
agent

# Or with task directly
agent "fix this bug"

# Switch model
/models

# Add context
@src/api/
@src/models/

📋 Cursor CLI Command Reference

Basic Commands

Command Description
agent Start interactive session
agent "task" Execute task directly
agent -p "task" Print mode (for scripts)
agent --model <name> Specify model
agent --resume="<id>" Resume session
agent ls List sessions
agent resume Resume most recent session
agent models List available models
agent update Update CLI

Slash Commands (Interactive Mode)

Command Description
/models Switch models
/compress Compress session history
/rules Manage rules
/commands Manage custom commands
/mcp enable <server> Enable MCP server
/mcp disable <server> Disable MCP server

Keyboard Shortcuts

Shortcut Description
Shift+Enter New line
Ctrl+D Exit (requires double-press)
Ctrl+R Review changes
↑/↓ History messages

🔧 Background Task Architecture

User (Discord/Feishu) 
  → OpenClaw Agent 
  → use_cursor_spawn tool 
  → tmux session 
  → Cursor CLI Agent

tmux Session Management

# Create session
tmux new-session -d -s cursor-task-001

# Send command
tmux send-keys -t cursor-task-001 "agent 'task description'" Enter

# Capture output
tmux capture-pane -t cursor-task-001 -p -S -100

# End session
tmux kill-session -t cursor-task-001

📊 Workflows

Code Review

agent -p 'Review the changes in the current branch against main. Focus on security and performance.'

Refactoring

agent -p 'Refactor src/utils.ts to reduce complexity and improve type safety.'

Debugging

agent -p 'Analyze the following error log and suggest a fix: [paste log here]'

Git Integration

agent -p 'Generate a commit message for the staged changes adhering to conventional commits.'

CI/CD

# Security audit (JSON output)
agent -p 'Audit this codebase for security vulnerabilities' --output-format json --force

# Test coverage
agent -p 'Run tests and generate coverage report' --output-format text

⚠️ Notes

TTY Issues

❌ These will hang:

agent "task"                    # No TTY
agent -p "task"                 # No TTY  
subprocess.run(["agent", ...])  # No TTY

✅ Correct approach:

# Use tmux for pseudo-terminal
tmux new-session -d -s cursor
tmux send-keys -t cursor "agent 'task'" Enter

Timeout Protection

  • Small tasks (<5 min): Use use_cursor_run directly
  • Medium tasks (5-30 min): Background mode + periodic checks
  • Large tasks (>30 min): Background mode +分段 execution

Resource Management

  • Each tmux session uses ~50-100MB memory
  • Recommend max 3-5 concurrent background tasks
  • Use use_cursor_kill to clean up completed tasks

🏥 Troubleshooting

use_cursor_doctor Checklist

  1. ✅ tmux installed
  2. ✅ agent CLI executable
  3. ✅ Authentication status (CURSOR_API_KEY or login)
  4. ✅ Working directory permissions
  5. ✅ Network connectivity

Common Issues

Q: Task exits immediately after starting

  • Check Cursor authentication status
  • Ensure working directory has code

Q: tmux session not found

  • Run use_cursor_list to check active sessions
  • May have been killed or timed out

Q: Garbled output

  • tmux encoding issue, try export LANG=en_US.UTF-8

Security FAQs

Q: Does this skill send my code to external servers?

  • A: No. Code stays on your machine. Cursor CLI may send to Anthropic/Claude API (that's how Cursor works).

Q: Can this skill access my Cursor API key?

  • A: It can detect if $CURSOR_API_KEY is set, but doesn't log or transmit it.

Q: Is my email address exposed?

  • A: No. Email is redacted to ***@domain.com in all outputs.

Q: Can malicious input cause shell injection?

  • A: v1.0.0+ escapes all shell arguments. Earlier versions had this risk.

📁 File Structure

use-cursor/
├── SKILL.md              # This document
├── scripts/
│   ├── spawn.sh          # Start background task
│   ├── check.sh          # Check status
│   ├── send.sh           # Send instructions
│   ├── kill.sh           # End task
│   └── doctor.sh         # Diagnose environment
├── extensions/
│   └── use-cursor/
│       └── index.js      # OpenClaw tool definitions
└── examples/
    └── openclaw.json     # Configuration example

🔗 References

  • Cursor Official Docs
  • Cursor CLI GitHub
  • tmux Usage Guide
  • OpenClaw ACP Docs

Version: 1.0.1 Merged from: cursor-agent (2.1.0) + openclaw-cursor-agent (1.0.0) Authors: Bruce + 凤雏 🦞 Skill Name: use-cursor

Changelog

v1.0.4 (2026-03-31)

  • ✅ Fixed: Newline/control character injection vulnerability - now sanitized before escaping
  • ✅ Added: Control char removal (/[x00-x1fx7f]/g) to prevent all tmux control sequence attacks
  • ✅ Updated: SECURITY.md with sanitization documentation
  • ✅ Fixed: Documentation mismatch - changed "JSON.stringify()" to "single-quote method" in SECURITY.md
  • ✅ Fixed: Repository/homepage URLs updated to openclaw/skills (no more placeholders)
  • ✅ Fixed: Added source field to manifest.json for provenance tracking
  • ✅ Enhanced: Detailed code comments explaining why child_process is safe
  • ✅ Clarified: Static analysis flag (child_process) is FALSE POSITIVE for this use case
  • ✅ Updated: manifest.json notes with child_process justification

v1.0.1 (2026-03-31)

  • ✅ Fixed: spawn-isolated.sh cd command now uses -l flag
  • ✅ Verified: ALL tmux send-keys use literal mode (-l)
  • ✅ Updated: manifest.json with detailed security notes
  • ✅ Clarified: Default mode inherits env, isolated mode uses env -i

v1.0.0 (2026-03-31)

  • Initial release with security hardening

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,013
Skill 文件
  • SKILL.md
    • Use Cursor - OpenClaw + Cursor CLI Integration
    • 🔒 Security Notes
      • What This Skill Does
      • Privacy Considerations
      • ⚠️ Critical: tmux Pane Execution Risk
      • Recommendations
      • Security Features (v1.0.0+)
    • 🎯 Use Cases
    • 📦 Installation
      • 1. Install Cursor CLI
      • 2. Authentication
      • 3. Install tmux (Required for background tasks)
    • 🛠️ OpenClaw Tools
      • Tool List
      • Execution Modes
    • 🚀 Usage
      • Method 1: Background Task Mode (Recommended for large jobs)
      • Method 2: Direct Run Mode (Small tasks)
      • Method 3: Interactive Mode (Local debugging)
    • 📋 Cursor CLI Command Reference
      • Basic Commands
      • Slash Commands (Interactive Mode)
      • Keyboard Shortcuts
    • 🔧 Background Task Architecture
      • tmux Session Management
    • 📊 Workflows
      • Code Review
      • Refactoring
      • Debugging
      • Git Integration
      • CI/CD
    • ⚠️ Notes
      • TTY Issues
      • Timeout Protection
      • Resource Management
    • 🏥 Troubleshooting
      • use_cursor_doctor Checklist
      • Common Issues
      • Security FAQs
    • 📁 File Structure
    • 🔗 References
    • Changelog
      • v1.0.4 (2026-03-31)
      • v1.0.1 (2026-03-31)
      • v1.0.0 (2026-03-31)
  • 项目或源文件

相关 Skill

更多
Cursor CLI Cursor CLI 使用Cursor编辑器及Agent完成编码任务
OpenClaw Cursor Agent OpenClaw Cursor Agent 通过 OpenClaw 工具(基于 tmux 会话)管理长时间运行的 Cursor CLI 编码任务。在用户请求启动持久编码作业、检查...时使用。
cursor-agent cursor-agent 全面掌握 Cursor CLI 代理的技能,适用于各类软件工程任务(包含 2026 新功能及 tmux 自动化指南)
Agent CLI (Cursor + Qoder) Agent CLI (Cursor + Qoder) 代码编辑 CLI 工具集合:Cursor CLI(agent)和 Qoder CLI(qodercli),用于代码修改、重构、Code Review 及自动化代码任务。
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.