gws-cli
Use this skill when the task should be executed through the Google Workspace CLI instead of handwritten HTTP requests or ad hoc API wrappers.
When to use this skill
- The user asks to interact with Google Drive, Gmail, Sheets, Docs, Slides, Calendar, Chat, Tasks, People, Meet, or Workspace Admin APIs.
- The user wants structured JSON output that is easy for an agent to inspect.
- The user needs to inspect Google API schemas before building a request.
- The user wants a repeatable CLI workflow that can run locally, in CI, or in a headless environment.
Required operating model
- Confirm that
gws is installed and available on PATH.
- Check authentication status before making API calls.
- Inspect the target method with
gws schema or gws <service> --help before composing flags.
- Prefer read-only commands first.
- For write, update, or delete operations, confirm intent with the user before execution.
- Prefer
--dry-run when the command supports local validation and the operation is risky.
Quick start
# Install the CLI
npm install -g @googleworkspace/cli
# Check the binary and auth status
bash scripts/check-prereqs.sh
# Inspect command space
gws drive --help
gws schema drive.files.list
# Run a read-only command
gws drive files list --params '{"pageSize": 10}' --format json
Authentication workflow
Choose the lightest auth flow that satisfies the task.
Local interactive
gws auth setup
gws auth login
Service account
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
gws auth status
CI or headless flows
- Prefer exported credentials or service-account based execution.
- Never echo secrets back to the user.
- If credentials are missing, stop and ask for the appropriate auth setup instead of guessing.
More detail is in references/REFERENCE.md.
Command discovery workflow
Always inspect before executing.
# Browse resources and helper commands for a service
gws sheets --help
# Inspect a specific method schema
gws schema sheets.spreadsheets.values.get
Use schema output to determine:
- required
--params values
- whether a request body is needed via
--json
- whether pagination or file upload flags apply
- which field names and types the API expects
Command patterns
Read-only list or get
gws drive files list --params '{"pageSize": 10}' --format json
gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}' --format json
Create or update with explicit confirmation
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}' --format json
gws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{"requests": [...]}' --format json
Schema-driven request building
gws schema calendar.events.insert
gws calendar events insert --params '{"calendarId": "primary"}' --json '{"summary": "Standup", "start": {"dateTime": "2026-03-07T09:00:00Z"}, "end": {"dateTime": "2026-03-07T09:15:00Z"}}'
Pagination
gws drive files list --params '{"pageSize": 100}' --page-all
File upload or download
gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf
gws drive files get --params '{"fileId": "FILE_ID", "alt": "media"}' --output ./download.bin
Safety rules
- Treat
create, insert, update, patch, delete, and helper commands that change state as write operations.
- Confirm the target resource, identity, and scope before executing a write operation.
- Never print tokens, OAuth client secrets, or service account JSON contents.
- Prefer
--format json unless the user explicitly wants a human-oriented table.
- Use
--page-all intentionally because it changes output shape to NDJSON.
- If the upstream API or CLI help is ambiguous, inspect the schema again instead of guessing flag names.
Available support files
- references/REFERENCE.md for installation, auth, and common command templates
scripts/check-prereqs.sh for local environment checks
Troubleshooting
- If
gws is missing, install it from npm or a GitHub release, confirm it is on PATH, and rerun bash scripts/check-prereqs.sh.
- If
gws auth status shows no credentials, run gws auth setup and gws auth login, or export GOOGLE_APPLICATION_CREDENTIALS for a service-account flow.
- If
gws auth login fails due to OAuth client restrictions, prefer the upstream manual OAuth flow or a service account where appropriate.
- If a request returns
403 Forbidden or insufficient permissions, confirm the active identity, API enablement, scopes, and resource sharing before retrying.
- If a method is unknown, confirm the service alias with
gws <service> --help before assuming the REST method name maps directly.
- If a request fails schema validation, rerun
gws schema <service.resource.method> and compare every required field name with the command you built.
- If
--page-all changes the output shape unexpectedly, remember that pagination output becomes NDJSON and should be parsed line by line.
1---2name: gws-cli3description: Use the Google Workspace CLI to inspect schemas, authenticate safely, and run Google Workspace API commands. Use when the user wants to work with Drive, Gmail, Sheets, Docs, Calendar, Chat, Tasks, or other Google Workspace APIs through the gws command.4license: MIT5---67# gws-cli89Use this skill when the task should be executed through the Google Workspace CLI instead of handwritten HTTP requests or ad hoc API wrappers.1011## When to use this skill1213- The user asks to interact with Google Drive, Gmail, Sheets, Docs, Slides, Calendar, Chat, Tasks, People, Meet, or Workspace Admin APIs.14- The user wants structured JSON output that is easy for an agent to inspect.15- The user needs to inspect Google API schemas before building a request.16- The user wants a repeatable CLI workflow that can run locally, in CI, or in a headless environment.1718## Required operating model19201. Confirm that `gws` is installed and available on `PATH`.212. Check authentication status before making API calls.223. Inspect the target method with `gws schema` or `gws <service> --help` before composing flags.234. Prefer read-only commands first.245. For write, update, or delete operations, confirm intent with the user before execution.256. Prefer `--dry-run` when the command supports local validation and the operation is risky.2627## Quick start2829```bash30# Install the CLI31npm install -g @googleworkspace/cli3233# Check the binary and auth status34bash scripts/check-prereqs.sh3536# Inspect command space37gws drive --help38gws schema drive.files.list3940# Run a read-only command41gws drive files list --params '{"pageSize": 10}' --format json42```4344## Authentication workflow4546Choose the lightest auth flow that satisfies the task.4748### Local interactive4950```bash51gws auth setup52gws auth login53```5455### Service account5657```bash58export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json59gws auth status60```6162### CI or headless flows6364- Prefer exported credentials or service-account based execution.65- Never echo secrets back to the user.66- If credentials are missing, stop and ask for the appropriate auth setup instead of guessing.6768More detail is in [references/REFERENCE.md](references/REFERENCE.md).6970## Command discovery workflow7172Always inspect before executing.7374```bash75# Browse resources and helper commands for a service76gws sheets --help7778# Inspect a specific method schema79gws schema sheets.spreadsheets.values.get80```8182Use schema output to determine:8384- required `--params` values85- whether a request body is needed via `--json`86- whether pagination or file upload flags apply87- which field names and types the API expects8889## Command patterns9091### Read-only list or get9293```bash94gws drive files list --params '{"pageSize": 10}' --format json95gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}' --format json96```9798### Create or update with explicit confirmation99100```bash101gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}' --format json102gws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{"requests": [...]}' --format json103```104105### Schema-driven request building106107```bash108gws schema calendar.events.insert109gws calendar events insert --params '{"calendarId": "primary"}' --json '{"summary": "Standup", "start": {"dateTime": "2026-03-07T09:00:00Z"}, "end": {"dateTime": "2026-03-07T09:15:00Z"}}'110```111112### Pagination113114```bash115gws drive files list --params '{"pageSize": 100}' --page-all116```117118### File upload or download119120```bash121gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf122gws drive files get --params '{"fileId": "FILE_ID", "alt": "media"}' --output ./download.bin123```124125## Safety rules126127- Treat `create`, `insert`, `update`, `patch`, `delete`, and helper commands that change state as write operations.128- Confirm the target resource, identity, and scope before executing a write operation.129- Never print tokens, OAuth client secrets, or service account JSON contents.130- Prefer `--format json` unless the user explicitly wants a human-oriented table.131- Use `--page-all` intentionally because it changes output shape to NDJSON.132- If the upstream API or CLI help is ambiguous, inspect the schema again instead of guessing flag names.133134## Available support files135136- [references/REFERENCE.md](references/REFERENCE.md) for installation, auth, and common command templates137- `scripts/check-prereqs.sh` for local environment checks138139## Troubleshooting140141- If `gws` is missing, install it from npm or a GitHub release, confirm it is on `PATH`, and rerun `bash scripts/check-prereqs.sh`.142- If `gws auth status` shows no credentials, run `gws auth setup` and `gws auth login`, or export `GOOGLE_APPLICATION_CREDENTIALS` for a service-account flow.143- If `gws auth login` fails due to OAuth client restrictions, prefer the upstream manual OAuth flow or a service account where appropriate.144- If a request returns `403 Forbidden` or insufficient permissions, confirm the active identity, API enablement, scopes, and resource sharing before retrying.145- If a method is unknown, confirm the service alias with `gws <service> --help` before assuming the REST method name maps directly.146- If a request fails schema validation, rerun `gws schema <service.resource.method>` and compare every required field name with the command you built.147- If `--page-all` changes the output shape unexpectedly, remember that pagination output becomes NDJSON and should be parsed line by line.