⌂ Home
Gemini CLI: From Zero to Production
Track 4 · Integrations
Module 14 of 17 ~50 min Intermediate
Module 13 · Track 4 — Integrations

Google Workspace Integration

Your inbox, documents, spreadsheets, and calendar hold the real context of your work — meeting decisions buried in threads, project status locked in sheets, action items scattered across docs. The Google Workspace extension wires Gemini CLI directly into all of it, turning a 45-minute "find and summarize all emails about the budget" task into a 10-second prompt.

What You'll Learn

  • Install the Google Workspace extension and complete OAuth authorization
  • Understand every scope the extension requests and what data flows where
  • Use /gmail, /gdocs, /gdrive, /gsheets, and /gcalendar slash commands
  • Chain Gmail, Drive, and GitHub into compound multi-tool workflows
  • Use Sheets as a readable/writable data layer for automated dashboards
  • Schedule meetings intelligently with conflict detection via /gcalendar
  • Revoke access safely and understand enterprise Workspace admin policies

Installing the Workspace Extension

Analogy — The Universal Adapter for Your Work Life

Before the Workspace extension, Gemini CLI was like a brilliant assistant who had read every programming book ever written — but had no access to your actual office. They couldn't read the email thread you're referring to, couldn't look up the spreadsheet you want summarized, couldn't see your calendar. The pain: you copy-pasted content manually, losing formatting, context, and the relationships between documents. The mapping: installing the Workspace extension is like giving your assistant a pass card to your entire office — they can now walk to the filing cabinet, pull the right folder, and work with it in full context without you having to describe what's in it.

One Command to Install

terminal
gemini extensions install google-workspace
WHAT: Downloads and registers the official Google Workspace extension bundle for Gemini CLI. GOTCHA: This requires Gemini CLI v0.4.0 or later. Run gemini --version first.

After installation, Gemini CLI opens your default browser for OAuth authorization. You'll see a Google consent screen listing every scope being requested.

Animation — OAuth Authorization Flow
gemini extensions install google-workspace
waiting
Browser opens → Google OAuth consent screen
waiting
You review scopes and click Allow
waiting
Google issues authorization code → redirect to localhost
waiting
Gemini CLI exchanges code for access + refresh tokens
waiting
Tokens stored in %USERPROFILE%\.gemini\credentials\workspace.json
waiting
New /gmail /gdocs /gdrive /gsheets /gcalendar commands active
waiting

New Commands After Install

/gmail

Read, search, draft, and send Gmail messages. Supports label filtering and attachment references.

/gdocs

Read and create Google Docs. Accepts Drive file IDs or names. Supports export to Markdown.

/gdrive

Search Drive, access files by URL or name using @drive:// syntax. List and navigate folders.

/gsheets

Read and write Google Sheets. Supports cell range notation (A1:C10), named ranges, and formulas.

/gcalendar

Read calendar events, check availability, and create new events. Supports timezone-aware scheduling.

Tip — Type / to Discover Commands

After installing the extension, start a Gemini CLI session and type / to see all available commands. The Workspace commands appear grouped under the google-workspace namespace with inline descriptions.

With the extension installed and OAuth authorized, every Workspace app is now a data source you can reference directly in any prompt. Let's start with the highest-value use case: your inbox.

Gmail Workflows

Technical Definition — How /gmail Accesses Your Inbox

The /gmail commandA Workspace extension skill that uses the Gmail API (gmail.readonly + gmail.compose + gmail.send scopes) to fetch message metadata, retrieve full message bodies, and draft or send messages. All API calls go directly from Gemini CLI to Google's servers — the content is processed by Gemini's model but never stored by the CLI. invokes the Gmail API on your behalf using the OAuth token stored locally. When you ask Gemini to "summarize unread emails," it calls messages.list with q: "is:unread", retrieves each message body, then passes the combined text as context to the model. The model response is streamed back to your terminal — your email content is never written to disk by the CLI.

Workflow 1 — Inbox Triage

PROMPT Real prompt, expected behavior
Summarize my last 10 unread emails and flag any requiring urgent action today
Inbox Summary (10 unread)
  • URGENT Re: Production incident — auth service down (DevOps, 08:14) — P0 outage affecting 12% of users, needs your go/no-go on rollback plan. Action needed by 10:00 AM.
  • URGENT Q3 budget sign-off deadline (Finance, yesterday) — Final approval window closes today at 5 PM. Document attached.
  • FYI Sprint planning notes (Engineering) — Summary of yesterday's planning session. No action required.
  • + 7 more emails — newsletters, calendar notifications, and team updates. No action required today.

