Communitygithub.com

xhs-publish — Xiaohongshu Full-Auto Publish

Drives a logged-in Xiaohongshu Creator Center to automatically complete the entire workflow: switch to graph mode, upload cover + multiple images, fill title/body, add topics, click publish, and track audit status. Packaged as a Hermes tool (`xhs_publish`) and a standalone script, without modifying the main Hermes agent.

What is xhs-publish — Xiaohongshu Full-Auto Publish?

This skill fully automates publishing notes to Xiaohongshu (XHS) by controlling a logged-in browser session via CDP (Chrome DevTools Protocol). It reads upstream artifacts (title, body, topics, images) and validates them before execution. The core workflow involves switching to image-text mode, uploading a cover and up to six images, filling the title (≤20 characters) and body (without topic lines or external links), adding up to 5 topics, clicking publish, and then tracking the audit status (pending/approved/rejected). It is available as a Hermes tool (`xhs_publish`) for seamless integration with the Hermes agent, or as a standalone Python script for direct usage and debugging. The skill also includes a companion tool (`xhs_enrich_stills`) to download high-resolution stills from TMDB and optionally attach them to published notes. It runs on Windows with Microsoft Edge 143+ and requires Node.js 22+ for the CDP proxy. The skill enforces strict content compliance rules, particularly against external promotion (e.g., references to WeChat, Taobao, etc.), and provides detailed guidance on optimal title and body structure for high engagement. It is designed for scenarios like promoting films, events, or any content requiring automated multi-image posting to Xiaohongshu.

Works with✓Claude Code✓Codex CLI~Cursor
npx skills add Natsummerance/skills

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does xhs-publish — Xiaohongshu Full-Auto Publish do?

Drives a logged-in Xiaohongshu Creator Center to automatically complete the entire workflow: switch to graph mode, upload cover + multiple images, fill title/body, add topics, click publish, and track audit status. Packaged as a Hermes tool (xhs_publish) and a standalone script, without modifying the main Hermes agent.

Codex Artifact Interface

Preferentially reads artifacts/metadata.json generated by the upstream github-promo-post:

  • title: Platform title, must be ≤20 characters;
  • body: Must not contain topic lines, real URLs, or external traffic-driving links;
  • topics: 5 topics without #;
  • images: 6 absolute paths, order fixed as cover to CTA;
  • version_state: Records whether the version is official Release, update line, or preparation.

Before publishing, never fabricate titles, body, topics, or images on your own; if a field is missing, return a list of missing fields.

Automated Publishing Workflow (Codex)

  1. Read the upstream artifacts/metadata.json and run github-promo-post/scripts/validate_artifacts.py <artifacts>; if it fails, stop.
  2. After the user explicitly requests publishing, execute a single command: publish --bootstrap-edge --restart-edge. It will close all Edge windows and start Edge 143's CDP using the default logged-in profile; never create a --user-data-dir temporary profile.
  3. --restart-edge is only used when CDP is not ready or needs to be rebuilt. It will close the user's Edge and must only be used when the user has explicitly authorized publishing and is aware of the impact.
  4. The script completes input validation, login check, six-image upload, body/topic filling, publishing, and URL success determination; then queries the audit status by title. Only returns the platform's actual status or a true error.
  5. If version_state is not an official Release, keep the wording "update line/preparation" and do not change it to "published".

Prefer using the native xhs_publish tool; only call scripts/xhs_publish.py inside this skill when the tool is unavailable. Using --force to bypass sensitive word or platform validation is prohibited.

When to Use

  • User says "publish a Xiaohongshu note", "send out this note", "publish XX movie notes"
  • Multiple images need to be attached to a Xiaohongshu note (cover + movie posters/stills)
  • Need to query the audit status of a note (pending/approved/rejected)

