SuperAPI AI Directory

post-to-xhs

Marketing & growth

View repository

Updated 10-16 01:30

About this skill

Xiaohongshu content publishing

Automatically determine the publishing method and publishing mode based on user input, simplifying the publishing process.

Publishing mode

  • Upload image and text(default): image + short text, suitable for daily sharing
  • Write long article: long article + layout template selection, suitable for in-depth content. Use when the user explicitly says "post a long article"

Workflow

用户输入
    │
    ├─ 完整内容 + 图片/图片URL → 判断模式 → 发布流程
    │
    └─ 网页 URL → WebFetch 提取内容和图片
                      │
                      ├─ 有图片 → 适当总结内容 → 判断模式 → 发布流程
                      │
                      └─ 无图片 → 提示用户手动下载图片
                                  │
                                  └─ 用户提供图片后 → 发布流程

Step 1: Determine input type

Determine based on user input:

  • Complete content mode: the user provided a title, body content, and images (local path or URL)
  • URL extraction mode: the user provided only a webpage URL

If uncertain, ask the user.

Step 2: Process content

Complete content mode

Directly use the title and body provided by the user, and skip to Step 3.

URL extraction mode

  1. Use WebFetch to extract webpage content
  2. Extract key information: title, body, image URLs
  3. Summarize the content appropriately, keeping:
    • Complete key information
    • Natural and fluent language
    • Suitable for Xiaohongshu reading habits

Handling image extraction failure

If no image URL can be extracted from the webpage, or the image URL is inaccessible,must:

  1. inform the user that image extraction failed
  2. provide the original webpage link and ask the user to visit it manually
  3. Guide the user:
    • Open the original webpage in a browser
    • Right-click the desired image → "Save image as" or "Copy image address"
    • Provide me with the saved image path or the copied image URL
  4. Wait for the user to provide images before continuing the publishing process

Example prompt:

从网页中未能提取到可用的图片。请手动获取:

1. 打开原文链接:[URL]
2. 找到合适的配图,右键另存为本地,或复制图片地址
3. 将图片路径或URL发给我

拿到图片后我们继续发布。

Step 3: Content check

Title check

Title length must be ≤ 38. Calculation rules:

  • Chinese characters and Chinese punctuation (《》, ,。 etc.): each counts as 2
  • English letters/numbers/spaces/ASCII punctuation: each counts as 1

If it is too long, automatically generate a new title that meets the length requirement while keeping the semantics consistent.

Body format

  • Use double line breaks to separate paragraphs
  • Natural language, avoid a machine-translation feel
  • Simplified Chinese

Step 4: Publish to Xiaohongshu

Complete publishing process reference: references/publish-workflow.md

4.1 User confirms content

Through AskUserQuestion show the user the content about to be published (title, body, images), and continue only after obtaining explicit confirmation.

4.2 Select publishing mode

Through AskUserQuestion let the user choose the publishing mode:

  • Headless mode(recommended): runs in the background, fast, no browser window. Report the result directly after publishing is complete.
  • Windowed mode:Display the browser window so the content can be previewed. User confirmation is required before clicking publish.
AskUserQuestion 示例:
问题:选择发布模式
选项:
  - 无头模式(推荐):后台快速发布,无需预览
  - 有窗口模式:显示浏览器,可预览确认

4.3 Write to a temporary file

Write the title and body to a temporary UTF-8 text file. Do not inline Chinese text in python -c .

4.4 Run publish (branch by mode)

A. Upload image-and-text mode (default)

Run the publish script according to the mode selected by the user:

Headless mode(add --headless parameter):

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\publish_pipeline.py" --headless --title-file title.txt --content-file content.txt --image-urls "URL1" "URL2"

Windowed mode(do not add --headless):

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\publish_pipeline.py" --title-file title.txt --content-file content.txt --image-urls "URL1" "URL2"

Other parameters:

# 发布到指定账号
python ... --account myaccount ...

# 使用本地图片
python ... --images "C:\path\to\image.jpg"

Handle the output:

  • NOT_LOGGED_IN (exit code 1) → the script automatically switches to windowed mode, prompts the user to scan the QR code to log in, and reruns after confirmation
  • READY_TO_PUBLISH (exit code 0) → proceed to the next step according to the mode
  • Exit code 2 → report an error

B. Write long-form article mode

Step B.1 — Fill in the long-form article content + one-click formatting:

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" long-article --title-file title.txt --content-file content.txt

Optional --images img1.jpg img2.jpg insert images into the editor.

The output includes TEMPLATES: [...] JSON array, which is the list of available formatting template names.

Step B.2 — Let the user choose a template:

Use AskUserQuestion to present the template names as options for the user to choose from (parsed from the TEMPLATES output).

Step B.3 — Select a template:

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" select-template --name "用户选择的模板名"

Step B.4 — Click Next and fill in the body description on the publish page:

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-next-step --content-file content.txt

Note: The publish page has an independent body description editor, and the content must be filled in via --content or --content-file pass in the content to fill in. If the body exceeds 1000 characters, it should be compressed to around 800 characters before filling it in, keeping the meaning unchanged.

Step B.5 — User previews, confirms, and publishes: Proceed to step 4.5 below.

4.5 User preview confirmation (windowed mode / long-form mode only)

Only when the user selects windowed mode or uses long-form mode, use AskUserQuestion to ask the user to check the preview in the browser, and publish only after confirmation.

Image-and-text publishing in headless mode skips this step and proceeds directly to 4.6.

4.6 Click Publish

Click the publish button:

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" click-publish

4.7 Report the result

Tell the user whether publishing succeeded based on the command output.

Important notes

  • Never publish automatically - user confirmation must be obtained
  • Image requirements - Upload image-and-text mode must have images; long-form article mode images are optional
  • Long-form mode - the user must choose the template; do not choose automatically
  • Body description - the publish page in long-form mode has an independent body description box; if it exceeds 1000 characters, it must be compressed to around 800 characters
  • Headless mode: use --headless parameter to automate publishing. If login is required, the script automatically switches to windowed mode
  • If page structure changes cause selectors to fail, refer to references/publish-workflow.md update

Account management

The system supports multiple Xiaohongshu accounts, and each account has an independent Chrome profile.

List accounts

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" list-accounts

Add account

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" add-account myaccount --alias "我的账号"

Login

# 默认账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" login

# 指定账号
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" --account myaccount login

Switch account

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" switch-account
python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" --account otheraccount switch-account

Set default account

python "C:\Users\admin\AI\.claude\skills\post-to-xhs\scripts\cdp_publish.py" set-default-account myaccount