2 emails flagged as urgent. Recommend addressing the auth incident first, then the budget approval.

Workflow 2 — Smart Email Drafting

PROMPT Using a file reference for context
Draft a polite decline to @email.txt — too busy but propose an async Loom instead
Draft created (not sent):

Hi [Name],

Thank you so much for the invite — I appreciate you thinking of me. My schedule is pretty packed this sprint, so I won't be able to join live, but I'd love to contribute asynchronously.

Would you be open to a short Loom from me instead? I can walk through my thoughts on [topic] in 5 minutes and you can watch when it fits your schedule. Let me know!

Best,
[Your name]

Reply "send" to send this draft, "edit: [changes]" to revise, or "save" to save to Drafts.

WHAT: @email.txt loads the email file as context so Gemini knows who you're declining and what the original request was. WHY: Without context, the draft would be generic. With it, Gemini tailors the tone and references the specific meeting topic.

Workflow 3 — Cross-App Research

PROMPT Multi-step cross-app workflow
Find all emails about the Q3 budget and create a Drive doc summarizing the thread
Found 14 emails matching "Q3 budget" (spanning 3 weeks)
  • Searching Gmail for subject:Q3 budget OR body:Q3 budget...
  • Extracting key decisions, figures, and action items across thread...
  • Creating Google Doc "Q3 Budget Thread Summary" in Drive root...
  • Doc created: drive://Q3-Budget-Thread-Summary.gdoc

The doc contains: Timeline, 3 key decisions made, final approved figures ($2.4M), and 5 open action items with owners. Link copied to clipboard.

What Just Happened?

Gemini CLI chained three API calls: Gmail search → message retrieval → Drive document creation. From your perspective it was one prompt. From the extension's perspective it was a coordinated multi-tool sequence — exactly the kind of workflow that previously took 45 minutes manually.

Gmail shows what's possible with read/write access to a single app. Docs and Drive unlock the same power for long-form content and file management.

Google Docs + Drive

Generate a Status Report from Code + Docs

PROMPT Multi-source document generation
Create a project status report doc in Drive from @prd.md and this week's git log
Reading @prd.md (Product Requirements Document)...
Running: git log --since="1 week ago" --oneline
Creating Google Doc: "Project Status Report — Week of June 9, 2026"

Doc structure: Executive Summary · Features Delivered (mapped against PRD goals) · In Progress · Blocked Items · Next Week Plan · Metrics

Doc link: drive://Project-Status-Report-June-9.gdoc — Shared with edit access.

Update a Spreadsheet via Drive Reference

prompt
@drive://project-tracker.gsheet Update the Status column for the auth module to 'Done'
WHAT: The @drive:// prefix tells Gemini CLI to resolve the filename against your Drive and load it as context. GOTCHA: File names must be unique in your Drive for this to work unambiguously. If multiple files match, Gemini CLI will ask you to clarify by file ID.

Extract Action Items to GitHub Issues

PROMPT Drive → GitHub cross-tool workflow
Summarize @drive://meeting-notes-june.gdoc and create GitHub issues for each action item
Reading meeting-notes-june.gdoc from Drive...
Extracted 6 action items. Creating GitHub issues in repo:
  • #247 — "Set up staging environment for auth service" (owner: @devops-team)
  • #248 — "Review and merge OpenAPI spec PR" (owner: @backend-team)
  • #249 — "Write migration guide for v2 API breaking changes" (owner: @you)
  • + 3 more issues created with labels from meeting context

All 6 issues created. Issues labelled meeting-action-item and assigned based on names mentioned in notes.

Sheets as a Data Layer

Analogy — Google Sheets as a Lightweight Database

Before using Sheets with Gemini CLI, teams would manually paste test results into spreadsheets at the end of a sprint — error-prone, delayed, and always out of date. The pain: a dashboard that's stale by definition, because updating it competes with actually doing the work. The mapping: Gemini CLI treats your Sheets file the same way a backend service treats a database — it can read it, process the data with model reasoning, and write results back. Your "dashboard" stays current because Gemini does the updating automatically after every test run.

A common pattern is an automated test results dashboard: read the current sheet, append new test run data, have Gemini compute trend summaries, and write back a formatted status row.

