New to Claude Skills? Learn how to install them →

mitsuhiko on GitHub

Google Workspace

Free

Access Google Workspace APIs with local scripts.

Get this skill

Free · Opens the source repo

What Google Workspace does

The Google Workspace skill provides developers with a straightforward way to interact with various Google Workspace APIs, including Gmail, Drive, Calendar, Docs, Sheets, and more. This skill utilizes local helper scripts to manage authentication and execute API calls without the need for a managed cloud platform (MCP). By handling OAuth login and direct API interactions, it simplifies the process of integrating Google services into your applications.

The skill is built around a profile-based account model, meaning users must specify their email address for each API call. This approach allows for multiple accounts to be managed seamlessly, with tokens stored securely on a per-email basis. The included scripts, such as auth.js for authentication and workspace.js for executing API calls, provide essential functionality to facilitate user interactions with Google services. Users can enumerate accounts, log in, and execute calls to various services with minimal setup.

For developers looking to automate tasks or build applications that leverage Google Workspace, this skill offers a robust solution. The ability to run JavaScript code within the API calls allows for dynamic data handling and manipulation. Additionally, the skill provides guidance on best practices, such as using small payloads and handling errors related to authorization, ensuring a smooth development experience.

Overall, the Google Workspace skill is ideal for developers and designers who need to integrate Google services into their workflows efficiently. Its local execution model and clear structure make it accessible for both beginners and experienced users alike, providing a powerful tool for enhancing productivity and collaboration through Google Workspace.

When to use it

Use this skill when you need to perform automated tasks or integrate Google Workspace services into your applications locally.

When not to use it

This skill is not suitable for users who prefer a fully managed cloud solution or those who do not require local execution of API calls.

What you can build with it

Automating Gmail Tasks

Use the skill to automate email management tasks, such as counting messages in the trash or organizing your inbox.

Managing Google Drive Files

Quickly list or manipulate files in Google Drive through API calls, streamlining file management processes.

Scheduling Events in Calendar

Integrate with Google Calendar to create or modify events programmatically, enhancing scheduling efficiency.

How to install Google Workspace

View source

1. Install with the skills CLI

npx skills add mitsuhiko/agent-stuff/google-workspace --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mitsuhiko

Google Workspace

Use this skill for Google Workspace tasks (Gmail, Drive, Calendar, Docs, Sheets, etc.).

Files

  • scripts/auth.js — OAuth login/status/clear + account enumeration
  • scripts/workspace.js — JavaScript execution based API runner

Account model (multi-account)

This skill is profile-based by email address.

  • There is no default account.
  • Every API call must specify --email <account@example.com>.
  • Tokens are stored per-email under ~/.pi/google-workspace/tokens/.

Before running API calls, discover available signed-in accounts:

node scripts/auth.js accounts

Usage

Always use exec and always provide --email.

node scripts/workspace.js exec --email user@example.com <<'JS'
const me = await workspace.whoAmI();
const files = await workspace.call('drive', 'files.list', {
  pageSize: 5,
  fields: 'files(id,name,mimeType)',
});
return { me, files: files.files };
JS

Available inside exec scripts:

  • auth (authorized OAuth client)
  • google (googleapis root)
  • workspace.accountEmail (selected profile email)
  • workspace.call(service, methodPath, params, {version})
  • workspace.service(service, {version})
  • workspace.whoAmI()

Optional flags:

  • --timeout <ms> (default 30000, max 300000)
  • --scopes s1,s2
  • --script 'return 42'

Agent guidance

  1. Prefer one exec script per user request.
  2. Keep payloads small (fields, maxResults, minimal props).
  3. Use Promise.all for independent requests.
  4. Never print token contents.
  5. If the user did not specify an account, run node scripts/auth.js accounts and choose/confirm an explicit email.
  6. If auth fails, first run node scripts/auth.js accounts to see known profiles.
  7. If account mismatch is possible, run workspace.whoAmI() in the selected profile.
  8. On 401/403/unauthorized errors, switch account (--email ...) or re-login that specific profile.

Unauthorized/account-switch playbook

If a request fails with unauthorized/forbidden/insufficient permissions:

  1. Enumerate profiles:
node scripts/auth.js accounts
  1. Retry with the intended account:
node scripts/workspace.js exec --email correct-user@example.com <<'JS'
return await workspace.whoAmI();
JS
  1. If token is stale or missing scopes, re-login that account:
node scripts/auth.js login --email correct-user@example.com
  1. Retry the original request with the same --email.

Short Gmail counting example

node scripts/workspace.js exec --email user@example.com <<'JS'
const gmail = google.gmail({ version: 'v1', auth });

let trash = 0;
let pageToken;
do {
  const res = await gmail.users.messages.list({
    userId: 'me',
    q: 'in:trash',
    maxResults: 500,
    pageToken,
    fields: 'messages/id,nextPageToken',
  });
  trash += (res.data.messages || []).length;
  pageToken = res.data.nextPageToken;
} while (pageToken);

return { currentlyInTrash: trash };
JS

Setup + auth

node scripts/auth.js login --email user@example.com

Notes:

  • Dependencies auto-install on first run.
  • Default auth mode is cloud (no local credentials.json needed).
  • Optional local mode: GOOGLE_WORKSPACE_AUTH_MODE=local and credentials at ~/.pi/google-workspace/credentials.json.
  • Useful diagnostics:
node scripts/auth.js accounts
node scripts/auth.js status --email user@example.com
node scripts/auth.js clear --email user@example.com

Frequently asked questions about Google Workspace

Similar skills