x-composer

Original🇺🇸 English
Translated
2 scripts

Compose and post to X.com using Chrome CDP automation. Use when user asks to "post to X", "tweet", "draft a tweet", "share on X", or "write a thread". Handles Chrome launch, text input with emoji/unicode support, and multi-paragraph formatting via real browser automation (no API costs, bypasses anti-bot detection).

7installs
Added on

NPX Install

npx skill4agent add junghoonghae/skills x-composer

Tags

Translated version includes tags in frontmatter

X Composer

Post to X.com via Chrome DevTools Protocol (CDP). Uses real Chrome to bypass anti-bot detection.

Prerequisites

  • Google Chrome installed
  • chrome-remote-interface
    npm package
Install if missing:
bash
npm install -g chrome-remote-interface

Workflow

Posting to X involves these steps:
  1. Launch Chrome with CDP (run
    scripts/cdp-launch.js
    )
  2. Wait for X.com compose page to load (~3s)
  3. Type draft text (run
    scripts/cdp-type.js
    )
  4. User reviews and clicks Post manually

Step 1: Launch Chrome

Run
scripts/cdp-launch.js
with optional URL argument:
bash
NODE_PATH=$(npm root -g) node scripts/cdp-launch.js
URLPurpose
(default)
https://x.com/compose/post
https://x.com/home
Open home feed
https://x.com/search?q=QUERY&f=live
Search posts
Reuses existing Chrome CDP instance if running. First run requires manual X.com login — session persists in
~/.chrome-cdp-profile
.
Wait ~3 seconds after launch before typing.

Step 2: Type Draft

Pipe JSON segments to
scripts/cdp-type.js
via stdin:
bash
echo '[{"text":"Hello world!"}]' | NODE_PATH=$(npm root -g) node scripts/cdp-type.js

Segment Format

SegmentEffect
{"text": "string"}
Insert text (emoji/unicode safe)
{"enter": true}
Single line break
{"enter": 2}
Multiple line breaks

Example: Multi-paragraph post

bash
cat << 'EOF' | NODE_PATH=$(npm root -g) node scripts/cdp-type.js
[
  {"text": "Hook line with emoji"},
  {"enter": 2},
  {"text": "Main content paragraph."},
  {"enter": 2},
  {"text": "- Point one"},
  {"enter": true},
  {"text": "- Point two"},
  {"enter": 2},
  {"text": "https://example.com"},
  {"enter": true},
  {"text": "#hashtag #tags"}
]
EOF

Step 3: User Posts

Draft is entered in browser. User reviews and clicks "Post" manually. Never auto-post.

Troubleshooting

IssueFix
Chrome not connecting
pkill -f "Chrome.*remote-debugging"
then relaunch
No X.com tab foundLaunch Chrome first, wait 3s
Text not typingClick compose box in browser first
Module not found
npm install -g chrome-remote-interface
Login requiredUse default profile path (
~/.chrome-cdp-profile
), login once

Notes

  • NODE_PATH=$(npm root -g)
    resolves globally installed
    chrome-remote-interface
  • Input.insertText()
    handles emoji/unicode reliably (not character-by-character)
  • Fixed
    --user-data-dir
    preserves login across Chrome restarts
  • If text appears scrambled, restart Chrome and retry