iMessage/SMS命令行工具Skill imsg

imsg 是一个 macOS 命令行工具,用于通过 Messages.app 读取和发送 iMessage 和 SMS 消息。它允许用户列出聊天记录、查看历史消息、监听新消息以及向电话号码或 Apple ID 发送文本和附件。适用于自动化消息处理、脚本集成和快速消息操作。关键词:iMessage, SMS, macOS, 命令行, 消息自动化, Messages.app, 聊天记录, 消息发送

操作系统 2 次安装 15 次浏览 更新于 2/24/2026

name: imsg description: 通过macOS Messages.app读取和发送iMessage/SMS的CLI工具。 homepage: https://imsg.to metadata: { “openclaw”: { “emoji”: “📨”, “os”: [“darwin”], “requires”: { “bins”: [“imsg”] }, “install”: [ { “id”: “brew”, “kind”: “brew”, “formula”: “steipete/tap/imsg”, “bins”: [“imsg”], “label”: “安装 imsg (brew)”, }, ], }, }

imsg

使用 imsg 通过 macOS Messages.app 读取和发送 iMessage/SMS。

使用时机

在以下情况使用此技能:

  • 用户明确要求发送 iMessage 或 SMS
  • 读取 iMessage 对话历史记录
  • 查看最近的 Messages.app 聊天
  • 向电话号码或 Apple ID 发送消息

不应使用的情况

在以下情况不要使用此技能:

  • Telegram 消息 → 使用 message 工具并指定 channel:telegram
  • Signal 消息 → 如果已配置,使用 Signal 通道
  • WhatsApp 消息 → 如果已配置,使用 WhatsApp 通道
  • Discord 消息 → 使用 message 工具并指定 channel:discord
  • Slack 消息 → 使用 slack 技能
  • 群聊管理(添加/移除成员)→ 不支持
  • 批量/群发消息 → 始终先与用户确认
  • 在当前对话中回复 → 正常回复即可(Clawdbot 会自动路由)

要求

  • 已登录 Messages.app 的 macOS 系统
  • 终端拥有完全磁盘访问权限
  • Messages.app 的自动化权限(用于发送)

常用命令

列出聊天

imsg chats --limit 10 --json

查看历史记录

# 通过聊天ID
imsg history --chat-id 1 --limit 20 --json

# 包含附件信息
imsg history --chat-id 1 --limit 20 --attachments --json

监听新消息

imsg watch --chat-id 1 --attachments

发送消息

# 仅文本
imsg send --to "+14155551212" --text "你好!"

# 带附件
imsg send --to "+14155551212" --text "看看这个" --file /path/to/image.jpg

# 指定服务
imsg send --to "+14155551212" --text "嗨" --service imessage
imsg send --to "+14155551212" --text "嗨" --service sms

服务选项

  • --service imessage — 强制使用 iMessage(要求接收方拥有 iMessage)
  • --service sms — 强制使用 SMS(绿色气泡)
  • --service auto — 让 Messages.app 决定(默认)

安全规则

  1. 发送前始终确认收件人和消息内容
  2. 未经用户明确批准,切勿向未知号码发送消息
  3. 小心处理附件 — 确认文件路径存在
  4. 自我限制发送频率 — 不要滥发

示例工作流程

用户:“给妈妈发短信说我可能会迟到”

# 1. 找到妈妈的聊天
imsg chats --limit 20 --json | jq '.[] | select(.displayName | contains("Mom"))'

# 2. 与用户确认
# "在 +1555123456 找到了妈妈。通过 iMessage 发送‘我可能会迟到’吗?"

# 3. 确认后发送
imsg send --to "+1555123456" --text "我可能会迟到"