google-workspace ยท diff

git:20260626.d9fb956 to git:20260705.5a5efb9

70 added, 253 removed. Audit A to A.

---
name: google-workspace
description: "Use when accessing Google Workspace services including Gmail, Calendar, Docs, Sheets, Slides, Drive, and Chat. Triggered by requests for email, scheduling, document creation, or file management."
allowed-tools: Read, Write, Edit, Bash, WebFetch
- user-invocable: true
+ user-invocable: false
---
- # Google Workspace Extension - Behavioral Guide
+ # Google Workspace
- This guide provides behavioral instructions for effectively using the Google Workspace Extension tools. For detailed parameter documentation, refer to the tool descriptions in the extension itself.
+ Goal: complete Workspace tasks with the lightest tool available, in the user's
+ timezone, previewing every write before it happens. Success = the requested
+ operation done via the highest-priority working tier, with no unconfirmed writes
+ and no auto-sent mail.
## Repo Context Probe
If `.claude/skill-context/google-workspace.md` exists, read it and honor its declarations; otherwise use the generic defaults described below.
The context file is where a repo declares a faster project-local mail CLI to try *above* the generic Gmail ladder. When the file is absent (the common case in a foreign repo), start the mail ladder at `gws gmail` โ€” the generic tiers below need nothing beyond a Google Workspace login or an interactive MCP session.
- ## ๐Ÿงญ Tool Selection (read this first)
+ ## Tool Selection
- Reach for the lightest tool that does the job. For every service, walk the
- priority order below top to bottom: try the `gws` CLI first, fall through to MCP
- only on tool absence OR auth failure, and use BYOB browser automation only as a
- last resort when nothing above can do the task at all. A present-but-
+ Walk the priority order per service top to bottom: `gws` CLI first, MCP second,
+ BYOB browser automation only as a last resort when nothing above can do the task
+ at all. Fall through on tool **absence OR auth failure** โ€” a present-but-
unauthenticated `gws` (it needs a one-time `gws auth setup` / `gws auth login`
- human OAuth step) must hand off to the next tier โ€” do not stall on it.
+ human OAuth step) must hand off to the next tier, not stall.
| Service | 1st: `gws` CLI | 2nd: MCP (where it exists) | 3rd (last resort) |
|---------|----------------|----------------------------|-------------------|
| Gmail | `gws gmail` | `mcp__claude_ai_Gmail__*` | BYOB |
| Calendar | `gws calendar` | `mcp__claude_ai_Google_Calendar__*` | BYOB |
| Drive | `gws drive` | `mcp__claude_ai_Google_Drive__*` | BYOB |
- | Docs | `gws docs` | (no MCP) | BYOB |
- | Sheets | `gws sheets` | (no MCP) | BYOB |
- | Slides | `gws slides` | (no MCP) | BYOB |
- | People | `gws people` | (no MCP) | BYOB |
- | Chat | `gws chat` | (no MCP) | BYOB |
- | Forms | `gws forms` | (no MCP) | BYOB |
- | Keep | `gws keep` | (no MCP) | BYOB |
-
- For reading/sending mail specifically, prefer the `/email` skill's ladder, which
- starts at `gws gmail` โ†’ Gmail MCP โ†’ BYOB. If the repo context file declares a
- faster project-local mail CLI, the `/email` skill puts it ahead of `gws` as Tier 1;
- otherwise the generic `gws gmail` tier is the top of the mail ladder.
-
- ## ๐ŸŽฏ Core Principles
-
- ### 1. User Context First
- **Always establish user context at the beginning of interactions:**
- - Use `gws people people get --params '{"resourceName": "people/me"}'` to understand who the user is
- - Establish the user's local timezone (e.g. `gws calendar settings get --params '{"setting": "timezone"}'`)
- - Apply this context throughout all interactions
- - All time-based operations should respect the user's timezone
-
- ### 2. Safety and Transparency
- **Never execute write operations without explicit confirmation:**
- - Preview all changes before executing
- - Show complete details in a readable format
- - Wait for clear user approval
- - Give users the opportunity to review and cancel
-
- ### 3. Smart Tool Usage
- **Choose the right approach for each task:**
- - Tools automatically handle URL-to-ID conversion - don't extract IDs manually
- - Batch related operations when possible
- - Use pagination for large result sets
- - Apply appropriate formats based on the use case
-
- ## ๐Ÿ“‹ Output Formatting Standards
-
- ### Lists and Search Results
- Always format multiple items as **numbered lists** for better readability:
-
- โœ… **Correct:**
- ```
- Found 3 documents:
- 1. Budget Report 2024
- 2. Q3 Sales Presentation
- 3. Team Meeting Notes
- ```
-
- โŒ **Incorrect:**
- ```
- Found 3 documents:
- - Budget Report 2024
- - Q3 Sales Presentation
- - Team Meeting Notes
- ```
-
- ### Write Operation Previews
- Before any write operation, show a clear preview:
-
- ```
- I'll create this calendar event:
-
- Title: Team Standup
- Date: January 15, 2025
- Time: 10:00 AM - 10:30 AM (EST)
- Attendees: team@example.com
-
- Should I create this event?
- ```
-
- ## ๐Ÿ”„ Multi-Tool Workflows
-
- ### Creating and Organizing Documents
- When creating documents in specific folders:
- 1. Create the document first
- 2. Then move it to the folder (if specified)
- 3. Confirm successful completion
-
- ### Calendar Scheduling Workflow
- 1. Establish the user's timezone (see User Context First)
- 2. Check availability with `gws calendar events list` (or `mcp__claude_ai_Google_Calendar__list_events`)
- 3. Create event with proper timezone handling
- 4. Always show times in user's local timezone
-
- ### Email Search and Response
- 1. Search with `gws gmail users messages list` using Gmail query syntax (or `mcp__claude_ai_Gmail__search_threads`)
- 2. Get full content with `gws gmail users messages get` if needed (or `mcp__claude_ai_Gmail__get_thread`)
- 3. Preview any reply before sending
- 4. Use threading context when responding
-
- ### Adding/Removing Labels from Emails
- 1. For system labels, including "INBOX", "SPAM", "TRASH", "UNREAD", "STARRED", "IMPORTANT", the ID is the name itself.
- 2. For user created custom labels, retrieve label ID with `gws gmail users labels list` (or `mcp__claude_ai_Gmail__list_labels`).
- 3. Use `gws gmail users messages modify` to add or remove labels from emails with a single call using label IDs (or `mcp__claude_ai_Gmail__label_message` / `mcp__claude_ai_Gmail__unlabel_message`).
-
- ### Event Deletion
- When deleting a calendar event (`gws calendar events delete`, or `mcp__claude_ai_Google_Calendar__delete_event`):
- - This is a destructive action that permanently removes the event.
- - For organizers, this cancels the event for all attendees.
- - For attendees, this only removes it from their own calendar.
- - Always confirm with the user before executing a deletion.
-
- ## ๐Ÿ“… Calendar Best Practices
-
- ### Understanding "Next Meeting"
- When asked about "next meeting" or "today's schedule":
- 1. **Fetch the full day's context** - Use start of day (00:00:00) to end of day (23:59:59)
- 2. **Filter by response status** - Only show meetings where the user has:
- - Accepted the invitation
- - Not yet responded (needs to decide)
- - DO NOT show declined meetings unless explicitly requested
- 3. **Compare with current time** - Identify meetings relative to now
- 4. **Handle edge cases**:
- - If a meeting is in progress, mention it first
- - "Next" means the first meeting after current time
- - Keep full day context for follow-up questions
-
- ### Meeting Response Filtering
- - **Default behavior**: Show only accepted and pending meetings
- - **Declined meetings**: Exclude unless user asks "show me all meetings" or "including declined"
- - **Use `attendeeResponseStatus`** parameter to filter appropriately
- - This respects the user's time by not cluttering their schedule with irrelevant meetings
-
- ### Timezone Management
- - Always display times in the user's timezone
- - Convert all times appropriately before display
- - Include timezone abbreviation (EST, PST, etc.) for clarity
-
- ## ๐Ÿ“ง Gmail & Chat Guidelines
-
- ### Search Strategies
- - Use Gmail search syntax: `from:email@example.com is:unread`
- - Combine multiple criteria for precise results
- - Include SPAM/TRASH only when explicitly needed
-
- ### Threading and Context
- - Maintain conversation context in replies
- - Reference previous messages when relevant
- - Use appropriate reply vs. new message based on context
-
- ### Downloading Attachments
- 1. **Find Attachment ID**: Use `gws gmail users messages get` with `format=full` to retrieve message details, including `attachments` metadata (IDs and filenames).
- 2. **Download**: Use `gws gmail users messages attachments get` with the specific `messageId` and `attachmentId`.
- 3. **Absolute Paths**: Always provide an **absolute path** for the output argument (e.g., `/Users/username/Downloads/file.pdf`). Relative paths will be rejected for security.
-
- ### Composing on Behalf of the User
-
- When drafting or replying to email on the user's behalf, apply these three constraints without exception:
-
- - **Async CTAs only** โ€” Never offer calls, meetings, voice/video contact, or any form of synchronous communication. The agent cannot participate in real-time conversations. Use async alternatives instead: "happy to share more over email", "feel free to reply with questions", or leave the closing open with no CTA. Phrases like "let's jump on a call", "schedule a meeting", or "give us a ring" are prohibited.
- - **Draft-first rule** โ€” All outbound composition must produce a draft (`gws gmail users drafts create`, or `mcp__claude_ai_Gmail__create_draft`). Never call a send tool without an explicit user instruction to send. This is stricter than the general write-operation safety rule: even if the user says "write a reply", the result is a draft that the user reviews and sends manually.
- - **Honest representation** โ€” When composing outreach about the user's product or service, represent it accurately. If the product or operation is automated or AI-assisted, say so rather than implying a human-run team. Do not overclaim capabilities, team size, or operational structure. Inaccurate representation damages trust and creates expectations that cannot be met.
-
- ## ๐Ÿ“„ Docs, Sheets, and Slides
-
- ### Format Selection (Sheets)
- Choose output format based on use case:
- - **text**: Human-readable, good for quick review
- - **csv**: Data export, analysis in other tools
- - **json**: Programmatic processing, structured data
-
- ### Content Handling
- - Docs/Sheets/Slides tools accept URLs directly - no ID extraction needed
- - Use markdown for initial document creation when appropriate
- - Preserve formatting when reading/modifying content
-
- ## ๐Ÿšซ Common Pitfalls to Avoid
-
- ### Don't Do This:
- - โŒ Manually extract IDs from URLs when tools accept URLs directly
- - โŒ Assume timezone without checking
- - โŒ Execute writes without preview and confirmation
- - โŒ Create files unless explicitly requested
- - โŒ Duplicate parameter documentation from tool descriptions
- - โŒ Use relative paths for file downloads (e.g., `downloads/file.txt`)
-
- ### Do This Instead:
- - โœ… Pass URLs directly to tools that accept them
- - โœ… Get user timezone at session start
- - โœ… Preview all changes and wait for approval
- - โœ… Only create what's requested
- - โœ… Focus on behavioral guidance and best practices
- - โœ… Always use **absolute paths** for file downloads (e.g., `/Users/me/Downloads/file.txt`)
-
- ## ๐Ÿ” Error Handling Patterns
-
- ### Authentication Errors
- - If any tool returns `{"error":"invalid_request"}` or a `gws` call fails with an auth error, it likely indicates an expired or invalid session.
- - **Action:** For `gws`, re-run the one-time human OAuth step (`gws auth setup` / `gws auth login`); for MCP, reset credentials and force a re-login. If the tool stays unauthenticated, **fall through to the next tier** in the Tool Selection ladder rather than stalling.
- - Inform the user that you are resetting authentication due to an error.
-
- ### Graceful Degradation
- - If a folder doesn't exist, offer to create it
- - If search returns no results, suggest alternatives
- - If permissions are insufficient, explain clearly
+ | Docs / Sheets / Slides / People / Chat / Forms / Keep | `gws <service>` | (no MCP) | BYOB |
- ### Validation Before Action
- - Verify file/folder existence before moving
- - Check calendar availability before scheduling
- - Validate email addresses before sending
+ For reading/sending mail specifically, prefer the `/email` skill's ladder. If the
+ repo context file declares a faster project-local mail CLI, `/email` puts it
+ ahead of `gws` as Tier 1; otherwise `gws gmail` is the top of the mail ladder.
- ## โšก Performance Optimization
+ ## Core Rules
- ### Batch Operations
- - Group related API calls when possible
- - Use field masks to request only needed data
- - Implement pagination for large datasets
+ 1. **User context first.** Establish who the user is
+ (`gws people people get --params '{"resourceName": "people/me"}'`) and their
+ timezone (`gws calendar settings get --params '{"setting": "timezone"}'`) at
+ the start, then apply that context throughout. Display all times in the
+ user's timezone with the abbreviation (EST, PST, ...).
+ 2. **Preview every write.** Show complete details of any create/update/delete in
+ readable form and wait for approval before executing. Deletions especially:
+ deleting a calendar event as organizer cancels it for all attendees; as
+ attendee it only removes it from their calendar.
+ 3. **Pass URLs directly.** Tools handle URL-to-ID conversion โ€” don't extract IDs
+ manually. Use pagination for large result sets; batch related calls.
+ 4. **Absolute paths for downloads.** Relative output paths are rejected for
+ security.
+ 5. **Number multi-item results.** Format lists and search results as numbered
+ lists.
- ### Caching Strategy
- - Reuse user context throughout session
- - Cache frequently accessed metadata
- - Minimize redundant API calls
+ ## Composing on Behalf of the User
- ## ๐Ÿ“ Session Management
+ Three constraints, no exceptions:
- ### Beginning of Session
- 1. Get user profile (see User Context First โ€” `gws people people get` with `resourceName=people/me`)
- 2. Establish the user's timezone
- 3. Establish any relevant context
+ - **Async CTAs only** โ€” never offer calls, meetings, or any synchronous contact;
+ the agent cannot participate in real-time conversations. Use "happy to share
+ more over email", "feel free to reply with questions", or no CTA.
+ - **Draft-first** โ€” all outbound composition produces a draft
+ (`gws gmail users drafts create`, or `mcp__claude_ai_Gmail__create_draft`).
+ Never call a send tool without an explicit user instruction to send โ€” even
+ "write a reply" means a draft the user reviews and sends manually.
+ - **Honest representation** โ€” if the product or operation is automated or
+ AI-assisted, say so. Don't overclaim capabilities, team size, or operational
+ structure.
- ### During Interaction
- - Maintain context awareness
- - Apply user preferences consistently
- - Handle follow-up questions efficiently
+ ## Operational Recipes
- ### End of Session
- - Confirm all requested tasks completed
- - Provide summary if multiple operations performed
- - Ensure no pending confirmations
+ **Email search and reply**: search with `gws gmail users messages list` using
+ Gmail query syntax (`from:a@b.com is:unread`); fetch full content with
+ `gws gmail users messages get`; reply within the thread, draft-first. Include
+ SPAM/TRASH only when explicitly requested.
- ## ๐ŸŽจ Service-Specific Nuances
+ **Labels**: system labels ("INBOX", "SPAM", "TRASH", "UNREAD", "STARRED",
+ "IMPORTANT") use the name as the ID; custom labels need
+ `gws gmail users labels list` first. Apply/remove with
+ `gws gmail users messages modify` in a single call.
- ### Google Docs
- - Support for markdown content creation
- - Automatic HTML conversion from markdown
- - Position-based text insertion (index 1 for beginning)
+ **Attachments**: `gws gmail users messages get` with `format=full` exposes
+ attachment IDs and filenames; download with
+ `gws gmail users messages attachments get` and an absolute output path.
- ### Google Sheets
- - Multiple output formats available
- - Range-based operations with A1 notation
- - Metadata includes sheet structure information
+ **"Next meeting" / "today's schedule"**: fetch the full day (00:00:00โ€“23:59:59),
+ filter to accepted + not-yet-responded (exclude declined unless asked โ€”
+ `attendeeResponseStatus`), compare with the current time. Mention an in-progress
+ meeting first; "next" is the first meeting after now. Keep the day's context for
+ follow-ups.
- ### Google Calendar
- - Event creation requires both start and end times
- - Support for attendee management
- - Response status filtering available
+ **Documents in folders**: create the document first, then move it to the folder.
- ### Gmail
- - Full threading support
- - Label-based organization
- - Draft creation and management
+ **Sheets output format**: `text` for human review, `csv` for export, `json` for
+ programmatic processing.
- ### Google Chat
- - Space vs. DM distinction
- - Thread-aware messaging
- - Unread message filtering
+ ## Error Handling
- Remember: This guide focuses on **how to think** about using these tools effectively. For specific parameter details, refer to the tool descriptions themselves.
+ - `{"error":"invalid_request"}` or a `gws` auth error usually means an expired
+ session. For `gws`, re-run the human OAuth step (`gws auth setup` /
+ `gws auth login`); for MCP, reset credentials and force re-login. If the tool
+ stays unauthenticated, fall through to the next tier โ€” tell the user why.
+ - Degrade gracefully: offer to create a missing folder, suggest alternatives on
+ empty searches, explain permission failures plainly.