X Post logo

X Post

Community
terryso
x-post

Post on X (x.com / twitter.com) through the logged-in Ego Lite session. Login-check first and soft-fail with exit 2 when ego-browser is missing or x.com is logged out. Sends only with --yes after the draft is shown. Uses page.fetch CreateTweet, not the composer click path. Optional --image uploads up to 4 png/jpeg/webp files only after --yes. Reply is best-effort. Use when the user asks to tweet, post, reply, or attach images on X or Twitter from Ego.

Overview

Publisherterryso
Repositoryego-skills
Skill namex-post
Stars
34
Forks
3
Bundled files
32
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 32 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by terryso on GitHub. Read the source before you install it.

Installation

Install the X Post AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/terryso/ego-skills/tree/main/skills/x-post
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/terryso/ego-skills.git /tmp/ego-skills
mkdir -p .claude/skills
cp -r /tmp/ego-skills/skills/x-post .claude/skills/x-post
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable X Post in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads X Post on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so X Post is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

x-post

用 Ego Lite 里已经登录的 Chromium 会话往 X 发帖。主路径是 page.fetch 的 CreateTweet,不点「发帖」。

Post to X through the logged-in Ego Lite session. The primary path is page.fetch CreateTweet. Do not click the composer.

成功标准是 stdout 打出 https://x.com/<screen_name>/status/<id>。没有这条链接就不算成功。不要顺手点其它确认框。

Success is the status URL on stdout: https://x.com/<screen_name>/status/<id>. Do not click unrelated confirmations.

先装 Ego

先装 Ego Lite,保证 ego-browser 在 PATH。缺失则 soft-fail(退出码 2),不要改用 Playwright、Puppeteer 或云端浏览器。

Install Ego Lite and put ego-browser on PATH. If it is missing, soft-fail with exit 2. Do not switch to Playwright, Puppeteer, or a cloud browser.

每次发帖前:登录闸门(必做)

bash
node scripts/check-login.mjs
node scripts/check-login.mjs --keep
退出码含义Agent 做什么
0已登录把 login_tip 告诉用户,继续
2未登录 / 无 ego-browser展示 how_to_login / how_to_login_zh,停
1其它错误报告 JSON error,不要假装已经发出

auth_token 是 HttpOnly,只存在于浏览器 Cookie 罐。不要打印 Cookie,不要粘贴 Cookie,不要代填密码。

默认 finish({ keep: [] })。--keep 才把页面留着并 handOff()。

确认规则

没有 --yes 只打印草稿并退出码 3,不发送。Agent 必须把草稿给人看,等人确认后再加 --yes。

Without --yes the command prints the draft and exits 3. It does not send. Show that draft to the user. Add --yes only after they confirm.

命令

仓库根目录:

bash
node skills/x-post/scripts/check-login.mjs
node skills/x-post/scripts/post.mjs --text "..."
node skills/x-post/scripts/post.mjs --text "..." --yes
node skills/x-post/scripts/post.mjs --text "..." --reply-to <statusId> --yes
node skills/x-post/scripts/post.mjs --text "..." --yes --json
node skills/x-post/scripts/post.mjs --text "..." --image /absolute/path/to/image.png
node skills/x-post/scripts/post.mjs --text "..." --image /absolute/path/to/image.png --image /absolute/path/to/other.webp --yes --json
node skills/x-post/scripts/cleanup.mjs

已安装的技能目录里用 node scripts/...。

退出码含义
0已登录,或已发出并打印状态链接,或 cleanup 关掉了本机空间
3草稿已打印,拒绝发送
2未登录,或没有 ego-browser
1参数、上传、HTTP、GraphQL 或浏览器错误。先看 JSON 的 outcome,不要只看退出码

--json 打出摘要 JSON。不加 --json 且发送成功时,stdout 只有状态链接。

outcome 决定能不能再发。脚本自己不会发第二次 CreateTweet。

outcomesent含义Agent 做什么
senttrue响应里有 rest_id把状态链接给人。不要再发
not_submittedfalse请求没发出(缺 --yes 时是退出码 3;缺 transaction、图片不合格、上传失败也算)确定没发出。修原因之后才可以重新 --yes
rejectedfalse服务端明确拒绝(401、429、226、186、带 errors 的响应,以及其它 4xx JSON)definitely_unsent: true。不要自动重试
unknownnull超时、连接中断、空响应、非 JSON、没有 errors 的 5xx,或 HTTP 成功但没有 rest_id不是 sent: false。先按 verify_before_retry 到时间线核对是否已有这条帖。不要自动重发

definitely_unsent: false 且 outcome 为 unknown 时,退出码 1 只表示没确认成功,不表示没发出。

cleanup 只对任务空间 x-post 执行 finish({ keep: [] })。它不删帖。

回复

--reply-to 会在同一条 mutation 上加 variables.reply。2026-11-04 的实页 page.fetch 回复返回 GraphQL 226,没有验证成功。当尽力而为:失败就把错误给人,不要改去点回复框,不要重试。

短帖和长文

加权长度用 twitter-text v3 的 maxWeightedTweetLength(280)。不超过就发 CreateTweet。超过,或显式 --long,就发 CreateNoteTweet(2026-11-04 捕获)。普通 /compose/post 的长文就会走这条,不必打开 Articles。

