$npx -y skills add ECNU-ICALK/AutoSkill --skill baoyu-post-to-xPosts content and articles to X (Twitter). Supports regular posts with images/videos and X Articles (long-form Markdown). Uses real Chrome with CDP to bypass anti-automation. Use when user asks to "post to X", "tweet", "publish to Twitter", or "share on X".
| 1 | # Post to X (Twitter) |
| 2 | |
| 3 | Posts text, images, videos, and long-form articles to X via real Chrome browser (bypasses anti-bot detection). |
| 4 | |
| 5 | ## Script Directory |
| 6 | |
| 7 | **Important**: All scripts are located in the `scripts/` subdirectory of this skill. |
| 8 | |
| 9 | **Agent Execution Instructions**: |
| 10 | 1. Determine this SKILL.md file's directory path as `SKILL_DIR` |
| 11 | 2. Script path = `${SKILL_DIR}/scripts/<script-name>.ts` |
| 12 | 3. Replace all `${SKILL_DIR}` in this document with the actual path |
| 13 | |
| 14 | **Script Reference**: |
| 15 | | Script | Purpose | |
| 16 | |--------|---------| |
| 17 | | `scripts/x-browser.ts` | Regular posts (text + images) | |
| 18 | | `scripts/x-video.ts` | Video posts (text + video) | |
| 19 | | `scripts/x-quote.ts` | Quote tweet with comment | |
| 20 | | `scripts/x-article.ts` | Long-form article publishing (Markdown) | |
| 21 | | `scripts/md-to-html.ts` | Markdown → HTML conversion | |
| 22 | | `scripts/copy-to-clipboard.ts` | Copy content to clipboard | |
| 23 | | `scripts/paste-from-clipboard.ts` | Send real paste keystroke | |
| 24 | | `scripts/check-paste-permissions.ts` | Verify environment & permissions | |
| 25 | |
| 26 | ## Preferences (EXTEND.md) |
| 27 | |
| 28 | Use Bash to check EXTEND.md existence (priority order): |
| 29 | |
| 30 | ```bash |
| 31 | # Check project-level first |
| 32 | test -f .baoyu-skills/baoyu-post-to-x/EXTEND.md && echo "project" |
| 33 | |
| 34 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 35 | test -f "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md" && echo "user" |
| 36 | ``` |
| 37 | |
| 38 | ┌──────────────────────────────────────────────────┬───────────────────┐ |
| 39 | │ Path │ Location │ |
| 40 | ├──────────────────────────────────────────────────┼───────────────────┤ |
| 41 | │ .baoyu-skills/baoyu-post-to-x/EXTEND.md │ Project directory │ |
| 42 | ├──────────────────────────────────────────────────┼───────────────────┤ |
| 43 | │ $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md │ User home │ |
| 44 | └──────────────────────────────────────────────────┴───────────────────┘ |
| 45 | |
| 46 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 47 | │ Result │ Action │ |
| 48 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 49 | │ Found │ Read, parse, apply settings │ |
| 50 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 51 | │ Not found │ Use defaults │ |
| 52 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 53 | |
| 54 | **EXTEND.md Supports**: Default Chrome profile |
| 55 | |
| 56 | ## Prerequisites |
| 57 | |
| 58 | - Google Chrome or Chromium |
| 59 | - `bun` runtime |
| 60 | - First run: log in to X manually (session saved) |
| 61 | |
| 62 | ## Pre-flight Check (Optional) |
| 63 | |
| 64 | Before first use, suggest running the environment check. User can skip if they prefer. |
| 65 | |
| 66 | ```bash |
| 67 | npx -y bun ${SKILL_DIR}/scripts/check-paste-permissions.ts |
| 68 | ``` |
| 69 | |
| 70 | Checks: Chrome, profile isolation, Bun, Accessibility, clipboard, paste keystroke, Chrome conflicts. |
| 71 | |
| 72 | **If any check fails**, provide fix guidance per item: |
| 73 | |
| 74 | | Check | Fix | |
| 75 | |-------|-----| |
| 76 | | Chrome | Install Chrome or set `X_BROWSER_CHROME_PATH` env var | |
| 77 | | Profile dir | Ensure `~/.local/share/x-browser-profile` is writable | |
| 78 | | Bun runtime | `curl -fsSL https://bun.sh/install \| bash` | |
| 79 | | Accessibility (macOS) | System Settings → Privacy & Security → Accessibility → enable terminal app | |
| 80 | | Clipboard copy | Ensure Swift/AppKit available (macOS Xcode CLI tools: `xcode-select --install`) | |
| 81 | | Paste keystroke (macOS) | Same as Accessibility fix above | |
| 82 | | Paste keystroke (Linux) | Install `xdotool` (X11) or `ydotool` (Wayland) | |
| 83 | |
| 84 | ## References |
| 85 | |
| 86 | - **Regular Posts**: See `references/regular-posts.md` for manual workflow, troubleshooting, and technical details |
| 87 | - **X Articles**: See `references/articles.md` for long-form article publishing guide |
| 88 | |
| 89 | --- |
| 90 | |
| 91 | ## Regular Posts |
| 92 | |
| 93 | Text + up to 4 images. |
| 94 | |
| 95 | ```bash |
| 96 | npx -y bun ${SKILL_DIR}/scripts/x-browser.ts "Hello!" --image ./photo.png |
| 97 | ``` |
| 98 | |
| 99 | **Parameters**: |
| 100 | | Parameter | Description | |
| 101 | |-----------|-------------| |
| 102 | | `<text>` | Post content (positional) | |
| 103 | | `--image <path>` | Image file (repeatable, max 4) | |
| 104 | | `--profile <dir>` | Custom Chrome profile | |
| 105 | |
| 106 | **Note**: Script opens browser with content filled in. User reviews and publishes manually. |
| 107 | |
| 108 | --- |
| 109 | |
| 110 | ## Video Posts |
| 111 | |
| 112 | Text + video file. |
| 113 | |
| 114 | ```bash |
| 115 | npx -y bun ${SKILL_DIR}/scripts/x-video.ts "Check this out!" --video ./clip.mp4 |
| 116 | ``` |
| 117 | |
| 118 | **Parameters**: |
| 119 | | Parameter | Description | |
| 120 | |-----------|-------------| |
| 121 | | `<text>` | Post content (positional) | |
| 122 | | `--video <path>` | Video file (MP4, MOV, WebM) | |
| 123 | | `--profile <dir>` | Custom Chrome profile | |
| 124 | |
| 125 | **Note**: Script opens browser with content filled in. User rev |