360 Secure SkillHub
360 安全技能中心

Google Docs Writer

这是弥补gog仅支持只读操作的谷歌文档读写工具,核心功能包括读写内容、追加文本、清空文档、查找替换,还能自动将Markdown标题转为谷歌文档原生标题。需先完成gog OAuth配置,且文档需授予认证账号编辑权限,通过命令行调用,输入文档ID、文件或目标文本即可执行操作,适合需编辑更新谷歌文档的场景。

agenttrust
agenttrust
热度 31.57
最近更新 2026-05-03 02:31:52
分类:效率依赖:代码执行 / 读写文件 / 第三方 API应用场景:文件转换 / 工作流

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add google-docs-writer
Metadata
name
google-docs-writer
description
Read, write, append, clear, and find-replace content in Google Docs via the Docs API. Use when gog CLI is insufficient (gog only supports read-only doc operations). Requires gog OAuth to be configured (gog auth add). Supports auto-formatting of markdown headers into native Google Docs headings.

Google Docs Writer

Extends gog with write operations for Google Docs. Uses the same OAuth credentials gog stores in the GNOME keyring.

Prerequisites

  • gog auth add completed (OAuth token in keyring)
  • secretstorage Python package (pre-installed on most Linux desktops)
  • Doc must be owned by or shared as Editor with the authenticated account

Commands

Script: scripts/gdocs.py

# Read doc content as plain text
python3 scripts/gdocs.py read <docId>

# Replace entire doc with content from file
python3 scripts/gdocs.py write <docId> <textFile>

# Append content from file to end of doc
python3 scripts/gdocs.py append <docId> <textFile>

# Clear all doc content
python3 scripts/gdocs.py clear <docId>

# Find and replace text
python3 scripts/gdocs.py replace <docId> "find this" "replace with"

Formatting

The write command auto-converts markdown headers to Google Docs headings:

  • # Heading → Heading 1
  • ## Heading → Heading 2
  • ### Heading → Heading 3

Header markers (#) are stripped from the final doc.

Workflow

  1. Write content to a temp file (markdown-formatted for best results)
  2. Use write (replace all) or append (add to end)
  3. Use read to verify

For creating new docs, use gog docs create <title> first, then write content with this skill.

Token Caching

Access tokens are cached at /tmp/.gdocs_access_token for ~50 minutes. No manual token management needed.

Error: 403 Permission Denied

The authenticated account (gabagent00@gmail.com) needs Editor access to the doc. Shared docs default to Viewer — the doc owner must grant edit permission.