Wechat Exporter banner
robbin robbin

Wechat Exporter

Communication community

Description

A Claude Code / Codex skill to export and decrypt WeChat (macOS) chat history into plaintext SQLite databases

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

wechat-exporter

一个 [Claude Code](https://docs.anthropic.com/en/docs/claude-code) / [Codex](https://openai.com/index/introducing-codex/) 技能(Skill),用于将 macOS 微信桌面端的本地聊天记录全量导出为明文 SQLite 数据库。

它能做什么

  • 自动安装所需依赖(sqlcipher、Python 虚拟环境等)
  • 对微信客户端进行重签名,从内存中提取数据库加密密钥
  • 解密全部聊天记录数据库(联系人、消息、会话等)
  • 输出为标准 SQLite 明文数据库,可直接用任何 SQL 工具查询
  • 注册为 MCP Server,解密后可在 Claude Code 中直接查询聊天记录

前置条件

条件 说明
macOS 仅支持 macOS 系统
微信桌面端 需要已安装并登录微信 Mac 版
聊天记录已备份到电脑 在手机微信中将聊天记录迁移/备份到 Mac 端
Claude Code 或 Codex 用于运行本技能
终端完全磁盘访问权限 系统设置 → 隐私与安全性 → 完全磁盘访问权限 → 添加你的终端

快速开始

1. 安装技能

将技能添加到你的 Claude Code 技能目录。以下两种方式任选其一:

# 方式一:直接复制文件
cp SKILL.md ~/.claude/skills/wechat-exporter.md

# 方式二:创建目录(适合后续扩展)
mkdir -p ~/.claude/skills/wechat-exporter
cp SKILL.md ~/.claude/skills/wechat-exporter/skill.md

以上示例为全局安装(所有项目可用)。如需项目级安装,将 `~/.claude/skills/` 替换为 `<你的项目>/.claude/skills/`。

2. 运行

在 Claude Code 中输入:

导出微信聊天记录

或直接调用技能名:

/wechat-exporter

技能会一步步引导你完成整个过程,包括:

  1. 安装系统依赖(brew install sqlcipher
  2. 下载并编译密钥扫描工具
  3. 对微信进行重签名(需要 sudo
  4. 提取数据库加密密钥(需要 sudo,需手动在终端执行)
  5. 解密所有聊天数据库
  6. 输出导出摘要

3. 导出结果

解密后的数据库存放在 `~/wechat-decrypt-macos/decrypted/`:

decrypted/
├── contact/
│   └── contact.db          # 联系人
├── message/
│   ├── message_0.db        # 消息分片(按时间段切割)
│   ├── message_1.db
│   └── ...
├── session/
│   └── session.db          # 会话列表
└── ...

所有数据库均为标准 SQLite 格式,可以用 `sqlite3`、DB Browser for SQLite 等任何工具直接查询。

数据库结构

联系人(contact.db)

`contact` 表中 `local_type` 字段含义:

local_type 含义
1 真实好友(双向添加)
3 有过消息往来但未必是好友
0 服务号、系统通知

消息分片(message_*.db)

消息按**时间段**分片存储,`message_0.db` 通常是最近一年的主力库。每个联系人的消息存储在独立的 `Msg_` 表中,`` 为联系人 `username` 的 MD5 哈希值。

可通过 `Name2Id` 表建立 username 到表名的映射:

import hashlib, sqlite3

conn = sqlite3.connect("message_0.db")
for (username,) in conn.execute("SELECT user_name FROM Name2Id"):
    table = "Msg_" + has