Home/Connecting Tools to Claude Code/Episode 2
IntermediateEpisode 2 of 415 min

Connect Google Workspace to Claude Code

Connect Claude Code to Google Sheets, Docs, and Drive using the official Google Workspace CLI.

Let's Work with a CLI: Google Workspace

Google Workspace is probably where a lot of your data lives — Sheets, Docs, Drive, Gmail. Let's connect Claude Code directly to it using the gog CLI tool.

What you'll be able to do

After setup, Claude can:

  • Read data from Google Sheets (no more exporting CSVs)
  • Search your Google Drive
  • Read Google Docs
  • Search and read Gmail
  • Create and update documents

All without leaving Claude Code or manually exporting anything.

Step 1: Install gog

The gog tool is a command-line interface for Google Workspace. Install it:

Mac:

bash
brew install gog

Linux / Windows (WSL):

bash
# Download the latest release for your platform from:
# https://github.com/uber/gog/releases
# Extract and add to your PATH

Verify installation:

bash
gog --version

Step 2: Authenticate

You need to connect gog to your Google account:

bash
gog auth login

This opens a browser window. Sign in with your Google account and grant the permissions requested. The tool stores credentials locally so you don't have to log in again.

Multiple accounts? Use gog auth login --account [email protected] to add specific accounts. Then specify which account to use with [email protected].

Step 3: Test it manually

Before involving Claude, make sure gog works:

List your Google Drive files:

bash
gog drive list

Search for a specific file:

bash
gog drive search "Q1 Budget"

Read a Google Sheet:

bash
gog sheets get "Q1 Budget" --sheet "Sheet1"

If these work, you're ready to use gog with Claude.

Step 4: Use with Claude Code

Now Claude can use gog. Try this:

Use gog to read my Google Sheet called "Q1 Budget".
Tell me the total for each department.

Claude runs the gog command, gets the data, and processes it — all in one step.

Common operations

Read a Google Sheet:

Read the Google Sheet named "Sales Tracker" and summarize the total revenue by month.

Search Google Drive:

Search my Google Drive for files containing "contract" that were modified this month.
List them with their last modified dates.

Read a Google Doc:

Read the Google Doc called "Q1 Marketing Plan" and extract all the action items.

Search Gmail:

Search my Gmail for emails from [email protected] in the last 30 days.
Summarize what they're about.

Combining with local files

The real power is combining Google data with local processing:

1. Read the "Customer List" Google Sheet
2. Read the local file invoices.csv
3. Match customers to invoices by email
4. Create a report showing which customers have unpaid invoices
5. Save as unpaid_report.md locally

Data from Google + local data + Claude processing = powerful workflows.

Creating and updating Google files

gog can also write back to Google:

Update a Google Sheet:

Read the sales data from sales.csv.
Update the Google Sheet "Sales Dashboard" with this data, replacing the existing content in Sheet1.

Create a new Google Doc:

Generate a weekly summary report from the files in /reports.
Create a new Google Doc called "Weekly Summary - [today's date]" with the content.

Setting up a CLAUDE.md for Google workflows

If you frequently work with specific Google files, add them to your CLAUDE.md:

markdown
# Sales Dashboard Project

## Google Workspace Files
- "Sales Tracker" — Main sales data, Sheet1 has current pipeline
- "Sales Dashboard" — Output sheet, update Sheet1 with processed data
- "Team Directory" — Reference sheet with rep names and regions

## Workflow
When generating the weekly report:
1. Read "Sales Tracker" via gog
2. Process and calculate metrics
3. Update "Sales Dashboard" via gog
4. Save a local backup to /output/

Handling Google authentication in scheduled tasks

If you schedule automations that use gog, authentication can be tricky. The token might expire.

Best practice: run gog auth refresh before your automation:

bash
#!/bin/bash
gog auth refresh  # Refresh credentials if needed
claude "Generate weekly report from Google Sheets"

Or set up a service account for fully automated access (more advanced — see gog documentation).

Troubleshooting

"File not found":

  • Check the exact file name (case-sensitive)
  • Make sure you have access to the file
  • Try gog drive search "partial name" to find it

"Permission denied":

  • Re-run gog auth login to refresh permissions
  • Check that your Google account can access the file

Rate limits:

  • Google APIs have limits on how many requests you can make
  • If you're processing many files, add delays between operations

What you've unlocked

You can now:

  • Skip the export step for Google Sheets
  • Search and read across your Drive and Gmail
  • Write processed data back to Google
  • Build workflows that span local files and Google Workspace

Next up: connecting to project management tools with MCP servers.

CLI and MCP Tools for Claude CodeNext: Manage Linear Projects Using Claude Code