Animation — Sheets Read → Process → Write Cycle
gemini: "Read test-results.gsheet A1:E50, analyze trends"
waiting
Sheets API: GET spreadsheet values (A1:E50)
waiting
Gemini model: compute pass rate trend, flag regressions
waiting
Sheets API: PATCH row 51 with today's summary + status
waiting
Dashboard row updated: "June 9 | 94.2% pass | STABLE"
waiting
prompt — test results dashboard update
@drive://test-results-dashboard.gsheet
Read columns A:E (date, suite, passed, failed, duration).
Calculate the 7-day pass rate trend.
Append a new row for today's run: passed=487, failed=12, duration=143s.
Add a summary in column F: STABLE if pass rate > 95%, DEGRADED if between 90-95%, CRITICAL if below 90%.
Why It Matters

Engineering teams spend an average of 90 minutes per week manually updating dashboards. A Sheets + Gemini CLI automation running in CI reduces this to zero. The @drive:// reference makes the automation self-documenting — anyone reading the prompt immediately knows which spreadsheet is being updated and why.

Google Calendar

The /gcalendar command brings free/busy lookupA Calendar API method (freebusy.query) that returns time ranges where a user has events, without revealing event details. Used for scheduling assistants to find open slots without exposing private calendar contents to the requester. and event creation directly into your prompts.

PROMPT Intelligent scheduling with conflict detection
Schedule a 30-min retro with the team for next Thursday 2pm in my timezone. Avoid conflicts in my calendar.
Checking your calendar for Thursday, June 18...
Timezone detected: America/New_York (UTC-4)

2:00 PM – 2:30 PM ET: Available
Checking for back-to-back conflicts... No meeting ends at 2:00 PM. No meeting starts before 2:30 PM.

Creating event: "Sprint Retro" · June 18 · 2:00–2:30 PM ET
Inviting: team@company.com (from GEMINI.md contacts)
Conferencing: Google Meet link auto-generated

Event created. Calendar invite sent to 4 attendees. Reply "cancel" within 60 seconds to undo.

WHAT: The Calendar skill calls freebusy.query for the requested time window, finds the first available 30-minute slot matching your request, then calls events.insert with the full event details. GOTCHA: Gemini CLI reads timezone from your system locale — verify this is correct before scheduling across timezones by checking /gcalendar timezone.
Before using these capabilities with real work data, it's important to understand exactly what you're authorizing — and how to limit or revoke that access.

Privacy Model & OAuth Scopes

When you authorize the Workspace extension, Google presents a consent screen listing each scope. Here's exactly what each scope means in plain English:

Scope What It Allows Used For
gmail.readonly Read all Gmail messages and metadata Inbox triage, email search, summarization
gmail.compose Create and save drafts (not send) Drafting replies — you review before sending
gmail.send Send email on your behalf Only invoked if you explicitly say "send"
drive.readonly Read files and folder metadata @drive:// file references
drive.file Create and modify files Gemini CLI creates Creating new Docs/Sheets from prompts
spreadsheets Read and write Sheets data Dashboard automation, data updates
calendar.events Read and create calendar events Scheduling, free/busy lookup
Data Flow — What Goes to Google

Your email and document content is sent to the Gemini API for processing. This is subject to Google's standard API data usage policy. For personal Google accounts: content may be used to improve models unless you opt out in myaccount.google.com. For Google Workspace (enterprise) accounts: data is processed under your organization's data processing agreement — admin policies control whether third-party apps can access Workspace data at all. Always check with your IT/security team before using Workspace integrations on corporate accounts.

Revoking Access

PowerShell — remove stored credentials
# Remove the locally stored OAuth tokens
Remove-Item "$env:USERPROFILE\.gemini\credentials\workspace.json" -Force

# Uninstall the extension
gemini extensions uninstall google-workspace

# Also revoke at the Google account level (recommended)
# Visit: https://myaccount.google.com/permissions
# Find "Gemini CLI" and click "Remove Access"
Enterprise Consideration

Google Workspace admins can block OAuth app installs via the Admin Console at admin.google.com → Security → API Controls → App Access Control. If your organization has this policy enabled, the authorization step will fail with a "This app is blocked" error. You'll need admin approval or a service account issued by your IT team.

Compound Multi-Tool Workflows

The real value of Workspace integration isn't any single skill — it's chaining them together with other tools (GitHub, Slack MCP, your codebase) into workflows that span your entire work context.

Animation — Gmail → Summarize → Slack Notification
/gmail search: "subject:incident" unread:true
waiting
Gemini: extract severity, affected services, ETA
waiting
Slack MCP: post_message → #engineering-alerts
waiting
Slack thread: formatted incident summary posted
waiting

Workflow: Gmail → Summarize → Slack

