关于 imsg
`imsg` 是 macOS 命令行工具,可通过 Messages.app 读取和发送 iMessage 与 SMS,适用于需要在终端处理消息的用户。它支持查看聊天记录、监听新消息及发送附件,但不支持管理群聊成员。
主要功能
- 01列出聊天并查看历史记录
- 02监听新到消息
- 03发送 iMessage 或 SMS
- 04发送文件附件
- 05按日期筛选消息
适用场景
- 01查找联系人对应的聊天
- 02查看指定聊天的近期消息
- 03监听聊天中的新消息
- 04向联系人发送文本或文件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ letta-ai/ skills --skill imsg安装后在 Claude Code 中输入/imsg确认已加载。
附带文件assets/imsg-small.svgLICENSE
详细介绍
imsg
使用 imsg 通过 macOS Messages.app 读取和发送 iMessage/SMS。
限制
- 不支持群聊管理(添加或移除成员)
- 仅限 macOS
要求
- 已登录 Messages.app 的 macOS
- 终端拥有“完全磁盘访问权限”
- Messages.app 的自动化权限(用于发送)
常用命令
列出聊天
imsg chats --limit 10 --json
查看历史记录
# By chat ID
imsg history --chat-id 1 --limit 20 --json
# With attachments info
imsg history --chat-id 1 --limit 20 --attachments --json
# Filter by date
imsg history --chat-id 1 --start 2026-01-01T00:00:00Z --json
监听新消息
imsg watch --chat-id 1 --attachments
imsg watch --chat-id 1 --debounce 250ms
发送消息
# Send to phone number
imsg send --to "+14155551212" --text "Hello!"
# Send to existing chat by ID (useful for replies)
imsg send --chat-id 86 --text "Hello!"
# With attachment
imsg send --to "+14155551212" --text "Check this out" --file /path/to/image.jpg
# Specify service
imsg send --to "+14155551212" --text "Hi" --service imessage
imsg send --to "+14155551212" --text "Hi" --service sms
服务选项
--service imessage— 强制使用 iMessage(要求收件人拥有 iMessage)--service sms— 强制使用 SMS(绿色气泡)--service auto— 由 Messages.app 决定(默认)
安全规则
- 发送前务必确认收件人和消息内容
- 未经用户明确批准,切勿发送给未知号码
- 谨慎处理附件——确认文件路径存在
- 注意控制发送频率——不要发送垃圾消息
示例工作流
用户:“给妈妈发短信,说我会晚点到”
# 1. Find mom's chat
imsg chats --limit 20 --json | jq '.[] | select(.displayName | contains("Mom"))'
# 2. Confirm with user
# "Found Mom at +1555123456. Send 'I'll be late' via iMessage?"
# 3. Send after confirmation
imsg send --to "+1555123456" --text "I'll be late"
评论
支持 Markdown