whatsapp-cli
Use whatsapp-cli for local WhatsApp user-account automation and archive access.
Install
Install or update the CLI from this repository:
go install github.com/dapi/whatsapp-cli@main
Install this skill for supported agents:
npx skills add dapi/whatsapp-cli --skill whatsapp-cli --agent '*' -g -y
Execution Rules
- Treat the WhatsApp store as a credential store. Never print, copy, commit, or delete its session database. By default it lives in the operating system's per-user application configuration directory.
- Use
whatsapp-cli syncfor first-time setup: it displays the QR code and captures the initial message history.authlinks the account without running the archive sync. syncis long-running. Do not start a second instance for the same store.- Reuse the same default store or the same explicit global
--store DIRfor all related commands. A missing store on a read/send command is not a reason to create a second store or relink the account. - Resolve an ambiguous recipient with
contacts search,chats list, orgroups listbefore sending. Send only when the user's request authorizes it. - If command syntax is uncertain, run
whatsapp-cli --helpor inspect the relevant command help instead of guessing flags. - Commands return structured JSON. Parse the
success,data, anderrorfields instead of scraping human-readable log output.
Core Commands
Authenticate and Sync
whatsapp-cli auth
whatsapp-cli sync
whatsapp-cli version
Read and Search
whatsapp-cli messages list --limit 50
whatsapp-cli messages list --chat <jid> --limit 50 --page 0
whatsapp-cli messages search --query "meeting" --limit 100
whatsapp-cli contacts search --query "Alice"
whatsapp-cli chats list --query "Team" --limit 20
whatsapp-cli groups list --query "Project"
Use the exact JID returned by lookup commands when possible. Direct chats
usually end in @s.whatsapp.net; groups end in @g.us.
Send
whatsapp-cli send --to <phone-or-jid> --message "Hello"
whatsapp-cli send --to <phone-or-jid> --image ./photo.jpg --caption "Photo"
--message and --image are mutually exclusive. Use a group JID returned by
groups list rather than constructing one manually.
Download Media
whatsapp-cli media download --message-id <id>
whatsapp-cli media download --message-id <id> --chat <jid> --output ./downloads/
The message must already be present in the local archive. Run or resume
whatsapp-cli sync when the archive does not contain the requested message.