Loading...
Loading...
Query and export local WeChat data (messages, contacts, moments, favorites) from the command line with daemon architecture
npx skill4agent add aradotso/devtools-skills wx-cli-wechat-local-dataSkill by ara.so — Devtools Skills collection.
wx-climetanew-messagesnpm install -g @jackwener/wx-clicurl -fsSL https://raw.githubusercontent.com/jackwener/wx-cli/main/install.sh | bashirm https://raw.githubusercontent.com/jackwener/wx-cli/main/install.ps1 | iex# 1. Sign WeChat (once per WeChat update)
codesign --force --deep --sign - /Applications/WeChat.app
# 2. Reset TCC privacy records (required after re-signing)
for s in ScreenCapture Camera Microphone AppleEvents AddressBook \
SystemPolicyDocumentsFolder SystemPolicyDownloadsFolder SystemPolicyDesktopFolder; do
tccutil reset "$s" com.tencent.xinWeChat
done
# 3. Restart WeChat and wait for full login
killall WeChat && open /Applications/WeChat.app
# 4. Initialize wx-cli
sudo wx initcodesignsignature in usecodesign --remove-signature "/Applications/WeChat.app/Contents/Frameworks/vlc_plugins/librtp_mpeg4_plugin.dylib"
codesign --force --deep --sign - /Applications/WeChat.appsudo wx initwx initwx sessions# Recent sessions (conversations)
wx sessions
# Unread sessions only
wx unread
# Filter unread (exclude official accounts and folded entries)
wx unread --filter private,group
# New messages since last check (incremental)
wx new-messages
# Chat history with a contact/group
wx history "张三"
wx history "张三" -n 2000 # More messages
wx history "AI群" --since 2026-04-01 --until 2026-04-15
# Search across all messages
wx search "关键词"
wx search "关键词" -n 500 # More results
wx search "会议" --in "工作群" --since 2026-01-01// history, search, sessions, new-messages, stats, attachments
{
"data": [...],
"meta": {
"status": "ok" | "possibly_stale" | "windowed",
"unknown_shards": ["message_3.db"], // If non-empty, run `wx init --force`
"chat_latest_timestamp": "2026-05-16T12:34:56+08:00",
"chat_latest_db": "message_2.db",
"session_last_timestamp": "2026-05-16T14:20:00+08:00"
}
}{
"time": "2026-05-16 10:23:45",
"timestamp": 1715832225,
"sender": "张三",
"content": "消息内容",
"type": "text",
"chat_type": "private",
"is_self": false
}chat_typeprivategroupofficial_accountfoldedtypetextimagevideofilelinkvoicesystem[引用] 当前回复
↳ 发送者: 被引用内容# List contacts
wx contacts
wx contacts --query "李" # Search by name
# List group members (prioritizes group nicknames)
wx members "AI交流群"
wx members "AI交流群" --json # JSON with username/display/group_nickname/is_owner{
"username": "wxid_abc123",
"display": "李四 (群昵称)",
"contact_display": "李四",
"group_nickname": "群昵称",
"is_owner": false
}# Like/comment notifications (unread by default)
wx sns-notifications
wx sns-notifications --include-read -n 100
# Moments timeline (your feed)
wx sns-feed
wx sns-feed --user "张三" -n 100
wx sns-feed --since 2026-04-01
# Search moments content
wx sns-search "关键词"
wx sns-search "婚礼" --user "李四" --since 2023-01-01{
"type": "like" | "comment",
"from_nickname": "张三",
"content": "评论内容",
"feed_preview": "原帖正文片段",
"feed_author": "李四",
"timestamp": 1715832225
}{
"author": "张三",
"content": "朋友圈正文",
"media": [
{
"url": "...",
"thumb": "...",
"key": "...",
"token": "...",
"md5": "...",
"enc_idx": 0,
"size": 123456
}
],
"media_count": 1,
"location": "北京",
"timestamp": 1715832225
}# Recent articles
wx biz-articles
wx biz-articles -n 200
# Filter by account name
wx biz-articles --account "返朴"
# Time range
wx biz-articles --since 2026-05-01 --until 2026-05-10
# Unread only (1 latest per account)
wx biz-articles --unread
# Extract URLs
wx biz-articles --json | jq '.[].url'{
"account": "返朴",
"account_username": "gh_abc123",
"title": "文章标题",
"url": "https://mp.weixin.qq.com/...",
"digest": "摘要",
"cover_url": "...",
"time": "2026-05-16 10:00:00",
"timestamp": 1715832000,
"recv_time_str": "2026-05-16 10:01:23"
}.dat# 1. List image attachments in a conversation
wx attachments "张三"
wx attachments "AI群" --kind image -n 100
wx attachments "AI群" --since 2026-04-01 --until 2026-04-15
# 2. Extract a specific attachment by ID
wx extract <attachment_id> -o ~/Desktop/photo.jpg
wx extract <attachment_id> -o /tmp/x.jpg --overwrite{
"attachment_id": "opaque-id-123",
"kind": "image",
"type": 3,
"local_id": 456,
"timestamp": 1715832225,
"time": "2026-05-16 10:23:45",
"sender": "张三"
}{
"md5": "abc123...",
"dat_path": "/.../msg/attach/.../abc.dat",
"dat_size": 123456,
"output": "~/Desktop/photo.jpg",
"output_size": 120000,
"format": "jpg",
"decoder": "v2"
}legacy_xorv1_aesv2# All favorites
wx favorites
wx favorites --type image # Filter by type: text/image/article/card/video
wx favorites --since 2026-01-01
# Conversation statistics
wx stats "AI群" # Message counts by sender (top 10)
wx stats "AI群" --top 20 # More senders# Export to text file
wx export "张三" -o chat.txt
# Export to JSON
wx export "AI群" -o chat.json --format json
wx export "AI群" -o chat.json --format json --since 2026-04-01# Check daemon status
wx status
# Stop daemon
wx stop
# Restart daemon
wx stop && wx sessions # Any query command restarts it
# Force re-initialize (re-scan WeChat memory)
wx init --force# Enable debug logging (not typically needed)
RUST_LOG=debug wx history "张三"#!/bin/bash
while true; do
wx new-messages --json | jq -r '.data[] | "\(.time) \(.sender): \(.content)"'
sleep 60
donefor session in $(wx sessions --json | jq -r '.[].username'); do
wx export "$session" -o "backup/${session}.json" --format json --since 2026-01-01
donewx search "项目" --json | jq -r '.data[] | "\(.time) [\(.sender)] \(.content)"'wx unread --json | jq '.[] | "\(.unread_count)\t\(.remark)"'# 1. Get attachment IDs
wx attachments "旅行群" --since 2026-05-01 --json | jq -r '.data[].attachment_id' > ids.txt
# 2. Extract each
mkdir -p images
while read id; do
wx extract "$id" -o "images/${id}.jpg" 2>/dev/null
done < ids.txtresult=$(wx history "张三" --json)
status=$(echo "$result" | jq -r '.meta.status')
if [ "$status" != "ok" ]; then
echo "Warning: Data may be stale. Unknown shards:"
echo "$result" | jq '.meta.unknown_shards'
echo "Run: wx init --force"
fi# Re-sign WeChat
codesign --force --deep --sign - /Applications/WeChat.app
# Reset TCC and reinitialize
for s in ScreenCapture Camera Microphone AppleEvents; do
tccutil reset "$s" com.tencent.xinWeChat
done
killall WeChat && open /Applications/WeChat.app
sudo wx init --force# Make sure WeChat is fully logged in
# Run as Administrator
wx init --forcemessage_N.dbwx init --forcewx stop
wx sessions # Restarts daemon# Force refresh all caches
wx init --force
# Check daemon status
wx statuswx init# Default limits are conservative to avoid overwhelming output
wx history "张三" -n 10000
wx search "keyword" -n 5000
wx sns-feed -n 500# Links, files, merged chat records, quoted messages
wx history "AI群" --type link --json
# Images only
wx history "AI群" --type image --json# Human-readable warnings go to stderr
wx history "张三" 2>&1 | grep "WARNING"
# Machine-readable meta in JSON stdout
wx history "张三" --json | jq '.meta'
# Extended meta with per-shard details
wx history "张三" --with-meta --json | jq '.meta.per_shard_latest'wx export "项目群" -o q1-2026.json --format json \
--since 2026-01-01 --until 2026-03-31npx skills add jackwener/wx-cli{data, meta}meta.statusnew-messages"Check my WeChat for any messages from 李四 in the last week mentioning '合同'"
wx search "合同" --in "李四" --since $(date -d '7 days ago' +%Y-%m-%d) --jsoninstall.shinstall.ps1docs/macos-permission-guide.md