WeChat Skill — 微信本地数据 CLI
Skill by ara.so — Devtools Skills collection.
也称作 wx-cli / WeChat Local Data CLI / 微信本地数据查询工具
📖 详细配置指南请参阅 README.md
Query and export local WeChat data (messages, contacts, moments, favorites, public account articles) from the command line. Built in Rust with a daemon architecture that caches decrypted databases for millisecond-level responses.
What it does
wx-cli provides a command-line interface to your local WeChat data without network calls. It:
- Scans WeChat’s memory to extract database encryption keys
- Maintains a background daemon that caches decrypted databases (reuses cache if mtime unchanged)
- Queries messages, contacts, groups, moments (SNS), favorites, and public account articles
- Extracts and decodes image attachments (.dat files)
- Returns structured JSON with metadata about data freshness
- Zero-dependency single binary
- Fully local (no data leaves your machine)
- AI-friendly JSON output with
metawrapper for freshness/source info - Supports incremental queries (
new-messagesreturns only messages since last check)
Installation
npm (recommended, cross-platform):Initial Setup
Keep WeChat running, then initialize (one-time):macOS
Ad-hoc signing is required to scan WeChat’s memory:codesign reports signature in use:
Linux
Windows
Run PowerShell as Administrator:Core Commands
Messages & Sessions
chat_type:private|group|official_account|foldedtype:text|image|video|file|link|voice|system| etc.
Contacts & Groups
Moments (SNS)
Three separate commands for notifications vs. posts:Public Account Articles
Official/subscription account articles are stored separately:Attachments (Images)
Image attachments are stored as.dat files that require decryption:
legacy_xor: Early single-byte XOR (no magic header)v1_aes: Fixed AES-128-ECB with hardcoded keyv2: AES + XOR with platform-derived keys
Favorites & Statistics
Export
Configuration
Daemon Management
The daemon starts automatically on first command. Manual control:Environment Variables
wx-cli reads configuration from standard WeChat data paths. No env vars required for normal operation. Logging:Common Patterns
Monitor new messages in a script
Export all conversations since date
Search for keywords and extract context
Get unread count per conversation
Extract all images from a date range
Check data freshness in automation
Troubleshooting
macOS: “Operation not permitted”
macOS: “WeChat 想访问其他 App 的数据” popups
This is a known side effect of re-signing. The popup occurs because macOS treats the re-signed WeChat as a different app accessing its old container. Click “Allow” to proceed. To avoid popups, you’d need to use official WeChat signature (which requires SSH-free local Terminal with Developer Tools TCC access).Windows: No decryption keys found
”unknown_shards” in meta output
WeChat may have created newmessage_N.db shards since initialization:
Daemon not responding
Empty results but WeChat has data
Image extraction fails with “unsupported decoder”
On Linux, V2 image keys are not yet supported. Legacy XOR and V1 AES work. On macOS/Windows, ensure WeChat is running duringwx init.
Advanced Usage
Custom limit for large queries
Filter messages by type
Include metadata in all outputs
Export with custom time windows
Integration with AI Agents
wx-cli is designed for AI agent consumption:-
Install via skills:
-
Structured output: All query commands return JSON with
{data, meta}wrapper -
Freshness indicators:
meta.statustells agents if data may be stale -
Incremental queries:
new-messagesreturns only messages since last check - Error handling: Non-zero exit codes + stderr for errors; JSON always valid on stdout
“Check my WeChat for any messages from 李四 in the last week mentioning ‘合同’”Agent execution:
Documentation
- GitHub: https://github.com/jackwener/wx-cli
- Installation: See
install.sh/install.ps1in repo - macOS Permission Guide:
docs/macos-permission-guide.md