XHS Note Auto Workflow
Use this repository as a self-contained workflow. Do not read or modify any private production Skill, legacy project, personal folder, browser ID, account name, Cookie, token, API key, or machine-specific absolute path unless the user explicitly supplies a runtime value for the current task.
Required runtime inputs
- Public Xiaohongshu note URL.
- BitBrowser environment ID supplied for the current run.
- Image mode:
localorapi.
Account requirements
The selected BitBrowser environment must already have Xiaohongshu Creator Center logged in. Local mode additionally requires ChatGPT to be logged in and capable of image generation.
- Xiaohongshu Creator Center logged in and able to open the image-note publishing page.
For api, configure the image API. The text API defaults to the same key/base, or can be configured separately with XHS_TEXT_API_*. API mode does not use the ChatGPT website. Do not print keys.
Cross-platform execution
Detect the host OS first.
macOS
For a person launching the workflow from Finder or an ordinary Terminal, use:
scripts/run_local.commandscripts/run_api.command
For Codex, WorkBuddy, or any other Agent, run python3 -u main.py ... directly in the Agent shell. Default execution stays in the background and writes a log under logs/; do not create or open a temporary .command launcher.
Windows
Preferred interactive launchers:
scripts\\run_local.batscripts\\run_api.bat
Run through cmd.exe when executing from an agent or terminal.
Proxy / agent-environment note
Some agent hosts (for example WorkBuddy) inject HTTP_PROXY / HTTPS_PROXY pointing at their own local service proxy when running shell commands, and may not set NO_PROXY for loopback addresses. This can hijack Selenium's connection to the local BitBrowser chromedriver and fail with unhandled request.
The interactive launchers in scripts/ clear these proxy variables. Agent hosts must run main.py directly; the Python browser layer also isolates local BitBrowser/ChromeDriver traffic from inherited proxy settings. Clearing proxy variables in the Agent command is still recommended, for example on macOS:
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ALL_PROXY all_proxy
export NO_PROXY="127.0.0.1,localhost,::1"
export no_proxy="127.0.0.1,localhost,::1"
python3 -u main.py --note-url "<PUBLIC_XHS_NOTE_URL>" --browser-id "<BITBROWSER_ID>" --image-mode local
On Windows (cmd.exe):
set "HTTP_PROXY=" & set "HTTPS_PROXY=" & set "http_proxy=" & set "https_proxy=" & set "ALL_PROXY=" & set "all_proxy=" & set "NO_PROXY=127.0.0.1,localhost"
Image-count contract
For a normal real workflow, parse every image from the single supplied note URL and redesign them in original order, one source image to one generated image.
- Do not pass
--image-countfor a normal run; default0means all images. --image-count Nis only a test/debug cap for the first N images.- Never silently skip a failed source image or failed generation and then save an incomplete draft.
Prompt contract
Default prompts are part of this repository:
prompts/rewrite_note.txtprompts/redesign_image.txt
Use them when the user has not configured anything. Custom prompt files may be selected with XHS_REWRITE_PROMPT_FILE and XHS_IMAGE_PROMPT_FILE in .env.
Before editing prompts, read docs/SETUP_GUIDE.md or docs/AI_SETUP.md for the supported placeholders. Prefer changing prompt files instead of changing Python workflow logic.
Validation order
- Run
python main.py --privacy-checkbefore public release. - Run
python main.py --browser-id <ID> --image-mode <local|api> --preflightbefore a real workflow. - Run the real note workflow only after preflight succeeds.
- After image generation, every generated image must pass the repository's dark-watermark cleanup step before draft upload.
- Success means all parsed images were regenerated, cleaned, and the note is saved as a draft; never publish automatically.
Privacy rules
Never commit or expose:
- personal absolute paths or usernames;
- browser IDs;
- Cookies, tokens, API keys;
- account names;
- local logs, screenshots, outputs, or state containing private runtime data.
Use relative paths, .env, command-line arguments, and generic placeholders only.
Dark-watermark cleanup
Before uploading generated images to Xiaohongshu, run the built-in cleanup step for every generated image. The workflow must stop if any image fails cleanup; never silently upload an uncleared image. Terminal-facing wording should stay simple and use 清除暗水印 rather than exposing low-level cleanup terminology. wmr is discovered from PATH, or may be configured with XHS_WMR_PATH.