xhs-cli
A headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, and perform social interactions like liking, commenting, and publishing from the terminal.
About this skill
This skill provides a robust command-line interface for interacting with Xiaohongshu (XHS), also known as RedNote. Leveraging a headless browser (camoufox) for its operations, `xhs-cli` offers a resilient way to automate various tasks on the platform, mitigating risks associated with API-based methods. Users can search for notes, view detailed post content (including comments), browse user profiles, and list a user's published notes. Beyond data retrieval, it enables active engagement through actions such as liking, favoriting, commenting on posts, and even publishing new content directly from the terminal. Authentication is flexible, supporting automatic extraction of Chrome cookies or manual cookie input, and offers QR code login as a fallback. This tool is ideal for developers, data analysts, and marketers who require programmatic access to Xiaohongshu for content monitoring, trend analysis, data collection, or automated social media management. Its headless browser approach ensures greater stability and resistance to platform changes or risk-control systems, making it a reliable choice for consistent, automated interactions.
Best use case
The primary use case is programmatic interaction and automation of tasks on Xiaohongshu. It is most beneficial for developers, data scientists, and social media managers who need to efficiently monitor content, gather data, or manage accounts on the platform, especially when reliability against platform changes is a key concern.
A headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, and perform social interactions like liking, commenting, and publishing from the terminal.
Users can expect to execute various Xiaohongshu actions—from content searching and reading to social interactions and publishing—directly from their terminal or through automated scripts, receiving structured output.
Practical example
Example input
Search Xiaohongshu for notes about '咖啡' (coffee) and display the results.
Example output
xhs search "咖啡" results:
[
{"note_id": "123abc", "title": "精品咖啡馆推荐", "author": "CoffeeLover", "likes": 120, "comments": 15},
{"note_id": "456def", "title": "手冲咖啡入门", "author": "BaristaPro", "likes": 85, "comments": 10}
]When to use this skill
- To programmatically search for and retrieve Xiaohongshu notes.
- When automating social interactions like liking, commenting, or publishing on Xiaohongshu.
- For reliable data scraping or monitoring of Xiaohongshu profiles and posts.
- When an API-based solution for Xiaohongshu interaction is too prone to detection or instability.
When not to use this skill
- When you only need casual, manual browsing of Xiaohongshu through its official app or website.
- If raw speed is the absolute highest priority and you are willing to risk less stable, API-based methods.
- For very high-volume, real-time data processing where headless browser overhead is unacceptable.
How xhs-cli Compares
| Feature / Agent | xhs-cli | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
A headless-browser-based CLI skill for Xiaohongshu (小红书, RedNote, XHS) to search notes, read posts, browse profiles, and perform social interactions like liking, commenting, and publishing from the terminal.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
AI Agent for Product Research
Browse AI agent skills for product research, competitive analysis, customer discovery, and structured product decision support.
AI Agent for SaaS Idea Validation
Use AI agent skills for SaaS idea validation, market research, customer discovery, competitor analysis, and documenting startup hypotheses.
SKILL.md Source
> [!NOTE]
> An alternative package [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) is available, which uses a reverse-engineered API and runs faster.
> This package (`xhs-cli`) uses a headless browser (camoufox) approach — slower but more resilient against risk-control detection.
> Choose whichever best fits your needs.
# xhs-cli Skill
A CLI tool for interacting with Xiaohongshu (小红书). Use it to search notes, read details, browse user profiles, and perform interactions like liking, favoriting, and commenting.
## Prerequisites
```bash
# Install (requires Python 3.8+)
uv tool install xhs-cli
# Or: pipx install xhs-cli
```
## Authentication
All commands require valid cookies to function.
```bash
xhs status # Check saved login session (no browser extraction)
xhs login # Auto-extract Chrome cookies
xhs login --cookie "a1=..." # Or provide cookies manually
```
Authentication first uses saved local cookies. If unavailable, it auto-detects local Chrome cookies via browser-cookie3. If extraction fails, QR code login is available.
## Command Reference
### Search
```bash
xhs search "咖啡" # Search notes (rich table output)
xhs search "咖啡" --json # Raw JSON output
```
### Read Note
```bash
# View note (xsec_token auto-resolved from search cache)
xhs read <note_id>
xhs read <note_id> --comments # Include comments
xhs read <note_id> --xsec-token <token> # Manual token
xhs read <note_id> --json
```
### User
```bash
# Look up user profile (by internal user_id, hex format)
xhs user <user_id>
xhs user <user_id> --json
# List user's published notes
xhs user-posts <user_id>
xhs user-posts <user_id> --json
# Followers / Following
xhs followers <user_id>
xhs following <user_id>
```
### Discovery
```bash
xhs feed # Explore page recommended feed
xhs feed --json
xhs topics "旅行" # Search topics/hashtags
xhs topics "旅行" --json
```
### Interactions (require login)
```bash
# Like / Unlike (xsec_token auto-resolved)
xhs like <note_id>
xhs like <note_id> --undo
# Favorite / Unfavorite
xhs favorite <note_id>
xhs favorite <note_id> --undo
# Comment
xhs comment <note_id> "好棒!"
# Delete your own note
xhs delete <note_id>
```
### Favorites
```bash
xhs favorites # List your favorites
xhs favorites --max 10 # Limit count
xhs favorites --json
```
### Post
```bash
xhs post "标题" --image photo1.jpg --image photo2.jpg --content "正文"
xhs post "标题" --image photo1.jpg --content "正文" --json
```
### Account
```bash
xhs status # Quick saved-session check
xhs whoami # Full profile info
xhs whoami --json
xhs login # Login
xhs logout # Clear cookies
```
## JSON Output
Major query commands support `--json` for machine-readable output:
```bash
xhs search "咖啡" --json | jq '.[0].id' # First note ID
xhs whoami --json | jq '.userInfo.userId' # Your user ID
xhs favorites --json | jq '.[0].displayTitle' # First favorite title
```
## Common Patterns for AI Agents
```bash
# Get your user ID for further queries
xhs whoami --json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('userInfo',{}).get('userId',''))"
# Search and get note IDs (xsec_token auto-cached for later use)
xhs search "topic" --json | python3 -c "import sys,json; [print(n['id']) for n in json.load(sys.stdin)[:3]]"
# Check login before performing actions
xhs status && xhs like <note_id>
# Read a note with comments for summarization
xhs read <note_id> --comments --json
```
## Error Handling
- Commands exit with code 0 on success, non-zero on failure
- Error messages are prefixed with ❌
- Login-required commands show clear instruction to run `xhs login`
- `xsec_token` is auto-resolved from cache; manual `--xsec-token` available as fallback
## Safety Notes
- Do not ask users to share raw cookie values in chat logs.
- Prefer auto-extraction via `xhs login` over manual cookie input.
- If auth fails, ask the user to re-login via `xhs login`.Related Skills
linkedin-cli
Use when automating LinkedIn via CLI: fetch profiles, search people/companies, send messages, manage connections, create posts, and Sales Navigator.
workspace-surface-audit
Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then recommend the highest-value ECC-native skills, hooks, agents, and operator workflows. Use when the user wants help setting up Claude Code or understanding what capabilities are actually available in their environment.
ui-demo
Record polished UI demo videos using Playwright. Use when the user asks to create a demo, walkthrough, screen recording, or tutorial video of a web application. Produces WebM videos with visible cursor, natural pacing, and professional feel.
token-budget-advisor
Offers the user an informed choice about how much response depth to consume before answering. Use this skill when the user explicitly wants to control response length, depth, or token budget. TRIGGER when: "token budget", "token count", "token usage", "token limit", "response length", "answer depth", "short version", "brief answer", "detailed answer", "exhaustive answer", "respuesta corta vs larga", "cuántos tokens", "ahorrar tokens", "responde al 50%", "dame la versión corta", "quiero controlar cuánto usas", or clear variants where the user is explicitly asking to control answer size or depth. DO NOT TRIGGER when: user has already specified a level in the current session (maintain it), the request is clearly a one-word answer, or "token" refers to auth/session/payment tokens rather than response size.
skill-comply
Visualize whether skills, rules, and agent definitions are actually followed — auto-generates scenarios at 3 prompt strictness levels, runs agents, classifies behavioral sequences, and reports compliance rates with full tool call timelines
santa-method
Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.
safety-guard
Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
repo-scan
Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.
project-flow-ops
Operate execution flow across GitHub and Linear by triaging issues and pull requests, linking active work, and keeping GitHub public-facing while Linear remains the internal execution layer. Use when the user wants backlog control, PR triage, or GitHub-to-Linear coordination.
product-lens
Use this skill to validate the "why" before building, run product diagnostics, and pressure-test product direction before the request becomes an implementation contract.
openclaw-persona-forge
为 OpenClaw AI Agent 锻造完整的龙虾灵魂方案。根据用户偏好或随机抽卡, 输出身份定位、灵魂描述(SOUL.md)、角色化底线规则、名字和头像生图提示词。 如当前环境提供已审核的生图 skill,可自动生成统一风格头像图片。 当用户需要创建、设计或定制 OpenClaw 龙虾灵魂时使用。 不适用于:微调已有 SOUL.md、非 OpenClaw 平台的角色设计、纯工具型无性格 Agent。 触发词:龙虾灵魂、虾魂、OpenClaw 灵魂、养虾灵魂、龙虾角色、龙虾定位、 龙虾剧本杀角色、龙虾游戏角色、龙虾 NPC、龙虾性格、龙虾背景故事、 lobster soul、lobster character、抽卡、随机龙虾、龙虾 SOUL、gacha。
manim-video
Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider ECC video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.