Communitygithub.com

aiagentwithdhruv/skills

自動為 Gmail 電子郵件標記「需要採取行動」、「等待回覆」和「參考資料」類別。當使用者要求標記郵件、收件匣分類、整理郵件或組織 Gmail 時使用。

skills 是什麼?

此技能可自動將 Gmail 收件匣中的電子郵件分類為「需要採取行動」、「等待回覆」和「參考資料」三個類別,並透過 Gmail API 批次套用標籤。它特別適合需要快速整理大量郵件、提升生產力的開發者或進階使用者。技能支援 Claude Code 或類似支援子代理 (subagent) 的平台,其運作流程為:首先擷取收件匣郵件摘要,然後將郵件分割成多個區塊,接著平行啟動多個子代理進行分類(建議使用 Sonnet 4.5 模型以兼顧速度與成本),最後合併分類結果並批次套用標籤。此技能透過檔案系統傳遞資料,避免直接讀取子代理輸出造成上下文視窗過大。使用者需先設定 Gmail 帳戶憑證,並可透過 `gmail_accounts.json` 註冊多個帳戶。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/aiagentwithdhruv/skills/tree/HEAD/gmail-label

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Gmail 自動標籤

目標

擷取收件匣郵件,透過平行子代理分類為「需要採取行動」/「等待回覆」/「參考資料」,並透過 Gmail API 批次套用標籤。

腳本

  • ./scripts/gmail_label_fetch.py - 擷取郵件摘要為精簡 JSON
  • ./scripts/gmail_label_split.py - 將郵件分割為 N 個區塊以進行平行分類
  • ./scripts/gmail_label_merge.py - 合併分類後的區塊為單一 labels.json
  • ./scripts/gmail_label_apply.py - 批次套用標籤分類

子代理

  • email-classifier — 定義於 .claude/agents/email-classifier.md
  • 模型:Sonnet 4.5(快速、成本效益高的分類)
  • 每個子代理讀取一個區塊,寫入一個分類輸出檔案

流程(平行 — 預設)

步驟 1:擷取郵件

python3 .claude/skills/gmail-label/scripts/gmail_label_fetch.py \
  --account ACCOUNT --query "in:inbox" --limit 100 --output .tmp/emails.json

步驟 2:分割為區塊

python3 .claude/skills/gmail-label/scripts/gmail_label_split.py \
  --input .tmp/emails.json --chunks 10 --output-dir .tmp/chunks

步驟 3:平行分類(產生 10 個子代理)

在背景中產生 10 個 email-classifier 子代理,每個處理一個區塊。每個子代理:

  • 讀取 .tmp/chunks/chunk_N.json
  • 分類每封郵件
  • 寫入 .tmp/chunks/classified_N.json

使用 Task 工具搭配 run_in_background: true 和 model: "sonnet"。在單一訊息中啟動所有 10 個以實現真正的平行處理:

對於每個區塊 0-9,產生一個 Task:
  subagent_type: "email-classifier"
  model: "sonnet"
  run_in_background: true
  prompt: "讀取 /absolute/path/.tmp/chunks/chunk_N.json,分類每封郵件,將結果寫入 /absolute/path/.tmp/chunks/classified_N.json"

關鍵:不要使用 TaskOutput 來讀取子代理結果。 子代理會將結果寫入檔案 — 主代理不需要看到分類資料。讀取 TaskOutput 會淹沒上下文視窗,並在處理大量郵件(500 封以上)時導致「提示過長」錯誤。

改為輪詢檔案是否存在:

# 等待所有分類檔案存在(逾時 120 秒後)
for i in $(seq 0 9); do
  while [ ! -f ".tmp/chunks/classified_$i.json" ]; do sleep 2; done
done

然後直接進行步驟 4(合併)。

步驟 4:合併分類結果

python3 .claude/skills/gmail-label/scripts/gmail_label_merge.py \
  --input-dir .tmp/chunks --output .tmp/labels.json

步驟 5:套用標籤

python3 .claude/skills/gmail-label/scripts/gmail_label_apply.py \
  --account ACCOUNT --input .tmp/labels.json

分類指南

需要採取行動:

  • 需要驗證的安全性警示
  • 具有截止日期的信用卡到期 / 網域續約通知
  • Slack @提及提出的問題
  • 需要打招呼的新團隊成員(Slack 加入通知)
  • 需要回覆的客戶郵件
  • 商家資訊更新(Google Business Profile、Bing Places)
  • Stripe 需要採取動作的通知

