Enable OpenClaw to execute Cursor CLI for various software engineering tasks, supporting interactive mode, background tasks, CI/CD, and more.
Before installing, understand these security implications:
~/.cursor/cli-config.json to check auth status (email redacted in output)Data AccessPurposeProtection~/.cursor/cli-config.jsonCheck auth statusEmail redacted (shows ***@domain.com)~/.cursor/credentialsCheck auth statusNot read, only existence checked$CURSOR_API_KEYOptional authNot logged or stored$PATH, $HOME, etc.Inherited by child processesNot modified or loggedtmux outputReturn task resultsMay contain workspace data
This skill sends user-provided strings into tmux panes via tmux send-keys.
How it works:
agent --print --trust 'TASK' in the paneRisk: 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:
EnvironmentRecommendationPersonal dev machine✅ Safe for normal projectsOpen source work✅ SafeCorporate environment⚠️ Review with security team firstProduction server❌ Not recommendedMachine with high-value secrets❌ Use isolated container/VM
-l flag) for all send-keys commands***@domain.com)always: false)ScenarioRecommended ModeDescriptionQuick tasksInteractiveDirect agent "task description"Long-running codingBackgroundtmux-managed, no timeoutCI/CD automationNon-interactiveagent -p + JSON outputCode reviewInteractive/BackgroundWith context analysisLarge refactoringBackgroundInterruptible, resumable
⚠️ Security Note: The following install commands use remote scripts. Review them first or use your package manager when possible.
macOS:
bash
# 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:
bash
# 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:
bash
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 authbash
agent login
# or set API key
export CURSOR_API_KEY=your_api_key_here
bash
# Ubuntu/Debian
sudo apt install tmux
# macOS
brew install tmux
# CentOS/RHEL
sudo yum install tmux
ToolDescriptionExampleuse_cursor_spawnStart background Cursor task (standard mode)use_cursor_spawn "refactor this module"``use_cursor_spawn_isolatedStart task with minimal environmentuse_cursor_spawn_isolated "task"``use_cursor_checkCheck task statususe_cursor_check session-name``use_cursor_sendSend additional instructionsuse_cursor_send session-name "make it async"``use_cursor_killEnd taskuse_cursor_kill session-name``use_cursor_listList all tasksuse_cursor_list``use_cursor_doctorDiagnose environmentuse_cursor_doctor
ModeScriptUse CaseStandardspawn.shNormal development, trusted tasksIsolatedspawn-isolated.shUntrusted inputs, shared machinesContainerDocker/PodmanMaximum isolation (manual setup)
text
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:
text
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>
text
User: Write a unit test for me
→ Call: use_cursor_run "write unit tests for src/utils.ts"
→ Wait for completion, return result
bash
# Start interactive session
agent
# Or with task directly
agent "fix this bug"
# Switch model
/models
# Add context
@src/api/
@src/models/
CommandDescriptionagentStart interactive sessionagent "task"Execute task directlyagent -p "task"Print mode (for scripts)agent --model <name>Specify modelagent --resume="<id>"Resume sessionagent lsList sessionsagent resumeResume most recent sessionagent modelsList available modelsagent updateUpdate CLI
CommandDescription/modelsSwitch models/compressCompress session history/rulesManage rules/commandsManage custom commands/mcp enable <server>Enable MCP server/mcp disable <server>Disable MCP server
ShortcutDescriptionShift+EnterNew lineCtrl+DExit (requires double-press)Ctrl+RReview changes↑/↓History messages
text
User (Discord/Feishu)
→ OpenClaw Agent
→ use_cursor_spawn tool
→ tmux session
→ Cursor CLI Agent
bash
# 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
bash
agent -p 'Review the changes in the current branch against main. Focus on security and performance.'
bash
agent -p 'Refactor src/utils.ts to reduce complexity and improve type safety.'
bash
agent -p 'Analyze the following error log and suggest a fix: [paste log here]'
bash
agent -p 'Generate a commit message for the staged changes adhering to conventional commits.'
bash
# 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
❌ These will hang:
bash
agent "task" # No TTY
agent -p "task" # No TTY
subprocess.run(["agent", ...]) # No TTY
✅ Correct approach:
bash
# Use tmux for pseudo-terminal
tmux new-session -d -s cursor
tmux send-keys -t cursor "agent 'task'" Enter
use_cursor_run directlyuse_cursor_kill to clean up completed tasksuse_cursor_doctor Checklist#Q: Task exits immediately after starting
Q: tmux session not found
use_cursor_list to check active sessionsQ: Garbled output
export LANG=en_US.UTF-8Q: Does this skill send my code to external servers?
Q: Can this skill access my Cursor API key?
$CURSOR_API_KEY is set, but doesn't log or transmit it.Q: Is my email address exposed?
***@domain.com in all outputs.Q: Can malicious input cause shell injection?
text
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
Version: 1.0.1 Merged from: cursor-agent (2.1.0) + openclaw-cursor-agent (1.0.0) Authors: Bruce + 凤雏 🦞 Skill Name: use-cursor
cd command now uses -l flag