前端设计
- 作者仓库星标 21,713
- 叉子 2,492
- 作者更新于 2026年6月13日 05:00
- 作者仓库 baoyu-skills
- 领域
- 文档
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 92 / 100 · 已通过审计
- 作者 / 版本 / 许可
- @JimLiu · v1.58.1 · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需手动接入
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- Node.js · Bun
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 读取环境变量
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: baoyu-post-to-x
description: Posts content and articles to X (Twitter). Supports regular posts with images/videos and X Artic…
category: 文档
runtime: Node.js / Bun
---
# baoyu-post-to-x 输出预览
## PART A: 任务判断
- 适用问题:PRD、RFC、README、项目说明或知识库整理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Script Directory / Execution Mode Selection (Required) / Codex Chrome Plugin Mode”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于PRD、RFC、README、项目说明或知识库整理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Script Directory / Execution Mode Selection (Required) / Codex Chrome Plugin Mode”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、读取环境变量、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/tmp`、`/absolute` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令、读取环境变量。
先用一个小任务确认它会围绕“Script Directory / Execution Mode Selection (Required) / Codex Chrome Plugin Mode”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: baoyu-post-to-x
description: Posts content and articles to X (Twitter). Supports regular posts with images/videos and X Artic…
category: 文档
source: JimLiu/baoyu-skills
---
# baoyu-post-to-x
## 什么时候使用
- 把文章发到 X (Twitter) 时自动拆长 thread、配图、补 thread 链接句 适合处理README、PRD、RFC、教程和知识库文档,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把…
- 面向PRD、RFC、README、项目说明或知识库整理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Script Directory / Execution Mode Selection (Required) / Codex Chrome Plugin Mode」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "baoyu-post-to-x" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Script Directory / Execution Mode Selection (Required) / Codex Chrome Plugin Mode
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Node.js / Bun | 读取文件、写入/修改文件、执行终端命令、读取环境变量 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} 发布到 X (Twitter)
通过真实的 Chrome 浏览器向 X 发布文本、图片、视频和长篇文章。
在 Codex 中,不要混淆以下浏览器路径:
- Codex Chrome 插件 /
@chrome/ Chrome 扩展程序:使用捆绑的chrome:Chrome技能及其 Node REPL 浏览器客户端。当用户说「Codex Chrome 插件」、「Codex 自带的 Chrome 插件」、@chrome或类似词语时,需要使用此模式。 - Chrome 电脑使用:仅当用户要求「电脑使用」或未声明 Chrome 插件偏好且「电脑使用」可用时,才针对可见的 Google Chrome UI 使用
mcp__computer_use__.*。 - CDP 脚本模式:仅当所选模式不可用或用户明确要求 CDP/脚本模式时,才作为备用方案使用。
脚本目录
重要提示:所有脚本都位于此技能的 scripts/ 子目录中。
Agent 执行说明:
- 确定此 SKILL.md 文件的目录路径为
{baseDir} - 脚本路径 =
{baseDir}/scripts/<script-name>.ts - 将此文档中的所有
{baseDir}替换为实际路径 - 解析
${BUN_X}运行时:如果安装了bun→bun;如果npx可用 →npx -y bun;否则建议安装 bun
脚本参考:
| 脚本 | 用途 |
|---|---|
scripts/x-browser.ts |
常规帖子(文本 + 图片),CDP 备用 |
scripts/x-video.ts |
视频帖子(文本 + 视频),CDP 备用 |
scripts/x-quote.ts |
带评论的引用推文,CDP 备用 |
scripts/x-article.ts |
长篇文章发布(Markdown),CDP 备用 |
scripts/md-to-html.ts |
Markdown → HTML 转换 |
scripts/copy-to-clipboard.ts |
将内容复制到剪贴板 |
scripts/paste-from-clipboard.ts |
发送真实的粘贴按键 |
scripts/check-paste-permissions.ts |
验证环境和权限 |
执行模式选择(必填)
在与 X 交互之前,请选择且仅选择一种模式:
- 如果用户明确要求 Codex Chrome 插件、
@chrome、Chrome 扩展程序或「Codex 自带的 Chrome 插件」,请使用Codex Chrome 插件模式。不要首先调用「电脑使用」。 - 如果用户明确要求 Chrome 电脑使用,请使用Chrome 电脑使用模式。未经用户告知并获得批准,请勿回退到 CDP、Playwright、应用内浏览器或 Chrome 插件。
- 如果用户明确要求 CDP/脚本模式,请使用CDP 脚本模式。
- 否则,优先选择Chrome 电脑使用模式。对于带有本地内容图片的 Markdown X 文章,请使用经过测试的 X 编辑器流程:从工具栏(「插入」->「媒体」-> 对话框图标按钮「添加照片或视频」)插入每个正文图片到其占位符,然后删除占位符文本。仅当所选浏览器控制模式不可用或 UI 上传/选择流程不可靠时,才使用 CDP 脚本模式。
切勿将应用内浏览器用于 X 发布工作流程。
Codex Chrome 插件模式
当用户请求 Codex Chrome 插件、@chrome 或 Chrome 扩展程序路径时,请使用此模式。此模式通过捆绑的 Chrome 插件使用用户的真实 Chrome 配置文件和 X 登录,而不是「电脑使用」和 CDP。
设置
- 在浏览器工作之前加载
chrome:Chrome技能。 - 如果 Node REPL
js工具尚未可见,请使用tool_search查找node_repl js。 - 严格按照 Chrome 技能的规定初始化 Chrome 浏览器客户端,然后运行一个轻量级调用,例如
browser.user.openTabs(),以验证扩展程序连接。 - 如果第一次轻量级调用失败,请等待 2 秒并重试一次。如果仍然失败,请按照 Chrome 技能的扩展程序检查和恢复步骤进行操作。如果检查通过但通信仍然失败,请在打开新 Chrome 窗口之前询问用户。不要静默切换到「电脑使用」或 CDP。
通用规则
- 使用 Chrome 插件的
browser.tabs.*、tab.playwright.*、tab.cua.*和文件选择器 API 进行 X UI 操作。 - 允许使用 Shell 命令进行 Markdown 预处理和富 HTML 剪贴板准备。对于 X 文章正文图片,不要依赖图片剪贴板粘贴;请使用编辑器的「插入」->「媒体」上传流程。
- 如果文件上传失败并显示
Not allowed,请告知用户:「要启用文件上传,请在 Chrome 中转到chrome://extensions,点击 Codex 扩展程序下的『详细信息』,然后启用『允许访问文件网址』。有关详细信息,请参阅 https://developers.openai.com/codex/app/chrome-extension#upload-files。」 - 如果 Chrome 插件报告
native pipe is closed,请在 2 秒后重试一次轻量级浏览器调用,然后运行 Chrome 技能健康检查。如果 Chrome 正在运行,扩展程序已启用,并且原生主机清单正确,请请求权限打开新的 Chrome 窗口并重试。不要通过损坏的管道继续发送浏览器操作。 - 未经用户在当前对话中明确最终确认,切勿点击「发布」、「Post」或任何外部可见的提交操作。
X 文章
- 转换 Markdown 并保留图片映射:
${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --save-html /tmp/x-article-body.html > /tmp/x-article.json - 读取 JSON 输出以获取
title、coverImage和contentImages(placeholder→localPath)。 - 在
https://x.com/compose/articles打开或创建文章草稿。 - 使用 Chrome 插件文件选择器流程上传封面。如果上传被扩展程序权限阻止,请停止并报告上述确切的权限修复方法。
- 填写标题,然后复制富 HTML:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts html --file /tmp/x-article-body.html - 通过 Chrome 插件使用真实的粘贴按键粘贴到文章正文。在 macOS 上使用
Meta+V。 - 验证编辑器文本包含文章正文和
XIMGPH_占位符。在 shell 剪贴板写入后,不要依赖tab.clipboard.readText()作为系统剪贴板的证明;在 macOS 上,如果需要,请使用pbpaste进行验证。 - 对于占位符顺序中的每个
contentImages项:- 找到可见的占位符文本(
XIMGPH_N)并点击它以将光标置于此处。 - 打开工具栏菜单「插入」->「媒体」。
- 在模态框中,点击
aria-label="Add photos or video"的图标按钮;不要点击文本/拖放区或隐藏的文件输入。 - 使用文件选择器上传该图片的
localPath。 - 图片出现后,如果
XIMGPH_N仍在其上方,请先精确选择该占位符并按Delete。仅当Delete失败且所选文本被确认为精确的占位符时,才使用Backspace。 - 验证该
XIMGPH_N的占位符计数为0。
- 找到可见的占位符文本(
- 打开预览并验证标题、封面、正文、链接和图片。
- 在点击「发布」之前请求明确确认。
首选项 (EXTEND.md)
按优先级顺序检查 EXTEND.md — 找到的第一个生效:
| 优先级 | 路径 | 范围 |
|---|---|---|
| 1 | .baoyu-skills/baoyu-post-to-x/EXTEND.md |
项目 |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-x/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md |
用户主目录 |
如果未找到,则使用默认值。
EXTEND.md 支持:默认 Chrome 配置文件
先决条件
- Google Chrome 或 Chromium
bun运行时- 首次运行:手动登录 X(会话已保存)
飞行前检查(可选)
首次使用前,建议运行环境检查。用户如果愿意可以跳过。
${BUN_X} {baseDir}/scripts/check-paste-permissions.ts
检查项:Chrome、配置文件隔离、Bun、辅助功能、剪贴板、粘贴按键、Chrome 冲突。
如果任何检查失败,请根据项目提供修复指导:
| 检查项 | 修复方法 |
|---|---|
| Chrome | 安装 Chrome 或设置 X_BROWSER_CHROME_PATH 环境变量 |
| 配置文件目录 | baoyu-skills/chrome-profile 中的共享配置文件(参见 CLAUDE.md Chrome 配置文件部分) |
| Bun 运行时 | brew install oven-sh/bun/bun (macOS) 或 npm install -g bun |
| 辅助功能 (macOS) | 系统设置 → 隐私与安全性 → 辅助功能 → 启用终端应用程序 |
| 剪贴板复制 | 确保 Swift/AppKit 可用 (macOS Xcode CLI 工具: xcode-select --install) |
| 粘贴按键 (macOS) | 同上辅助功能修复 |
| 粘贴按键 (Linux) | 安装 xdotool (X11) 或 ydotool (Wayland) |
参考资料
- 常规帖子:请参阅
references/regular-posts.md获取手动工作流程、故障排除和技术细节 - X 文章:请参阅
references/articles.md获取长篇文章发布指南
Chrome 电脑使用模式
当用户明确要求 Chrome 电脑使用,或者未声明 Chrome 插件偏好且 Codex 可以通过「电脑使用」控制 Google Chrome 时,请使用此模式。此模式使用用户现有的 Chrome 窗口、cookie、登录、扩展程序和 X 会话。
通用规则:
- 每个控制 Chrome 的助手回合都通过调用
get_app_state获取Google Chrome的状态来开始。 - 优先使用元素索引操作(如果可用);仅在编辑器文本选择或拖动选择时使用坐标。
- 在此模式下,除非用户批准模式更改,否则不要使用应用内浏览器、Chrome 插件、Playwright 或 CDP 进行 X UI 操作。
- 未经用户在当前对话中明确最终确认,切勿点击「发布」、「Post」或任何外部可见的提交操作。
常规帖子:
- 打开或导航 Chrome 到
https://x.com/compose/post。 - 使用「电脑使用」在撰写器中输入帖子文本。
- 对于每张图片,运行:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts image /absolute/path/to/image.png - 使用「电脑使用」粘贴(macOS 上为
super+v,Windows/Linux 上为control+v),然后等待 X 完成媒体上传。 - 在点击「Post」之前请求确认。
视频帖子:
- 打开或导航 Chrome 到
https://x.com/compose/post。 - 在撰写器中输入帖子文本。
- 使用可见的媒体上传/文件选择器 UI 附加视频。
- 等待上传和处理完成。
- 在点击「Post」之前请求确认。
引用推文:
- 在 Chrome 中打开推文 URL。
- 使用可见的引用/转发 UI 选择「引用」。
- 输入评论。
- 在点击「Post」之前请求确认。
X 文章:
- 转换 Markdown 并保留图片映射:
${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --save-html /tmp/x-article-body.html > /tmp/x-article.json - 读取 JSON 输出以获取
title、coverImage和contentImages(placeholder→localPath)。 - 在 Chrome 中,打开
https://x.com/compose/articles,创建或打开草稿,如果存在则上传封面,并填写标题。 - 将富 HTML 复制到剪贴板:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts html --file /tmp/x-article-body.html - 使用「电脑使用」粘贴到文章正文。
- 对于占位符顺序中的每个
contentImages条目:- 找到精确的可见占位符文本,例如
XIMGPH_3,并点击它以设置插入点。 - 打开工具栏「插入」下拉菜单,选择「媒体」,然后点击模态框中标记为「添加照片或视频」的图标按钮。
- 使用原生文件选择器选择图片的
localPath。 - 等待图片块出现并完成任何上传活动。
- 如果占位符仍位于插入图片上方,请重新精确选择该占位符文本并首先按
Delete。仅当Delete失败且所选文本被确认为精确的占位符时,才使用Backspace。
- 找到精确的可见占位符文本,例如
- 验证没有
XIMGPH_占位符残留,并且显示了预期的图片。 - 打开预览并验证标题、封面、正文、链接和图片。
- 在点击「发布」之前请求明确确认。
如果「电脑使用」选择、工具栏上传或文件选择器控制变得不可靠,请停止并报告阻止程序,而不是静默切换到 Chrome 插件或 CDP。
CDP 脚本模式(备用)
仅当所选浏览器控制模式不可用、不可靠或未明确请求时,才使用以下脚本部分。这些脚本通过 CDP 启动或重用真实的 Chrome 实例,并保持浏览器打开以供审查。
当用户明确要求 Codex Chrome 插件或 Chrome 电脑使用时,除非用户在您解释阻止程序后批准回退,否则不要使用 CDP 脚本模式。
帖子类型选择
除非用户明确指定帖子类型:
- 纯文本 + 10,000 字符以内 → 常规帖子(高级会员支持最多 10,000 字符,非高级会员:280)
- Markdown 文件 (.md) → X 文章
常规帖子
${BUN_X} {baseDir}/scripts/x-browser.ts "Hello!" --image ./photo.png
参数:
| 参数 | 描述 |
|---|---|
<text> |
帖子内容(位置参数) |
--image <path> |
图片文件(可重复,最多 4 张) |
--profile <dir> |
自定义 Chrome 配置文件 |
注意:脚本会打开浏览器并填充内容。用户手动审查和发布。
Codex 模式注意:如果用户明确请求 Codex Chrome 插件,请使用Codex Chrome 插件模式。否则,如果启用了 Chrome 电脑使用,请使用Chrome 电脑使用模式,而不是运行 x-browser.ts。
视频帖子
文本 + 视频文件。
${BUN_X} {baseDir}/scripts/x-video.ts "Check this out!" --video ./clip.mp4
参数:
| 参数 | 描述 |
|---|---|
<text> |
帖子内容(位置参数) |
--video <path> |
视频文件(MP4、MOV、WebM) |
--profile <dir> |
自定义 Chrome 配置文件 |
注意:脚本会打开浏览器并填充内容。用户手动审查和发布。
Codex 模式注意:如果用户明确请求 Codex Chrome 插件,请使用Codex Chrome 插件模式。否则,如果启用了 Chrome 电脑使用,请使用Chrome 电脑使用模式,而不是运行 x-video.ts。
限制:常规最长 140 秒,高级最长 60 分钟。处理时间:30-60 秒。
引用推文
引用现有推文并添加评论。
${BUN_X} {baseDir}/scripts/x-quote.ts https://x.com/user/status/123 "Great insight!"
参数:
| 参数 | 描述 |
|---|---|
<tweet-url> |
要引用的 URL(位置参数) |
<comment> |
评论文本(位置参数,可选) |
--profile <dir> |
自定义 Chrome 配置文件 |
注意:脚本会打开浏览器并填充内容。用户手动审查和发布。
Codex 模式注意:如果用户明确请求 Codex Chrome 插件,请使用Codex Chrome 插件模式。否则,如果启用了 Chrome 电脑使用,请使用Chrome 电脑使用模式,而不是运行 x-quote.ts。
X 文章
长篇 Markdown 文章(需要 X Premium)。
${BUN_X} {baseDir}/scripts/x-article.ts article.md
${BUN_X} {baseDir}/scripts/x-article.ts article.md --cover ./cover.jpg
参数:
| 参数 | 描述 |
|---|---|
<markdown> |
Markdown 文件(位置参数) |
--cover <path> |
封面图片 |
--title <text> |
覆盖标题 |
Frontmatter:YAML front matter 中支持 title、cover_image。
Codex 模式注意:如果用户明确请求 Codex Chrome 插件,请遵循上述Codex Chrome 插件模式。如果用户明确请求 Chrome 电脑使用,请遵循Chrome 电脑使用模式。否则,优先使用 Chrome 电脑使用;对于带有本地内容图片的 Markdown 文章,请在使用工具栏「插入」->「媒体」图片上传工作流程后,再回退到CDP 脚本模式中的 x-article.ts。
CDP 回退注意:脚本会打开浏览器并填充文章内容。除非使用 --submit,否则用户必须手动审查和发布。
发布安全:除非用户明确确认最终的公开发布操作,否则不要使用 --submit 或点击「发布」。
撰写后检查:脚本会在所有图片插入后自动验证:
- 编辑器内容中剩余的
XIMGPH_占位符 - 预期与实际的图片数量
如果检查失败(输出中出现警告),请在用户发布之前向其提示具体问题。
故障排除
Chrome 调试端口未就绪
仅限 CDP 回退:如果脚本失败并显示 Chrome debug port not ready 或 Unable to connect,请先终止现有的 Chrome CDP 实例,然后重试:
pkill -f "Chrome.*remote-debugging-port" 2>/dev/null; pkill -f "Chromium.*remote-debugging-port" 2>/dev/null; sleep 2
重要提示:这应该自动完成——当遇到此错误时,终止 Chrome CDP 实例并重试命令,无需询问用户。
注意事项
- 首次运行:需要手动登录(会话会持久保存)
- 在 Codex Chrome 插件模式和 Chrome 电脑使用模式下,使用用户现有的 Chrome 会话,不要启动单独的 CDP 配置文件
- CDP 脚本默认只填充浏览器内容;除非明确使用
--submit,否则用户必须手动审查和发布 - 跨平台:macOS、Linux、Windows
扩展支持
通过 EXTEND.md 进行自定义配置。请参阅首选项部分了解路径和支持的选项。
Post to X (Twitter)
Posts text, images, videos, and long-form articles to X via a real Chrome browser.
In Codex, do not conflate these browser paths:
- Codex Chrome plugin /
@chrome/ Chrome Extension: use the bundledchrome:Chromeskill and its Node REPL browser client. This is required whenever the user says "Codex Chrome plugin", "Codex 自带的 Chrome 插件",@chrome, or similar. - Chrome Computer Use: use
mcp__computer_use__.*against the visible Google Chrome UI only when the user asks for Computer Use or no Chrome-plugin preference is stated and Computer Use is available. - CDP script mode: use only as a fallback when the selected mode is unavailable or the user explicitly asks for CDP/script mode.
Script Directory
Important: All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions:
- Determine this SKILL.md file's directory path as
{baseDir} - Script path =
{baseDir}/scripts/<script-name>.ts - Replace all
{baseDir}in this document with the actual path - Resolve
${BUN_X}runtime: ifbuninstalled →bun; ifnpxavailable →npx -y bun; else suggest installing bun
Script Reference:
| Script | Purpose |
|---|---|
scripts/x-browser.ts |
Regular posts (text + images), CDP fallback |
scripts/x-video.ts |
Video posts (text + video), CDP fallback |
scripts/x-quote.ts |
Quote tweet with comment, CDP fallback |
scripts/x-article.ts |
Long-form article publishing (Markdown), CDP fallback |
scripts/md-to-html.ts |
Markdown → HTML conversion |
scripts/copy-to-clipboard.ts |
Copy content to clipboard |
scripts/paste-from-clipboard.ts |
Send real paste keystroke |
scripts/check-paste-permissions.ts |
Verify environment & permissions |
Execution Mode Selection (Required)
Choose exactly one mode before interacting with X:
- If the user explicitly asks for the Codex Chrome plugin,
@chrome, the Chrome extension, or "Codex 自带的 Chrome 插件", use Codex Chrome Plugin Mode. Do not call Computer Use first. - If the user explicitly asks for Chrome Computer Use, use Chrome Computer Use Mode. Do not fall back to CDP, Playwright, the in-app Browser, or the Chrome plugin without telling the user and getting approval.
- If the user explicitly asks for CDP/script mode, use CDP Script Mode.
- Otherwise, prefer Chrome Computer Use Mode. For Markdown X Articles with local content images, use the tested X editor flow: insert each body image from the toolbar (
Insert->Media-> dialog icon buttonAdd photos or video) at its placeholder, then delete the placeholder text. Use CDP Script Mode only when the selected browser-control mode is unavailable or the UI upload/selection flow is unreliable.
Never use the in-app Browser for X publishing workflows.
Codex Chrome Plugin Mode
Use this mode whenever the user requests the Codex Chrome plugin, @chrome, or the Chrome Extension path. This uses the user's real Chrome profile and X login through the bundled Chrome plugin, not Computer Use and not CDP.
Setup
- Load the
chrome:Chromeskill before browser work. - Use
tool_searchfornode_repl jsif the Node REPLjstool is not already visible. - Initialize the Chrome browser client exactly as the Chrome skill specifies, then run a lightweight call such as
browser.user.openTabs()to verify the extension connection. - If the first lightweight call fails, wait 2 seconds and retry once. If it still fails, follow the Chrome skill's extension checks and recovery steps. If checks pass but communication still fails, ask the user before opening a new Chrome window. Do not switch to Computer Use or CDP silently.
General rules
- Use the Chrome plugin's
browser.tabs.*,tab.playwright.*,tab.cua.*, and file chooser APIs for X UI actions. - Shell commands are allowed for Markdown preprocessing and rich-HTML clipboard preparation. For X Article body images, do not rely on image clipboard paste; use the editor's
Insert->Mediaupload flow. - If a file upload fails with
Not allowed, tell the user:To enable file upload, go to chrome://extensions in Chrome, click Details under the Codex extension, and enable "Allow access to file URLs." See https://developers.openai.com/codex/app/chrome-extension#upload-files for details. - If the Chrome plugin reports
native pipe is closed, retry the lightweight browser call once after 2 seconds, then run the Chrome skill health checks. If Chrome is running, the extension is enabled, and the native host manifest is correct, ask permission to open a new Chrome window and retry. Do not keep sending browser actions through the broken pipe. - Never click
Publish,Post, or any externally visible submit action without explicit final confirmation from the user in the current conversation.
X Articles
- Convert Markdown and keep the image map:
${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --save-html /tmp/x-article-body.html > /tmp/x-article.json - Read the JSON output for
title,coverImage, andcontentImages(placeholder→localPath). - Open or create the article draft at
https://x.com/compose/articles. - Upload the cover with the Chrome plugin file chooser flow. If upload is blocked by extension permissions, stop and report the exact permission fix above.
- Fill the title, then copy rich HTML:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts html --file /tmp/x-article-body.html - Paste into the article body with a real paste keystroke through the Chrome plugin. On macOS use
Meta+V. - Verify the editor text contains the article body and
XIMGPH_placeholders. Do not rely ontab.clipboard.readText()as proof of the system clipboard after shell clipboard writes; on macOS verify withpbpasteif needed. - For each
contentImagesitem in placeholder order:- Locate the visible placeholder text (
XIMGPH_N) and click it to place the caret there. - Open the toolbar menu
Insert->Media. - In the modal, click the icon button with
aria-label="Add photos or video"; do not click the text/dropzone or hidden file input. - Use the file chooser to upload that image's
localPath. - After the image appears, if
XIMGPH_Nremains above it, select exactly that placeholder and pressDeletefirst. UseBackspaceonly ifDeletefails and the selected text is confirmed to be exactly the placeholder. - Verify the placeholder count for that
XIMGPH_Nis0.
- Locate the visible placeholder text (
- Open Preview and verify title, cover, body, links, and images.
- Ask for explicit confirmation before clicking
Publish.
Preferences (EXTEND.md)
Check EXTEND.md in priority order — the first one found wins:
| Priority | Path | Scope |
|---|---|---|
| 1 | .baoyu-skills/baoyu-post-to-x/EXTEND.md |
Project |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-x/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md |
User home |
If none found, use defaults.
EXTEND.md supports: Default Chrome profile
Prerequisites
- Google Chrome or Chromium
bunruntime- First run: log in to X manually (session saved)
Pre-flight Check (Optional)
Before first use, suggest running the environment check. User can skip if they prefer.
${BUN_X} {baseDir}/scripts/check-paste-permissions.ts
Checks: Chrome, profile isolation, Bun, Accessibility, clipboard, paste keystroke, Chrome conflicts.
If any check fails, provide fix guidance per item:
| Check | Fix |
|---|---|
| Chrome | Install Chrome or set X_BROWSER_CHROME_PATH env var |
| Profile dir | Shared profile at baoyu-skills/chrome-profile (see CLAUDE.md Chrome Profile section) |
| Bun runtime | brew install oven-sh/bun/bun (macOS) or npm install -g bun |
| Accessibility (macOS) | System Settings → Privacy & Security → Accessibility → enable terminal app |
| Clipboard copy | Ensure Swift/AppKit available (macOS Xcode CLI tools: xcode-select --install) |
| Paste keystroke (macOS) | Same as Accessibility fix above |
| Paste keystroke (Linux) | Install xdotool (X11) or ydotool (Wayland) |
References
- Regular Posts: See
references/regular-posts.mdfor manual workflow, troubleshooting, and technical details - X Articles: See
references/articles.mdfor long-form article publishing guide
Chrome Computer Use Mode
Use this mode when the user explicitly asks for Chrome Computer Use, or when no Chrome-plugin preference is stated and Codex can control Google Chrome with Computer Use. This uses the user's existing Chrome window, cookies, login, extensions, and X session.
General rules:
- Start each assistant turn that controls Chrome by calling
get_app_stateforGoogle Chrome. - Prefer element-index actions when available; use coordinates only for editor text selection or drag selection.
- Do not use the in-app Browser, the Chrome plugin, Playwright, or CDP for X UI actions in this mode unless the user approves a mode change.
- Never click
Publish,Post, or any externally visible submit action without an explicit final confirmation from the user in the current conversation.
Regular posts:
- Open or navigate Chrome to
https://x.com/compose/post. - Type the post text into the composer using Computer Use.
- For each image, run:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts image /absolute/path/to/image.png - Paste with Computer Use (
super+von macOS,control+von Windows/Linux), then wait until X finishes uploading media. - Ask for confirmation before clicking
Post.
Video posts:
- Open or navigate Chrome to
https://x.com/compose/post. - Type the post text into the composer.
- Use the visible media upload/file picker UI to attach the video.
- Wait for upload and processing to complete.
- Ask for confirmation before clicking
Post.
Quote tweets:
- Open the tweet URL in Chrome.
- Use the visible quote/repost UI to choose Quote.
- Type the comment.
- Ask for confirmation before clicking
Post.
X Articles:
- Convert Markdown and keep the image map:
${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --save-html /tmp/x-article-body.html > /tmp/x-article.json - Read the JSON output for
title,coverImage, andcontentImages(placeholder→localPath). - In Chrome, open
https://x.com/compose/articles, create or open the draft, upload the cover if present, and fill the title. - Copy rich HTML to the clipboard:
${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts html --file /tmp/x-article-body.html - Paste into the article body with Computer Use.
- For each
contentImagesentry in placeholder order:- Locate the exact visible placeholder text such as
XIMGPH_3and click it to set the insertion point. - Open the toolbar
Insertdropdown, chooseMedia, then click the modal's icon button labeledAdd photos or video. - Use the native file picker to choose the image's
localPath. - Wait until the image block appears and any upload activity is finished.
- If the placeholder remains above the inserted image, reselect exactly that placeholder text and press
Deletefirst. UseBackspaceonly ifDeletefails and the selected text is confirmed to be exactly the placeholder.
- Locate the exact visible placeholder text such as
- Verify no
XIMGPH_placeholders remain and the expected images appear. - Open Preview and verify title, cover, body, links, and images.
- Ask for explicit confirmation before clicking
Publish.
If Computer Use selection, toolbar upload, or file-picker control becomes unreliable, stop and report the blocker instead of switching to the Chrome plugin or CDP silently.
CDP Script Mode (Fallback)
Use the script sections below only when the selected browser-control mode is unavailable, unreliable, or explicitly not requested. These scripts launch or reuse a real Chrome instance via CDP and keep the browser open for review.
Do not use CDP Script Mode when the user explicitly requires the Codex Chrome plugin or Chrome Computer Use unless the user approves the fallback after you explain the blocker.
Post Type Selection
Unless the user explicitly specifies the post type:
- Plain text + within 10,000 characters → Regular Post (Premium members support up to 10,000 characters, non-Premium: 280)
- Markdown file (.md) → X Article
Regular Posts
${BUN_X} {baseDir}/scripts/x-browser.ts "Hello!" --image ./photo.png
Parameters:
| Parameter | Description |
|---|---|
<text> |
Post content (positional) |
--image <path> |
Image file (repeatable, max 4) |
--profile <dir> |
Custom Chrome profile |
Note: Script opens browser with content filled in. User reviews and publishes manually.
Codex mode note: If the user explicitly requested the Codex Chrome plugin, use Codex Chrome Plugin Mode. Otherwise, if Chrome Computer Use is enabled, use Chrome Computer Use Mode instead of running x-browser.ts.
Video Posts
Text + video file.
${BUN_X} {baseDir}/scripts/x-video.ts "Check this out!" --video ./clip.mp4
Parameters:
| Parameter | Description |
|---|---|
<text> |
Post content (positional) |
--video <path> |
Video file (MP4, MOV, WebM) |
--profile <dir> |
Custom Chrome profile |
Note: Script opens browser with content filled in. User reviews and publishes manually.
Codex mode note: If the user explicitly requested the Codex Chrome plugin, use Codex Chrome Plugin Mode. Otherwise, if Chrome Computer Use is enabled, use Chrome Computer Use Mode instead of running x-video.ts.
Limits: Regular 140s max, Premium 60min. Processing: 30-60s.
Quote Tweets
Quote an existing tweet with comment.
${BUN_X} {baseDir}/scripts/x-quote.ts https://x.com/user/status/123 "Great insight!"
Parameters:
| Parameter | Description |
|---|---|
<tweet-url> |
URL to quote (positional) |
<comment> |
Comment text (positional, optional) |
--profile <dir> |
Custom Chrome profile |
Note: Script opens browser with content filled in. User reviews and publishes manually.
Codex mode note: If the user explicitly requested the Codex Chrome plugin, use Codex Chrome Plugin Mode. Otherwise, if Chrome Computer Use is enabled, use Chrome Computer Use Mode instead of running x-quote.ts.
X Articles
Long-form Markdown articles (requires X Premium).
${BUN_X} {baseDir}/scripts/x-article.ts article.md
${BUN_X} {baseDir}/scripts/x-article.ts article.md --cover ./cover.jpg
Parameters:
| Parameter | Description |
|---|---|
<markdown> |
Markdown file (positional) |
--cover <path> |
Cover image |
--title <text> |
Override title |
Frontmatter: title, cover_image supported in YAML front matter.
Codex mode note: If the user explicitly requested the Codex Chrome plugin, follow Codex Chrome Plugin Mode above. If the user explicitly requested Chrome Computer Use, follow Chrome Computer Use Mode. Otherwise, prefer Chrome Computer Use; for Markdown articles with local content images, use the toolbar Insert -> Media image-upload workflow before falling back to x-article.ts in CDP Script Mode.
CDP fallback note: The script opens browser with article filled in. User reviews and publishes manually unless --submit is used.
Publish safety: Do not use --submit or click Publish unless the user explicitly confirms the final public publish action.
Post-Composition Check: The script automatically verifies after all images are inserted:
- Remaining
XIMGPH_placeholders in editor content - Expected vs actual image count
If the check fails (warnings in output), alert the user with the specific issues before they publish.
Troubleshooting
Chrome debug port not ready
CDP fallback only: if a script fails with Chrome debug port not ready or Unable to connect, kill existing Chrome CDP instances first, then retry:
pkill -f "Chrome.*remote-debugging-port" 2>/dev/null; pkill -f "Chromium.*remote-debugging-port" 2>/dev/null; sleep 2
Important: This should be done automatically — when encountering this error, kill Chrome CDP instances and retry the command without asking the user.
Notes
- First run: manual login required (session persists)
- In Codex Chrome Plugin Mode and Chrome Computer Use Mode, use the user's existing Chrome session and do not launch a separate CDP profile
- CDP scripts only fill content into the browser by default; user must review and publish manually unless
--submitis explicitly used - Cross-platform: macOS, Linux, Windows
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核