xhs-kit: Instructions file for Claude Code

CLAUDE.md

xhs-kit CLAUDE.md is an instructions file for Claude Code from luweizheng/xhs-kit. It costs 1,080 tokens per session, scanned A, original, MIT.

Project instructions describing xhs-kit, a browser-automation tool for Xiaohongshu, a Chinese social-media platform.

In plain words
What is it for?
Helping maintain or extend xhs-kit, including browser login, posting content, retrieving posts and profiles, and connecting features to AI assistants.
Why use it?
They give the coding agent background on the project’s login, publishing, search, and data-collection code.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md.

This is luweizheng/xhs-kit's own configuration. It tells Claude Code how to work on xhs-kit itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything xhs-kit configures →

Reuse

Borrowing it

Nothing to install: this file belongs to luweizheng/xhs-kit. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/luweizheng/xhs-kit/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/luweizheng/xhs-kit

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for xhs-kit CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/luweizheng/xhs-kit/claude-md.svg)](https://agentmods.dev/instructions/luweizheng/xhs-kit/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/luweizheng/xhs-kit/claude-md"><img src="https://agentmods.dev/badge/instructions/luweizheng/xhs-kit/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,080 This file is loaded in full into every session.
When invoked 1,080 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01080 $0.01080
Opus 5 $0.00540 $0.00540
Sonnet 5 $0.00216 $0.00216
Haiku 4.5 $0.00108 $0.00108

Measured 6d ago against content hash 142922fe81d2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

xhs-kit CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 140 lines

How it starts

The opening of the file, as written. The whole thing — 140 lines — stays where its author put it; the contents beside it link to each section on GitHub.

xhs-kit 项目说明

项目概述

xhs-kit 是一个小红书自动化工具,基于 Playwright 浏览器自动化框架实现,支持通过 MCP 协议与 AI 助手集成。

核心功能:

  • 扫码登录(浏览器/二维码两种模式)
  • 发布图文、视频、文字配卡笔记
  • 搜索内容、获取推荐流
  • 点赞、收藏、评论、回复
  • 获取笔记详情、用户主页

实现思路

1. 浏览器自动化核心

基于 Playwright 模拟真实浏览器行为:

  • 创建持久化浏览器上下文(Persistent Context)
  • 复用用户数据目录和 cookies,避免重复登录
  • 模拟真实用户操作(点击、输入、滚动等)
  • 拦截和分析网络请求,获取 API 数据

核心文件:src/xhs_kit.po/browser.py

2. 登录机制

小红书需要登录才能使用,实现了两种登录方式:

浏览器扫码登录:

  • 弹出浏览器窗口访问小红书登录页
  • 用户扫码后自动保存 cookies

二维码登录(CLI 模式):

  • 通过截取登录页的二维码获取登录二维码
  • 支持终端显示二维码(需安装 zbar)
  • 支持保存二维码图片
  • 轮询检测登录状态

核心文件:src/xhs_kit.po/login.pysrc/xhs_kit.po/cookies.py

3. 内容发布

图文发布:

  • 访问创作者发布页面
  • 上传图片、填写标题和正文
  • 支持添加话题标签
  • 支持定时发布

文字配卡发布:

  • 使用小红书自带的文字生图将文字渲染为卡片
  • 支持多页、多种样式(基础、边框、手写等)

核心文件:src/xhs_kit.po/publish.pysrc/xhs_kit.po/text_card.py

4. 数据获取

搜索与推荐:

  • 访问搜索页面,模拟用户输入关键词
  • 监听网络请求拦截搜索结果 API 响应
  • 解析返回的 JSON 数据

笔记详情、用户主页:

  • 直接访问笔记/用户页面 URL
  • 监听 API 响应获取结构化数据

核心文件:src/xhs_kit.po/search.pysrc/xhs_kit.po/feeds.pysrc/xhs_kit.po/feed_detail.py

5. MCP 协议集成

将上述功能封装为 MCP 工具:

MCP Server (stdio 模式)
  ├── login_with_browser
  ├── check_login_status
  ├── get_login_qrcode
  ├── publish_content
  ├── publish_text_card
  ├── publish_with_video
  ├── search_feeds
  ├── list_feeds
  ├── get_feed_detail
  ├── get_user_profile
  ├── like_feed / favorite_feed
  └── post_comment / reply_comment

核心文件:src/xhs_kit.po/mcp_server.py

6. CLI 封装

提供命令行接口 xhs-kit,支持所有 MCP 工具的对应命令:

核心文件:src/xhs_kit.po/cli.py


开发规范

不修改已有功能

本项目遵循「只修 bug,不改功能」原则:

  • ✅ 可以修复现有 bug
  • ✅ 可以优化错误提示和日志
  • ✅ 可以改进代码结构和注释
  • ❌ 不要修改现有功能的业务逻辑
  • ❌ 不要添加未经讨论的新功能
  • ❌ 不要删除或重命名现有接口

添加新功能的流程

如果需要添加新功能:

  1. 先与项目维护者讨论需求和设计
  2. 确认后再进行实现
  3. 新功能应通过 MCP 工具和 CLI 双暴露

代码结构

src/xhs_kit.po/
├── browser.py        # Playwright 浏览器封装
├── cookies.py        # Cookies 管理
├── login.py          # 登录逻辑(浏览器/二维码)
├── publish.py        # 发布图文/视频
├── text_card.py      # 文字生图生成
├── search.py         # 搜索功能
├── feeds.py          # 推荐流获取
├── feed_detail.py    # 笔记详情
├── user_profile.py   # 用户主页
├── interact.py       # 点赞/收藏/评论
├── models.py         # Pydantic 数据模型
├── mcp_server.py     # MCP 服务入口
└── cli.py            # 命令行入口

Read the full file on GitHub · 140 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 140 lines · 1,080 tokens per session scan A 142922fe81d2

Subscribe to this mod's changes

xhs-kit CLAUDE.md is an instructions file published in the GitHub repository luweizheng/xhs-kit (1 stars, last pushed 6mo ago), licensed MIT. It adds 1,080 tokens to every session, about $0.0054 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens