Skip to main content
Clear all content from the macOS system clipboard (pasteboard), leaving it empty.

Usage

agent-desktop clipboard-clear

Parameters

This command takes no parameters.

Response

cleared
boolean
required
Always true if the operation succeeded

Examples

Clear Clipboard

agent-desktop clipboard-clear
{
  "version": "1.0",
  "ok": true,
  "command": "clipboard-clear",
  "data": {
    "cleared": true
  }
}

Verify Clipboard is Empty

agent-desktop clipboard-clear
agent-desktop clipboard-get
{
  "version": "1.0",
  "ok": true,
  "command": "clipboard-get",
  "data": {
    "text": ""
  }
}

Use Cases

Clear clipboard after copying sensitive information:
# Copy password to clipboard
agent-desktop clipboard-set "secret-password"

# Paste into password field
agent-desktop click @e5
agent-desktop press cmd+v

# Clear clipboard immediately
agent-desktop clipboard-clear
Ensure clipboard starts empty before operations:
# Clear any existing clipboard content
agent-desktop clipboard-clear

# Perform copy operation
agent-desktop click @e3
agent-desktop press cmd+c

# Read copied content
agent-desktop clipboard-get
Clear clipboard to prevent users from pasting old content:
# After automated workflow
agent-desktop clipboard-clear

# Now cmd+v will paste nothing
Clear clipboard when locking screen or ending session:
# Before locking screen
agent-desktop clipboard-clear
osascript -e 'tell application "System Events" to keystroke "q" using {control down, command down}'

Clipboard Behavior

  • All data types cleared: Removes text, images, files, and any other clipboard content
  • System-wide effect: Affects all applications immediately
  • Permanent: Content cannot be recovered after clearing
  • Idempotent: Safe to call multiple times; no error if clipboard is already empty

Security Considerations

Clearing the clipboard is important for security when handling sensitive data:
  • Passwords: Always clear clipboard after pasting passwords
  • API keys: Clear after pasting tokens or credentials
  • Personal information: Clear after handling PII (emails, phone numbers, addresses)
  • Temporary data: Clear after automated workflows to avoid leaking intermediate values

Permissions

Clearing the clipboard requires macOS accessibility permission. If permission is not granted, the command will return a PERM_DENIED error:
{
  "version": "1.0",
  "ok": false,
  "command": "clipboard-clear",
  "error": {
    "code": "PERM_DENIED",
    "message": "Accessibility permission not granted",
    "suggestion": "Open System Settings > Privacy & Security > Accessibility and add your terminal app"
  }
}

Notes

  • The operation is synchronous and completes immediately
  • After clearing, clipboard-get will return an empty string
  • Clearing the clipboard does not affect clipboard history in apps that maintain it (e.g., Alfred, Paste)
  • This command is faster than clipboard-set "" and more explicit in intent

Build docs developers (and LLMs) love