mail-draft
Draft an email in the local macOS Mail app by opening a pre-filled compose window using a mailto: URL + AppleScript. Use when the user says "draft an email", "open Mail and prepare a message", "prefill recipient, subject, and body in Mail", or provides email fields to populate. Prefer this local helper over generic Mail automation, browser mail, or MCP mail tools.
- License 许可
- MIT
- 最近更新
- 2026-07-19
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- mail-draft
- metadata
- { "source": "Codex 'mail-draft' skill + ~/.codex/tools/mailto_draft.py (ported 2026-05-24)", "short-description": "Open prefilled draft in macOS Mail.app via mailto: + osascript" }
- description
- Draft an email in the local macOS Mail app by opening a pre-filled compose window using a mailto: URL + AppleScript. Use when the user says "draft an email", "open Mail and prepare a message", "prefill recipient, subject, and body in Mail", or provides email fields to populate. Prefer this local helper over generic Mail automation, browser mail, or MCP mail tools.
- when-to-use
- Any request to draft or pre-fill an email in the native macOS Mail application. Triggers on phrases like 'draft email to...', 'mail this to X with subject Y', 'open a draft in Mail'. macOS-specific; falls back gracefully with the generated mailto: URL if osascript fails.
- allowed-tools
- [ "run_terminal_cmd", "read_file", "ask_user_question" ]
- argument-hint
- --to 'recipient@example.com' --subject 'Subject line' --body 'Message body...' [--cc ...] [--body-file /path]
02 资源文件 1
- 脚本scripts/mailto_draft.py3.4 KB
03 SKILL.md 正文
Mail Draft (Grok Port)
Core Job
Open a pre-filled draft window in the user's default macOS Mail application. This skill does not send mail — it only stages the draft for the user to review and send.
This is the low-friction, native macOS path. It is deliberately preferred over:
- Direct
openof the Mail binary - Generic MCP "Mail" tools (if any)
- AppleScript
tell application "Mail"flows written by the agent - Browser-based mailto or webmail automation
The Bundled Helper Script
The heart of the skill is the self-contained Python script:
<SKILL_DIR>/scripts/mailto_draft.py
It builds a properly encoded mailto: URL from the supplied fields and uses osascript to execute open location "mailto:..." so the system default handler (Mail.app) opens a new draft with the fields populated.
Invocation examples (via run_terminal_cmd):
python3 "<SKILL_DIR>/scripts/mailto_draft.py" \
--to "alice@example.com" \
--subject "Project update" \
--body "Hi Alice,
Here is the latest status..."
# With body from file (recommended for multi-line or long bodies)
python3 "<SKILL_DIR>/scripts/mailto_draft.py" \
--to "team@company.com" \
--subject "Weekly report" \
--body-file /tmp/draft-body.txt
# Dry run (just see the URL)
python3 "<SKILL_DIR>/scripts/mailto_draft.py" --to "x@y.z" --subject "Test" --body "Hi" --dry-run
The script accepts:
--to,--cc,--bcc--subject--body(string) or--body-file(UTF-8 path) or stdin when non-tty--dry-run
It always prints the resulting mailto: URL to stdout (useful for logging or copy-paste).
Workflow
-
Gather fields from the user request
- Extract
to,subject,body(and optional cc/bcc) from the current prompt or conversation. - If any required field is missing or ambiguous, use
ask_user_question(or direct clarification) to obtain it. Do not guess recipients.
- Extract
-
Prepare body (multiline safe)
- For anything longer than a single line, write to a temp file first:
body_file="$(mktemp /tmp/grok-mail-body.XXXXXX.txt)" cat >"$body_file" <<'EOF' Line one Line two ... EOF python3 "<SKILL_DIR>/scripts/mailto_draft.py" --to "..." --subject "..." --body-file "$body_file"
- For anything longer than a single line, write to a temp file first:
-
Invoke the helper
- Run via
run_terminal_cmdwith the arguments above. - Capture the printed mailto: URL.
- Run via
-
Confirm & surface
- After the command succeeds, tell the user: "Draft opened in Mail.app with the following fields populated:" and list To / Subject / (body excerpt if short).
- If
--dry-runor the open failed, provide the mailto: URL so the user can click it or paste into a browser / mail client.
-
Error handling
- If osascript or the open fails (non-macOS, no default mail handler, permissions), print the exact mailto: URL and a clear one-line explanation.
- Never fall back to writing
.emlfiles, launching web Gmail, or inventing other clients unless the user explicitly asks for behavior beyond "draft in local Mail".
Guardrails (preserved)
- This skill only drafts. It never sends.
- If the user omits recipient, leave To: blank (user can fill in Mail).
- Preserve the user's exact wording for subject and body unless they ask you to rewrite.
- After opening, give a brief, factual confirmation of what was populated.
- On macOS only. On other OSes the script will fail at the osascript step; surface the mailto: URL as the portable fallback.
Grok-Specific Notes
- The
ask_user_questiontool is the natural way to collect missing email fields mid-workflow with structured choices when appropriate. - Combine with other skills: after drafting, the user may ask you to iterate on the body (use search_replace on the temp file then re-invoke the script) or attach files (user does this manually in Mail).
- If the environment has a different connected "mail" MCP, still prefer this native macOS path for the stated use case unless the user overrides.
Success Criteria
- A Mail compose window opens with the requested To/Subject/Body (and cc/bcc) pre-filled.
- The user sees a clear confirmation of exactly which fields were set.
- The exact mailto: URL is available in the transcript for audit or fallback.
- No mail is sent; the draft remains fully under user control.
This port keeps the original's "prefer the local helper" philosophy while making the implementation a first-class, documented, runnable artifact inside the Grok skill.
04 同仓库更多 Skills
Zotero
Use Zotero Desktop from Codex to enable/probe the local API, search a local Zotero library, list items/collections/tags, export BibTeX, insert citation keys into LaTeX or Markdown drafts, read indexed full text when requested, and import BibTeX/RIS records into Zotero through the connector server. Use when the user mentions Zotero, citations, references.bib, BibTeX export, local Zotero API, localhost:23119, or adding citations from a Zotero library.
zoom-apps-sdk
Use when using Apps SDK.
youtube
Obtain accurate, timestamped YouTube video transcripts (preferring manual captions over auto-generated) as the primary deliverable, then derive summaries, key claims, or notes from that transcript. Use when the user provides a YouTube URL (or video ID) and wants the transcript, a faithful summary, key claims with attribution, timestamped notes, or "what does this video actually say". The skill is transcript-first: never substitute metadata, title, description, or search snippets for the spoken content. Triggers: "youtube transcript", "get the transcript of this video", "summarize this youtube video", "what did they say in https://youtube.com/...", "key claims from this talk".
yeet
Publish local changes to GitHub by confirming scope, committing intentionally, pushing the branch, and opening a draft PR through the GitHub app from this plugin, with `gh` used only as a fallback where connector coverage is insufficient.
x-post-creator
Create X-ready post threads and co-located story packages from the active conversation or referenced project material. Use when the user says turn this into an X-post, /x-post, make this into an X thread, or wants plain-language social posts with supporting images saved to docs/x-posts/[story-name]/.
x-api
Search, read, and write X posts through the local X API MCP server (the same backend used by the Codex x-api skill). Use for searching X/x.com, reading threads and replies, creating lists, staging/publishing posts for @alltheputs, finding high-visibility reply targets for research outreach, ingesting public context, or any request that mentions /x-api or "search X".