Ops inbox

From davepoon/buildwithclaude · View interactive version

Ops inbox is an AI agent skill from the GitHub repository davepoon/buildwithclaude. Full inbox management across all channels — WhatsApp (wacli), Email (Gmail MCP), Slack (MCP), Telegram (user-auth MCP), Discord (webhook + REST read), Notion (MCP — comments, mentions, assigned tasks). Scans FULL inbox (not just unread), identifies messages needing replies, archives handled conversa

How to use this skill

Skill file

OPS ► INBOX ZERO

Runtime Context

Before executing, load available context:

  1. Preferences: Read ${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/preferences.json
  1. Daemon health: Read ${CLAUDE_PLUGIN_DATA_DIR}/daemon-health.json
  1. Ops memories: Check ${CLAUDE_PLUGIN_DATA_DIR}/memories/ before drafting any reply:

CLI/API Reference

wacli (WhatsApp)

Health file — check ~/.wacli/.health BEFORE any wacli command:

| Command | Usage | Output |

|---------|-------|--------|

| wacli doctor --json | Check auth/connected/lock/FTS | {data: {authenticated, connected, lock_held, fts_enabled}} |

| wacli chats list --json | All chats | {data: [{JID, Name, Kind, LastMessageTS}]} |

| wacli messages list --chat "<JID>" --limit N --json | Messages for chat | {data: {messages: [{FromMe, Text, Timestamp, SenderName, ChatName}]}} |

| wacli messages search --query "<text>" --json | FTS search | Same as above |

| wacli contacts --search "<name>" --json | Contact lookup | Contact objects |

| wacli send --to "<JID>" --message "<msg>" | Send text | Success/error |

| wacli history backfill --chat="<JID>" --count=50 --requests=2 --wait=30s --idle-exit=5s --json | Fetch older messages | Backfill result |

gog CLI (Gmail/Calendar)

| Command | Usage | Output |

|---------|-------|--------|

| gog gmail search "in:inbox" --max 50 -j --results-only --no-input | Full inbox scan | JSON array of threads |

| gog gmail thread get <threadId> -j | Get full thread with all messages | Full message JSON |

| gog gmail get <messageId> -j | Get single message | Message JSON |

| gog gmail archive <messageId> ... --no-input --force | Archive messages (remove from inbox) | Archive result |

| gog gmail archive --query "<gmail-query>" --max N --force | Archive by query | Archive result |

| gog gmail send --to "<email>" --subject "<subj>" --body "<body>" | Send email | Send result |

| gog gmail send --reply-to-message-id <msgId> --reply-all --body "text" | Reply all | Send result |

| gog gmail mark-read <messageId> ... --no-input | Mark as read | Result |

| gog gmail labels list -j | List all labels | Labels JSON |


Agent Teams support

If CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 is set, use Agent Teams when processing "all channels" mode. This enables:

Team setup (only when flag is enabled, "all channels" mode):

TeamCreate("inbox-channels")
Agent(team_name="inbox-channels", name="whatsapp-scanner", ...)
Agent(team_name="inbox-channels", name="email-scanner", ...)
Agent(team_name="inbox-channels", name="slack-scanner", ...)
Agent(team_name="inbox-channels", name="telegram-scanner", ...)
Agent(team_name="inbox-channels", name="notion-scanner", ...)

Each agent scans its channel and reports back classified results. You then process NEEDS_REPLY items across all channels in priority order.

If the flag is NOT set, process channels sequentially or use fire-and-forget subagents.

Pre-gathered data

${CLAUDE_PLUGIN_ROOT}/../../bin/ops-unread 2>/dev/null || echo '{}'

Environment variables

All channel credentials come from env vars or CLI auth — no hardcoded secrets.

| Variable | Default | Purpose |

| ------------------- | ----------- | ---------------------------------------------------- |

| GMAIL_ACCOUNT | auto-detect | Gmail account for gog CLI |

| SLACK_MCP_ENABLED | false | Set true when Slack MCP server is configured |

| TELEGRAM_ENABLED | false | Set true when Telegram user-auth MCP is configured |

| NOTION_MCP_ENABLED| false | Set true when Notion MCP integration is configured |

| WACLI_STORE | ~/.wacli | wacli store directory |

Core principle: FULL INBOX SCAN

Do NOT just check unread. Scan the FULL recent inbox for each channel and classify every conversation:

Core principle: FULL CONTEXT — NEVER ASSUME

CRITICAL SAFETY RULE — NEVER SEND WITHOUT UNDERSTANDING:

Before drafting or sending ANY reply on ANY channel, you MUST have read the FULL conversation history (20+ messages) and PROVEN you understand it by summarizing:

  1. What the conversation is about
  2. What each party said (distinguish user messages from contact messages)
  3. What the contact is actually asking/saying in their last message
  4. What a sensible reply would address

Failure mode this prevents: An agent reads only the last message "je kan het toch uit Klaviyo halen?" and replies "Welke data heb je nodig?" — completely wrong because the contact was telling the user to pull data themselves (they have 2FA), not asking for data. Without the full thread, the reply was nonsensical and confused the contact.

Hard rule: if you cannot summarize the conversation arc in 2 sentences, you have not read enough messages. Go back and read more.

The user does NOT remember every thread. For EVERY message you present, you MUST build full context BEFORE showing it. Never show just a subject line and ask "what do you want to do?" — the user needs to understand what it's about first.

For every NEEDS REPLY item, gather this context automatically:

  1. Full thread body — read the ENTIRE thread (gog gmail thread get / wacli messages list --limit 20), not just the last message. Summarize the full conversation arc.
  2. Contact profile — search across channels to build a card:
  1. Topic context — identify the subject matter and search for related threads:
  1. ops-memories (if available) — check ~/.claude/plugins/data/ops-ops-marketplace/memories/ for any stored context about this contact or topic

When presenting a NEEDS REPLY item:

━━━ [Contact Name] — [Subject] ━━━
 Who: [role, company, relationship — from contact search]
 History: [last 3 interactions across channels]
 Thread: [2-3 sentence summary of full conversation arc]
 Last msg: [full body of their last message]
 Context: [related threads/decisions/deadlines found]
 
 Draft reply: "[contextually aware draft based on all above]"
 
 [Send] [Edit] [Read full thread] [Skip]

When drafting replies:

Channel availability + fallback

For each channel, detect availability at runtime:

  1. Email: Try gog CLI first. If gog unavailable, try mcp__gog__gmail_* MCP tools. If neither, report unavailable.
  2. WhatsApp: First check ~/.wacli/.health for keepalive daemon status. If status=needs_auth or status=needs_reauth, do NOT attempt wacli commands — instead prompt the user: "WhatsApp needs re-authentication. Run wacli auth in a separate terminal and scan the QR code, then type 'done'." Use AskUserQuestion: [Done — re-paired], [Skip WhatsApp]. On Done, restart the daemon: launchctl kickstart -k gui/$(id -u)/com.claude-ops.wacli-keepalive, wait 5s, re-check health. If no health file exists, fall back to wacli doctor for auth/connection status. If outdated (405 error), advise rebuilding from source.
  3. Slack: Only via MCP tools (mcp__claude_ai_Slack__*). Check SLACK_MCP_ENABLED env var.
  4. Telegram: Only via user-auth MCP (tdlib/MTProto). Check TELEGRAM_ENABLED env var. Never use BotFather bots.
  5. Discord: Via ${CLAUDE_PLUGIN_ROOT}/bin/ops-discord read <CHANNEL_ID> --limit 20 --json. Requires DISCORD_BOT_TOKEN (v1 is channel-scoped — no DM/gateway support yet). Pre-configured read list lives at ${CLAUDE_PLUGIN_DATA_DIR}/preferences.json under discord.inbox_channels (array of channel IDs). If neither a bot token nor a read list is configured, skip Discord with a one-line note ("Discord not configured — run /ops:setup discord") rather than prompting — ops-inbox is not a setup flow. Rule 3 still applies to /ops:setup.
  6. Notion: Only via MCP tools (mcp__claude_ai_Notion__* or self-hosted Notion MCP). Check NOTION_MCP_ENABLED env var. Searches workspace for recent comments, mentions, and assigned tasks.

Your task

  1. Parse pre-gathered data for initial counts (unread is just a starting signal).
  1. For each channel, run a FULL scan (not just unread):
  1. Display the full inbox:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 OPS ► INBOX MANAGER
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 📱 WhatsApp    [N need reply] | [N waiting] | [N archive]
 📧 Email       [N need reply] | [N waiting] | [N FYI]
 💬 Slack       [N need reply] | [N waiting]
 ✈️  Telegram   [N need reply] | [N waiting]

──────────────────────────────────────────────────────

Use batched AskUserQuestion calls (max 4 options each). Only show channels that are configured and have messages. If <=4 total options, use a single call.

AskUserQuestion call 1:

  [All channels (fastest — one pass)]
  [WhatsApp only]
  [Email only]
  [More...]

AskUserQuestion call 2 (only if "More..."):

  [Slack only]
  [Telegram only]
  [Skip — already done]

If only 3 channels are configured, "All channels" + 3 channel options = 4, fits in one call. Then process the selected channel(s).


Processing each channel

WhatsApp (FULL SCAN + DEEP CONTEXT)

Phase 1 — Classify:

  1. Get all chats: wacli chats list --json
  2. Filter to chats with LastMessageTS in the last 7 days
  3. For each, fetch the FULL recent conversation: wacli messages list --chat "<JID>" --limit 20 --json — get 20 messages, NOT 5. You need the full conversation thread to understand context.
  4. Parse data.messages[] — fields: FromMe, Text, Timestamp, ChatName, SenderName
  5. For EVERY chat, understand the conversation:
  1. Classify each chat:

Phase 2 — Build context for NEEDS REPLY chats (run in parallel):

For each NEEDS REPLY chat:

  1. Full conversation summary — read all 20 messages, summarize the arc: what was discussed, key decisions, open questions
  2. Contact profile — search for this person:
  1. Topic context — extract keywords from the conversation and search:
  1. User's messaging style — from the FromMe: true messages in this chat, note: language (NL/EN), formality, emoji usage, typical response length

Phase 3 — Present with full context:

📱 WHATSAPP — NEEDS REPLY (with context)

━━━ 1. [Contact Name] ━━━
 Who: [role, company, relationship — from contact search]
 History: [last 3 interactions across channels]
 Conversation: [2-3 sentence summary of the full chat thread]
 Their message: [full text of their last message(s)]
 Your last msg: [what you said before they replied]
 Context: [related threads/topics found]
 Language: [NL/EN — match the user's previous messages in this chat]

 Draft reply: "[context-aware draft matching user's style + language]"

 [Send] [Edit] [Read full thread] [More...]

If "More...":
 [Archive] [Skip]

📱 WHATSAPP — WAITING (no action needed)
 N. [Contact] — you said: "[your last message]" — [time ago]
    Thread: [1-line summary of what you're waiting for]

Use AskUserQuestion for each NEEDS REPLY chat.

When drafting WhatsApp replies:

Reply via: wacli send --to "<JID>" --message "<msg>"

wacli CLI reference (v0.5.0):

| Command | Usage | Notes |

|---------|-------|-------|

| wacli doctor | wacli doctor --json | Check auth/connected/lock/FTS status |

| wacli auth | wacli auth | QR pairing (interactive — shows QR in terminal) |

| wacli sync | wacli sync --follow --refresh-contacts --refresh-groups | Persistent sync (managed by launchd keepalive) |

| wacli sync --once | wacli sync --once --idle-exit=10s | One-shot sync, exits when idle |

| wacli chats list | wacli chats list --json | All chats with JID, Name, Kind, LastMessageTS |

| wacli messages list | wacli messages list --chat "<JID>" --limit 5 --json | Messages: ChatJID, FromMe, Text, Timestamp, SenderName |

| wacli messages search | wacli messages search --query "<text>" --json | FTS5 search across all messages |

| wacli contacts | wacli contacts --search "<name>" --json | Contact lookup by name |

| wacli send | wacli send --to "<JID>" --message "<msg>" | Send text message |

| wacli history backfill | wacli history backfill --chat="<JID>" --count=50 --requests=2 --wait=30s --idle-exit=5s --json | Fetch older messages from phone (needs store lock) |

Health file contract (~/.wacli/.health):

Before ANY wacli command, read ~/.wacli/.health:

Requesting backfill for @lid chats with empty messages:

The keepalive daemon holds the store lock, so you can't run backfill directly. Instead:

  1. Write JIDs to ~/.wacli/.backfill_jids (one per line)
  2. Restart the daemon: launchctl kickstart -k gui/$(id -u)/com.claude-ops.wacli-keepalive
  3. The daemon runs backfill before starting persistent sync

wacli troubleshooting:

Email (FULL SCAN + DEEP CONTEXT)

Phase 1 — Classify:

  1. Search in:inbox (NOT is:unread) via gog gmail search -a $GMAIL_ACCOUNT -j --results-only --no-input --max 30 "in:inbox"
  2. For each thread, read the FULL thread via gog gmail thread get -a $GMAIL_ACCOUNT <threadId> -j — read ALL messages, not just the last one
  3. Check the last message's From header and labelIds (SENT, DRAFT)
  4. Classify:

Phase 2 — Build context for NEEDS REPLY items (run in parallel):

For each NEEDS REPLY thread, gather:

  1. Full thread summary — read every message in the thread, summarize the conversation arc (who said what, key decisions, open questions)
  2. Contact profile — for the sender:
  1. Topic search — extract key terms from subject + body, then:

Phase 3 — Present with full context:

📧 EMAIL — NEEDS REPLY (with context)

━━━ 1. [Sender] — [Subject] ━━━
 Who: [sender's role, company — from contact search]
 History: [last 3 email exchanges with this person]
 Thread summary: [2-3 sentences covering the full conversation arc]
 Their message: [full body of their last message — NOT truncated]
 Related: [any related threads or pending decisions found]

 Draft reply: "[context-aware draft using full thread + contact history]"

 [Send draft] [Edit draft] [Read full thread] [More...]

If "More...":
 [Archive] [Skip]

📧 EMAIL — DRAFTS (unsent)
 N. [Recipient] — [Subject] (draft ready to send)

📧 EMAIL — FYI / ARCHIVE
 N. [Sender] — [Subject] (newsletter/notification)

  For each NEEDS REPLY:
  a) Read full thread + draft reply
  b) Archive (no reply needed)
  c) Skip

  For FYI section:
  x) Archive all FYI at once

