google-workspace-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Workspace CLI (gws
)
gwsGoogle Workspace CLI(gws
)
gwsOne CLI for all of Google Workspace — Drive, Gmail, Calendar, Sheets, Docs, Slides, Chat, Tasks, Admin, Meet, Forms, Keep, and every other Workspace API. Built for humans and AI agents. Structured JSON output. 100+ agent skills included.
Note: This is not an officially supported Google product.
Important: This project is under active development. Expect breaking changes as we march toward v1.0.
Repository: https://github.com/googleworkspace/cli
一款适用于所有Google Workspace服务的CLI工具——涵盖Drive、Gmail、Calendar、Sheets、Docs、Slides、Chat、Tasks、Admin、Meet、Forms、Keep以及其他所有Workspace API。为人类用户和AI Agent打造,输出结构化JSON,内置100+ Agent技能。
注意: 这并非Google官方支持的产品。
重要提示: 本项目正处于活跃开发阶段,在推进至v1.0版本过程中可能会出现破坏性变更。
How It Works
工作原理
gwsgwsgwsgwsPrerequisites
前置要求
- Node.js 18+ — for (or download a pre-built binary from GitHub Releases)
npm install - A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console, with the CLI, or with the
gcloudcommand.gws auth setup - A Google account with access to Google Workspace
- Node.js 18+ — 用于(也可从GitHub Releases下载预构建二进制文件)
npm install - Google Cloud项目 — 用于获取OAuth凭证。可通过Google Cloud Console、CLI或
gcloud命令创建。gws auth setup - 拥有Google Workspace访问权限的Google账号
Installation
安装方式
bash
undefinedbash
undefinedInstall globally via npm (recommended — bundles native binaries, no Rust needed)
通过npm全局安装(推荐——捆绑原生二进制文件,无需Rust环境)
npm install -g @googleworkspace/cli
npm install -g @googleworkspace/cli
Verify installation
验证安装
gws --version
Alternative installation methods:
```bashgws --version
其他安装方式:
```bashFrom GitHub Releases (pre-built binaries)
从GitHub Releases下载预构建二进制文件
Download from: https://github.com/googleworkspace/cli/releases
Build from source (requires Rust toolchain)
从源码构建(需要Rust工具链)
cargo install --git https://github.com/googleworkspace/cli --locked
cargo install --git https://github.com/googleworkspace/cli --locked
Nix flake
Nix flake方式
nix run github:googleworkspace/cli
undefinednix run github:googleworkspace/cli
undefinedQuick Start
快速开始
bash
gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'bash
gws auth setup # 引导完成Google Cloud项目配置
gws auth login # 后续OAuth登录
gws drive files list --params '{"pageSize": 5}'Authentication
认证方式
Which setup should I use?
如何选择认证方式?
| I have… | Use |
|---|---|
| |
A GCP project but no | Manual OAuth setup in Cloud Console |
| An existing OAuth access token | |
| Existing credentials JSON (service account or exported) | |
| 我已拥有… | 推荐使用 |
|---|---|
已安装并完成认证的 | |
GCP项目但未安装 | 在Cloud Console中手动配置OAuth |
| 已获取的OAuth访问令牌 | |
| 已有的凭证JSON文件(服务账号或导出的凭证) | |
Quick Setup (recommended — requires gcloud CLI)
快速配置(推荐——需安装gcloud CLI)
bash
gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent logins with scope selectionCredentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.
bash
gws auth setup # 一次性操作:创建Cloud项目、启用API、完成登录
gws auth login # 后续登录时选择权限范围凭证会通过AES-256-GCM加密存储,密钥保存在系统密钥环中。
Scoped Login (for unverified/testing OAuth apps, limited to ~25 scopes)
限定权限范围登录(针对未验证/测试版OAuth应用,最多支持约25个权限范围)
Warning: Unverified (testing-mode) apps are limited to ~25 OAuth scopes. Thescope preset includes 85+ scopes and will fail for unverified apps (especially forrecommendedaccounts). Choose individual services instead:@gmail.com
bash
undefined警告: 未验证(测试模式)的应用最多支持约25个OAuth权限范围。权限预设包含85+个权限范围,会导致未验证应用登录失败(尤其针对recommended账号)。请选择所需的特定服务:@gmail.com
bash
undefinedSelect only the services you need to stay under the scope limit
仅选择需要的服务,避免超出权限范围限制
gws auth login -s drive,gmail,sheets
gws auth login --scopes drive,gmail,calendar,docs,chat
undefinedgws auth login -s drive,gmail,sheets
gws auth login --scopes drive,gmail,calendar,docs,chat
undefinedMultiple Accounts
多账号管理
bash
gws auth login --account work@corp.com
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com # set the default
gws --account personal@gmail.com drive files list # one-off override
export GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var overrideCredentials are stored per-account as in , with an registry tracking defaults.
credentials.<b64-email>.enc~/.config/gws/accounts.jsonbash
gws auth login --account work@corp.com
gws auth login --account personal@gmail.com
gws auth list # 列出已注册账号
gws auth default work@corp.com # 设置默认账号
gws --account personal@gmail.com drive files list # 单次覆盖默认账号
export GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # 通过环境变量覆盖默认账号凭证按账号存储为目录下的文件,文件用于跟踪默认账号。
~/.config/gws/credentials.<b64-email>.encaccounts.jsonManual OAuth Setup (no gcloud)
手动OAuth配置(无需gcloud)
Use this when cannot automate project/client creation, or when you want explicit control.
gws auth setup- Open Google Cloud Console in the target project:
- OAuth consent screen:
https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID> - Credentials:
https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
- OAuth consent screen:
- Configure OAuth branding/audience if prompted — App type: External (testing mode is fine)
- Add your account under Test users
- Create an OAuth client — Type: Desktop app
- Download the client JSON → save to
~/.config/gws/client_secret.json
Important: You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.
Then run:
bash
gws auth login当无法自动完成项目/客户端创建,或需要完全手动控制时,可使用此方式。
gws auth setup- 在目标项目中打开Google Cloud Console:
- OAuth consent screen:
https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID> - 凭证页面:
https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
- OAuth consent screen:
- 按提示配置OAuth品牌/受众——应用类型选择External(测试模式即可)
- 在测试用户中添加你的账号
- 创建OAuth客户端——类型选择Desktop app
- 下载客户端JSON文件→保存至
~/.config/gws/client_secret.json
重要提示: 必须将自己添加为测试用户。在OAuth consent screen页面,点击测试用户 → 添加用户并输入你的Google账号邮箱。否则登录时会显示通用的"Access blocked"错误。
然后运行:
bash
gws auth loginHeadless / CI
无头模式 / CI环境
bash
undefinedbash
undefinedOn a machine with a browser:
在有浏览器的机器上执行:
gws auth export --unmasked > credentials.json
gws auth export --unmasked > credentials.json
On the headless machine:
在无头机器上执行:
export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
gws drive files list # just works
undefinedexport GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
gws drive files list # 直接运行即可
undefinedService Account (server-to-server)
服务账号(服务器到服务器)
bash
export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files listbash
export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files listFor Domain-Wide Delegation:
针对域范围委派:
export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com
undefinedexport GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com
undefinedPre-obtained Access Token
预先获取的访问令牌
bash
export GOOGLE_WORKSPACE_CLI_TOKEN=$(gcloud auth print-access-token)bash
export GOOGLE_WORKSPACE_CLI_TOKEN=$(gcloud auth print-access-token)Browser-Assisted Auth (for AI agents)
浏览器辅助认证(针对AI Agent)
Agents can complete OAuth with browser automation:
- Human flow: Run , open the printed URL, approve scopes.
gws auth login - Agent-assisted flow: The agent opens the URL, selects the account, handles consent prompts, and returns control once the localhost callback succeeds.
If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.
Agent可通过浏览器自动化完成OAuth认证:
- 人工流程: 运行,打开打印的URL,同意权限范围。
gws auth login - Agent辅助流程: Agent打开URL,选择账号,处理授权提示,在本地回调成功后恢复控制权。
如果授权页面显示"Google hasn't verified this app"(测试模式),点击继续。如果出现权限范围复选框,选择所需权限(或全选)后继续。
Auth Precedence
认证优先级
| Priority | Method | Source |
|---|---|---|
| 1 | Access token | |
| 2 | Credentials file | |
| 3 | Per-account encrypted credentials | |
| 4 | Plaintext credentials | |
Account resolution: flag > env var > default in .
--accountGOOGLE_WORKSPACE_CLI_ACCOUNTaccounts.jsonAll environment variables can also live in afile in your project root..env
| 优先级 | 方式 | 来源 |
|---|---|---|
| 1 | 访问令牌 | |
| 2 | 凭证文件 | |
| 3 | 按账号加密存储的凭证 | |
| 4 | 明文凭证 | |
账号解析优先级:参数 > 环境变量 > 中的默认账号。
--accountGOOGLE_WORKSPACE_CLI_ACCOUNTaccounts.json所有环境变量也可存储在项目根目录的文件中。.env
Command Structure
命令结构
The universal pattern for ALL gws commands:
gws <service> <resource> <method> [--params '{ JSON }'] [--json '{ JSON }'] [flags]所有gws命令遵循统一格式:
gws <服务名> <资源名> <方法名> [--params '{ JSON }'] [--json '{ JSON }'] [参数]Global Flags
全局参数
| Flag | Description |
|---|---|
| Show help for any service, resource, or method |
| URL/query parameters as JSON |
| Request body as JSON |
| Preview the HTTP request without executing |
| Auto-paginate, one JSON line per page (NDJSON) |
| Max pages to fetch (default: 10) |
| Delay between pages (default: 100ms) |
| Multipart file upload |
| Use a specific authenticated account |
| Model Armor response sanitization |
| 参数 | 描述 |
|---|---|
| 查看任意服务、资源或方法的帮助信息 |
| URL/查询参数(JSON格式) |
| 请求体(JSON格式) |
| 预览HTTP请求但不执行 |
| 自动分页,每页输出一行JSON(NDJSON格式) |
| 最大获取页数(默认:10) |
| 分页请求间隔(默认:100ms) |
| 多部分文件上传 |
| 使用指定的已认证账号 |
| Model Armor响应内容清理 |
Introspecting Schemas
查看Schema
bash
undefinedbash
undefinedSee the full request/response schema for any method
查看任意方法的完整请求/响应Schema
gws schema drive.files.list
gws schema gmail.users.messages.send
gws schema calendar.events.insert
undefinedgws schema drive.files.list
gws schema gmail.users.messages.send
gws schema calendar.events.insert
undefinedCore Services — Commands & Examples
核心服务——命令与示例
Google Drive
Google Drive
bash
undefinedbash
undefinedList files (paginated)
列出文件(分页)
gws drive files list --params '{"pageSize": 10}'
gws drive files list --params '{"pageSize": 10}'
List ALL files (auto-paginate as NDJSON)
列出所有文件(自动分页,输出NDJSON格式)
gws drive files list --params '{"pageSize": 100}' --page-all
gws drive files list --params '{"pageSize": 100}' --page-all
Search for files
搜索文件
gws drive files list --params '{"q": "name contains '''report''' and mimeType = '''application/pdf'''", "pageSize": 20}'
gws drive files list --params '{"q": "name contains '\''report'\'' and mimeType = '\''application/pdf'\''", "pageSize": 20}'
Get file metadata
获取文件元数据
gws drive files get --params '{"fileId": "FILE_ID"}'
gws drive files get --params '{"fileId": "FILE_ID"}'
Upload a file
上传文件
gws drive files create --json '{"name": "report.pdf", "parents": ["FOLDER_ID"]}' --upload ./report.pdf
gws drive files create --json '{"name": "report.pdf", "parents": ["FOLDER_ID"]}' --upload ./report.pdf
Create a folder
创建文件夹
gws drive files create --json '{"name": "Project Docs", "mimeType": "application/vnd.google-apps.folder"}'
gws drive files create --json '{"name": "Project Docs", "mimeType": "application/vnd.google-apps.folder"}'
Move a file to a folder
移动文件至文件夹
gws drive files update --params '{"fileId": "FILE_ID", "addParents": "FOLDER_ID", "removeParents": "OLD_PARENT_ID"}'
gws drive files update --params '{"fileId": "FILE_ID", "addParents": "FOLDER_ID", "removeParents": "OLD_PARENT_ID"}'
Share a file
分享文件
gws drive permissions create --params '{"fileId": "FILE_ID"}' --json '{"role": "writer", "type": "user", "emailAddress": "user@example.com"}'
gws drive permissions create --params '{"fileId": "FILE_ID"}' --json '{"role": "writer", "type": "user", "emailAddress": "user@example.com"}'
Download a file (export Google Docs as PDF)
下载文件(将Google Docs导出为PDF)
gws drive files export --params '{"fileId": "FILE_ID", "mimeType": "application/pdf"}'
gws drive files export --params '{"fileId": "FILE_ID", "mimeType": "application/pdf"}'
Delete a file
删除文件
gws drive files delete --params '{"fileId": "FILE_ID"}'
gws drive files delete --params '{"fileId": "FILE_ID"}'
List shared drives
列出共享云端硬盘
gws drive drives list --params '{"pageSize": 10}'
gws drive drives list --params '{"pageSize": 10}'
Create a shared drive
创建共享云端硬盘
gws drive drives create --params '{"requestId": "unique-id"}' --json '{"name": "Team Drive"}'
undefinedgws drive drives create --params '{"requestId": "unique-id"}' --json '{"name": "Team Drive"}'
undefinedGmail
Gmail
bash
undefinedbash
undefinedList messages in inbox
列出收件箱邮件
gws gmail users messages list --params '{"userId": "me", "maxResults": 10}'
gws gmail users messages list --params '{"userId": "me", "maxResults": 10}'
Search messages
搜索邮件
gws gmail users messages list --params '{"userId": "me", "q": "from:boss@company.com is:unread", "maxResults": 20}'
gws gmail users messages list --params '{"userId": "me", "q": "from:boss@company.com is:unread", "maxResults": 20}'
Get a specific message
获取指定邮件
gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}'
gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}'
Send an email
发送邮件
gws gmail users messages send --params '{"userId": "me"}' --json '{
"raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"
}'
gws gmail users messages send --params '{"userId": "me"}' --json '{
"raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"
}'
List labels
列出标签
gws gmail users labels list --params '{"userId": "me"}'
gws gmail users labels list --params '{"userId": "me"}'
Create a label
创建标签
gws gmail users labels create --params '{"userId": "me"}' --json '{"name": "Important/Projects"}'
gws gmail users labels create --params '{"userId": "me"}' --json '{"name": "Important/Projects"}'
Modify message labels
修改邮件标签
gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}'
gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}'
Trash a message
将邮件移至垃圾箱
gws gmail users messages trash --params '{"userId": "me", "id": "MESSAGE_ID"}'
gws gmail users messages trash --params '{"userId": "me", "id": "MESSAGE_ID"}'
List drafts
列出草稿
gws gmail users drafts list --params '{"userId": "me"}'
gws gmail users drafts list --params '{"userId": "me"}'
Create a draft
创建草稿
gws gmail users drafts create --params '{"userId": "me"}' --json '{
"message": {"raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"}
}'
gws gmail users drafts create --params '{"userId": "me"}' --json '{
"message": {"raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"}
}'
Set vacation auto-reply
设置假期自动回复
gws gmail users settings updateVacation --params '{"userId": "me"}' --json '{
"enableAutoReply": true,
"responseSubject": "Out of Office",
"responseBodyPlainText": "I am out of office until March 10.",
"restrictToContacts": false,
"restrictToDomain": false
}'
undefinedgws gmail users settings updateVacation --params '{"userId": "me"}' --json '{
"enableAutoReply": true,
"responseSubject": "Out of Office",
"responseBodyPlainText": "I am out of office until March 10.",
"restrictToContacts": false,
"restrictToDomain": false
}'
undefinedGoogle Calendar
Google Calendar
bash
undefinedbash
undefinedList upcoming events
列出即将到来的日程
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-05T00:00:00Z", "maxResults": 10, "singleEvents": true, "orderBy": "startTime"}'
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-05T00:00:00Z", "maxResults": 10, "singleEvents": true, "orderBy": "startTime"}'
Get a specific event
获取指定日程
gws calendar events get --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
gws calendar events get --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
Create an event
创建日程
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
"summary": "Team Standup",
"description": "Daily standup meeting",
"start": {"dateTime": "2026-03-06T09:00:00-05:00", "timeZone": "America/New_York"},
"end": {"dateTime": "2026-03-06T09:30:00-05:00", "timeZone": "America/New_York"},
"attendees": [{"email": "alice@example.com"}, {"email": "bob@example.com"}]
}'
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
"summary": "Team Standup",
"description": "Daily standup meeting",
"start": {"dateTime": "2026-03-06T09:00:00-05:00", "timeZone": "America/New_York"},
"end": {"dateTime": "2026-03-06T09:30:00-05:00", "timeZone": "America/New_York"},
"attendees": [{"email": "alice@example.com"}, {"email": "bob@example.com"}]
}'
Update an event
更新日程
gws calendar events update --params '{"calendarId": "primary", "eventId": "EVENT_ID"}' --json '{
"summary": "Updated Standup",
"start": {"dateTime": "2026-03-06T10:00:00-05:00"},
"end": {"dateTime": "2026-03-06T10:30:00-05:00"}
}'
gws calendar events update --params '{"calendarId": "primary", "eventId": "EVENT_ID"}' --json '{
"summary": "Updated Standup",
"start": {"dateTime": "2026-03-06T10:00:00-05:00"},
"end": {"dateTime": "2026-03-06T10:30:00-05:00"}
}'
Delete an event
删除日程
gws calendar events delete --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
gws calendar events delete --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
List calendars
列出日历
gws calendar calendarList list
gws calendar calendarList list
Check free/busy
查看空闲/忙碌状态
gws calendar freebusy query --json '{
"timeMin": "2026-03-06T08:00:00Z",
"timeMax": "2026-03-06T18:00:00Z",
"items": [{"id": "alice@example.com"}, {"id": "bob@example.com"}]
}'
gws calendar freebusy query --json '{
"timeMin": "2026-03-06T08:00:00Z",
"timeMax": "2026-03-06T18:00:00Z",
"items": [{"id": "alice@example.com"}, {"id": "bob@example.com"}]
}'
Create a recurring event
创建重复日程
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
"summary": "Weekly Review",
"recurrence": ["RRULE:FREQ=WEEKLY;BYDAY=FR"],
"start": {"dateTime": "2026-03-06T16:00:00-05:00", "timeZone": "America/New_York"},
"end": {"dateTime": "2026-03-06T17:00:00-05:00", "timeZone": "America/New_York"}
}'
undefinedgws calendar events insert --params '{"calendarId": "primary"}' --json '{
"summary": "Weekly Review",
"recurrence": ["RRULE:FREQ=WEEKLY;BYDAY=FR"],
"start": {"dateTime": "2026-03-06T16:00:00-05:00", "timeZone": "America/New_York"},
"end": {"dateTime": "2026-03-06T17:00:00-05:00", "timeZone": "America/New_York"}
}'
undefinedGoogle Sheets
Google Sheets
Important: Sheets ranges use which bash interprets as history expansion. Always wrap values in single quotes.
!bash
undefined重要提示: Sheets范围使用,而bash会将其解析为历史扩展。请始终用单引号包裹对应值。
!bash
undefinedCreate a spreadsheet
创建电子表格
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'
Read cells
读取单元格内容
gws sheets spreadsheets values get --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'
gws sheets spreadsheets values get --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'
Write cells
写入单元格内容
gws sheets spreadsheets values update --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Name", "Score"], ["Alice", 95], ["Bob", 87]]}'
gws sheets spreadsheets values update --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Name", "Score"], ["Alice", 95], ["Bob", 87]]}'
Append rows
追加行
gws sheets spreadsheets values append --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Charlie", 92]]}'
gws sheets spreadsheets values append --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Charlie", 92]]}'
Get spreadsheet metadata
获取电子表格元数据
gws sheets spreadsheets get --params '{"spreadsheetId": "SPREADSHEET_ID"}'
gws sheets spreadsheets get --params '{"spreadsheetId": "SPREADSHEET_ID"}'
Clear a range
清空指定范围内容
gws sheets spreadsheets values clear --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'
gws sheets spreadsheets values clear --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'
Batch update (add sheet, format cells, etc.)
批量更新(添加工作表、格式化单元格等)
gws sheets spreadsheets batchUpdate --params '{"spreadsheetId": "SPREADSHEET_ID"}' --json '{
"requests": [
{"addSheet": {"properties": {"title": "March Data"}}},
{"repeatCell": {
"range": {"sheetId": 0, "startRowIndex": 0, "endRowIndex": 1},
"cell": {"userEnteredFormat": {"textFormat": {"bold": true}}},
"fields": "userEnteredFormat.textFormat.bold"
}}
]
}'
undefinedgws sheets spreadsheets batchUpdate --params '{"spreadsheetId": "SPREADSHEET_ID"}' --json '{
"requests": [
{"addSheet": {"properties": {"title": "March Data"}}},
{"repeatCell": {
"range": {"sheetId": 0, "startRowIndex": 0, "endRowIndex": 1},
"cell": {"userEnteredFormat": {"textFormat": {"bold": true}}},
"fields": "userEnteredFormat.textFormat.bold"
}}
]
}'
undefinedGoogle Docs
Google Docs
bash
undefinedbash
undefinedCreate a document
创建文档
gws docs documents create --json '{"title": "Meeting Notes"}'
gws docs documents create --json '{"title": "Meeting Notes"}'
Get document content
获取文档内容
gws docs documents get --params '{"documentId": "DOC_ID"}'
gws docs documents get --params '{"documentId": "DOC_ID"}'
Update document (insert text)
更新文档(插入文本)
gws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{
"requests": [
{"insertText": {"location": {"index": 1}, "text": "Hello, World!\n"}}
]
}'
undefinedgws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{
"requests": [
{"insertText": {"location": {"index": 1}, "text": "Hello, World!
"}} ] }'
"}} ] }'
undefinedGoogle Slides
Google Slides
bash
undefinedbash
undefinedCreate a presentation
创建演示文稿
gws slides presentations create --json '{"title": "Q1 Review"}'
gws slides presentations create --json '{"title": "Q1 Review"}'
Get presentation
获取演示文稿
gws slides presentations get --params '{"presentationId": "PRES_ID"}'
gws slides presentations get --params '{"presentationId": "PRES_ID"}'
Add a slide
添加幻灯片
gws slides presentations batchUpdate --params '{"presentationId": "PRES_ID"}' --json '{
"requests": [
{"createSlide": {"slideLayoutReference": {"predefinedLayout": "TITLE_AND_BODY"}}}
]
}'
undefinedgws slides presentations batchUpdate --params '{"presentationId": "PRES_ID"}' --json '{
"requests": [
{"createSlide": {"slideLayoutReference": {"predefinedLayout": "TITLE_AND_BODY"}}}
]
}'
undefinedGoogle Chat
Google Chat
bash
undefinedbash
undefinedList spaces
列出空间
gws chat spaces list
gws chat spaces list
Send a message to a space
向空间发送消息
gws chat spaces messages create --params '{"parent": "spaces/SPACE_ID"}' --json '{"text": "Deploy complete."}'
gws chat spaces messages create --params '{"parent": "spaces/SPACE_ID"}' --json '{"text": "Deploy complete."}'
Get a message
获取消息
gws chat spaces messages get --params '{"name": "spaces/SPACE_ID/messages/MSG_ID"}'
gws chat spaces messages get --params '{"name": "spaces/SPACE_ID/messages/MSG_ID"}'
List messages in a space
列出空间内的消息
gws chat spaces messages list --params '{"parent": "spaces/SPACE_ID", "pageSize": 25}'
gws chat spaces messages list --params '{"parent": "spaces/SPACE_ID", "pageSize": 25}'
Create a space
创建空间
gws chat spaces create --json '{"displayName": "Project Alpha", "spaceType": "SPACE"}'
undefinedgws chat spaces create --json '{"displayName": "Project Alpha", "spaceType": "SPACE"}'
undefinedGoogle Tasks
Google Tasks
bash
undefinedbash
undefinedList task lists
列出任务列表
gws tasks tasklists list
gws tasks tasklists list
Create a task list
创建任务列表
gws tasks tasklists insert --json '{"title": "Sprint 42"}'
gws tasks tasklists insert --json '{"title": "Sprint 42"}'
List tasks in a list
列出任务列表中的任务
gws tasks tasks list --params '{"tasklist": "TASKLIST_ID"}'
gws tasks tasks list --params '{"tasklist": "TASKLIST_ID"}'
Create a task
创建任务
gws tasks tasks insert --params '{"tasklist": "TASKLIST_ID"}' --json '{"title": "Review PR #123", "due": "2026-03-07T00:00:00Z"}'
gws tasks tasks insert --params '{"tasklist": "TASKLIST_ID"}' --json '{"title": "Review PR #123", "due": "2026-03-07T00:00:00Z"}'
Complete a task
标记任务为完成
gws tasks tasks update --params '{"tasklist": "TASKLIST_ID", "task": "TASK_ID"}' --json '{"status": "completed"}'
undefinedgws tasks tasks update --params '{"tasklist": "TASKLIST_ID", "task": "TASK_ID"}' --json '{"status": "completed"}'
undefinedGoogle Meet
Google Meet
bash
undefinedbash
undefinedCreate a meeting space
创建会议空间
gws meet spaces create --json '{}'
gws meet spaces create --json '{}'
Get meeting space info
获取会议空间信息
gws meet spaces get --params '{"name": "spaces/SPACE_ID"}'
undefinedgws meet spaces get --params '{"name": "spaces/SPACE_ID"}'
undefinedGoogle Forms
Google Forms
bash
undefinedbash
undefinedCreate a form
创建表单
gws forms forms create --json '{"info": {"title": "Feedback Survey"}}'
gws forms forms create --json '{"info": {"title": "Feedback Survey"}}'
Get form
获取表单
gws forms forms get --params '{"formId": "FORM_ID"}'
gws forms forms get --params '{"formId": "FORM_ID"}'
List responses
列出表单响应
gws forms forms responses list --params '{"formId": "FORM_ID"}'
undefinedgws forms forms responses list --params '{"formId": "FORM_ID"}'
undefinedGoogle Admin (Directory)
Google Admin(目录)
bash
undefinedbash
undefinedList users
列出用户
gws admin users list --params '{"domain": "example.com", "maxResults": 100}'
gws admin users list --params '{"domain": "example.com", "maxResults": 100}'
Get a user
获取用户信息
gws admin users get --params '{"userKey": "user@example.com"}'
gws admin users get --params '{"userKey": "user@example.com"}'
Create a user
创建用户
gws admin users insert --json '{
"primaryEmail": "newuser@example.com",
"name": {"givenName": "Jane", "familyName": "Doe"},
"password": "TempP@ssw0rd!"
}'
gws admin users insert --json '{
"primaryEmail": "newuser@example.com",
"name": {"givenName": "Jane", "familyName": "Doe"},
"password": "TempP@ssw0rd!"
}'
List groups
列出群组
gws admin groups list --params '{"domain": "example.com"}'
gws admin groups list --params '{"domain": "example.com"}'
Add member to group
添加成员至群组
gws admin members insert --params '{"groupKey": "group@example.com"}' --json '{"email": "user@example.com", "role": "MEMBER"}'
undefinedgws admin members insert --params '{"groupKey": "group@example.com"}' --json '{"email": "user@example.com", "role": "MEMBER"}'
undefinedGoogle Keep
Google Keep
bash
undefinedbash
undefinedList notes
列出笔记
gws keep notes list
gws keep notes list
Get a note
获取笔记
gws keep notes get --params '{"name": "notes/NOTE_ID"}'
undefinedgws keep notes get --params '{"name": "notes/NOTE_ID"}'
undefinedGoogle People (Contacts & Profiles)
Google People(联系人和个人资料)
bash
undefinedbash
undefinedList contacts
列出联系人
gws people people connections list --params '{"resourceName": "people/me", "personFields": "names,emailAddresses,phoneNumbers", "pageSize": 50}'
gws people people connections list --params '{"resourceName": "people/me", "personFields": "names,emailAddresses,phoneNumbers", "pageSize": 50}'
Get a specific contact
获取指定联系人
gws people people get --params '{"resourceName": "people/PERSON_ID", "personFields": "names,emailAddresses,organizations"}'
gws people people get --params '{"resourceName": "people/PERSON_ID", "personFields": "names,emailAddresses,organizations"}'
Search contacts
搜索联系人
gws people people searchContacts --params '{"query": "Alice", "readMask": "names,emailAddresses"}'
gws people people searchContacts --params '{"query": "Alice", "readMask": "names,emailAddresses"}'
Create a contact
创建联系人
gws people people createContact --json '{
"names": [{"givenName": "Jane", "familyName": "Smith"}],
"emailAddresses": [{"value": "jane@example.com"}],
"phoneNumbers": [{"value": "+1-555-0100"}]
}'
gws people people createContact --json '{
"names": [{"givenName": "Jane", "familyName": "Smith"}],
"emailAddresses": [{"value": "jane@example.com"}],
"phoneNumbers": [{"value": "+1-555-0100"}]
}'
List directory (domain contacts)
列出目录联系人(域内联系人)
gws people people listDirectoryPeople --params '{"readMask": "names,emailAddresses", "sources": ["DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE"], "pageSize": 100}'
undefinedgws people people listDirectoryPeople --params '{"readMask": "names,emailAddresses", "sources": ["DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE"], "pageSize": 100}'
undefinedGoogle Workspace Events
Google Workspace Events
bash
undefinedbash
undefinedCreate a subscription to watch for changes
创建订阅以监控变更
gws events subscriptions create --json '{
"targetResource": "//calendar.googleapis.com/calendars/primary",
"eventTypes": ["google.workspace.calendar.event.v1.created"],
"notificationEndpoint": {"pubsubTopic": "projects/PROJECT/topics/TOPIC"},
"payloadOptions": {"includeResource": true}
}'
gws events subscriptions create --json '{
"targetResource": "//calendar.googleapis.com/calendars/primary",
"eventTypes": ["google.workspace.calendar.event.v1.created"],
"notificationEndpoint": {"pubsubTopic": "projects/PROJECT/topics/TOPIC"},
"payloadOptions": {"includeResource": true}
}'
List subscriptions
列出订阅
gws events subscriptions list
gws events subscriptions list
Delete a subscription
删除订阅
gws events subscriptions delete --params '{"name": "subscriptions/SUB_ID"}'
undefinedgws events subscriptions delete --params '{"name": "subscriptions/SUB_ID"}'
undefinedGoogle Vault (eDiscovery)
Google Vault(电子取证)
bash
undefinedbash
undefinedList matters
列出事项
gws vault matters list
gws vault matters list
Create a matter
创建事项
gws vault matters create --json '{"name": "Investigation Q1", "description": "Q1 compliance audit"}'
gws vault matters create --json '{"name": "Investigation Q1", "description": "Q1 compliance audit"}'
Create a hold
创建保留规则
gws vault matters holds create --params '{"matterId": "MATTER_ID"}' --json '{
"name": "Email Hold",
"corpus": "MAIL",
"accounts": [{"accountId": "user@example.com"}]
}'
undefinedgws vault matters holds create --params '{"matterId": "MATTER_ID"}' --json '{
"name": "Email Hold",
"corpus": "MAIL",
"accounts": [{"accountId": "user@example.com"}]
}'
undefinedGoogle Classroom
Google Classroom
bash
undefinedbash
undefinedList courses
列出课程
gws classroom courses list
gws classroom courses list
Create a course
创建课程
gws classroom courses create --json '{"name": "CS101", "section": "Fall 2026", "ownerId": "me"}'
gws classroom courses create --json '{"name": "CS101", "section": "Fall 2026", "ownerId": "me"}'
List students in a course
列出课程中的学生
gws classroom courses students list --params '{"courseId": "COURSE_ID"}'
gws classroom courses students list --params '{"courseId": "COURSE_ID"}'
Create coursework
创建课程作业
gws classroom courses courseWork create --params '{"courseId": "COURSE_ID"}' --json '{
"title": "Assignment 1",
"workType": "ASSIGNMENT",
"dueDate": {"year": 2026, "month": 3, "day": 15}
}'
undefinedgws classroom courses courseWork create --params '{"courseId": "COURSE_ID"}' --json '{
"title": "Assignment 1",
"workType": "ASSIGNMENT",
"dueDate": {"year": 2026, "month": 3, "day": 15}
}'
undefinedAdmin Reports (Audit Logs)
Admin Reports(审计日志)
bash
undefinedbash
undefinedList admin activities
列出管理员活动
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "admin", "maxResults": 50}'
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "admin", "maxResults": 50}'
List login activities
列出登录活动
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "login", "maxResults": 50}'
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "login", "maxResults": 50}'
List Drive audit logs
列出Drive审计日志
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "drive", "maxResults": 50}'
undefinedgws admin-reports activities list --params '{"userKey": "all", "applicationName": "drive", "maxResults": 50}'
undefinedAlert Center (Security Alerts)
Alert Center(安全警报)
bash
undefinedbash
undefinedList alerts
列出警报
gws alertcenter alerts list
gws alertcenter alerts list
Get alert details
获取警报详情
gws alertcenter alerts get --params '{"alertId": "ALERT_ID"}'
undefinedgws alertcenter alerts get --params '{"alertId": "ALERT_ID"}'
undefinedCloud Identity
Cloud Identity
bash
undefinedbash
undefinedList groups
列出群组
gws cloudidentity groups list --params '{"parent": "customers/CUSTOMER_ID"}'
gws cloudidentity groups list --params '{"parent": "customers/CUSTOMER_ID"}'
Search groups
搜索群组
gws cloudidentity groups search --params '{"query": "parent == "customers/CUSTOMER_ID""}'
gws cloudidentity groups search --params '{"query": "parent == \"customers/CUSTOMER_ID\""}'
List memberships
列出群组成员
gws cloudidentity groups memberships list --params '{"parent": "groups/GROUP_ID"}'
undefinedgws cloudidentity groups memberships list --params '{"parent": "groups/GROUP_ID"}'
undefinedGroups Settings
Groups Settings
bash
undefinedbash
undefinedGet group settings
获取群组设置
gws groupssettings groups get --params '{"groupUniqueId": "group@example.com"}'
gws groupssettings groups get --params '{"groupUniqueId": "group@example.com"}'
Update group settings
更新群组设置
gws groupssettings groups update --params '{"groupUniqueId": "group@example.com"}' --json '{
"whoCanPostMessage": "ALL_MEMBERS_CAN_POST",
"messageModerationLevel": "MODERATE_NONE"
}'
undefinedgws groupssettings groups update --params '{"groupUniqueId": "group@example.com"}' --json '{
"whoCanPostMessage": "ALL_MEMBERS_CAN_POST",
"messageModerationLevel": "MODERATE_NONE"
}'
undefinedLicensing
Licensing
bash
undefinedbash
undefinedList license assignments
列出许可证分配情况
gws licensing licenseAssignments listForProduct --params '{"productId": "Google-Apps", "customerId": "CUSTOMER_ID"}'
gws licensing licenseAssignments listForProduct --params '{"productId": "Google-Apps", "customerId": "CUSTOMER_ID"}'
Assign a license
分配许可证
gws licensing licenseAssignments insert --params '{"productId": "Google-Apps", "skuId": "SKU_ID"}' --json '{"userId": "user@example.com"}'
undefinedgws licensing licenseAssignments insert --params '{"productId": "Google-Apps", "skuId": "SKU_ID"}' --json '{"userId": "user@example.com"}'
undefinedReseller
Reseller
bash
undefinedbash
undefinedList subscriptions
列出订阅
gws reseller subscriptions list --params '{"customerId": "CUSTOMER_ID"}'
gws reseller subscriptions list --params '{"customerId": "CUSTOMER_ID"}'
Get a subscription
获取订阅
gws reseller subscriptions get --params '{"customerId": "CUSTOMER_ID", "subscriptionId": "SUB_ID"}'
undefinedgws reseller subscriptions get --params '{"customerId": "CUSTOMER_ID", "subscriptionId": "SUB_ID"}'
undefinedApps Script
Apps Script
bash
undefinedbash
undefinedList projects
列出项目
gws apps-script projects list
gws apps-script projects list
Get project content
获取项目内容
gws apps-script projects getContent --params '{"scriptId": "SCRIPT_ID"}'
gws apps-script projects getContent --params '{"scriptId": "SCRIPT_ID"}'
Deploy a project
部署项目
gws apps-script projects deployments create --params '{"scriptId": "SCRIPT_ID"}' --json '{"versionNumber": 1}'
gws apps-script projects deployments create --params '{"scriptId": "SCRIPT_ID"}' --json '{"versionNumber": 1}'
Run a function
运行函数
gws apps-script scripts run --params '{"scriptId": "SCRIPT_ID"}' --json '{"function": "myFunction", "parameters": []}'
undefinedgws apps-script scripts run --params '{"scriptId": "SCRIPT_ID"}' --json '{"function": "myFunction", "parameters": []}'
undefinedWorkflow Helpers (Shortcut Commands)
工作流助手(快捷命令)
gwsbash
undefinedgwsbash
undefined--- Drive ---
--- Drive ---
Upload a file to Drive with automatic metadata
上传文件至Drive并自动添加元数据
gws drive-upload ./report.pdf
gws drive-upload ./report.pdf
--- Sheets ---
--- Sheets ---
Append a row to a sheet
向表格追加行
gws sheets-append --spreadsheet-id ID --range 'Sheet1!A1' --values '[["Name", "Score"]]'
gws sheets-append --spreadsheet-id ID --range 'Sheet1!A1' --values '[["Name", "Score"]]'
Read sheet values
读取表格内容
gws sheets-read --spreadsheet-id ID --range 'Sheet1!A1:C10'
gws sheets-read --spreadsheet-id ID --range 'Sheet1!A1:C10'
--- Gmail ---
--- Gmail ---
Send an email (simplified)
简化版发送邮件
gws gmail-send --to user@example.com --subject "Hello" --body "Hi there"
gws gmail-send --to user@example.com --subject "Hello" --body "Hi there"
Triage inbox — show unread summary (sender, subject, date)
收件箱分类——显示未读邮件摘要(发件人、主题、日期)
gws gmail-triage
gws gmail-triage
Watch for new emails and stream them as NDJSON
监控新邮件并以NDJSON格式输出
gws gmail-watch
gws gmail-watch
--- Calendar ---
--- Calendar ---
Show upcoming calendar agenda across all calendars
显示所有日历中即将到来的日程
gws calendar-agenda
gws calendar-agenda
Insert a calendar event quickly
快速创建日历日程
gws calendar-insert --summary "Lunch" --start "2026-03-06T12:00:00" --end "2026-03-06T13:00:00"
gws calendar-insert --summary "Lunch" --start "2026-03-06T12:00:00" --end "2026-03-06T13:00:00"
--- Docs ---
--- Docs ---
Append text to a Google Doc
向Google Doc追加文本
gws docs-write --document-id DOC_ID --text "New paragraph here"
gws docs-write --document-id DOC_ID --text "New paragraph here"
--- Chat ---
--- Chat ---
Send a Chat message to a space
向Chat空间发送消息
gws chat-send --space "spaces/SPACE_ID" --text "Hello team!"
gws chat-send --space "spaces/SPACE_ID" --text "Hello team!"
--- Apps Script ---
--- Apps Script ---
Upload local files to an Apps Script project
将本地文件上传至Apps Script项目
gws apps-script-push --script-id SCRIPT_ID --source ./src
gws apps-script-push --script-id SCRIPT_ID --source ./src
--- Workspace Events ---
--- Workspace Events ---
Subscribe to Workspace events and stream them as NDJSON
订阅Workspace事件并以NDJSON格式输出
gws events-subscribe --target "//calendar.googleapis.com/calendars/primary" --event-types "google.workspace.calendar.event.v1.created"
gws events-subscribe --target "//calendar.googleapis.com/calendars/primary" --event-types "google.workspace.calendar.event.v1.created"
Renew/reactivate Workspace Events subscriptions
续订/重新激活Workspace Events订阅
gws events-renew --subscription-id SUB_ID
gws events-renew --subscription-id SUB_ID
--- Model Armor ---
--- Model Armor ---
Sanitize a user prompt through a Model Armor template
通过Model Armor模板清理用户提示
gws modelarmor-sanitize-prompt --template "projects/P/locations/L/templates/T" --text "user input here"
gws modelarmor-sanitize-prompt --template "projects/P/locations/L/templates/T" --text "user input here"
Sanitize a model response through a Model Armor template
通过Model Armor模板清理模型响应
gws modelarmor-sanitize-response --template "projects/P/locations/L/templates/T" --text "model output here"
gws modelarmor-sanitize-response --template "projects/P/locations/L/templates/T" --text "model output here"
Create a new Model Armor template
创建新的Model Armor模板
gws modelarmor-create-template --project PROJECT --location LOCATION --template-id my-template
gws modelarmor-create-template --project PROJECT --location LOCATION --template-id my-template
--- Cross-service Workflows ---
--- 跨服务工作流 ---
Today's standup report (meetings + open tasks)
今日站会报告(会议+未完成任务)
gws workflow-standup-report
gws workflow-standup-report
Meeting prep (agenda, attendees, linked docs)
会议准备(议程、参会人、关联文档)
gws workflow-meeting-prep
gws workflow-meeting-prep
Convert email to task
将邮件转换为任务
gws workflow-email-to-task --message-id MSG_ID
gws workflow-email-to-task --message-id MSG_ID
Weekly digest (meetings + unread count)
每周摘要(会议+未读邮件数)
gws workflow-weekly-digest
gws workflow-weekly-digest
Announce a Drive file in a Chat space
在Chat空间中分享Drive文件
gws workflow-file-announce --file-id FILE_ID --space "spaces/SPACE_ID"
undefinedgws workflow-file-announce --file-id FILE_ID --space "spaces/SPACE_ID"
undefinedInstalling gws Skills Into Your Agent Project
将gws技能安装至你的Agent项目
The gws repo ships 100+ SKILL.md files you can install directly into your agent's skills directory:
bash
undefinedgws仓库提供了100+ SKILL.md文件,可直接安装至Agent的技能目录:
bash
undefinedInstall ALL gws skills at once
一次性安装所有gws技能
npx skills add https://github.com/googleworkspace/cli
npx skills add https://github.com/googleworkspace/cli
Or pick only what you need
或仅安装所需技能
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-calendar
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-sheets
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-docs
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-chat
<details>
<summary>OpenClaw setup</summary>
```bashnpx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-calendar
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-sheets
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-docs
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-chat
<details>
<summary>OpenClaw配置</summary>
```bashSymlink all skills (stays in sync with repo)
符号链接所有技能(与仓库保持同步)
ln -s $(pwd)/skills/gws-* ~/.openclaw/skills/
ln -s $(pwd)/skills/gws-* ~/.openclaw/skills/
Or copy specific skills
或复制指定技能
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/
The `gws-shared` skill includes an `install` block so OpenClaw auto-installs the CLI via `npm` if `gws` isn't on PATH.
</details>
This places SKILL.md files into your project's `.github/skills/` (Copilot), `.claude/skills/` (Claude Code), or equivalent directory, giving your agent deep per-service knowledge.cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/
`gws-shared`技能包含`install`块,因此如果`gws`未在PATH中,OpenClaw会自动通过`npm`安装CLI。
</details>
此操作会将SKILL.md文件添加至项目的`.github/skills/`(Copilot)、`.claude/skills/`(Claude Code)或对应目录,让Agent具备各服务的深度操作能力。Personas (Role-Based Skill Bundles)
角色模板(基于角色的技能包)
The gws repo includes 10 pre-built persona bundles that combine multiple services for common roles:
| Persona | Description | Services Used |
|---|---|---|
| Manage an executive's schedule, inbox, and communications | Calendar, Gmail, Chat, Tasks |
| Coordinate projects — track tasks, schedule meetings, share docs | Tasks, Calendar, Drive, Chat |
| Handle HR workflows — onboarding, announcements, employee comms | Admin, Gmail, Calendar, Docs |
| Manage sales workflows — track deals, schedule calls, client comms | Sheets, Gmail, Calendar, Chat |
| Administer IT — manage users, monitor security, configure Workspace | Admin, Alert Center, Cloud Identity |
| Create, organize, and distribute content across Workspace | Docs, Slides, Drive, Gmail |
| Manage customer support — track tickets, respond, escalate issues | Gmail, Sheets, Chat, Tasks |
| Plan and manage events — scheduling, invitations, and logistics | Calendar, Gmail, Drive, Chat |
| Lead a team — run standups, coordinate tasks, communicate | Calendar, Tasks, Chat, Gmail |
| Organize research — manage references, notes, collaboration | Drive, Docs, Keep, Sheets |
Install a persona:
bash
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-exec-assistant
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-it-admingws仓库包含10个预构建的角色模板,整合了多个服务以适配常见角色:
| 角色模板 | 描述 | 使用的服务 |
|---|---|---|
| 管理高管的日程、收件箱和沟通事务 | Calendar、Gmail、Chat、Tasks |
| 协调项目——跟踪任务、安排会议、分享文档 | Tasks、Calendar、Drive、Chat |
| 处理HR工作流——入职、公告、员工沟通 | Admin、Gmail、Calendar、Docs |
| 管理销售工作流——跟踪客户、安排通话、客户沟通 | Sheets、Gmail、Calendar、Chat |
| 管理IT事务——用户管理、安全监控、Workspace配置 | Admin、Alert Center、Cloud Identity |
| 创建、整理和分发Workspace内容 | Docs、Slides、Drive、Gmail |
| 管理客户支持——跟踪工单、响应、升级问题 | Gmail、Sheets、Chat、Tasks |
| 策划和管理活动——日程安排、邀请、后勤 | Calendar、Gmail、Drive、Chat |
| 领导团队——主持站会、协调任务、沟通 | Calendar、Tasks、Chat、Gmail |
| 整理研究资料——管理参考资料、笔记、协作 | Drive、Docs、Keep、Sheets |
安装角色模板:
bash
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-exec-assistant
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-it-adminRecipes (Multi-Step Task Sequences)
工作流模板(多步骤任务序列)
The gws repo ships 50 curated recipes — multi-step task sequences with real commands. Key recipes:
| Recipe | What It Does |
|---|---|
| Find and review Drive files shared outside the org |
| Apply Gmail labels to matching messages and archive them |
| Read from Sheets, send personalized Gmail to each row |
| Read a Google Doc and use it as Gmail body |
| Create folder structure and move files into place |
| Share a Drive folder with collaborators |
| Share a file and email the link |
| Copy a Docs template, fill content, share |
| Set up Sheets for expense tracking |
| Create recurring focus time on Calendar |
| Move event and notify attendees |
| Find matching Gmail messages and export |
| Auto-label/star incoming messages |
| Delete event and send cancellation email |
| Query free/busy for multiple users |
| Download all files from a Drive folder |
| Identify large Drive files consuming storage |
| Create Shared Drive and add members |
| Transfer Drive file ownership between users |
| Create Doc, schedule Calendar review, notify via Chat |
| Save Gmail attachments to Drive |
| Announce via Gmail and Chat simultaneously |
| Create Form and share via Gmail |
| Export contacts directory to Sheets |
| Read Sheets data and create Calendar events |
| Read Sheets data and create Docs report |
| Archive Gmail message body into a Doc |
| Find matching emails and send standard reply |
| Rename Drive files to consistent naming |
| Enable Gmail out-of-office auto-reply |
| Review Workspace security alerts |
| Push local files to Apps Script project |
| Create Meet space and share join link |
| Create Slides presentation with initial slides |
| Create Classroom course and invite students |
Install recipes:
bash
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-send-personalized-emails
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-audit-external-sharinggws仓库提供了50个精心设计的工作流模板——包含实际命令的多步骤任务序列。核心模板:
| 模板 | 功能 |
|---|---|
| 查找并审核Drive中分享至外部的文件 |
| 为匹配的邮件添加Gmail标签并归档 |
| 读取Sheets数据,向每行记录发送个性化Gmail邮件 |
| 读取Google Doc内容并作为Gmail邮件正文 |
| 创建文件夹结构并移动文件至对应位置 |
| 与团队成员分享Drive文件夹 |
| 分享文件并通过邮件发送链接 |
| 复制Docs模板、填充内容并分享 |
| 设置Sheets用于费用跟踪 |
| 在Calendar中创建重复的专注时段 |
| 调整会议时间并通知参会人 |
| 查找匹配的Gmail邮件并导出 |
| 自动为收到的邮件添加标签/星标 |
| 删除日程并发送取消通知邮件 |
| 查询多个用户的空闲/忙碌状态 |
| 下载Drive文件夹中的所有文件 |
| 识别占用存储空间的大文件 |
| 创建共享云端硬盘并添加成员 |
| 在用户间转移Drive文件所有权 |
| 创建Doc、安排Calendar回顾会议、通过Chat通知 |
| 将Gmail附件保存至Drive |
| 同时通过Gmail和Chat发送团队公告 |
| 创建Form并通过Gmail分享 |
| 将联系人目录导出至Sheets |
| 读取Sheets数据并创建Calendar日程 |
| 读取Sheets数据并创建Docs报告 |
| 将Gmail邮件正文归档至Doc |
| 查找匹配的邮件并发送标准回复 |
| 将Drive文件重命名为统一格式 |
| 启用Gmail外出自动回复 |
| 审核Workspace安全警报 |
| 将本地文件推送至Apps Script项目 |
| 创建Meet空间并分享加入链接 |
| 创建Slides演示文稿并添加初始幻灯片 |
| 创建Classroom课程并邀请学生 |
安装工作流模板:
bash
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-send-personalized-emails
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-audit-external-sharingMCP Server Integration
MCP服务器集成
gws mcpbash
undefinedgws mcpbash
undefinedStart MCP server for specific services
为指定服务启动MCP服务器
gws mcp -s drive # Drive only
gws mcp -s drive,gmail,calendar # multiple services
gws mcp -s all # all services (many tools!)
gws mcp -s drive # 仅Drive服务
gws mcp -s drive,gmail,calendar # 多个服务
gws mcp -s all # 所有服务(工具数量较多!)
Include workflow and helper tools
同时暴露工作流和辅助工具
gws mcp -s drive,gmail -w -e
gws mcp -s drive,gmail -w -e
Compact tool mode — reduces context window usage for LLMs
精简工具模式——减少LLM的上下文窗口占用
gws mcp -s drive,gmail --compact
undefinedgws mcp -s drive,gmail --compact
undefinedMCP Client Configuration
MCP客户端配置
VS Code / Copilot ( or ):
settings.json.vscode/mcp.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
}
}
}Claude Desktop ():
claude_desktop_config.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
}
}
}Cursor ():
.cursor/mcp.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}Gemini CLI Extension:
bash
gws auth setup
gemini extensions install https://github.com/googleworkspace/cliInstalling the Gemini extension gives your Gemini CLI agent direct access to all commands and skills. The extension automatically inherits your terminal credentials.
gwsTip: Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools). Useflag to reduce context window usage.--compact
VS Code / Copilot(或):
settings.json.vscode/mcp.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
}
}
}Claude Desktop():
claude_desktop_config.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
}
}
}Cursor():
.cursor/mcp.jsonjson
{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}Gemini CLI扩展:
bash
gws auth setup
gemini extensions install https://github.com/googleworkspace/cli安装Gemini扩展后,Gemini CLI Agent可直接访问所有命令和技能。扩展会自动继承终端中的凭证。
gws提示: 每个服务会添加约10–80个工具。请仅保留实际需要的服务,以避免超出客户端的工具数量限制(通常为50–100个工具)。使用参数可减少上下文窗口占用。--compact
MCP Flags
MCP参数
| Flag | Description |
|---|---|
| Comma-separated services to expose, or |
| Also expose workflow tools |
| Also expose helper tools |
| Compact tool mode — reduces tool descriptions to save context window |
| 参数 | 描述 |
|---|---|
| 逗号分隔的要暴露的服务列表,或 |
| 同时暴露工作流工具 |
| 同时暴露辅助工具 |
| 精简工具模式——简化工具描述以节省上下文窗口 |
Advanced Usage
高级用法
Dry Run (preview requests without executing)
试运行(预览请求但不执行)
bash
gws drive files list --params '{"pageSize": 5}' --dry-runbash
gws drive files list --params '{"pageSize": 5}' --dry-runPagination
分页
bash
undefinedbash
undefinedAuto-paginate everything as NDJSON
自动分页并以NDJSON格式输出所有内容
gws drive files list --params '{"pageSize": 100}' --page-all
gws drive files list --params '{"pageSize": 100}' --page-all
Limit pages
限制获取页数
gws drive files list --params '{"pageSize": 100}' --page-all --page-limit 5
gws drive files list --params '{"pageSize": 100}' --page-all --page-limit 5
Delay between pages (rate limiting)
分页请求间隔(限流)
gws drive files list --params '{"pageSize": 100}' --page-all --page-delay 200
undefinedgws drive files list --params '{"pageSize": 100}' --page-all --page-delay 200
undefinedPiping & Processing Output
管道与输出处理
All output is structured JSON. Pipe to for processing:
jqbash
undefined所有输出均为结构化JSON。可通过进行处理:
jqbash
undefinedGet just file names
仅获取文件名
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'
Get unread email subjects
获取未读邮件ID
gws gmail users messages list --params '{"userId": "me", "q": "is:unread", "maxResults": 5}' | jq '.messages[].id'
gws gmail users messages list --params '{"userId": "me", "q": "is:unread", "maxResults": 5}' | jq '.messages[].id'
Count events this week
统计本周日程数量
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-02T00:00:00Z", "timeMax": "2026-03-08T00:00:00Z", "singleEvents": true}' | jq '.items | length'
undefinedgws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-02T00:00:00Z", "timeMax": "2026-03-08T00:00:00Z", "singleEvents": true}' | jq '.items | length'
undefinedMultipart Uploads
多部分上传
bash
gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdfbash
gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdfModel Armor (Response Sanitization)
Model Armor(响应内容清理)
Scan API responses for prompt injection before they reach your agent:
bash
gws gmail users messages get --params '{"userId": "me", "id": "MSG_ID"}' \
--sanitize "projects/P/locations/L/templates/T"| Environment Variable | Description |
|---|---|
| Default Model Armor template |
| |
在API响应传递给Agent前,扫描是否存在提示注入:
bash
gws gmail users messages get --params '{"userId": "me", "id": "MSG_ID"}' \\
--sanitize "projects/P/locations/L/templates/T"| 环境变量 | 描述 |
|---|---|
| 默认Model Armor模板 |
| |
Agent Decision Guide
Agent决策指南
Use this table to decide which command to run based on what the user is asking:
gws| User Intent | Service | Example Command |
|---|---|---|
| List, search, upload, download, share files | | |
| Create folders, manage permissions | | |
| Read, send, search, label emails | | |
| Create drafts, manage filters | | |
| View, create, update, delete calendar events | | |
| Check availability / free-busy | | |
| Read, write, append spreadsheet data | | |
| Create spreadsheets, format cells | | |
| Create, read, edit documents | | |
| Create, edit presentations | | |
| Send messages, manage chat spaces | | |
| Manage tasks and to-do lists | | |
| Create meeting links | | |
| Create forms, read responses | | |
| Manage contacts and profiles | | |
| Manage users, groups, devices | | |
| Manage notes | | |
| Run/deploy Apps Script projects | | |
| Audit logs and usage reports | | |
| Manage security alerts | | |
| Manage identity and groups | | |
| Subscribe to Workspace events | | |
| Manage Google Vault (eDiscovery) | | |
| Manage Workspace licenses | | |
| Manage Google Classroom | | |
| Configure Google Groups settings | | |
| Manage Workspace subscriptions | | |
| Sanitize content for safety | | |
根据用户需求选择对应的命令:
gws| 用户需求 | 服务 | 示例命令 |
|---|---|---|
| 列出、搜索、上传、下载、分享文件 | | |
| 创建文件夹、管理权限 | | |
| 读取、发送、搜索、标记邮件 | | |
| 创建草稿、管理过滤器 | | |
| 查看、创建、更新、删除日历日程 | | |
| 查看可用性/空闲状态 | | |
| 读取、写入、追加电子表格数据 | | |
| 创建电子表格、格式化单元格 | | |
| 创建、读取、编辑文档 | | |
| 创建、编辑演示文稿 | | |
| 发送消息、管理Chat空间 | | |
| 管理任务和待办事项 | | |
| 创建会议链接 | | |
| 创建表单、读取响应 | | |
| 管理联系人和个人资料 | | |
| 管理用户、群组、设备 | | |
| 管理笔记 | | |
| 运行/部署Apps Script项目 | | |
| 审计日志和使用报告 | | |
| 管理安全警报 | | |
| 管理身份和群组 | | |
| 订阅Workspace事件 | | |
| 管理Google Vault(电子取证) | | |
| 管理Workspace许可证 | | |
| 管理Google Classroom | | |
| 配置Google Groups设置 | | |
| 管理Workspace订阅 | | |
| 清理内容以确保安全 | | |
Environment Variables Reference
环境变量参考
| Variable | Description |
|---|---|
| Pre-obtained OAuth access token |
| Path to credentials JSON (service account or exported) |
| Default account email |
| User to impersonate (domain-wide delegation) |
| Default Model Armor template |
| |
| 变量 | 描述 |
|---|---|
| 预先获取的OAuth访问令牌 |
| 凭证JSON文件路径(服务账号或导出的凭证) |
| 默认账号邮箱 |
| 要模拟的用户(域范围委派) |
| 默认Model Armor模板 |
| |
Troubleshooting
故障排除
| Error | Fix |
|---|---|
| "Access blocked" or 403 during login | Add yourself as a test user in OAuth consent screen |
| "Google hasn't verified this app" | Click Advanced → Continue (safe for personal use) |
| Too many scopes error | Use |
| Install gcloud or set up OAuth manually in Cloud Console |
| Re-create OAuth client as Desktop app type |
| See detailed fix below |
| Stale credentials | Run |
| 错误 | 解决方法 |
|---|---|
| 登录时出现"Access blocked"或403错误 | 在OAuth consent screen中添加自己为测试用户 |
| 出现"Google hasn't verified this app"提示 | 点击高级 → 继续(个人使用安全) |
| 权限范围过多错误 | 使用 |
未找到 | 安装gcloud或在Cloud Console中手动配置OAuth |
| 重新创建类型为Desktop app的OAuth客户端 |
| 查看下方详细解决方法 |
| 凭证过期 | 运行 |
API not enabled — accessNotConfigured
accessNotConfiguredAPI未启用——accessNotConfigured
accessNotConfiguredIf a required Google API is not enabled for your GCP project, you will see a 403 error:
json
{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}gws💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.Steps to fix:
- Click the link (or copy it from the JSON
enable_urlfield).enable_url - In the GCP Console, click Enable.
- Wait ~10 seconds, then retry your command.
gws
Tip: You can also runwhich walks you through enabling all required APIs for your project automatically.gws auth setup
如果GCP项目未启用所需的Google API,会出现403错误:
json
{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}gws💡 API未在你的GCP项目中启用。
点击以下链接启用:https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
启用后等待几秒,然后重试命令。解决步骤:
- 点击链接(或从JSON的
enable_url字段复制)。enable_url - 在GCP Console中,点击启用。
- 等待约10秒,然后重试命令。
gws
提示: 也可运行,它会自动引导完成项目所需API的启用。gws auth setup
Architecture
架构
gws- Read to identify the service (e.g.
argv[1])drive - Fetch the service's Discovery Document (cached 24 hours)
- Build a tree from the document's resources and methods
clap::Command - Re-parse the remaining arguments
- Authenticate, build the HTTP request, execute
All output — success, errors, download metadata — is structured JSON. This means every response is directly parseable by agents without any text extraction.
gws- 读取以识别服务(如
argv[1])drive - 获取服务的Discovery Document(缓存24小时)
- 从文档的资源和方法构建树
clap::Command - 重新解析剩余参数
- 认证、构建HTTP请求、执行
所有输出——成功结果、错误、下载元数据——均为结构化JSON。这意味着所有响应可直接被Agent解析,无需进行文本提取。
Resources
资源
- GitHub Repo: https://github.com/googleworkspace/cli
- npm Package: https://www.npmjs.com/package/@googleworkspace/cli
- Skills Index (100+ skills): https://github.com/googleworkspace/cli/blob/main/docs/skills.md
- Google Discovery API: https://developers.google.com/discovery
- Google Workspace APIs: https://developers.google.com/workspace
- Releases & Binaries: https://github.com/googleworkspace/cli/releases
- GitHub仓库:https://github.com/googleworkspace/cli
- npm包:https://www.npmjs.com/package/@googleworkspace/cli
- 技能索引(100+技能):https://github.com/googleworkspace/cli/blob/main/docs/skills.md
- Google Discovery API:https://developers.google.com/discovery
- Google Workspace APIs:https://developers.google.com/workspace
- 版本与二进制文件:https://github.com/googleworkspace/cli/releases
License
许可证
Apache-2.0
Apache-2.0",