prompt
Find unread emails about production incidents from the last 24 hours.
Summarize each one: service affected, severity, current status, and next action.
Post a formatted summary to the #engineering-alerts Slack channel.
WHAT: Gmail provides incident emails. Gemini extracts structured data. Slack MCP (from M11) posts the result. WHY: Incident awareness doesn't require manual monitoring of two apps. GOTCHA: Requires the Slack MCP server to be configured in your GEMINI.md — see M11.

Workflow: Drive → Extract → GitHub Issues

📄
Drive
Read meeting notes or project brief from Google Drive
🤖
Gemini
Extract action items, owners, and due dates from unstructured text
🐛
GitHub
Create issues with labels, assignees, and milestone from extracted items
prompt
Read @drive://q3-planning-brief.gdoc.
Find every action item — look for lines starting with "Action:", "TODO:", or owner names followed by a colon.
For each action item, create a GitHub issue in org/repo with:
- Title from the action
- Body with context from the surrounding paragraph
- Assignee from the owner name (map to GitHub usernames in GEMINI.md)
- Label: planning-q3
- Milestone: Q3 2026

Checkpoint — You Now Have a Workspace-Connected AI Workflow Layer

Gmail, Docs, Drive, Sheets, and Calendar are now part of your Gemini CLI context. The compound patterns here — read from one app, process with AI, write to another — are the foundation of everything in Track 5. Save a useful compound prompt as a Skill (.gemini/skills/) to run it again with one command.

Knowledge Check

Five questions on the Google Workspace extension.

1. After running gemini extensions install google-workspace, what is the next required step before Workspace commands are available?

A
Restart the terminal session
B
Set the WORKSPACE_API_KEY environment variable
C
Complete OAuth authorization in the browser that opens automatically
D
Add the extension to GEMINI.md manually
Correct! The install command triggers an OAuth flow that opens your browser. You must complete the Google consent screen and grant permissions before any /gmail, /gdocs, etc. commands become active.
Not quite. The install command automatically opens a browser OAuth consent screen. No manual API key configuration is needed — OAuth tokens are stored automatically after you grant permissions.

2. You want to reference a Google Sheets file called "project-tracker" in a prompt without knowing its full Drive URL. Which syntax should you use?

A
@sheets:project-tracker
B
@drive://project-tracker.gsheet
C
/gsheets open project-tracker
D
@https://docs.google.com/spreadsheets/...
Correct! The @drive://filename.extension syntax tells Gemini CLI to search your Drive for a file matching that name. It works for .gdoc, .gsheet, .gslides, and regular files stored in Drive.
The correct syntax is @drive://filename.gsheet. The @drive:// prefix triggers a Drive search by filename. You can also use a full Drive URL if you have it.

3. Which Gmail OAuth scope is required specifically for the CLI to send an email (not just draft it)?

A
gmail.readonly
B
gmail.compose
C
gmail.send
D
gmail.full
Correct! gmail.compose only creates drafts. gmail.send is the additional scope required to actually transmit the message. The CLI only invokes send when you explicitly confirm in the prompt (e.g. "send this").
The scope needed to actually send (not just draft) is gmail.send. gmail.compose creates drafts only. This separation is intentional — you stay in control of what actually leaves your inbox.

4. A developer on a corporate Google Workspace account gets "This app is blocked" when trying to authorize the extension. What is the most likely cause?

A
The Gemini CLI version is outdated
B
The GEMINI_API_KEY is not set
C
The Workspace admin has restricted third-party OAuth app installs via API Controls
D
The extension requires a paid Google One subscription
Correct! Google Workspace admins can block all third-party OAuth apps from accessing Workspace data via Admin Console → Security → API Controls → App Access Control. The fix is to contact IT for admin approval or a service account.
This is an enterprise admin policy. Google Workspace admins can restrict third-party apps from accessing Workspace data. The error is not version or API key related — it's a policy enforcement at the Google tenant level.

5. You want to chain Gmail → Gemini summarization → Slack notification in a single prompt. What prerequisite must be set up for the Slack step to work?

A
A Slack OAuth token stored as SLACK_TOKEN in .env
B
The Slack MCP server must be configured in GEMINI.md (as covered in M11)
C
Install a slack Gemini extension separately
D
The Workspace extension includes Slack support by default
Correct! Slack is not a Google product, so the Workspace extension doesn't cover it. Cross-app workflows involving Slack require the Slack MCP server configured in GEMINI.md — as covered in M11 (MCP Servers).
Slack is outside the Google Workspace extension scope. For Gemini CLI to interact with Slack, you need the Slack MCP server registered in your GEMINI.md file. See M11 for the full MCP server setup.