Use AskUserQuestion for each NEEDS REPLY email with options [Read + Reply] / [Archive] / [Skip].

When replying, draft the reply and use AskUserQuestion to confirm:

Reply to [Sender] — [Subject]:
  "[drafted reply]"

  [Send]  [Edit]  [Skip]

For FYI bulk archive, use AskUserQuestion:

Archive N FYI/newsletter emails?
  [list of subjects]

  [Archive all N]  [Review each]  [Skip]

Draft replies via gog gmail send. Archive via gog gmail archive <messageId> ... --no-input --force.

Slack

Use Slack MCP tools with query: "in:*" (NOT is:unread — scan full recent activity, not just unread) for mentions.

For each result, show channel, sender, preview. Read thread for context.

  a) Read thread
  b) Reply
  c) Mark read / skip

Telegram (FULL SCAN — User Account, NOT Bot)

Telegram integration must authenticate as the user's personal account (user-auth via tdlib/MTProto), NOT a BotFather bot. The goal is to manage real conversations just like WhatsApp via wacli.

Use the Telegram user-auth MCP server if available.

  1. List recent dialogs/conversations (last 7 days)
  2. For each, check who sent the last message
  3. Classify: NEEDS REPLY / WAITING / HANDLED
✈️  TELEGRAM — NEEDS REPLY
 1. [Contact] — [preview] — [time ago]

  a) Read thread + reply
  b) Archive
  c) Skip

