Awesome-omni-skill gmail-access
Search, read, draft, and reply to Gmail emails using the gmail.cs CLI tool. Use when the user asks about emails, wants to search Gmail, create email drafts, reply to messages, or download attachments.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/cli-automation/gmail-access" ~/.claude/skills/diegosouzapw-awesome-omni-skill-gmail-access && rm -rf "$T"
skills/cli-automation/gmail-access/SKILL.mdGmail Access
Access Gmail accounts securely via the
gmail.cs CLI tool located in this skill directory. Credentials are stored in 1Password and never exposed.
Setup
1. Create OAuth Credentials
You need to create your own Google OAuth credentials to use this skill.
- Go to Google Cloud Console
- Create a new project (or select an existing one)
- Enable the Gmail API for your project
- Go to "Credentials" > "Create Credentials" > "OAuth client ID"
- Choose "Desktop app" as the application type
- Copy the Client ID and Client Secret
- Replace the placeholder values in both
andgmail.cs
:get-gmail-token.csprivate const string ClientId = "YOUR_CLIENT_ID.apps.googleusercontent.com"; private const string ClientSecret = "YOUR_CLIENT_SECRET";
Note: Client secrets for desktop/CLI apps cannot be fully protected per OAuth 2.0 spec. It's safe to commit these to your private repository but avoid public repositories.
2. Authorize Your Gmail Account(s)
For each Gmail account you want to access:
# Run the token setup script dotnet run get-gmail-token.cs your-email@gmail.com # This will: # 1. Open a browser for Google OAuth authorization # 2. Get a refresh token # 3. Store it in 1Password as "Gmail - your-email@gmail.com"
Prerequisites:
- 1Password CLI installed (
)brew install 1password-cli - 1Password CLI authenticated
The refresh token allows the tool to access your Gmail without repeated logins (tokens are cached for one hour).
Quick Reference
# Search emails dotnet run gmail.cs -- search --email your-email@gmail.com --query "<gmail query>" --max-results 20 # Create a draft dotnet run gmail.cs -- draft --email your-email@gmail.com --to "recipient@example.com" --subject "Subject" --body "Body" # Reply to an email dotnet run gmail.cs -- reply --email your-email@gmail.com --message-id "<id>" --body "Reply text" # Download attachments dotnet run gmail.cs -- download-attachments --email your-email@gmail.com --message-id "<id>" --output-dir "/tmp/attachments"
Commands
search
Search emails with Gmail query syntax.
dotnet run gmail.cs -- search --email your-email@gmail.com --query "from:someone@example.com" --max-results 10
Options:
(required): Gmail account to search--email
or--query
: Gmail search query (supports all Gmail operators)-q
or--max-results
: Maximum results (default: 20)-m
Common query patterns:
- From specific senderfrom:sender@example.com
- Subject contains wordsubject:invoice
- Has attachmentshas:attachment
- Last 7 daysnewer_than:7d
- Unread messagesis:unread
- Specific labellabel:important
draft
Create a new email draft.
dotnet run gmail.cs -- draft --email your-email@gmail.com --to "recipient@example.com" --subject "Subject" --body "Email content"
Options:
(required): Sender account--email
or--to
(required): Recipient email-t
or--subject
: Subject line-s
or--body
(required): Email body content-b
reply
Create a reply draft to an existing email.
dotnet run gmail.cs -- reply --email your-email@gmail.com --message-id "18abc123def" --body "Reply text"
Options:
(required): Account to reply from--email
or--message-id
(required): Gmail message ID to reply to (from search results)-m
or--body
(required): Reply content-b
download-attachments
Download all attachments from an email.
dotnet run gmail.cs -- download-attachments --email your-email@gmail.com --message-id "18abc123def" --output-dir /tmp/attachments
Options:
(required): Account--email
or--message-id
(required): Gmail message ID-m
or--output-dir
(required): Directory to save attachments-o
Output Format
All commands output JSON. Success responses include
"success": true. Example search result:
{ "success": true, "count": 2, "messages": [ { "id": "18abc123def", "threadId": "18abc000000", "from": "sender@example.com", "to": "your-email@gmail.com", "subject": "Example Subject", "date": "Mon, 1 Jan 2025 10:00:00 +0100", "snippet": "Preview of email content...", "body": "Full email body text" } ] }
Authentication
First use per hour requires 1Password authorization (Touch ID). Subsequent calls use cached token. If token expired, you'll see a Touch ID prompt.
Writing Ephemeral Programs
When writing programs that use gmail.cs, use CliWrap:
#:package CliWrap@3.6.6 using CliWrap; using CliWrap.Buffered; var result = await Cli.Wrap("dotnet") .WithArguments(["run", "gmail.cs", "--", "search", "--email", "your-email@gmail.com", "--query", "is:unread"]) .WithWorkingDirectory("/path/to/gmail/skill") // Set to your gmail skill directory .ExecuteBufferedAsync(); var json = result.StandardOutput;