Running Google Workspace from Claude Code / Cursor with gog CLI — Implementation Guide

Published: 2026-05-14 · Author: AI Agent Camp · Reading time: ~20 min

1. Why the gog CLI

gog wraps the main Google Workspace APIs (Gmail / Calendar / Drive / Sheets / Docs) behind a single CLI. We built it because we wanted learners to run real Workspace tasks ("summarise my latest 5 emails", "find a free slot next week") from inside Claude Code or Cursor in 30 minutes, without first writing a Workspace API client in Python or TypeScript.

One agent operating Gmail, Calendar, Drive, Sheets and Docs via gog
One agent operating Gmail, Calendar, Drive, Sheets and Docs via gog
Module 4 at a glance
Duration ~180 min · 7 lessons · Tools: gogcli / google-workspace-ops / gas-clasp-ops · Tech: Google Workspace API / Gemini API

2. Five operating rules

  1. Never commit the OAuth client JSON. Reference it through .env or the OS credential manager.
  2. Keep refresh tokens in gog's local directory only. Never paste them into Slack, Notion or GitHub issues.
  3. Remember scope inheritance: when the agent reads shared Drives, it sees them with your own permissions.
  4. Wrap destructive actions (sending mail, deleting events, moving files) with dry-runs or previews.
  5. If you need other users' credentials, coordinate with the Workspace admin and use the official Test Users flow.

3. Tool layout

How gogcli, google-workspace-ops and gas-clasp-ops share responsibilities
How gogcli, google-workspace-ops and gas-clasp-ops share responsibilities
gogcli — direct Workspace operations
Gmail / Calendar / Drive / Sheets / Docs reads and writes through one command surface. OAuth lives here too.
google-workspace-ops — high-level skills
Composite tasks (e.g. "find missed replies and prepare 3 drafts") packaged as Claude Code / Cursor skills, calling gogcli underneath.
gas-clasp-ops — Apps Script bridge
Drives GAS projects (push / deploy / run) through clasp so an agent can edit Apps Script directly and wire up Sheets triggers.

4. A typical day

  1. Morning email triage (missed replies → drafts)
  2. Scheduling (free-slot search → event creation)
  3. Drive cleanup (list → rename / move)
  4. Sheets / Excel aggregation (read → transform → export)
  5. Meeting notes draft in Docs
  6. GAS triggers to automate the next day's routines

5. GCP setup

  1. Create a new project in Cloud Console and link a billing account (required even when the practical usage stays near the free tier).
  2. APIs & Services → Library: enable Gmail, Calendar, Drive, Sheets and Docs APIs.
  3. Google Auth Platform → Branding: fill in app name, contact and logo. Keep the app in test mode.
  4. Audience tab → Test users: add your own Google account.
  5. Credentials → Create credentials → OAuth client ID. Choose user type "External" and application type "Desktop app".
  6. Download the JSON. Keep it out of the repo (e.g. credentials/my-google-workspace-oauth.json under a local-only directory).

6. gog authentication

gog terminal session: version check, credentials register, OAuth, list
gog terminal session: version check, credentials register, OAuth, list
# 1. Confirm installation
gog --version

# 2. Register OAuth client
gog auth credentials set credentials/my-google-workspace-oauth.json

# 3. Add account (opens a browser)
gog auth add your-email@example.com

# 4. Check connection
gog auth list

The browser will show the "This app isn't verified" warning. That's the expected state for an app still in test mode — open Details and continue to the app you created. Approve the Calendar / Gmail / Drive scopes you need. Claude Code / Cursor users can run the slash command /module-4-gcp-quick and have the agent walk through the four steps above.

7. Authentication test

# Latest 5 inbox messages
gog gmail search --query "is:inbox" --max 5

# Calendar events for the next 7 days
gog calendar events --days 7

Three common failure modes:

8. Calendar

Calendar workflow: free-slot search → create event
Calendar workflow: free-slot search → create event
# Find a 60-minute slot in the next 7 working days
gog calendar free-slots --duration 60 --days 7 --working-hours 10-18

# Create an event
gog calendar create-event \
  --title "1on1 @ koheinakamura" \
  --start "2026-05-20T15:00:00+09:00" \
  --duration 30 \
  --attendees "partner@example.com"

Ask "book a 1on1 for any free slot next week" inside Claude Code or Cursor and the agent chains free-slots → create-event automatically. The module covers six scenarios (internal / customer / interview / conference / focus block / deadline reminder).

9. Morning email triage

Detect missed replies in Gmail and generate drafts with Gemini API
Detect missed replies in Gmail and generate drafts with Gemini API
  1. Use gog gmail search to find threads where you sent the last message but never received a reply.
  2. Feed each thread to an agent and ask Gemini to score priority and decide whether a reply is needed.
  3. For those that need one, generate a pre-send draft with gog gmail draft create.

10. Drive

Drive operations: list / upload / download / CSV export
Drive operations: list / upload / download / CSV export
# List 20 latest files under a folder
gog drive list --parent <folder-id> --max 20

# Download to local
gog drive download <file-id> --output ./downloads/

# Export Sheets as CSV
gog drive export <sheet-id> --format csv --output ./out.csv

11. Sheets / Excel

# List sheets
gog sheets list <spreadsheet-id>

# Export a range to CSV
gog sheets export <spreadsheet-id> \
  --range "Sheet1!A1:F100" \
  --format csv \
  --output ./out.csv

# Preview first 20 rows
gog sheets preview <spreadsheet-id> --max 20

12. GAS automation

A GAS-triggered pipeline: Drive → Sheets → Slack notification
A GAS-triggered pipeline: Drive → Sheets → Slack notification

To keep things running while no one is typing, combine GAS triggers with the gas-clasp-ops skill. The agent can push and deploy Apps Script directly, then wire it to Sheets triggers for nightly or weekly runs.

13. Skills you walk away with

Download the corporate training white paper (free)

Get the PDF that summarizes the Day 1 schedule, subsidy options and curriculum design for corporate programs. Fill in the form below and our team can also discuss bringing this to your company.

If the form does not load, please reach us at kohei@aibrainpartners.jp.

Go deeper with videos and the community

AI Agent Camp membership unlocks hands-on videos for every section, Claude Code / Cursor slash commands, troubleshooting playbooks, instructor support and the community. JPY 12,800 / month.

See the whole course

FAQ

What is the gog CLI?
A CLI that AI Agent Camp maintains for Google Workspace automation. It wraps Gmail, Calendar, Drive, Sheets and Docs APIs behind a single command surface so you can call them from Claude Code or Cursor in natural language.
How do I authenticate the gog CLI?
Create an OAuth client (Desktop app) in Google Cloud, download the JSON, run gog auth credentials set <path-to-json> to register it, then gog auth add <email> to finish browser-based OAuth.
Why do you use the gog CLI in a Claude Code / Cursor course?
So learners can complete real Workspace tasks (inbox triage, scheduling, file operations) by writing prompts instead of API client code. They get the agent-collaboration feeling in 30 minutes without first learning Python or TypeScript SDKs.
Why must the OAuth client be of type Desktop app?
Desktop allows the local-browser redirect flow and keeps a long-lived refresh token. Web app type requires a fixed redirect URI and ships shorter tokens, neither of which fits CLI usage.
How do I get the videos, slash commands and support?
AI Agent Camp membership unlocks all 33 modules, the slash commands (/setup-gogcli, /module-4-gcp-quick and others), instructor support and the community. JPY 12,800 / month.
Running Google Workspace from Claude Code / Cursor with gog CLI — Implementation Guide