等待回覆:

  • 等待回覆的銷售開發郵件
  • 等待解決的支援單
  • 已送出、等待回覆的提案

參考資料:

  • 行銷電子報(DigitalMarketer 等)
  • 慈善/非營利電子報(RAPS 等)
  • Google Business Profile 成效報告
  • 促銷優惠(Blinkist、特賣等)
  • 平台更新通知(Google Play、Apify 等)
  • 確認碼(已使用)
  • 房地產電子報(Westbank 等)
  • 遊戲帳戶郵件(Riot Games 等)
  • 資訊性安全警示(已開啟雙重驗證等)
  • 健康建議
  • 法律/政策更新通知

帳戶註冊

帳戶儲存在工作區根目錄的 gmail_accounts.json 中。每個帳戶需要:

  • email - Gmail 地址
  • token_file - OAuth 權杖檔案路徑

新增帳戶

python3 .claude/skills/gmail-inbox/scripts/gmail_multi_auth.py --account ACCOUNT_NAME --email EMAIL

效能

  • 序列流程:100 封郵件約 36 秒(擷取 1 秒 + 分類 34 秒 + 套用 1 秒)
  • 平行流程:100 封郵件約 30 秒(分類 19 秒 + 合併 <1 秒 + 套用約 10 秒)
  • 分類是瓶頸;10 個平行子代理將其從 34 秒降至 19 秒(約 1.8 倍加速)
  • 子代理啟動開銷(約 4 秒交錯)限制了理論增益
  • 套用步驟可能因 Gmail API 速率限制而有所變動

結構

輸入

名稱類型必填描述
accountstring是註冊表中的 Gmail 帳戶名稱
querystring否Gmail 搜尋查詢(預設:'in:inbox')
limitinteger否要分類的最大郵件數(預設:100)
chunksinteger否平行分類的區塊數(預設:10)

輸出

名稱類型描述
labels_appliedobject每個類別的計數:需要採取行動、等待回覆、參考資料

憑證

名稱來源
credentials.json檔案
token_*.json檔案(自動產生)

可組合使用

與此技能搭配良好的技能:gmail-inbox

成本

Claude Sonnet API 用於分類

Individual skills in this repo

This repo contains 10 individual skills — each has its own dedicated page.

aiagentwithdhruv/skills

Add new Modal webhooks for event-driven execution. Use when user asks to create a webhook, add an endpoint, or set up event triggers.

aiagentwithdhruv/skills

Answer Euron Gen AI Bootcamp doubts instantly. Covers Euri API setup across all frameworks (Python, LangChain, OpenAI SDK, TypeScript, n8n, curl), MCP server setup, common errors, model recommendations, and token limits. Use when someone in the bootcamp asks a question.

aiagentwithdhruv/skills

Manage emails across multiple Gmail accounts with unified tooling. Use when user asks to check email, read inbox, label emails, archive messages, or manage Gmail across accounts.

aiagentwithdhruv/skills

Scrape Google Maps for B2B leads with deep website enrichment and contact extraction. Use when user asks to find local businesses, scrape Google Maps, generate contractor lists, or build local service business databases.

aiagentwithdhruv/skills

Run Claude orchestrator locally with Cloudflare tunneling. Use when user asks to run locally, start local server, or test webhooks locally.

aiagentwithdhruv/skills

MCP server for AI-powered macOS control — apps, display, audio, files, screenshots, clipboard

aiagentwithdhruv/skills

Deploy execution scripts to Modal cloud. Use when user asks to deploy to Modal, push code to cloud, or update Modal functions.

aiagentwithdhruv/skills

Scrape and verify business leads using Apify, classify with LLM, enrich emails, and save to Google Sheets. Use when user asks to find leads, scrape businesses, generate prospect lists, or build lead databases for any industry or location.

aiagentwithdhruv/skills

Query Skool community content using RAG pipeline with vector search. Use when user asks to search Skool knowledge, find community answers, or query Skool content.

aiagentwithdhruv/skills

Scrape Upwork jobs and generate personalized proposals with cover letters. Use when user asks to find Upwork jobs, create Upwork proposals, or apply to Upwork listings.

相關技能