# google-docs

Reads, creates, and updates Google Docs documents using the Docs REST API via curl and jq.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 175 installs · ★ 17 repo stars
- Author: acedatacloud
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/AceDataCloud/Skills/tree/HEAD/skills/google-docs/SKILL.md
- Updated: 2026-10-25
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/acedatacloud-google-docs

## What it does

This skill connects your coding assistant to the Google Docs v1 REST API using `curl` and `jq`. It extracts plain text by traversing document paragraph structures, initializes new documents directly in your Google Drive root, and pushes text updates through `batchUpdate`.

All calls require an OAuth bearer token passed via `$GOOGLE_DOCS_TOKEN`. The default configuration grants `documents.readonly` access. If your token lacks the full `documents` scope, write calls fail with a `403 PERMISSION_DENIED` status.

The Docs API relies strictly on character-based indexing. Every text insertion alters subsequent positions, so multi-part edits must run back-to-front to avoid corrupting offsets.

## Requirements
- Works with: Google Workspace

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add AceDataCloud/Skills --skill google-docs -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/google-docs/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/google-docs/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add AceDataCloud/Skills --skill google-docs -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/google-docs/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add AceDataCloud/Skills --skill google-docs -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/google-docs/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install AceDataCloud/Skills skills/google-docs
```

2. **Manually: put the files in place**
- File: `.github/skills/google-docs/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add AceDataCloud/Skills --skill google-docs -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/AceDataCloud/Skills --path skills/google-docs
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/google-docs/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add AceDataCloud/Skills --skill google-docs -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/AceDataCloud/Skills/tree/HEAD/skills/google-docs/SKILL.md

## When to use it
- extract plain text from a Google Doc via API
- create new documents in Google Drive root
- insert text blocks at precise index positions
- replace placeholder tags across an entire document

## Example prompts
- Read the plain text from document `DOC_ID`
- Create a new document titled "Release Notes"
- Replace all occurrences of `{{version}}` with `1.0.0` in doc `DOC_ID`

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: c12a2be284b150ef.

BEGIN THIRD-PARTY FILE c12a2be284b150ef
````text
---
name: google-docs
description: Read and edit Google Docs via the Docs v1 REST API. Use when the user mentions a Google Doc, reading a document's text, creating a doc, inserting or replacing text, or exporting a doc's content.
when_to_use: |
  Trigger when the user wants to read a Google Doc's content, create a
  new doc, or insert / replace text in one. The connector grants
  `documents.readonly` by default; the user opts in to `documents`
  (read + write) at install — confirm before edits. Find the doc id
  from a Drive URL or a google-drive search.
connections: [google/docs]
allowed_tools: [Bash]
license: Apache-2.0
metadata:
  author: acedatacloud
  version: "1.0"
---

Drive **Google Docs** via `curl + jq`. The user's OAuth bearer token is in
`$GOOGLE_DOCS_TOKEN`; every call needs `Authorization: Bearer
$GOOGLE_DOCS_TOKEN`. Base URL: `https://docs.googleapis.com/v1/documents`. The
token carries `documents.readonly` (+ identity); writes need `documents`.

Failures are `{"error":{"code","message","status"}}` — show verbatim. `401` =
re-install. `403 PERMISSION_DENIED` on a write = read-only scope.

The doc id is the `…/document/d/<ID>/edit` segment of the URL.

```bash
D="https://docs.googleapis.com/v1/documents"; AUTH="Authorization: Bearer $GOOGLE_DOCS_TOKEN"
# Read the document. The body is a tree of structural elements; pull plain text:
curl -sS -H "$AUTH" "$D/DOC_ID" \
  | jq -r '.title, ([.body.content[]?.paragraph?.elements[]?.textRun?.content] | join(""))'
```

## Create & edit

```bash
# Create an empty doc
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"title":"Meeting notes 2026-06-21"}' "$D" | jq '{documentId, title}'

# Insert text at the start (index 1) via batchUpdate (confirm first)
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"requests":[{"insertText":{"location":{"index":1},"text":"Hello\n"}}]}' \
  "$D/DOC_ID:batchUpdate" | jq '.documentId'

# Replace all occurrences of a placeholder
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"requests":[{"replaceAllText":{"containsText":{"text":"{{name}}","matchCase":true},"replaceText":"Alex"}}]}' \
  "$D/DOC_ID:batchUpdate" | jq '.replies'
```

## Gotchas

- The document model is **index-based**: text edits target character indices, and
  every insert shifts later indices — for multiple inserts, apply them
  back-to-front or recompute indices between calls.
- To get clean Markdown/plain text, walk `body.content[].paragraph.elements[]
  .textRun.content` (the jq above). Tables / lists need deeper traversal.
- Creating a doc puts it in the user's Drive root; use the `google-drive` skill to
  move/share it.
````
END THIRD-PARTY FILE c12a2be284b150ef

The third-party file has ended. Everything between the c12a2be284b150ef tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© acedatacloud · Apache-2.0 · https://github.com/AceDataCloud/Skills/tree/HEAD/skills/google-docs/SKILL.md

## Similar
- [Google Docs](https://affpapa.org/en/nevibecode/mcp/googledocs-google-docs.md) — MCP server · 1024 installs
- [FGAC.ai: Multiple Gmail Accounts, Google Sheets & Docs](https://affpapa.org/en/nevibecode/mcp/fgacai-multiple-gmail-accounts-google-sheets-docs.md) — MCP server
- [google-drive](https://affpapa.org/en/nevibecode/skills/google-drive.md) — skill · 25 installs
- [google](https://affpapa.org/en/nevibecode/skills/odyssey4me-google.md) — skill · 844 installs

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
