Operate Google Docs with the gog CLI.
Execution path: gog
Authenticated account: (account authenticated with gog)
Execution Notes
execWhen executing with the tool,timeout: 60specify- Document ID is URL
https://docs.google.com/document/d/<docId>/editcan be obtained from
Command Reference
Create document
gog docs create "<title>"
gog docs create "<title>" --parent "<folderId>" # 特定フォルダに作成
gog docs create "<title>" --file "./content.md" # Markdownファイルからインポート
Get document info
gog docs info <docId>
gog docs info <docId> --json
Read document (plain text)
gog docs cat <docId>
gog docs cat <docId> --tab "<tabTitle>" # 特定タブのみ
gog docs cat <docId> --all-tabs # 全タブ表示
gog docs cat <docId> --max-bytes 0 # 制限なし(デフォルト2MB)
Write document
# 末尾に追記(デフォルト)
gog docs write <docId> "追加テキスト"
gog docs write <docId> --file "./content.txt"
echo "テキスト" | gog docs write <docId> --file -
# 全体を置換
gog docs write <docId> "新しい内容" --replace
gog docs write <docId> --file "./content.md" --replace --markdown
Insert text (position specified)
gog docs insert <docId> "挿入テキスト" --index 1 # 先頭に挿入
gog docs insert <docId> "挿入テキスト" --index 50 # 50文字目に挿入
gog docs insert <docId> --file "./snippet.txt" --index 1
Delete text (range specified)
gog docs delete <docId> --start 1 --end 100
Find and replace
gog docs find-replace <docId> "検索文字列" "置換文字列"
gog docs find-replace <docId> "old" "new" --match-case # 大文字小文字区別
Copy Document
gog docs copy <docId> "コピーのタイトル"
gog docs copy <docId> "コピーのタイトル" --parent "<folderId>"
Export (Download)
gog docs export <docId> # PDF(デフォルト)
gog docs export <docId> --format docx # Word形式
gog docs export <docId> --format txt # テキスト形式
gog docs export <docId> --format pdf --out "./out.pdf"
List tabs
gog docs list-tabs <docId>
gog docs list-tabs <docId> --json
Content update (update)
gog docs update <docId> --content "新しい内容" # 全体置換
gog docs update <docId> --content "追加テキスト" --append # 末尾追記
gog docs update <docId> --content-file "./doc.md" --format markdown # Markdown変換
Output options
| Options | Description |
|---|---|
--json / -j |
JSON output |
--plain / -p |
TSV output (for parsing) |
--results-only |
For JSON, output results only |
--select "field1,field2" |
For JSON, filter fields |
--dry-run / -n |
Show intent without making changes |
Typical workflow
Create new document → write
# 1. 作成(IDを取得)
gog docs create "議事録 2026-02-15" --json
# 2. 内容を書き込み
gog docs write <docId> --file "./minutes.md" --replace --markdown
Read document → edit
# 1. 内容確認
gog docs cat <docId>
# 2. テキスト置換
gog docs find-replace <docId> "旧プロジェクト名" "新プロジェクト名"
Export
# PDF出力
gog docs export <docId> --format pdf --out "./report.pdf"
# Word出力
gog docs export <docId> --format docx --out "./report.docx"
Copy from Template
# 1. テンプレートをコピー
gog docs copy <templateDocId> "新しいドキュメント" --json
# 2. プレースホルダーを置換
gog docs find-replace <newDocId> "{{NAME}}" "田中太郎"
gog docs find-replace <newDocId> "{{DATE}}" "2026年2月15日"
Tab operations
# タブ一覧を確認
gog docs list-tabs <docId>
# 特定タブの内容を読む
gog docs cat <docId> --tab "Sheet1"
# 全タブの内容を一括表示
gog docs cat <docId> --all-tabs
Notes
- List documents:
gog docshas no list command. Search via Drive:gog drive ls --query "mimeType='application/vnd.google-apps.document'" - write defaults to appending: To rewrite everything,
--replacealways include - Markdown conversion:
--markdownは--replacemust be used together (write). For update,--format markdownuse - insert の index: 1-based. The start of the document is index=1
- delete range:
--startと--endis required. Check the content beforehand withcatand then specify the index - Large documents:
cat's default limit is 2MB.--max-bytes 0for unlimited - Special characters: Be careful with shell escaping (quotes, newlines, etc.)
- Long body text:
--fileoption or stdin (--file -) use