/fe-draft-replies-email:draft-replies-emailfrom fe-draft-replies-email
Find unanswered emails, detect unfollowed promises, draft contextual replies matching the user's writing style, and save them as Gmail drafts for manual review and sending. Use when the user mentions unanswered emails, email inbox review, emails I missed, email catch-up, draft email replies, or email follow-ups.
Ships in fe-draft-replies-email. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Find unanswered emails, classify them by priority, draft replies matching the user's writing style, and save them as Gmail drafts (properly threaded) for manual review and sending.
Run /google-auth first to authenticate with Google Workspace. The skill uses the gmail_builder.py helper from the fe-google-tools gmail skill.
# Locate the gmail_builder.py helper
GMAIL_BUILDER=$(find ~/.claude/plugins/cache/fe-vibe/fe-google-tools/*/skills/gmail/resources/gmail_builder.py 2>/dev/null | head -1)
# Check auth
python3 $(find ~/.claude/plugins/cache/fe-vibe/fe-google-tools/*/skills/google-auth/resources/google_auth.py 2>/dev/null | head -1) status
The skill accepts optional arguments for timeframe and priority:
7, 30, 1401-02-2026 15-03-2026Examples:
/draft-replies-email — prompts for timeframe, then drafts all priorities/draft-replies-email 30 — scan last 30 days, all priorities/draft-replies-email 10 high — scan last 10 days, only high priority/draft-replies-email 01-02-2026 28-02-2026 — scan Feb 1-28, all priorities/draft-replies-email 01-02-2026 28-02-2026 high — scan Feb 1-28, high priority onlyGOOGLE_AUTH=$(find ~/.claude/plugins/cache/fe-vibe/fe-google-tools/*/skills/google-auth/resources/google_auth.py 2>/dev/null | head -1)
GMAIL_BUILDER=$(find ~/.claude/plugins/cache/fe-vibe/fe-google-tools/*/skills/gmail/resources/gmail_builder.py 2>/dev/null | head -1)
python3 "$GOOGLE_AUTH" status || python3 "$GOOGLE_AUTH" login
TOKEN=$(python3 "$GOOGLE_AUTH" token)
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/profile" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
user_email, user_name (from profile)The writing style analysis is expensive (fetches 250+ sent emails). To save time and cost, the result is cached locally and only regenerated quarterly or on first use.
Cache location: ~/.claude/personal-plugins/style-cache/email-style-profile.md
Check for cached profile:
~/.claude/personal-plugins/style-cache/email-style-profile.mdgenerated_date in its YAML frontmattergenerated_date is less than 90 days old → use the cached profile, skip to Phase 3generated_date is more than 90 days old → regenerate (continue below)Regenerate style profile (only when cache is missing or stale):
# Get sent messages — paginate to collect 250+ messages
# First page
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/messages?q=in:sent+newer_than:180d&maxResults=100" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
# Continue with nextPageToken until 250+ messages collected
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/messages?q=in:sent+newer_than:180d&maxResults=100&pageToken=${NEXT_PAGE_TOKEN}" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
Save the profile to cache:
~/.claude/personal-plugins/style-cache/email-style-profile.md with YAML frontmatter:---
generated_date: YYYY-MM-DD
platform: email
message_count: <number of messages analyzed>
---
<style profile summary text>
Use the style profile (cached or freshly generated) to guide draft generation in Phase 5.
This phase uses a Python helper script (email_scanner.py) to handle mechanical pre-filtering — automated senders, mailing lists, bulk emails — so the LLM only processes threads that actually need attention.
NOTE: Calendar invites are intentionally NOT filtered. Email threads are often written around calendar invites, so filtering them would risk missing important conversations.
# Locate the helper script
EMAIL_SCANNER=$(find ~/.claude/plugins/cache/fe-vibe/fe-draft-replies-email/*/skills/draft-replies-email/resources/email_scanner.py 2>/dev/null | head -1)
# Fallback to personal-plugins if not installed via marketplace
[ -z "$EMAIL_SCANNER" ] && EMAIL_SCANNER=$(find ~/.claude/personal-plugins/fe-draft-replies-email/skills/draft-replies-email/resources/email_scanner.py 2>/dev/null | head -1)
Parse timeframe: Convert the user's input into Gmail search date format:
30): newer_than:30d01-02-2026 28-02-2026): after:2026/02/01 before:2026/02/28Find emails received but not replied to (batch + filter):
Strategy: Fetch all thread metadata in bulk, pre-filter with the helper script, then only fetch full content for threads that pass.
# Step 1: Get all threads in inbox within timeframe (paginate to collect all)
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/threads?q=in:inbox+newer_than:${DAYS}d&maxResults=100" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
# Step 2: For each thread, fetch ONLY metadata (From, Subject, List-Unsubscribe, Precedence)
# Batch these — fetch 10-20 threads per iteration using lightweight metadata format
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/threads/${THREAD_ID}?format=metadata&metadataHeaders=From&metadataHeaders=To&metadataHeaders=Subject&metadataHeaders=Date&metadataHeaders=List-Unsubscribe&metadataHeaders=Precedence&metadataHeaders=List-Id&metadataHeaders=X-Mailer" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
# Step 3: Save all thread metadata to a temp file as JSON array
# Each item: {"thread_id": "...", "last_message_from": "...", "headers": {...}}
# Step 4: Run the Python helper to pre-filter
python3 "$EMAIL_SCANNER" filter-threads /tmp/thread_metadata.json \
--user-email "$USER_EMAIL" \
> /tmp/filtered_threads.json
The helper script automatically filters out:
Precedence: bulk/list headersList-Unsubscribe or List-Id headersThe output includes stats showing how many threads were skipped and why — log these for the summary.
Step 5: Read /tmp/filtered_threads.json — this contains ONLY threads needing attention, with Gmail links already constructed. Now fetch full content only for these threads.
STARRED, IMPORTANT, and any custom labels the user may use for follow-up tracking.Search the user's sent emails for messages containing follow-up language — promises the user made but may not have kept.
# Search sent emails with follow-up language
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/messages?q=in:sent+newer_than:${DAYS}d+%22get+back+to+you%22&maxResults=20" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
Run multiple searches for common promise phrases:
Check for follow-through: For each promise message found:
Calculate promise age: Record how many days have elapsed since each unfollowed promise was made.
Before classification, detect cases where the same sender sent a follow-up "bump" email about the same topic. These should be merged into a single draft rather than generating separate drafts for the original and the bump.
Group unanswered threads by sender: After Phase 3 collects all unanswered threads, group them by the sender's email address.
For each sender with multiple unanswered threads, check if any are bump/follow-up duplicates:
Bump detection signals — a thread is a bump if:
Detection logic:
For each sender with 2+ unanswered threads:
Sort threads by date (oldest first)
For each pair of threads (A, B) where B is newer:
subject_match = normalize(A.subject) == normalize(B.subject)
body_has_bump_language = any(phrase in B.body for phrase in BUMP_PHRASES)
b_references_a = A.message_id in B.references_header
if subject_match OR body_has_bump_language OR b_references_a:
→ MERGE: combine A and B into one item
Merge strategy: When threads are merged:
is_bump = true and bump_count = N on the merged itemExample merge:
Thread A (Mar 3): "Q2 Planning Input Needed" from [email protected]
→ "Hi Matthias, could you share your team's Q2 priorities?"
Thread B (Mar 7): "Re: Q2 Planning Input Needed" from [email protected]
→ "Hi Matthias, just following up on this — we need to finalize by Friday."
→ MERGED into single item:
reply_to: Thread B (most recent)
context: includes both messages
priority: bumped from MEDIUM → HIGH (sender followed up)
draft includes: apology for delay + answer
Classify each unanswered email into priority tiers:
HIGH PRIORITY — Action or decision required:
MEDIUM PRIORITY — Response warranted:
LOW PRIORITY — Informational or quick ack:
For each unanswered email (filtered by requested priority level):
Before drafting, analyze the thread to decide whether to reply to sender only or reply-all:
curl -s "https://gmail.googleapis.com/gmail/v1/users/me/threads/${THREAD_ID}?format=metadata&metadataHeaders=From&metadataHeaders=To&metadataHeaders=Cc&metadataHeaders=Reply-To" \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-user-project: gcp-sandbox-field-eng"
Analyze the thread's reply pattern:
Use REPLY-ALL (--reply-all) when:
Use REPLY (sender only) when:
Detection logic:
For each unanswered thread:
messages = thread.messages
last_msg = messages[-1]
to_recipients = parse_addresses(last_msg.headers['To'])
cc_recipients = parse_addresses(last_msg.headers['Cc'])
all_recipients = to_recipients + cc_recipients
# Check if user is the sole To recipient
user_is_sole_to = (len(to_recipients) == 1 and user_email in to_recipients)
# Check thread reply pattern: did participants use reply-all?
if len(messages) >= 3:
recipient_counts = [len(parse_all_recipients(m)) for m in messages[-3:]]
reply_all_pattern = all(c >= 3 for c in recipient_counts)
else:
reply_all_pattern = False
# Check for group greeting
group_greeting = any(g in last_msg.body[:100].lower()
for g in ["hi all", "hi team", "hey all", "everyone", "hi zusammen", "hallo zusammen"])
# Decision
if len(all_recipients) <= 2 or user_is_sole_to:
reply_mode = "reply"
elif reply_all_pattern or group_greeting:
reply_mode = "reply-all"
elif len(to_recipients) > 2:
reply_mode = "reply-all"
else:
reply_mode = "reply" # Default to reply when uncertain
Store the decision alongside each item: reply_mode = "reply" | "reply-all"
is_bump = true)For LOW priority emails where no text reply is needed, note: "(No reply needed — consider archiving)"
For each draft reply, create an actual Gmail draft that is properly threaded so it appears in the correct email conversation. Use the reply_mode decision from Phase 5a to determine reply vs reply-all.
Batch strategy: Instead of creating drafts one-by-one (which is slow and expensive), collect all draft data first, then create them in a batch loop. This minimizes round-trips and allows progress tracking.
drafts_to_create = []
for item in classified_items:
drafts_to_create.append({
"message_id": item["original_message_id"],
"body": item["draft_text"],
"reply_all": item["reply_mode"] == "reply-all",
"is_bump": item.get("is_bump", False),
"priority": item["priority"],
"subject": item["subject"],
"sender": item["sender"],
})
# For each draft in the batch
for draft in drafts_to_create:
REPLY_ALL_FLAG=""
if draft["reply_all"]:
REPLY_ALL_FLAG="--reply-all"
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${draft[message_id]}" \
--body "${draft[body]}" \
${REPLY_ALL_FLAG}
done
Use the gmail_builder.py helper to create reply drafts:
# Create a REPLY draft (sender only) — when reply_mode = "reply"
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${ORIGINAL_MESSAGE_ID}" \
--body "Draft reply text here"
# Create a REPLY-ALL draft — when reply_mode = "reply-all"
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${ORIGINAL_MESSAGE_ID}" \
--body "Draft reply text here" \
--reply-all
# For HTML-formatted replies (either mode)
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${ORIGINAL_MESSAGE_ID}" \
--html "<p>Draft reply text here</p>" \
${REPLY_ALL_FLAG}
Reply mode selection:
--reply-all ONLY when Phase 5a determined reply_mode = "reply-all"--reply-all when reply_mode = "reply" (sends to sender only)gmail_builder.py handles recipient resolution: reply-all includes all To + Cc from the original, minus the userFor merged/bumped threads (from Phase 3c):
ORIGINAL_MESSAGE_ID of the bump message, not the first message# For bumped threads — reply to the latest bump message
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${BUMP_MESSAGE_ID}" \
--body "Sorry for the delayed response — addressing your question from the original thread as well as your follow-up. [draft text]" \
${REPLY_ALL_FLAG}
Important: The create-reply-draft command automatically:
For unfollowed promises, create a new draft reply in the original thread:
# Get the thread's latest message ID for proper threading
python3 "$GMAIL_BUILDER" create-reply-draft \
--message-id "${PROMISE_THREAD_LAST_MESSAGE_ID}" \
--body "Follow-up reply here"
After creating all drafts, print a summary table to the user in the CLI:
| # | Priority | From | Subject | Reply Mode | Bump | Draft Status |
|---|---|---|---|---|---|---|
| 1 | HIGH | [Sender] | [Subject line] | Reply-All | 2x bumped | Draft created |
| 2 | HIGH | [Sender] | [Subject line] | Reply | — | Draft created |
| 3 | MEDIUM | [Sender] | [Subject line] | Reply-All | — | Draft created |
| ... | ... | ... | ... | ... | ... | ... |
Column notes:
Then the unfollowed promises section:
| # | Priority | To | Your Promise | Days Ago | Draft Status |
|---|---|---|---|---|---|
| 1 | HIGH | [Recipient] | "I'll get back to you on..." | 12 | Draft created |
| ... | ... | ... | ... | ... | ... |
And the message:
✅ [X] reply drafts created in Gmail.
Reply: [A] | Reply-All: [B]
Merged bumps: [C] threads combined from [D] originals
⏳ [Y] follow-up drafts created for unfollowed promises.
Open Gmail → Drafts to review and send each reply.
Each draft is properly threaded in its original conversation.
⚠️ Review Reply-All drafts carefully — check the recipient list before sending.
User says: "check my unanswered emails" Result: Asks "What timeframe should I check?", then proceeds with user's answer
User says: "/draft-replies-email 30 high" Result: Scans last 30 days, only drafts for HIGH priority emails, creates Gmail drafts
User says: "/draft-replies-email 01-01-2026 31-01-2026" Result: Scans January 2026, drafts replies for all priorities, creates Gmail drafts
User says: "I was on vacation for 2 weeks, help me catch up on emails" Result: Parses "2 weeks" as 14 days, classifies all unanswered emails, creates threaded Gmail drafts for each
/google-authWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub sarah-hord-db/vibe --plugin fe-draft-replies-email