google-docs

Create, read, edit, and format Google Docs documents using the gws CLI.

Updated Mar 29, 2024
One-click install
npx skills add https://github.com/petobens/ai-harness --skill google-docs-petobens
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: google-docs
Source: https://github.com/petobens/ai-harness/tree/main/skills/google-docs
Command: npx skills add https://github.com/petobens/ai-harness --skill google-docs-petobens

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gws.

What problem does it solve? Working with Google Docs programmatically is error-prone: batchUpdate index math, styling ranges, and formatting drift make automated document creation and editing tedious. This Skill provides proven workflows and a default document format for producing polished Google Docs via the gws CLI. ## Core Features & Use Cases - Document lifecycle management: Create, read, inspect, copy, rename, and trash Google Docs, with safe confirmation rules and dry-run validation for risky writes. - Rich content writing: Insert text first, then apply paragraph styles, text styles, bullets, and links over exact UTF-16 ranges using atomic batchUpdate requests. - Default document format: Apply a consistent house style (title, subtitle, metadata block, numbered headings, justified body text, branded header/footer) when creating or substantially rewriting docs. - Use Case: Ask the agent to turn a Markdown memo into a polished Google Doc with numbered sections, a metadata block, and company branding, then get back the title, ID, and URL. ## Quick Start Ask the agent to create a new Google Doc titled "Q3 Planning Memo" from your Markdown notes using the default document format.

Frequently Asked Questions about google-docs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create and format a Google Doc from the command line?

Use gws docs documents create to make the doc, then documents.batchUpdate to insert text and apply styles. Insert all text first, then apply paragraph and text styles over tracked UTF-16 index ranges, since inserts shift downstream indexes.

How do I add headings, bullets, and links to a Google Doc programmatically?

Use batchUpdate with updateParagraphStyle for named styles like HEADING_2, createParagraphBullets with a bulletPreset such as BULLET_DISC_CIRCLE_SQUARE, and updateTextStyle with link.url for links. Always specify narrow fields masks.

Can I validate a Google Docs batchUpdate request before sending it?

Yes, gws supports --dry-run on batchUpdate and other write methods to validate request bodies locally. For complex JSON, write the body to a file like /tmp/gdoc-requests.json and pass it with --json "$(cat /tmp/gdoc-requests.json)".

Why did my Google Docs styling apply to the wrong text range?

insertText shifts every downstream index, so mixing inserts and styling in one pass causes drift. Insert all text first, track UTF-16 start and end indexes, then apply styles in a separate pass, and re-inspect the doc afterward.

What should I do when gws commands fail with network errors?

Google Docs operations require network access, so DNS or discovery errors in restricted sandboxes indicate a permissions issue, not an API problem. Rerun the same command with escalated tool permissions rather than changing the request.