Inbox Summary

Quickly understand what's in your inbox without reading every email. Get AI-powered summaries grouped by topic or sender.

What it does

  1. Fetches your unread emails from Gmail
  2. Sends email content to Claude for summarization
  3. Returns a structured summary with urgent items highlighted

Prerequisites

  • cli4ai add gmail - Install the Gmail package
  • Gmail OAuth configured via cli4ai run gmail auth
  • claude CLI installed and authenticated

Usage

# Summarize last 20 unread emails
cli4ai routines run inbox-summary

# Summarize more emails
cli4ai routines run inbox-summary --var limit=50

Variables

Variable Default Description
limit 20 Number of unread emails to fetch

JSON Version

Save as ~/.cli4ai/routines/inbox-summary.routine.json

{
  "version": 1,
  "name": "inbox-summary",
  "description": "Summarize unread emails using AI",
  "vars": {
    "limit": { "default": "20" }
  },
  "steps": [
    {
      "id": "unread",
      "type": "cli4ai",
      "package": "gmail",
      "command": "unread",
      "args": ["{{vars.limit}}"],
      "capture": "json"
    },
    {
      "id": "summarize",
      "type": "exec",
      "cmd": "bash",
      "args": ["-c", "echo \"Summarize my unread emails. Group by sender or topic, highlight urgent items and action required:\n\n$EMAILS\" | claude --print"],
      "env": { "EMAILS": "{{steps.unread.stdout}}" },
      "capture": "text",
      "timeout": 60000
    }
  ],
  "result": "{{steps.summarize.stdout}}"
}

Bash Version

Save as ~/.cli4ai/routines/inbox-summary.routine.sh

#!/usr/bin/env bash
set -euo pipefail

# inbox-summary.routine.sh
# Usage: cli4ai routines run inbox-summary

LIMIT="${CLI4AI_VAR_LIMIT:-20}"

echo "📧 Fetching unread emails..." >&2

# Get unread emails
EMAILS=$(cli4ai run gmail unread "$LIMIT")

if [ -z "$EMAILS" ] || [ "$EMAILS" = "[]" ]; then
  echo "📭 No unread emails"
  exit 0
fi

# Summarize with Claude
echo "📝 Summarizing with Claude..." >&2
echo -e "Summarize my unread emails. Group by sender or topic, highlight urgent items:\n\n$EMAILS" | claude --print

Tips

  • Run this first thing in the morning to prioritize your inbox
  • Modify the prompt to filter for specific senders or subjects
  • Chain with Slack to post your inbox summary to a channel

← Back to Examples