# wacli

WhatsApp CLI for syncing messages locally, searching offline, and sending messages. Built on `whatsmeow` (WhatsApp Web protocol). Local-first: stores everything in SQLite with FTS5 for fast offline search.

## What it does

- Sync message history locally with continuous capture
- Fast offline full-text search
- Send text messages and files
- Contact and group management
- Best-effort backfill of older messages

## Key commands

```bash
# Authenticate (shows QR code) and initial sync
wacli auth

# Continuous sync (no QR, requires prior auth)
wacli sync --follow

# Search messages offline
wacli messages search "meeting"

# Send a message
wacli send text --to 1234567890 --message "hello"

# Send a file with caption
wacli send file --to 1234567890 --file ./pic.jpg --caption "hi"

# Backfill older messages for a chat
wacli history backfill --chat 1234567890@s.whatsapp.net --requests 10 --count 50

# List and manage groups
wacli groups list
wacli groups rename --jid 123456789@g.us --name "New name"
```

## Storage

Default: `~/.wacli` (override with `--store DIR`). SQLite with FTS5 for search.

## History backfill

WhatsApp Web sends what it sends opportunistically. To fetch older messages:

- Request from your primary device (phone must be online)
- Per-chat, anchored to oldest local message
- Best-effort: WhatsApp may not return full history
- Recommended: `--count 50` per request

Backfill all known chats:

```bash
wacli --json chats list --limit 100000 \
  | jq -r '.[].JID' \
  | while read -r jid; do
      wacli history backfill --chat "$jid" --requests 3 --count 50
    done
```

## Install

```bash
# Homebrew
brew install steipete/tap/wacli

# Or build from source
go build -tags sqlite_fts5 -o ./dist/wacli ./cmd/wacli
```

## Environment

- `WACLI_DEVICE_LABEL` — linked device label shown in WhatsApp
- `WACLI_DEVICE_PLATFORM` — override platform (defaults to CHROME)

## Notes

Third-party tool, not affiliated with WhatsApp. Uses WhatsApp Web protocol via whatsmeow. Output is human-readable by default; `--json` for machine-readable.

---

Repo: https://github.com/steipete/wacli (1,554 stars)
