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.

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

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
- Morning email triage (missed replies → drafts)
- Scheduling (free-slot search → event creation)
- Drive cleanup (list → rename / move)
- Sheets / Excel aggregation (read → transform → export)
- Meeting notes draft in Docs
- GAS triggers to automate the next day's routines
5. GCP setup
- Create a new project in Cloud Console and link a billing account (required even when the practical usage stays near the free tier).
- APIs & Services → Library: enable Gmail, Calendar, Drive, Sheets and Docs APIs.
- Google Auth Platform → Branding: fill in app name, contact and logo. Keep the app in test mode.
- Audience tab → Test users: add your own Google account.
- Credentials → Create credentials → OAuth client ID. Choose user type "External" and application type "Desktop app".
- Download the JSON. Keep it out of the repo (e.g.
credentials/my-google-workspace-oauth.jsonunder a local-only directory).
6. gog authentication

# 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 listThe 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 7Three common failure modes:
- Your address is missing from the OAuth Test Users list.
- The OAuth client is not of type Desktop app.
- You enabled Gmail but forgot Calendar (or any other API).
8. Calendar

# 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

- Use
gog gmail searchto find threads where you sent the last message but never received a reply. - Feed each thread to an agent and ask Gemini to score priority and decide whether a reply is needed.
- For those that need one, generate a pre-send draft with
gog gmail draft create.
10. Drive

# 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.csv11. 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 2012. GAS automation

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
- Gmail triage and draft generation
- Calendar free-slot search and event creation
- Drive listing, naming, sharing
- Sheets export and integration with other tools
- Docs draft generation for meeting notes
- Scheduled execution via GAS triggers
- One-shot operations from Claude Code / Cursor slash commands
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 courseFAQ
- 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.