Prerequisites (One-Time)

  1. Browser Debug Port: Edge 143+ does not have the chrome://inspect switch; use startup parameters:
    $flag = "--remote-allow-origins=*"
    & "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "--remote-debugging-port=9222" "--remote-allow-origins=*"
    
    If the proxy reports "not connected", start the browser first then call the tool; the proxy will auto-reconnect.
  2. CDP Proxy: Z:\Natsumer\.codex\skills\web-access\scripts\cdp-proxy.mjs must be running on port 3456.
    • Edge 143 Compatibility Patch: The discoverChromePort() fallback branch of the proxy has been modified to get the real wsPath from /json/version (bare /devtools/browser will return 404). The web-access update may overwrite this patch; if you encounter 404, reapply the patch.
  3. Login Status: The browser must be logged into creator.xiaohongshu.com (login is done manually by the user; do not type passwords on their behalf).
  4. Risk Notice (display to the user before each automation):

    Some sites strictly detect browser automation, posing a risk of account ban. Protective measures are built-in but cannot be completely avoided.

Usage

Method A: Hermes Tool (Recommended)

The xhs_publish tool is registered into the hermes-cli toolset by the plugins/xhs-publish plugin. It is a non-core plugin tool, lazy-loaded by the Tool Search progressive disclosure mechanism by default: the main schema only has three bridge tools (tool_search/tool_describe/tool_call). When the user asks to "publish a Xiaohongshu", first tool_search searches for xhs_publish, then calls it with tool_call (consistent with spotify/MCP tools).

Example call:

