Skip to main content

Run a coding CLI (codex / claude) behind a dedicated WhatsApp number.

Project description

whatsapp-agent-cli

Run a coding CLI behind a dedicated WhatsApp number.

PyPI Python versions Platform MIT License

whatsapp-agent installs a WhatsApp bridge on your server, wires it to a local coding CLI (codex or claude), and keeps per-chat session state — so you can message your server like a real operator instead of SSHing in every time.

You (WhatsApp)  ──▶  Baileys bridge  ──▶  gateway  ──▶  codex / claude
                          ▲                  │
                          └──── replies ◀────┘

Why

  • One number per server. Your phone becomes the control surface. No web UIs, no port forwarding, no VPNs.
  • Per-chat memory. Each WhatsApp chat keeps its own working directory, model, session, and summary — so chat A can stay on one repo while chat B works somewhere else.
  • Real CLI access. It's not a wrapper API — it shells out to the actual codex / claude binary on the host with full tool use, file edits, etc.
  • Self-hosted, local-only. Everything (bridge, gateway, state) runs on your box. No third-party message broker.

Requirements

  • Linux server with systemd --user (or macOS for whatsapp-agent run foreground mode)
  • Python 3.10+
  • Node.js 18+
  • One of codex or claude, already installed and authenticated on the server
  • A WhatsApp account or number to pair with the bridge

Install

The fastest path — one command, zero clones:

uvx whatsapp-agent-cli install

Or install the CLI persistently:

# uv (recommended)
uv tool install whatsapp-agent-cli

# pip
pip install whatsapp-agent-cli

Then run:

whatsapp-agent install

The installer is an interactive TUI (arrow keys to pick, Enter to confirm). It will:

  • auto-detect claude and codex on your PATH and pick one
  • ask whether to run in bot or self-chat mode
  • ask for your allowed WhatsApp number(s)
  • pick the next free bridge port starting at 3010
  • hide root / model / port / CLI-path behind an opt-in Advanced toggle
  • show a review screen, then install Python + Node deps, write .env, and install the user service
  • offer to pair WhatsApp immediately

Default install root: ~/.agent-whatsapp. Default service: agent-whatsapp.service.

Non-interactive install

WHATSAPP_ALLOWED_USERS=919876543210 \ (Your WhatsApp number with country code)
  whatsapp-agent install --non-interactive

Reads from env vars (AGENT_BACKEND, AGENT_COMMAND, WHATSAPP_MODE, WHATSAPP_PORT, AGENT_ROOT, AGENT_MODEL) and falls back to auto-detection. Only WHATSAPP_ALLOWED_USERS is mandatory.

From source

git clone https://github.com/kalki-kgp/whatsapp-agent-cli.git
cd whatsapp-agent-cli
bash scripts/install.sh

Pair WhatsApp

If you skipped pairing during install:

whatsapp-agent pair

A QR code prints in the terminal. Scan it from WhatsApp → Linked devices. The session is stored under ~/.agent-whatsapp/whatsapp/session and survives restarts.

CLI reference

whatsapp-agent install [--reconfigure] [--non-interactive]
                                    # interactive setup; --reconfigure re-runs
                                    # prompts using saved .env as defaults
whatsapp-agent pair                 # re-pair WhatsApp (prints QR)
whatsapp-agent run                  # foreground gateway (no systemd; macOS too)
whatsapp-agent service start        # systemd user service controls
whatsapp-agent service stop
whatsapp-agent service restart
whatsapp-agent service status
whatsapp-agent service logs         # journalctl -f
whatsapp-agent doctor               # diagnose the install
whatsapp-agent path                 # print the install dir
whatsapp-agent --version

--install-dir <path> works on every subcommand if you want to manage multiple installs side-by-side.

Chat commands

Send these as WhatsApp messages from any allowed number:

Command What it does
/status Backend, root, active thread, model, summary state, saved-session count
/new (or /clear) Archive the current session, start fresh
/reset Clear the live session immediately
/resume List saved sessions for this chat
/resume <name> Restore a saved session by name
/title <name> Name the current session
/root /abs/path Change the working directory for this chat
/model <name> Change the model for this chat
/compact Roll the conversation into a carry-forward summary
/help Show the command list

Configuration

Settings live in ~/.agent-whatsapp/.env. Edit by hand or re-run whatsapp-agent install --reconfigure.

