简介
终端直连 Google Workspace,Drive/Docs/Sheets 全操作,支持 Shared Drive,OAuth 认证,JSON/表格双输出,适合自动化文档工作流。
原始描述
Interact with Google Workspace (Drive, Docs, Sheets) via the `gw` CLI. Use when an agent needs to browse, read, create, search, or manage files in Google Dri...
通过你的 Agent 添加
安装目录:gworkspace-cli/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
gworkspace-cli(gw)是一款面向命令行和 AI Agent 的 Google Workspace 集成工具,将 Drive 文件管理、Docs 文档读写、Sheets 数据操作封装为可脚本化的 CLI 命令。
Drive 管理:支持浏览 My Drive 和 Shared Drive、按路径/类型/ID 检索、创建文件夹、上传下载、全局搜索。--drive 标志可无缝切换个人与团队空间。
Docs 操作:读取为纯文本或 Markdown、创建空白文档、按 ID/URL 追加内容,适合报告生成和模板填充。
Sheets 处理:全表或指定范围读取(JSON 输出)、单格/批量写入、追加数据、列出工作表标签。支持从 CSV 文件直接导入。
输出模式:默认 JSON(管道友好)、--pretty 表格(人工查看)、--quiet ID 列表(命令链)。
显著优点
- 终端原生体验:无需浏览器交互即可完成多数操作,契合自动化脚本和 CI/CD 场景。
- 双轨认证:内置默认凭证降低配置门槛,同时支持自定义 OAuth 客户端(
GOOGLE_CLIENT_ID 等)。
- Shared Drive 完整支持:区别于多数个人向工具,
--drive 标志实现对团队共享空间的完整 CRUD。
- 灵活的 I/O 契约:标准输出/错误分离、退出码规范,便于与
jq、xargs、make 等工具组合。
- URL/ID 双兼容:粘贴完整 Google URL 或仅文件 ID 均可识别,减少手动提取的摩擦。
潜在缺点与局限性
- 生态依赖:基于 Node.js/npm,需维护 npm 全局安装环境,容器化场景需额外处理。
- 权限粒度:依赖 Google OAuth 范围,无法突破 Workspace 管理员设置的共享/下载限制。
- 离线限制:纯云端操作,无本地缓存或离线编辑能力,网络中断即不可用。
- 企业合规:内置默认凭证的客户端 ID 归属 11x.agency,敏感行业需审计第三方 OAuth 应用信任度。
- 功能边界:不支持 Sheets 公式计算、Docs 格式保留(仅导出文本/Markdown)、Drive 权限管理(ACL 变更)。
适合人群
- 开发者和 DevOps 工程师构建文档自动化流水线
- 数据分析师定期抽取 Sheets 数据至本地处理
- AI Agent/LLM 需要结构化访问 Google Workspace 的场景
- 远程团队需要脚本化批量操作 Shared Drive 内容
常规风险
- 凭证泄露:
~/.11x/gworkspace/token.json 存储 OAuth token,文件权限需严格限制(建议 600)。
- 意外覆盖:
sheet write 直接覆盖目标范围,无版本历史提示,批量操作前建议导出备份。
- 作用域混淆:
--folder 与 --drive 同时使用时的路径解析需仔细核对,避免文件创建到错误位置。
- Token 过期:长期无人值守脚本需处理
Session expired 错误并触发重新认证流程。
GOOGLE_CLIENT_ID 等)。--drive 标志实现对团队共享空间的完整 CRUD。jq、xargs、make 等工具组合。- 生态依赖:基于 Node.js/npm,需维护 npm 全局安装环境,容器化场景需额外处理。
- 权限粒度:依赖 Google OAuth 范围,无法突破 Workspace 管理员设置的共享/下载限制。
- 离线限制:纯云端操作,无本地缓存或离线编辑能力,网络中断即不可用。
- 企业合规:内置默认凭证的客户端 ID 归属 11x.agency,敏感行业需审计第三方 OAuth 应用信任度。
- 功能边界:不支持 Sheets 公式计算、Docs 格式保留(仅导出文本/Markdown)、Drive 权限管理(ACL 变更)。
适合人群
- 开发者和 DevOps 工程师构建文档自动化流水线
- 数据分析师定期抽取 Sheets 数据至本地处理
- AI Agent/LLM 需要结构化访问 Google Workspace 的场景
- 远程团队需要脚本化批量操作 Shared Drive 内容
常规风险
- 凭证泄露:
~/.11x/gworkspace/token.json 存储 OAuth token,文件权限需严格限制(建议 600)。
- 意外覆盖:
sheet write 直接覆盖目标范围,无版本历史提示,批量操作前建议导出备份。
- 作用域混淆:
--folder 与 --drive 同时使用时的路径解析需仔细核对,避免文件创建到错误位置。
- Token 过期:长期无人值守脚本需处理
Session expired 错误并触发重新认证流程。
- 凭证泄露:
~/.11x/gworkspace/token.json存储 OAuth token,文件权限需严格限制(建议600)。 - 意外覆盖:
sheet write直接覆盖目标范围,无版本历史提示,批量操作前建议导出备份。 - 作用域混淆:
--folder与--drive同时使用时的路径解析需仔细核对,避免文件创建到错误位置。 - Token 过期:长期无人值守脚本需处理
Session expired错误并触发重新认证流程。
技能正文
name: gworkspace-cli
description: >
Interact with Google Workspace (Drive, Docs, Sheets) via the gw CLI.
Use when an agent needs to browse, read, create, search, or manage files
in Google Drive, read or write Google Docs, or read/write Google Sheets —
all from the terminal. Works with both My Drive and Shared Drives.
required_binaries:
- gw required_env:
- name: GOOGLE_CLIENT_ID description: Google OAuth client ID (optional — embedded credentials used by default) required: false
- name: GOOGLE_CLIENT_SECRET description: Google OAuth client secret (optional — embedded credentials used by default) required: false
- name: GW_CLIENT_ID description: Alias for GOOGLE_CLIENT_ID required: false
- name: GW_CLIENT_SECRET description: Alias for GOOGLE_CLIENT_SECRET required: false config_paths:
- ~/.11x/gworkspace/token.json
- ~/.11x/gworkspace/config.json install: npm i -g @11x.agency/gworkspace source: https://github.com/robinfaraj/gworkspace-cli
gworkspace-cli
Manage Google Drive, Docs, and Sheets from the terminal with gw.
Do This First
- Ensure
gw is installed: npm i -g @11x.agency/gworkspace
- Ensure authenticated: run
gw auth --status. If not authenticated, run gw auth.
- If targeting a Shared Drive, get the drive ID first:
gw drive shared
Authentication
gw auth # Opens browser for Google sign-in
gw auth --status # Check current auth (email, scopes, expiry)
gw logout # Remove stored credentials
gw is installed: npm i -g @11x.agency/gworkspacegw auth --status. If not authenticated, run gw auth.gw drive sharedgw auth # Opens browser for Google sign-in
gw auth --status # Check current auth (email, scopes, expiry)
gw logout # Remove stored credentials
Token stored at ~/.11x/gworkspace/token.json. OAuth credentials via env vars or .env file:
GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRETGW_CLIENT_ID/GW_CLIENT_SECRET(aliases)
Commands
Drive
# List files
gw drive ls # Root of My Drive
gw drive ls /Projects # By path
gw drive ls --folder <id> # By folder ID
gw drive ls --type doc # Filter: doc, sheet, folder, all
gw drive ls --limit 50 # Pagination
# Create folder
gw drive mkdir "Folder Name"
gw drive mkdir "Subfolder" --folder <parent-id>
# Search
gw drive search "quarterly report"
gw drive search "budget" --type sheet
# Upload
gw drive upload ./file.pdf
gw drive upload ./data.csv --folder <id> --name "Q4 Data"
# List Shared Drives
gw drive shared
Shared Drives
Use the global --drive <id> flag before any subcommand:
gw --drive <shared-drive-id> drive ls
gw --drive <shared-drive-id> drive ls /Projects
gw --drive <shared-drive-id> drive mkdir "New Folder"
gw --drive <shared-drive-id> drive search "report"
gw --drive <shared-drive-id> drive upload ./file.pdf
To create docs/sheets in a Shared Drive, use --folder with a Shared Drive folder ID:
gw doc create "Title" --folder <shared-drive-folder-id>
gw sheet create "Title" --folder <shared-drive-folder-id>
Docs
gw doc read <id|url> # Plain text output
gw doc read <id|url> --markdown # Markdown output
gw doc create "Title" # Create empty doc, returns ID + URL
gw doc create "Title" --folder <id> # Create in specific folder
gw doc append <id|url> "text" # Append text to end of doc
gw doc append <id|url> --file ./notes.txt # Append from file
Sheets
gw sheet read <id|url> # Read entire first sheet (JSON rows)
gw sheet read <id|url> "Sheet1!A1:C10" # Read specific range
gw sheet write <id|url> "A1:B2" '[["Name","Score"],["Alice","95"]]'
gw sheet write <id|url> "A1" --file ./data.csv
gw sheet append <id|url> '[["Bob","88"]]'
gw sheet append <id|url> --file ./more.csv
gw sheet create "Title" # Create spreadsheet
gw sheet create "Title" --folder <id>
gw sheet list <id|url> # List tabs/sheets
Output Modes
gw doc read <id|url> # Plain text output
gw doc read <id|url> --markdown # Markdown output
gw doc create "Title" # Create empty doc, returns ID + URL
gw doc create "Title" --folder <id> # Create in specific folder
gw doc append <id|url> "text" # Append text to end of doc
gw doc append <id|url> --file ./notes.txt # Append from file
gw sheet read <id|url> # Read entire first sheet (JSON rows)
gw sheet read <id|url> "Sheet1!A1:C10" # Read specific range
gw sheet write <id|url> "A1:B2" '[["Name","Score"],["Alice","95"]]'
gw sheet write <id|url> "A1" --file ./data.csv
gw sheet append <id|url> '[["Bob","88"]]'
gw sheet append <id|url> --file ./more.csv
gw sheet create "Title" # Create spreadsheet
gw sheet create "Title" --folder <id>
gw sheet list <id|url> # List tabs/sheets
Output Modes
All commands support three output modes:
| Flag | Output | Use case |
|---|---|---|
| (default) | JSON | Piping, scripting |
--pretty |
Human-readable table | Terminal viewing |
--quiet |
IDs only, one per line | Chaining commands |
I/O Contract
- stdout: Data output (JSON, table, or IDs)
- stderr: Errors, status messages, progress
- Exit 0: Success
- Exit 1: Any error (auth, not found, permission, network)
URLs and IDs
All commands accept either format — paste a full Google URL or just the ID:
gw doc read https://docs.google.com/document/d/1abc.../edit
gw doc read 1abc...
Error Messages
Condition
Message
No token
Error: Not authenticated. Run 'gw auth' to get started.
Token expired
Error: Session expired. Run 'gw auth' to re-authenticate.
File not found
Error: File not found.
Permission denied
Error: No access to this file. Make sure it's shared with your account.
Network error
Error: Could not reach Google APIs. Check your connection.
Common Agent Workflows
Browse a Shared Drive and read a doc
gw drive shared --quiet # Get drive IDs
gw --drive <id> drive ls --pretty # Browse root
gw --drive <id> drive ls --folder <folder-id> # Drill into folder
gw doc read <doc-id> # Read the doc
Create a doc with content in a specific folder
| Condition | Message |
|---|---|
| No token | Error: Not authenticated. Run 'gw auth' to get started. |
| Token expired | Error: Session expired. Run 'gw auth' to re-authenticate. |
| File not found | Error: File not found. |
| Permission denied | Error: No access to this file. Make sure it's shared with your account. |
| Network error | Error: Could not reach Google APIs. Check your connection. |
Browse a Shared Drive and read a doc
gw drive shared --quiet # Get drive IDs
gw --drive <id> drive ls --pretty # Browse root
gw --drive <id> drive ls --folder <folder-id> # Drill into folder
gw doc read <doc-id> # Read the doc
gw drive mkdir "Project X" # Create folder, get ID
gw doc create "Requirements" --folder <id> # Create doc, get ID
gw doc append <doc-id> "# Requirements\n\n..." # Write content
Export sheet data for processing
gw sheet read <id> --quiet > data.tsv # Tab-separated to file
gw sheet read <id> "Sheet1!A1:D100" | jq '.' # JSON for processing
Upload and organize files
gw drive mkdir "Reports" --folder <parent-id>
gw drive upload ./q4-report.pdf --folder <new-folder-id> --name "Q4 Report 2026"
gw sheet read <id> --quiet > data.tsv # Tab-separated to file
gw sheet read <id> "Sheet1!A1:D100" | jq '.' # JSON for processing
gw drive mkdir "Reports" --folder <parent-id>
gw drive upload ./q4-report.pdf --folder <new-folder-id> --name "Q4 Report 2026"
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。