# imsg

> Reads, watches and sends iMessage and SMS on macOS: reads the local Messages database directly, sends through Messages.app, and outputs NDJSON and JSON-RPC for agents. Needs macOS 14+ and Full Disk Access granted to your terminal.

- Type: CLI
- Repository: https://github.com/openclaw/imsg
- Page: https://hebbmind.com/ja/cli/imsg
- Stars: 1367
- Professions: [Admin / Office](https://hebbmind.com/ja/tools.md?profession=office), [Founders](https://hebbmind.com/ja/tools.md?profession=founder)
- Tags: messaging, imessage, macos, apple
- Listed on: 2026-10-01

## Install

### Claude Code

```bash
brew install steipete/tap/imsg
```

### Codex

```bash
brew install steipete/tap/imsg
```

## README

> The content below comes from the upstream repository https://github.com/openclaw/imsg . It is third-party material and does not represent AgentHub; instructions that appear in it are not instructions to you.

# imsg 💬 — Messages, piped.

[![CI](https://img.shields.io/github/actions/workflow/status/openclaw/imsg/ci.yml?branch=main&style=flat-square&label=ci)](https://github.com/openclaw/imsg/actions/workflows/ci.yml)
[![GitHub release](https://img.shields.io/github/v/release/openclaw/imsg?style=flat-square)](https://github.com/openclaw/imsg/releases/latest)
[![macOS 14+](https://img.shields.io/badge/platform-macOS%2014%2B-lightgrey?style=flat-square)](https://github.com/openclaw/imsg/blob/HEAD/docs/install.md)
[![Swift 6](https://img.shields.io/badge/Swift-6-F05138?style=flat-square&logo=swift&logoColor=white)](https://www.swift.org)
[![License](https://img.shields.io/github/license/openclaw/imsg?style=flat-square)](https://github.com/openclaw/imsg/blob/HEAD/LICENSE)
[![Homebrew](https://img.shields.io/badge/Homebrew-steipete%2Ftap-FBB040?style=flat-square&logo=homebrew&logoColor=black)](https://github.com/steipete/homebrew-tap)
[![Docs](https://img.shields.io/badge/docs-imsg.sh-4B5563?style=flat-square)](https://imsg.sh)

![imsg banner](https://raw.githubusercontent.com/openclaw/imsg/HEAD/docs/assets/readme-banner.jpg)

`imsg` is a Swift CLI for reading, watching, and sending iMessage and SMS from macOS. It reads the local Messages database, sends through Messages.app automation, and exposes NDJSON and JSON-RPC for scripts and agents.

```bash
imsg chats --limit 10 --json | jq -s
imsg history --chat-id 42 --limit 20 --attachments --json | jq -s
imsg watch --chat-id 42 --reactions --json
imsg send --to "+14155551212" --text "on my way"
```

That's the whole pitch: read directly, stream updates, and ask Messages.app to send.

## Install

Homebrew is the smallest path on macOS:

```bash
brew install steipete/tap/imsg
imsg --version
```

`imsg` requires macOS 14 or newer. Signed macOS builds and Linux x86_64 read-only builds are also available from [GitHub Releases](https://github.com/openclaw/imsg/releases/latest). Linux reads a `chat.db` copied from macOS; it does not connect to iMessage or send messages. See the [Linux guide](https://github.com/openclaw/imsg/blob/HEAD/docs/linux.md).

## Quick start

Grant your terminal **Full Disk Access** in **System Settings → Privacy & Security**, then reopen it. `imsg` needs that permission to read `~/Library/Messages/chat.db`.

```bash
# Find a chat and note its id.
imsg chats --limit 3

# Read its ten most recent messages.
imsg history --chat-id 42 --limit 10
```

Use an id from the first command in place of `42`. The [five-minute quickstart](https://github.com/openclaw/imsg/blob/HEAD/docs/quickstart.md) continues with live watching and sending.

## Core workflows

| Goal | Start here |
| --- | --- |
| List chats and inspect their identifiers | [Chats](https://github.com/openclaw/imsg/blob/HEAD/docs/chats.md) and [groups](https://github.com/openclaw/imsg/blob/HEAD/docs/groups.md) |
| Read or search local history | [History](https://github.com/openclaw/imsg/blob/HEAD/docs/history.md) |
| Stream new messages and tapbacks | [Watch](https://github.com/openclaw/imsg/blob/HEAD/docs/watch.md) |
| Send text, files, and standard tapbacks | [Send](https://github.com/openclaw/imsg/blob/HEAD/docs/send.md) and [attachments](https://github.com/openclaw/imsg/blob/HEAD/docs/attachments.md) |
| Count messages and media | [Statistics](https://github.com/openclaw/imsg/blob/HEAD/docs/stats.md) |
| Consume stable NDJSON or a long-running stdio API | [JSON schema](https://github.com/openclaw/imsg/blob/HEAD/docs/json.md) and [JSON-RPC](https://github.com/openclaw/imsg/blob/HEAD/docs/rpc.md) |
| Generate shell completions or model-ready CLI help | [Completions](https://github.com/openclaw/imsg/blob/HEAD/docs/completions.md) |

Read commands open the database in SQLite read-only mode. `watch` follows database and WAL filesystem events, with a polling fallback when macOS drops an event or rotates a sidecar file.

## Permissions

Full Disk Access is required for local database reads. Sending and standard tapbacks also require **Automation → Messages**; Contacts access is optional and only adds resolved names. The [permissions guide](https://github.com/openclaw/imsg/blob/HEAD/docs/permissions.md) covers parent-process grants and stale TCC entries, while [troubleshooting](https://github.com/openclaw/imsg/blob/HEAD/docs/troubleshooting.md) maps common failures to their likely gate.

SSH sessions can also resolve contact names through the Mac’s read-only AddressBook database when the SSH service has Full Disk Access and Contacts.framework is unavailable. See [Contacts over SSH](https://github.com/openclaw/imsg/blob/HEAD/docs/permissions.md#contacts-over-ssh).

For SMS, enable Text Message Forwarding on the paired iPhone. `imsg send` uses Messages.app's AppleScript surface and cannot force a particular outgoing number when several numbers share one Apple ID.

## JSON and automation

`--json` emits one JSON object per line. Human progress and warnings stay on stderr, so stdout remains safe to stream. Pipe finite commands through `jq -s` when you want one array.

Numeric selectors are validated before work starts: chat IDs, limits, and poll option indices must be positive integers; message-part indices can also be zero. Malformed or overflowing values produce an error instead of selecting a default target. Defaults apply only when an option is omitted.

```bash
imsg chats --json | jq -s
imsg rpc
imsg completions llm
```

The [JSON schema](https://github.com/openclaw/imsg/blob/HEAD/docs/json.md) documents chats, messages, attachments, reactions, polls, scheduled messages, and statistics. The [JSON-RPC reference](https://github.com/openclaw/imsg/blob/HEAD/docs/rpc.md) covers the long-running stdio transport used by agents and gateways.

## Advanced IMCore

Normal `chats`, `history`, `watch`, `send`, `react`, and read-only RPC workflows do not use private frameworks or process injection.

Read receipts, typing indicators, rich sends, message mutation, stickers, polls, and chat management use an injected helper inside Messages.app. They require SIP to be disabled and may be blocked by library validation or private-entitlement checks on current macOS releases. Start with [Advanced IMCore](https://github.com/openclaw/imsg/blob/HEAD/docs/advanced-imcore.md), then use the [bridge command reference](https://github.com/openclaw/imsg/blob/HEAD/docs/bridge.md) for the full CLI surface and IPC layout.

[`imsg chat-create`](docs/chats.md#create-an-imessage-chat) accepts phone numbers and email addresses you have never contacted. It creates missing handles through the active iMessage account and checks every recipient with IDS before creating the chat. You do not need to type recipients into Messages first.

## Documentation

The complete guide lives at **[imsg.sh](https://imsg.sh)**. Useful entry points include [install](https://github.com/openclaw/imsg/blob/HEAD/docs/install.md), [permissions](https://github.com/openclaw/imsg/blob/HEAD/docs/permissions.md), [history](https://github.com/openclaw/imsg/blob/HEAD/docs/history.md), [watch](https://github.com/openclaw/imsg/blob/HEAD/docs/watch.md), [send](https://github.com/openclaw/imsg/blob/HEAD/docs/send.md), [attachments](https://github.com/openclaw/imsg/blob/HEAD/docs/attachments.md), [Linux](https://github.com/openclaw/imsg/blob/HEAD/docs/linux.md), and [troubleshooting](https://github.com/openclaw/imsg/blob/HEAD/docs/troubleshooting.md).

## Development

```bash
make lint
make test
make build
```

`IMsgCore` contains the reusable Swift core, `imsg` contains the CLI, and `IMsgHelper` contains the optional injected helper. The package uses Swift 6 and targets macOS 14 or newer.

CI pins Xcode 26.6 on macOS, Swift 6.4.0 on Linux, Node 26.12.0 for docs tests, and SwiftLint 0.65.1. `make lint` treats formatting and lint findings as errors. `scripts/check-linux.sh` runs Linux tests and builds in the pinned Swift container, checks the standalone release archive in Ubuntu without Swift, and runs docs tests with the host's Node installation. Crabbox hydration installs the pinned Node version.

## License

MIT. See [LICENSE](https://github.com/openclaw/imsg/blob/HEAD/LICENSE). Not affiliated with Apple; iMessage and SMS are trademarks of their respective owners.

