360 Secure SkillHub
360 安全技能中心

drivectl - your command-line tool for interacting with Google Drive

该技能说明如何使用 drivectl CLI 访问 Google Workspace:列出、查询、搜索和下载 Drive 文件,读取与更新 Sheets 范围并导出 CSV,创建、读取和转换 Google Docs,并可通过 Discovery 动态调用任意 Workspace API。使用前需完成 OAuth 登录,需要结构化结果时用 -O json 输出。

ghchinoy
ghchinoy
热度 52.05
最近更新 2026-05-11 17:46:45
分类:效率依赖:代码执行 / 读写文件 / 第三方 API应用场景:文件转换 / 数据处理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add google-drive-cli
Metadata
name
google-drive-cli
description
Interact with Google Drive, Docs, and Sheets using the drivectl CLI. Use this skill when asked to list Drive files, download files, read/update Sheets, or create/export Google Docs.
metadata
{"discovery_doc_drive_v3":"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"}

google-drive-cli

This skill provides guidance on using the drivectl command-line tool to interact with Google Workspace (Drive, Docs, Sheets).

Prerequisites & Authentication

  • Ensure drivectl is available in your PATH or in the current working directory (e.g., ./drivectl). If it is not installed, you can quickly download the latest prebuilt binary by running the bundled script: scripts/install.sh.
  • Crucial Rule: Always append -O json to drivectl commands when you need to parse the output programmatically or return structured information.

First-time Authentication

The user must authenticate before using drivectl. It securely caches tokens locally so this only needs to happen once. If the user hasn't authenticated, guide them to do so:

drivectl auth login --secret-file /path/to/your/client_secret.json

(If operating on a headless system or inside an agent environment without a browser, append the --no-browser-auth flag to print a manual authorization URL that the user can click).

Available Modules

The drivectl tool provides several subcommands organized by Workspace service. Pick the correct reference depending on the user's request.

  • Google Drive (Files/Folders): See references/drive.md for listing, querying, searching, and downloading files.
  • Google Docs: See references/docs.md for creating docs from Markdown, reading docs, converting to Markdown, and exploring tab structures.
  • Google Sheets: See references/sheets.md for reading ranges, updating cells, and exporting sheets to CSV.

Dynamic Discovery (Fallback)

If the built-in commands (list, docs, sheets) do not cover the requirement, you can use the call subcommand to dynamically invoke any Google Workspace API endpoint using Google Discovery.

See references/discovery.md for detailed instructions on how to formulate and execute these dynamic API calls.