If no Telegram user-auth tool is available, report: "Telegram not configured — needs user-auth MCP server (tdlib/MTProto)".

Notion (MCP — comments, mentions, assigned tasks)

Notion serves as a knowledge base and task management channel. Unlike messaging channels, Notion "inbox" items are:

Phase 1 — Discover and scan:

  1. Search for recent activity using mcp__claude_ai_Notion__notion-search:
  1. For each result, fetch full content: mcp__claude_ai_Notion__notion-fetch with the page URL/ID
  2. Get comments on active pages: mcp__claude_ai_Notion__notion-get-comments with the page ID — scan comment authors and timestamps to determine which need replies

Phase 2 — Classify:

For each page with comments or mentions:

Phase 3 — Present with context:

📓 NOTION — NEEDS REPLY

━━━ 1. [Page Title] — [Database Name] ━━━
 Page: [page URL]
 Comment by: [commenter name] — [time ago]
 Comment: "[full comment text]"
 Page context: [2-3 sentence summary of the page content]

 Draft reply: "[context-aware reply to the comment]"

 [Reply] [View page] [Skip] [More...]

If "More...":
 [Mark resolved] [Archive]

📓 NOTION — ASSIGNED TASKS

 N. [Task title] — [database] — Status: [status] — Due: [date]
    Context: [1-line summary]