Var Purpose
AGENT_BACKEND codex or claude
AGENT_COMMAND Path or command name for the selected CLI
AGENT_MODEL Default model (blank = CLI default)
AGENT_ROOT Default working directory for new chats
WHATSAPP_MODE bot (separate WhatsApp account) or self-chat (your own number)
WHATSAPP_ALLOWED_USERS Comma-separated phone numbers / LIDs allowed to message the bridge
WHATSAPP_PORT Local bridge HTTP port (default 3010)
CW_LOG_LEVEL Python log level (default INFO)

For WHATSAPP_ALLOWED_USERS, full international format is the safest:

WHATSAPP_ALLOWED_USERS=917385166726, 14155551212

The bridge also tolerates suffix-only input and resolves LID↔phone via bridge/allowlist.js, but country-code format is the cleanest.

Troubleshooting

Run a self-diagnostic:

whatsapp-agent doctor

It checks Python / Node / uv versions, install dir population, .env validity, CLI binary existence, the runtime venv, and bridge node_modules — and tells you exactly what's broken.

For deeper digging, tail the live logs:

whatsapp-agent service logs       # systemd
# or, in foreground / on macOS
whatsapp-agent run

Architecture

Two processes, one wrapper CLI on top.

┌────────────────────────────────────────────────────────────────┐
│  ~/.agent-whatsapp/                                            │
│                                                                │
│   bridge/bridge.js  (Node + Baileys)                           │
│     ├─ pairs with WhatsApp                                     │
│     ├─ exposes 127.0.0.1:WHATSAPP_PORT                         │
│     └─ stores creds in whatsapp/session/                       │
│                                                                │
│   server/gateway.py  (Python + aiohttp)                        │
│     ├─ polls bridge /messages                                  │
│     ├─ per-chat asyncio.Lock                                   │
│     ├─ persists state.json                                     │
│     └─ shells out to codex / claude with --resume              │
│                                                                │
│   .venv/             (python deps for the gateway)             │
│   bridge/node_modules/                                         │
│   .env               (config, mode 600)                        │
│   state.json         (per-chat session metadata)               │
└────────────────────────────────────────────────────────────────┘

whatsapp-agent install populates this layout from a wheel-bundled copy of bridge/, server/, scripts/, and systemd/, then runs npm install and uv pip install. Subsequent whatsapp-agent install --reconfigure rewrites only .env, leaving the venv / node_modules / WhatsApp session intact.

Per-chat session state stores: thread_id, root, model, summary, and up to 30 saved_sessions.

Repository layout

Path What it is
src/whatsapp_agent/cli.py The whatsapp-agent Python CLI (entry point)
bridge/ Node WhatsApp bridge (Baileys)
server/gateway.py Python async gateway + per-chat session state
scripts/install.sh The TUI installer (also runnable standalone)
scripts/pair.sh Pairing helper
scripts/start.sh, stop.sh Service convenience wrappers
systemd/agent-whatsapp.service User-mode systemd unit template
pyproject.toml Hatchling build, ships the runtime inside the wheel

Privacy

  • All data stays on your host. WhatsApp credentials, chat sessions, and CLI output never leave the box.
  • The bridge speaks to WhatsApp's servers only — same as the official WhatsApp Web client.
  • .env is mode 600 and intentionally not committed.

Notes

  • Wiping ~/.agent-whatsapp also wipes the WhatsApp session — you'll need to whatsapp-agent pair again.
  • This project is designed as an isolated WhatsApp control layer for coding CLIs. It does not need to attach itself to your existing Telegram setup or other local agent workflows.
  • macOS hosts work for whatsapp-agent install and whatsapp-agent run; the service subcommands need Linux + systemd --user.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whatsapp_agent_cli-0.1.1.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatsapp_agent_cli-0.1.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_agent_cli-0.1.1.tar.gz.

File metadata

  • Download URL: whatsapp_agent_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for whatsapp_agent_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ceb76f1175e558d6c4f3408432aacd1029ea6a3a00fd8ad833a4c0e495635a06
MD5 1af8f567dd7212220fc093d33d37ad44
BLAKE2b-256 48e6085a9161ed5db67a86c7d11f7ce933f22c22d2218f8d7609f7ec9798de42

See more details on using hashes here.

File details

Details for the file whatsapp_agent_cli-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_agent_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a1625e119c74f62af74465f9e07f31d8828964761485f74adad9f5e27d27e1c
MD5 1e654978131d652cf41e7b33c80299d4
BLAKE2b-256 ca23e85e852095e34b3e9a3e1b2261f03657651767b3aca46d21425f7bbf9f97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page