Regular Posts - Detailed Guide
Detailed documentation for posting text and images to X.
Manual Workflow
If you prefer step-by-step control:
Step 0: Prefer Chrome Computer Use in Codex
When running inside Codex, first detect whether Chrome Computer Use is enabled:
- If Computer Use tools are already visible, call
get_app_stateforGoogle Chrome. - If not, use
tool_searchforcomputer-use get_app_state click press_key drag scroll Google Chrome, then callget_app_state. - If
get_app_statesucceeds, use the user's real Chrome with Computer Use for all X UI actions. - Use CDP scripts only when Computer Use is unavailable or explicitly requested.
If the user explicitly asks for Chrome Computer Use, do not use Playwright, the in-app Browser, or CDP without approval.
Step 1: Copy Image to Clipboard
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts image /path/to/image.pngStep 2: Paste from Clipboard
# Simple paste to frontmost app
${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts
# Paste to Chrome with retries
${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts --app "Google Chrome" --retries 5
# Quick paste with shorter delay
${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts --delay 200Step 3: Use Chrome Computer Use (Preferred)
- Use
get_app_stateforGoogle Chrome. - Navigate Chrome to
https://x.com/compose/postif needed. - Click the composer and type the post text.
- Copy each image to the clipboard with
copy-to-clipboard.ts image <path>. - Press
super+von macOS orcontrol+von Windows/Linux with Computer Use. - Wait until X finishes media upload.
- Ask for explicit confirmation before clicking
Post.
Image Support
- Formats: PNG, JPEG, GIF, WebP
- Max 4 images per post
- Images copied to system clipboard, then pasted via keyboard shortcut
Example Session
User: /post-to-x "Hello from Claude!" --image ./screenshot.png
Claude:
1. Detects Chrome Computer Use
2. Opens X compose in the user's real Chrome
3. Types text into editor
4. Copies image to clipboard and pastes with Computer Use
5. Waits for upload and verifies the preview
6. Asks before clicking PostTroubleshooting
- Chrome not found: Set
X_BROWSER_CHROME_PATHenvironment variable - Not logged in: First run opens Chrome - log in manually, cookies are saved
- Image paste fails:
- Verify clipboard script:
${BUN_X} {baseDir}/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
In Chrome Computer Use mode:
- Codex controls the user's visible Google Chrome window
- Text is typed through the real UI
- Images are copied to the system clipboard and pasted with real keystrokes
- The user confirms before the final public post
The x-browser.ts script is the CDP fallback. It uses Chrome DevTools Protocol (CDP) to:
- Launch real Chrome (not Playwright) with
--disable-blink-features=AutomationControlled - Use 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
osascript - Send real Cmd+V keystroke via
osascriptand System Events - Wait for upload to complete
This requires Terminal to have "Accessibility" permission in System Settings.