{"action": "publish", "title": "...", "body": "...", "cover": "C:/.../cover.png",
 "images": ["C:/.../poster1.jpg"], "topics": ["Herzog", "China Film Archive"]}
  • action: publish (full auto-publish) / update (edit a published note, requires note_id, modify title/body/topics then republish) / draft (fill only, no publish) / status (check status, with note_title or note_id) / login / tabs
  • body should not contain topic lines (#xxx #yyy), topics are passed uniformly via topics; the script automatically strips pure-topic lines at the end of the body.
  • Title hard limit ≤20 characters (including punctuation), exceeding will be blocked by the platform (toast: "Title can be up to 20 characters~").

Method B: Direct Command Line (Standard Artifact)

$a = 'C:/.../artifacts'
python C:/.../github-promo-post/scripts/validate_artifacts.py $a
python scripts\xhs_publish.py publish --bootstrap-edge --restart-edge `
  --title-file "$a/title.txt" --body-file "$a/body.txt" `
  --cover "$a/images/xhs-01-cover.jpg" `
  --image "$a/images/xhs-02-pain.jpg" --image "$a/images/xhs-03-fast.jpg" `
  --image "$a/images/xhs-04-fix.jpg" --image "$a/images/xhs-05-convert.jpg" --image "$a/images/xhs-06-cta.jpg" `
  --topic "GitHub" --topic "Open Source" --topic "Programmer" --topic "Productivity Tools" --topic "Markdown"
python scripts\xhs_publish.py status --note-title "Title"

bootstrap can be run independently for diagnosis: python scripts\xhs_publish.py bootstrap; if the port is not ready and the user has authorized to close Edge, run bootstrap --restart-edge. The CDP proxy stays on 3456; if the proxy was already running before Edge restarts, it will auto-reconnect.

Common parameters: --title-file/--body-file (use files for long text to avoid escaping), --no-publish (draft mode), --dry-run (validate only), --force (bypass sensitive words, not recommended), status --note-title "Title".

Edit a published note (after modifying copy, republish; the audit will run again):

python scripts\xhs_publish.py update --note-id 6a74b839000000003303782b `
  --title "New Title (≤20 chars)" --body-file body_v2.txt `
  --topic "Herzog" --topic "China Film Archive"
  • update opens /publish/update?id=<noteId>, clears old body → writes new title/body → re-adds topics → clicks publish.
  • Image-Only Mode: update can also append images without changing copy – do not provide --title/--body, only --note-id + one or more --image; the script keeps the original title/body/topics, just uploads images and clicks publish (audit will run again).
  • On success, the page redirects (publish page redirects published=true, edit page redirects editSuccess or note management page); the script judges accordingly. If publishing is blocked (e.g., title too long), it reads the validation toast and reports the error quickly.

Method C: Still Search → Download → Match Images (xhs_enrich_stills Tool)

Hermes tool xhs_enrich_stills (registered by the same plugin, toolset=hermes-cli): Downloads high-definition stills (original quality, up to 4K) from TMDB sorted by community rating, optionally appending directly to a published note.

{"tmdb_id": 6404, "count": 6, "min_width": 1280,
 "out_dir": "T:/.../stills", "note_id": "6a7513720000000033008657"}
  • slug built-in mappings: kaspar_hauser(11710) / stroszek(11698) / woyzeck(10319) / nosferatu(6404); or pass tmdb_id directly. Note: the 1979 version of Woyzeck is 10319 (1368217 is not the Herzog version).
  • Image selection logic: TMDB backdrops page ?image_sort=rating.desc (highest community rating first) → filter by --min-width → take the top --count original images.
  • If note_id is provided, it automatically uses the image-only mode of update (does not change copy). no_publish: true allows manual review before publishing.
  • Still copyright belongs to the original production studio/distributor; for public notes, it is recommended to note "Still copyright belongs to the production studio"; cover images without copyright risk should still use custom covers/cover_*.png.

Content Red Lines (Mandatory Check Before Publishing)

External traffic-driving is a hard red line; beyond literal terms, implicit references to "another platform" also violate policy. The platform determines "promoting third-party platforms" includes:

  1. Guiding others to search/browse on other platforms (literal terms like 公众号, 微信, 加我V, 闲鱼, 抖音, B站, etc.);
  2. Promoting other platforms through content seeding/tutorials/reviews (e.g., "full article in WeChat public account", "complete version elsewhere" – even without naming the platform, such comparative statements implying another platform can be flagged as text violation);
  3. Using welfare red envelopes/exclusive offers to induce redirection, or recommending paid content on other platforms.
  • Forbidden in public body/title: 公众号, 微信, 闲鱼, 咸鱼, 转卖, 出票, 转让, 售票, 二维码, 淘口令, 淘宝, etc. The script blocks them by default; if hit, it reports an error and lists the words.
  • Implicit statements also forbidden: do not write "I'll write a long article about these elsewhere" or "full version on another platform"; to express content plans, rephrase as a commitment within the platform (e.g., "I'll explain each of these films one by one before the screening").
  • Tested: body containing "公众号" → audit fails with "Note contains content promoting third-party platforms". Must redo the full publishing process after fixing (update --note-id edit page → modify copy → click publish again); merely changing the front-end display does not take effect.
  • Ticket transfer/purchase information only goes to private messages and Xianyu (see ops/private_dm.md), never in body, title, cover, or pinned comments.

Content Preparation Suggestions (Film Promotion Scenario)

  • Cover: output/herzog_campaign/covers/cover_*.png (3:4 text poster, no stills, no copyright risk).
  • Images: output/herzog_campaign/stills/ already includes official posters (*_poster.jpg, downloaded via Wikipedia REST) and high-definition stills (*_still_*.jpg, TMDB originals, downloaded on 2026-08-07 sorted by community rating + resolution, already matched to four notes); for new films, use xhs_enrich_stills tool to fetch on the fly.
  • Before each publication, run dbs-content five-dimension diagnosis + title candidates using dbs-xhs-title formula.

High-Engagement Note Style Template (Verified Tips)

Title: First 8 characters decide fate; ≤20 characters including punctuation. Three high-click types: Number style (location/number/film festival, e.g., "Beijing's Most Unmissable Film Festival in August: Herzog Complete Retrospective", formula #26), Pain point/counter-intuitive style (e.g., "A man who hasn't seen the sun in 17 years shatters 'normal'", formula #24+#1), Curiosity gap style (e.g., "After watching this, you'll question 'normal' itself", formula #12). Use dbs-xhs-title to generate 5-8 candidates with formula numbers, then finalize.

First Image: Text poster ≤15 characters, information flow dwell time 0.5-1 second; for film types, common styles are collage/multiple images or real-scene still style.

Body Structure: One sentence at the beginning stating value → point-by-point breakdown (1️⃣2️⃣3️⃣ short lines + line breaks, replace bold) → conclusion + question to encourage interaction (what to chat about in comments). Structured content gets more bookmarks; ending with a question directly invites "let's talk in the comments".

Human Feel > Correctness: Avoid AI voice (empty parallelism, consecutive imperative sentences like "Remember", "The truth is"); vary sentence length, allow colloquial language; be specific with data/quotes (year, film name, director's original words).

Common Pitfalls

  1. Edge Background Preload Instance Grabs Profile → Debug Port Silently Fails (Verified 2026-08-14): On Windows, Edge often runs a --no-startup-window background preload instance that locks the default profile; when starting msedge.exe --remote-debugging-port=9222, the parameter is handed off to the existing instance and ignored, port 9222 is unresponsive, the publishing script reports "Request failed /targets: WinError 10061 Target machine actively refused". Fix: First taskkill -F -IM msedge.exe to kill all Edge instances (including preload), then start the debug instance with the default profile (login is in the default profile, preserved). Diagnosis order: curl 127.0.0.1:9222/json/version → curl 127.0.0.1:3456/ → xhs_publish.py login.
  2. Publish Button is a Closed Shadow DOM: xhs-publish-btn internal content cannot be queried, normal click is ineffective. Correct trigger: document.querySelector("xhs-publish-btn").dispatchEvent(new CustomEvent("publish", {bubbles:true, composed:true}))
  3. After Switching to Image-Text Mode, .creator-tab is Removed from DOM: To determine if in image-text mode, check the image input (input[type=file] accept contains .jpg), don't just look at the tab.
  4. Multiple Image Upload: The first image uses input[type=file].upload-input; subsequent images hide this input; use input[type=file][accept*=".jpg"] (there are 2 hidden copies in the DOM, use the first one). Verify count with div.status (n/18).
  5. Title: Must use the native setter of HTMLInputElement.prototype.value + input/change events; direct assignment is not recognized by Vue.
  6. Body: .tiptap.ProseMirror contenteditable, use document.execCommand("insertText"), \n represents a paragraph break.
  7. Topics: Typing #topicname in the body triggers a #creator-editor-topic-container overlay; click the first .item (exact match is first) to insert <a class="tiptap-topic">.
  8. Duplicate Topics: xhs_note.md body may already have a #topic plain text line at the end; the script automatically strips it; do not manually concatenate again.
  9. Audit Status: The note management page (/new/note-manager) cards do not directly display status; use the "Published/Pending/Rejected" filter tabs to determine which tab the note belongs to; when rejected, click "View Modification Suggestions" to read the .audit-modal reason.
  10. Login Redirect: If the publishing page redirects to login/passport, the tool reports "Not logged in"; have the user manually log in and retry.
  11. Node/Proxy Environment: check-deps.mjs requires Node 22+; start cdp-proxy.mjs with node scripts/cdp-proxy.mjs.
  12. Title ≤20 Characters: When too long, publishing is blocked with a toast "Title can be up to 20 characters~". When updating notes, write the title first then check length.
  13. Editing Published Notes: The body editor must be cleared before writing (JS_CLEAR_BODY), otherwise new body appends after old body; old topics are also deleted with the clear, requiring --topic to re-add.
  14. Publish Success Determination: After successful publish, the URL includes published=true or redirects; after successful edit, it redirects to editSuccess or note management page. JS_PUBLISH_STATE simultaneously detects validation failure toasts (title too long/empty) to report errors quickly, avoiding waiting indefinitely.

Verification Checklist

  • python xhs_publish.py login → {"loggedIn": true}
  • draft mode preview: correct title, div.status count = cover + image count, a.tiptap-topic count = number of topics, no topic line in body
  • After publishing, status --note-title "<Title>" → Auditing (or Published)
  • Edit published note: update --note-id <noteId> --title "≤20 chars" --body-file ... → page redirects editSuccess → status recheck
  • When rejected, read .audit-modal reason, update to modify body then republish
  • Public content has no sensitive words (公众号/微信/闲鱼/转卖/出票/转让)
  • After publishing, add pinned comment and private message follow-up per ops/private_dm.md

Related Skills