Regular Posts - Detailed Guide
Detailed documentation for posting text and images to X.
Manual Workflow
If you prefer step-by-step control:
Step 1: Copy Image to Clipboard
npx -y bun ${SKILL_DIR}/scripts/copy-to-clipboard.ts image /path/to/image.pngStep 2: Paste from Clipboard
# Simple paste to frontmost app
npx -y bun ${SKILL_DIR}/scripts/paste-from-clipboard.ts
# Paste to Chrome with retries
npx -y bun ${SKILL_DIR}/scripts/paste-from-clipboard.ts --app "Google Chrome" --retries 5
# Quick paste with shorter delay
npx -y bun ${SKILL_DIR}/scripts/paste-from-clipboard.ts --delay 200Step 3: Use Playwright MCP (if Chrome session available)
# Navigate
mcp__playwright__browser_navigate url="https://x.com/compose/post"
# Get element refs
mcp__playwright__browser_snapshot
# Type text
mcp__playwright__browser_click element="editor" ref="<ref>"
mcp__playwright__browser_type element="editor" ref="<ref>" text="Your content"
# Paste image (after copying to clipboard)
mcp__playwright__browser_press_key key="Meta+v" # macOS
# or
mcp__playwright__browser_press_key key="Control+v" # Windows/Linux
# Screenshot to verify
mcp__playwright__browser_take_screenshot filename="preview.png"Image Support
Formats: PNG, JPEG, GIF, WebP
Max 4 images per post
Images copied to system clipboard, then pasted via keyboard shortcut
Example Session
Troubleshooting
Chrome not found: Set
X_BROWSER_CHROME_PATHenvironment variableNot logged in: First run opens Chrome - log in manually, cookies are saved
Image paste fails:
Verify clipboard script:
npx -y bun ${SKILL_DIR}/scripts/copy-to-clipboard.ts image <path>On macOS, grant "Accessibility" permission to Terminal/iTerm in System Settings > Privacy & Security > Accessibility
Keep Chrome window visible and in front during paste operations
osascript permission denied: Grant Terminal accessibility permissions in System Preferences
Rate limited: Wait a few minutes before retrying
How It Works
The x-browser.ts script uses Chrome DevTools Protocol (CDP) to:
Launch real Chrome (not Playwright) with
--disable-blink-features=AutomationControlledUse persistent profile directory for saved login sessions
Interact with X via CDP commands (Runtime.evaluate, Input.dispatchKeyEvent)
Paste images using osascript (macOS): Sends real Cmd+V keystroke to Chrome, bypassing CDP's synthetic events that X can detect
This approach bypasses X's anti-automation detection that blocks Playwright/Puppeteer.
Image Paste Mechanism (macOS)
CDP's Input.dispatchKeyEvent sends "synthetic" keyboard events that websites can detect. X ignores synthetic paste events for security. The solution:
Copy image to system clipboard via Swift/AppKit (
copy-to-clipboard.ts)Bring Chrome to front via
osascriptSend real Cmd+V keystroke via
osascriptand System EventsWait for upload to complete
This requires Terminal to have "Accessibility" permission in System Settings.
Last updated