一键导入
google-sheets
Google Sheets via gws: read/write cells, append rows, structured batch edits.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Google Sheets via gws: read/write cells, append rows, structured batch edits.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Google Calendar via gws: list events, create, accept, find free time.
Google Docs via gws: read, append text, structured batch edits.
Google Drive via gws: search, list, upload, download, share.
Google Forms via gws: create forms, add items, read responses.
Gmail via gws: send, read, search, label, draft, reply, forward.
Sign a Google account into its own gws config dir and register it (tagged). Used by google-workspace-setup; runs the OAuth login + records the account.
| name | google-sheets |
| description | Google Sheets via gws: read/write cells, append rows, structured batch edits. |
| license | MIT |
| compatibility | macOS and Linux. Requires the `gws` CLI authenticated with Sheets scopes. |
| metadata | {"gini":{"version":"1.1.2","author":"Gini","platforms":["macos","linux"],"prerequisites":{"commands":["gws"],"env":["GOOGLE_WORKSPACE_CLI_CLIENT_ID","GOOGLE_WORKSPACE_CLI_CLIENT_SECRET"]},"requires":{"credentials":["google-workspace-oauth"]}}} |
Use gws sheets to create spreadsheets, read cell ranges, append rows, update values, and run structured batch updates against the Sheets v4 API. This is the content surface for Google Sheets — for the file as an object (sharing, copying, moving, trashing) use google-drive instead.
gws is installed and authenticated, so skip the setup flow below and run gws directly. Scopes are fixed at sign-in on a managed deployment: when a call fails with scope required or HTTP 401, tell the user which action needs a scope their account wasn't granted, instead of trying to set anything up. (The scope list below still describes which verb needs which scope.)gws installed and authenticated. If gws is not on PATH OR gws auth status reports no authenticated user, do NOT silently call setup. Instead, in a single short reply to the user:
read_skill with name google-workspace-setup and run that skill's onboarding flow turn-by-turn. If they say no or ask to defer, acknowledge briefly and stop — do not retry the original request.gws sheets ... call fails mid-task with command not found / ENOENT, HTTP 401, "no credentials", or "scope required". Don't report the failure as a dead end — surface the missing prerequisite and ask if the user wants to set it up before moving on.sheets (maps to https://www.googleapis.com/auth/spreadsheets)--scopes "https://www.googleapis.com/auth/spreadsheets.readonly" at logindrive.readonlydrive scope, which covers finding sheets by title too — an account with a full drive grant needs no separate sheets scopeThe connected Google accounts (each with its tag, email, and config dir) are listed in your system context under "Connected Google accounts". To target a specific account, prefix the command with its config dir:
GOOGLE_WORKSPACE_CLI_CONFIG_DIR="<configDir>" gws sheets spreadsheets create --json '{"properties":{"title":"Tracker"}}'
Selection rule: one account connected → just use it. Two or more:
gws call per config dir) and aggregate, labeling each result by its tag and email. Don't pick just one, and don't ask — the user wants the whole picture across accounts.If no accounts are connected yet, fall back to the setup flow in Prerequisites (read_skill with google-workspace-setup). On a managed/hosted deployment an account is always connected, so this case doesn't arise.
spreadsheets.batchUpdate.google-drive for the file-as-object surface.google-docs.gws slides ...), not Sheets.memory tool, not a sheet.+read, compute locally, write the result back if needed. Don't round-trip every calculation through the Sheets API.The Sheets surface splits into two layers: helper commands for the common cases (+read, +append) and the raw API (spreadsheets.get, spreadsheets.values.*, spreadsheets.batchUpdate) for everything else.
gws sheets spreadsheets create --json '{"properties":{"title":"Weekly tracker"}}'
The response includes a spreadsheetId you will need for subsequent reads and writes. The spreadsheetUrl field is the user-facing URL — surface that, not the bare ID, when telling the user where the new sheet is.
gws sheets +read --spreadsheet <SHEET_ID> --range 'Sheet1!A1:D10'
gws sheets +read --spreadsheet <SHEET_ID> --range Sheet1
+read is read-only. The response is the matched values array (rows of cells), already unwrapped from the raw API envelope. Pass --format csv if the user wants to pipe the result somewhere; --format table for human review in chat.
# Simple single row, comma-separated
gws sheets +append --spreadsheet <SHEET_ID> --values 'Alice,100,true'
# Bulk multi-row insert as JSON
gws sheets +append --spreadsheet <SHEET_ID> --json-values '[["a","b"],["c","d"]]'
+append finds the first empty row at the bottom of the existing data range and writes there. To write to a specific range (overwriting), use spreadsheets.values.update instead.
gws sheets spreadsheets values get \
--params '{"spreadsheetId":"<SHEET_ID>","range":"Sheet1!A1:D10"}'
The raw response wraps the values in { "range": "...", "majorDimension": "ROWS", "values": [[…]] }. Useful when you need the range echo or want to set majorDimension=COLUMNS.
gws sheets spreadsheets values update \
--params '{"spreadsheetId":"<SHEET_ID>","range":"Sheet1!A1:B2","valueInputOption":"USER_ENTERED"}' \
--json '{"values":[["Header1","Header2"],["Row1A","Row1B"]]}'
valueInputOption matters:
RAW — strings are stored verbatim, no formula or number parsing.USER_ENTERED — Sheets parses input as if the user typed it: =SUM(A1:A5) becomes a formula, 1,000 becomes a number. This is almost always what you want.# Read several disjoint ranges in one call
gws sheets spreadsheets values batchGet \
--params '{"spreadsheetId":"<SHEET_ID>","ranges":["Sheet1!A1:B2","Sheet1!D1:D5"]}'
# Write several disjoint ranges in one call (atomic)
gws sheets spreadsheets values batchUpdate \
--params '{"spreadsheetId":"<SHEET_ID>"}' \
--json '{
"valueInputOption":"USER_ENTERED",
"data":[
{"range":"Sheet1!A1","values":[["Top-left"]]},
{"range":"Sheet2!Z99","values":[["Far corner"]]}
]
}'
spreadsheets.batchUpdate)Different from values.batchUpdate (which writes cell values). spreadsheets.batchUpdate mutates the structure: add sheets, freeze rows, set tab colors, apply conditional formats, insert charts. Each entry in requests is one mutation; the whole batch is atomic — if any request is invalid, nothing applies.
# Add a new tab
gws sheets spreadsheets batchUpdate \
--params '{"spreadsheetId":"<SHEET_ID>"}' \
--json '{
"requests":[
{"addSheet":{"properties":{"title":"Q1 Results"}}}
]
}'
# Freeze the header row and set a tab color
gws sheets spreadsheets batchUpdate \
--params '{"spreadsheetId":"<SHEET_ID>"}' \
--json '{
"requests":[
{"updateSheetProperties":{
"properties":{
"sheetId":0,
"gridProperties":{"frozenRowCount":1},
"tabColor":{"red":0.2,"green":0.6,"blue":1.0}
},
"fields":"gridProperties.frozenRowCount,tabColor"
}}
]
}'
For the schema of each request type:
gws schema sheets.spreadsheets.batchUpdate
gws sheets spreadsheets values clear \
--params '{"spreadsheetId":"<SHEET_ID>","range":"Sheet1!A2:D"}'
Wipes cell values but leaves formatting in place. To also strip formatting, use spreadsheets.batchUpdate with an updateCells request.
Use google-drive to locate the spreadsheet, then hand the ID to gws sheets:
gws drive files list \
--params '{"q":"mimeType = '\''application/vnd.google-apps.spreadsheet'\'' and name contains '\''Weekly tracker'\''"}'
spreadsheets.create, values.update, values.append, values.clear, values.batchUpdate, spreadsheets.batchUpdate, or +append. The runtime's terminal_exec approval gate is the user's safety net. When the user's command is clear ("append a row 'Alice, 100' to my tracker"), execute. Do ask one clarifying question when the command is ambiguous — multiple spreadsheets match a name, the user didn't specify which tab to write to, or clear would wipe a range larger than what they named.valueInputOption is required for any values write. Default to USER_ENTERED unless the user specifically asks to skip formula/number parsing; only use RAW for opaque strings the user wants stored verbatim.spreadsheets.batchUpdate and values.batchUpdate are atomic across the whole requests / data array. Build the full list, send once, and check the reply rather than retrying mid-batch on partial failure.'Sheet1!A1:D10'. Range-only (e.g. A1:D10) implicitly uses the first sheet. When the user's spreadsheet has multiple tabs, always qualify the sheet name to avoid silently writing to the wrong tab.google-drive. Sheets only owns the cells; Drive owns the file.--range to what you actually need; for whole-sheet scans, prefer spreadsheets.get with includeGridData:false to inspect structure first and pull cell ranges narrowly afterward.+read the values once and compute locally — don't round-trip every reduction through the Sheets API.PERMISSION_DENIED. If the user asks for an edit and gets that error, ask whether the spreadsheet is theirs to edit before retrying — re-running the same call won't help.For flags not shown here, run gws sheets --help or gws schema sheets.<resource>.<method> to inspect a specific API method.