CreateTweet 和 CreateNoteTweet 都带现算的 x-client-transaction-id。verification key 和 loading-x-anim 从 x.com 文档读。ondemand.s 和 main.*.js 的地址从文档或 performance 发现。字节谁先返回用谁:页面里已经加载的脚本;并行的 Node HTTPS(ECONNRESET 等中断会退避重试)和 Ego 浏览器网络。浏览器这条走 CDP Network.loadNetworkResource;该方法没有正文时,把 <script src> 插进当前 x.com 页面,再用 script 文本、performance resource、Page.getResourceContent 和 Network.getResponseBody 读取。check-login 刚结束时主页常常还没有 ondemand.s,所以短帖也会主动让浏览器去拉,而不是只读空缓存。page.fetch 不用于 abs.twimg.com(CORS 会得到 0 字节),也不为了热身去点作曲框。query id 来自这份 main.*.js。不要复用别的 GraphQL 请求上的 transaction id。长文仍在材料齐了之后打开 https://x.com/compose/post,等两秒,再发。两边都拿不到字节就退出码 1、sent: false,错误里写明缺什么。也可以传 --transaction-id。不要编一个假的。

成功仍然是 https://x.com/<screen_name>/status/<id>。长文的完整正文在 note_tweet.note_tweet_results.result.text;legacy.full_text 会被截断,不当成全文。

接口

queryId 会随 main.*.js 轮换。先从当前包里读对应的 operationName,读不到再用 2026-11-04 的捕获值:CreateTweet l4hk8uVGvR-a8kzQ4nOhPA,CreateNoteTweet seOZkIS8AysCGfPo6yYPVA。不要发明其它 query id。字段见 references/create-tweet.md。坑见 references/pitfalls.md。

没有 --image 时 media.media_entities 仍是 []。私信、点赞、关注不做。GraphQL 186 表示这条文本对短帖太长。

图片

--image <路径> 可重复,最多 4 张。只接受 png、jpeg、webp,每张不超过 5 MiB(5242880 字节)。GIF 不支持。文件是否存在、类型、大小和张数都在任何网络请求之前检查;不合格是退出码 1。没有 --yes 时草稿列出路径、字节数和 md5,不上传。加上 --yes 之后,在已登录的 x.com 页面里用 page.evaluate 走 upload.x.com 的 INIT → APPEND → FINALIZE,再把 media_id_string 放进 CreateTweet 或 CreateNoteTweet。不点「发帖」。细节见 references/media-upload.md。

Images

--image <path> is repeatable, up to 4 files. png, jpeg, and webp only, each at most 5 MiB (5242880 bytes). GIF is rejected. Existence, type, size, and count are checked before any network call; a bad file exits 1. Without --yes the draft lists path, bytes, and md5, and nothing is uploaded. With --yes, page.evaluate runs INIT → APPEND → FINALIZE on upload.x.com, then CreateTweet or CreateNoteTweet receives media_id_string. The script does not click Post. See references/media-upload.md.

Pro 冒烟(公告原文)

先 check-login(退出码 0)。把下面这段原文给人看,确认后再加 --yes。成功时 stdout 是 https://x.com/<screen_name>/status/<id>。不要删这条公告。

text
ego-skills x-post: post on X from a logged-in Ego Lite session (page.fetch CreateTweet). Login-check first. Nothing sends without --yes. https://github.com/terryso/ego-skills
bash
node skills/x-post/scripts/post.mjs --text "ego-skills x-post: post on X from a logged-in Ego Lite session (page.fetch CreateTweet). Login-check first. Nothing sends without --yes. https://github.com/terryso/ego-skills"
node skills/x-post/scripts/post.mjs --text "ego-skills x-post: post on X from a logged-in Ego Lite session (page.fetch CreateTweet). Login-check first. Nothing sends without --yes. https://github.com/terryso/ego-skills" --yes

测试

bash
npm test

npm test 用 c8 统计 scripts/lib/**/*.mjs(不含 ego-deps.mjs),行覆盖率不低于 80%。单测不访问 x.com。

Changelog

  • 0.2.1 — CreateTweet 发出之后如果超时、响应丢失或成功体不完整,outcome 是 unknown,sent 是 null。先核对时间线,不要自动重发。上传失败和请求没发出仍是 not_submitted / sent: false。图片上传自己的重试不变。
  • 0.2.0 — --image 可附最多 4 张 png/jpeg/webp(每张 ≤ 5 MiB)。上传按 2026-11-04 捕获的 upload.x.com INIT → APPEND → FINALIZE,在 page.evaluate 里执行。没有 --yes 不上传。GIF 不支持。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the X Post AI skill do?

Post on X (x.com / twitter.com) through the logged-in Ego Lite session. Login-check first and soft-fail with exit 2 when ego-browser is missing or x.com is logged out. Sends only with --yes after the draft is shown. Uses page.fetch CreateTweet, not the composer click path. Optional --image uploads up to 4 png/jpeg/webp files only after --yes. Reply is best-effort. Use when the user asks to tweet, post, reply, or attach images on X or Twitter from Ego.

Why use X Post on TypingMind?

Because you install it once and use it with any model. X Post is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install X Post in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/terryso/ego-skills/tree/main/skills/x-post. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use X Post?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with X Post?

As many as you like. As long as a model supports skills, you can use X Post with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the X Post AI skill free?

Yes. It is published on GitHub by terryso under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