Skip to main content

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
Key features:
  • Zero-dependency single binary
  • Fully local (no data leaves your machine)
  • AI-friendly JSON output with meta wrapper for freshness/source info
  • Supports incremental queries (new-messages returns only messages since last check)

Installation

npm (recommended, cross-platform):
macOS / Linux (curl):
Windows (PowerShell as Administrator):

Initial Setup

Keep WeChat running, then initialize (one-time):

macOS

Ad-hoc signing is required to scan WeChat’s memory:
If codesign reports signature in use:

Linux

Windows

Run PowerShell as Administrator:
Verify installation:
If you see recent sessions, setup is complete. The daemon starts automatically on first command.

Core Commands

Messages & Sessions

JSON output structure:
Message fields:
  • chat_type: private | group | official_account | folded
  • type: text | image | video | file | link | voice | system | etc.
Quoted messages: History/search output shows quoted replies with original context:

Contacts & Groups

Member JSON structure:

Moments (SNS)

Three separate commands for notifications vs. posts:
sns-notifications output:
sns-feed / sns-search output:

Public Account Articles

Official/subscription account articles are stored separately:
Output fields:

Attachments (Images)

Image attachments are stored as .dat files that require decryption:
attachments output:
extract output:
Supported decoders:
  • legacy_xor: Early single-byte XOR (no magic header)
  • v1_aes: Fixed AES-128-ECB with hardcoded key
  • v2: 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 new message_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 during wx 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:
  1. Install via skills:
  2. Structured output: All query commands return JSON with {data, meta} wrapper
  3. Freshness indicators: meta.status tells agents if data may be stale
  4. Incremental queries: new-messages returns only messages since last check
  5. Error handling: Non-zero exit codes + stderr for errors; JSON always valid on stdout
Example agent prompt:
“Check my WeChat for any messages from 李四 in the last week mentioning ‘合同’”
Agent execution:

Documentation

License

Apache-2.0