📓 NOTION — RECENTLY UPDATED (FYI)

 N. [Page title] — updated by [person] — [time ago]

Use AskUserQuestion for each NEEDS REPLY item.

When replying to Notion comments:

When updating tasks:

API fallback (when MCP is down):

If Notion MCP tools fail or are unavailable but NOTION_API_KEY is set, fall back to direct API:

curl -s -H "Authorization: Bearer $NOTION_API_KEY" -H "Notion-Version: 2022-06-28" \
  -H "Content-Type: application/json" \
  -X POST https://api.notion.com/v1/search \
  -d '{"sort":{"direction":"descending","timestamp":"last_edited_time"},"page_size":10}'

If NOTION_MCP_ENABLED is not set or Notion MCP tools are unavailable, report: "Notion not configured — set NOTION_MCP_ENABLED=true and add Notion integration via claude.ai or self-hosted MCP".

Discord (v1 — REST channel scan)

Discord v1 support is channel-scoped (webhook send + REST read). DM + gateway are deferred to a v2 issue.

  1. Resolve the read list: read ${CLAUDE_PLUGIN_DATA_DIR}/preferences.json → discord.inbox_channels[]. If empty and DISCORD_GUILD_ID is set, fall back to bin/ops-discord channels --json (list the guild's text channels and let the user pick via AskUserQuestion, ≤4 per Rule 1 — paginate with [More...]).
  2. For each channel ID:

```bash

${CLAUDE_PLUGIN_ROOT}/bin/ops-discord read "<CHANNEL_ID>" --limit 20 --json

```

  1. Classify each channel's recent messages:
  1. For replies, reuse the send path documented in skills/ops-comms/SKILL.md → Discord send.

If bin/ops-discord exits 1 with {"error":"no discord credential configured — run /ops:setup discord"}, print a single-line note and continue to the next channel — do not prompt inside the inbox flow.

💬 DISCORD — activity (last 7d)
 #channel-name  [N messages] | [M need reply]

Completion

After all selected channels are processed, print:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 INBOX ZERO ✓ — [timestamp]
 Processed: [N] messages | Replied: [N] | Archived: [N]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

If $ARGUMENTS specifies a channel (e.g. whatsapp), skip the menu and go directly to that channel.


Native tool usage

Tasks — inbox progress

Use TaskCreate for each channel being processed. Update with TaskUpdate as messages are replied/archived/skipped. Gives the user a live inbox-zero progress bar.

Cron — scheduled inbox checks

After processing, offer to schedule recurring inbox checks via AskUserQuestion:

  [Schedule inbox check every 2 hours]  [Schedule morning + evening]  [No schedule]

Use CronCreate if selected. Show existing schedules with CronList.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.