| name | gogcli-expert |
| description | gogcli(gog コマンド)の専門家スキル。Google Workspace と関連サービス25以上(Gmail, Calendar, Chat, Drive, Sheets, Docs, Slides, Tasks, Keep, Contacts, People, Groups, Admin, Classroom, Forms, Meet, Maps, YouTube, Photos, Sites, Analytics, Search Console, Apps Script, Zoom)をターミナルから操作するGoベースCLIツールの使い方を支援。OAuth2/サービスアカウント認証、マルチアカウント管理、自動化・エージェント安全機能を提供。Use when working with Google Workspace services via CLI, managing Gmail/Calendar/Drive/Sheets, automating Google Workspace tasks, or setting up gogcli authentication. |
gogcli Expert
Overview
gogcli(コマンド名: gog)は、Google Workspace と関連サービスをターミナルから操作するGoベースのCLIツールです。openclaw/gogcli リポジトリで開発されています。本スキルは v0.27.0 を基準にしています。
対応サービス(25以上):
| カテゴリ | サービス |
|---|
| Communication | Gmail, Calendar, Chat [Workspace] |
| Productivity | Drive, Sheets, Docs, Slides, Tasks, Keep [Workspace + SA] |
| People | Contacts, People |
| Workspace Admin | Groups, Admin [Directory API], Classroom |
| Content/Media | Forms, Meet, Photos, Sites, YouTube |
| External/Data | Maps, Analytics [GA4], Search Console, Apps Script, Zoom |
| Utility | Time, backup(暗号化バックアップ), batch, mcp(MCPサーバ) |
主要特徴:
- OAuth2 + サービスアカウント認証
- マルチアカウント・マルチクライアント対応
--json / --plain 出力でパイプライン統合に最適
- OSキーリングまたは暗号化ファイルによる認証情報の安全な保管
- エージェント安全機能:
--gmail-no-send、--dry-run、--enable-commands / --disable-commands、mcp サブコマンド
- シェル補完(Bash, Zsh, Fish, PowerShell)
バージョン確認:
gog --version
Prerequisites
このスキルを使用する前に以下を準備してください:
-
gogcli のインストール
- macOS/Linux:
brew install openclaw/tap/gogcli
- または GitHub からソースビルド
-
Google Cloud Console でのセットアップ
- Google Cloud プロジェクト
- 必要な API の有効化(Gmail API, Calendar API, Drive API 等)
- OAuth 同意画面の設定とテストユーザー追加
- 「デスクトップアプリケーション」タイプの OAuth2 クライアント ID 作成
- クレデンシャル JSON のダウンロード
-
初期認証
gog auth credentials set <path-to-json> でクレデンシャル登録
gog auth add <email>(別名 gog login <email>)でアカウント認証
Workflow
gogcli を使った基本的なワークフロー:
1. セットアップ
└─> gog auth credentials set ~/client_secret.json
└─> gog auth add user@gmail.com # 別名: gog login user@gmail.com
└─> gog status # 認証・設定確認(別名: gog auth status)
2. 日常操作
├─> Gmail: gog gmail search "is:unread" / gog gmail send ...
├─> Calendar: gog calendar events --today
├─> Drive: gog drive ls / gog drive download <id>
└─> Sheets: gog sheets get <id> <range>
3. 自動化・スクリプト統合
└─> --json 出力 + jq でパース
└─> CI/CD: GOG_KEYRING_PASSWORD + --no-input
4. マルチアカウント管理
└─> gog auth alias set work user@company.com
└─> gog --account work <command>
5. 不調時の診断
└─> gog auth doctor --check # 認証・キーリング・トークンを診断
When to Use This Skill
このスキルを使用するタイミング:
- gogcli(gog コマンド)のインストール・セットアップ方法を知りたい
- Google Workspace サービスをCLIから操作したい
- Gmail の検索・送信・ラベル管理をターミナルで行いたい
- Calendar のイベント管理・空き時間確認をCLIで行いたい
- Drive のファイル操作・権限管理をCLIで自動化したい
- Sheets / Docs / Slides の読み書き・書式設定をスクリプトで行いたい
- OAuth2 認証やサービスアカウントの設定方法を知りたい
- マルチアカウント環境の設定方法を知りたい
- gogcli のエラーやトラブルを解決したい
Example triggers:
- "gog コマンドで Gmail を検索するには?"
- "gogcli でカレンダーのイベントを作成したい"
- "Drive のファイルをダウンロードするコマンドは?"
- "Sheets のデータを読み取るには?"
- "gogcli の認証設定を教えて"
- "gog コマンドでメール送信したい"
- "How do I search Gmail with gogcli?"
- "How to set up gogcli service account?"
Installation
brew install openclaw/tap/gogcli
brew trust openclaw/tap
brew install openclaw/tap/gogcli
brew upgrade gogcli
git clone https://github.com/openclaw/gogcli.git
cd gogcli && make
./bin/gog --version
gog --version
Shell Completions
gog completion bash > $(brew --prefix)/etc/bash_completion.d/gog
gog completion zsh > "${fpath[1]}/_gog"
gog completion fish > ~/.config/fish/completions/gog.fish
gog completion powershell > gog.ps1
Google Cloud Console Setup
gogcli を利用するには、Google Cloud Console で OAuth2 クレデンシャルを準備します:
- Google Cloud Console でプロジェクトを作成または選択
- 必要な API を有効化(Gmail API, Calendar API, Drive API 等)
- OAuth 同意画面を設定し、テストユーザーを追加
- 「デスクトップアプリケーション」タイプの OAuth2 クライアント ID を作成
- クレデンシャル JSON をダウンロード
Authentication Setup
OAuth2 Basic Setup
gog auth credentials set ~/Downloads/client_secret.json
gog auth add user@gmail.com
gog auth list
gog status
Scope Control
認証時にサービスやスコープを限定できます(最小権限の原則):
gog auth add user@gmail.com --services gmail,calendar,drive
gog auth add user@gmail.com --readonly
gog auth add user@gmail.com --gmail-scope readonly
gog auth add user@gmail.com --drive-scope readonly
利用可能なサービス名は gog auth services で一覧できます。代表例: gmail, calendar, chat, classroom, drive, driveactivity, drivelabels, docs, slides, contacts, tasks, sheets, people, forms, sites, meet, appscript, analytics, searchconsole, ads, youtube, photos。photospicker は明示的なオプトイン指定が必要です。admin, groups, keep はサービスアカウント専用です(gog auth services で user=false)。
Adding Services Later
後からサービスを追加する場合、再同意が必要なことがあります:
gog auth add user@gmail.com --services sheets --force-consent
Multiple Accounts
gog auth add personal@gmail.com
gog auth add work@company.com
gog --account work@company.com calendar events --today
gog auth alias set work work@company.com
gog auth alias set personal personal@gmail.com
gog auth alias list
gog --account work calendar events --today
export GOG_ACCOUNT=work
Multiple OAuth Clients
組織ごとに異なる OAuth クライアントを使用する場合:
gog --client work auth credentials set ~/work-client-secret.json
gog --client personal auth credentials set ~/personal-client-secret.json
gog --client work auth add user@company.com
gog --client personal auth add user@gmail.com
gog auth credentials set ~/work-client-secret.json --domain company.com
Service Account (Workspace Only)
ドメイン全体の委任を使用する場合:
gog auth service-account set admin@domain.com --key ~/service-account.json
gog auth service-account status admin@domain.com
gog auth service-account unset admin@domain.com
前提条件:
- Google Cloud Console でサービスアカウントを作成
- キーファイル(JSON)をダウンロード
- Workspace 管理コンソールでドメイン全体の委任を設定
- 必要なスコープを許可リストに追加
Google Keep はサービスアカウント専用です。gog auth keep --key ~/sa.json <email> で設定します。
Keyring Configuration
gog auth keyring
gog auth keyring auto
gog auth keyring keychain
gog auth keyring file
export GOG_KEYRING_BACKEND=file
export GOG_KEYRING_PASSWORD='your-secure-password'
⚠️ バージョン更新後のキーリング・タイムアウト: gog のバイナリが更新されると macOS Keychain がアクセス許可を再要求します。非対話実行だと keyring connection timed out after 10s で失敗します。ターミナルで一度 gog auth list を実行し、Keychain プロンプトで「常に許可」を押してください。詳細は references/troubleshooting.md 参照。
Diagnostics
gog auth doctor
gog auth doctor --check
gog auth list --check
Core Services -- Communication
Gmail
スレッド・メッセージ検索(v0.27 ではクエリ必須):
gog gmail search "in:inbox" --max 10
gog gmail search "from:boss@company.com subject:report"
gog gmail search "is:unread newer_than:7d"
gog gmail search "has:attachment filename:pdf"
gog gmail messages search "is:unread"
gog gmail get <messageId>
gog gmail get <messageId> --format metadata --headers "From,Subject,Date"
gog gmail thread get <threadId>
メール送信:
gog gmail send --to recipient@example.com --subject "件名" --body "本文"
gog gmail send --to a@example.com --cc b@example.com --bcc c@example.com \
--subject "件名" --body "本文"
gog gmail send --to recipient@example.com --subject "Report" --body-html "<h1>Report</h1><p>...</p>"
gog gmail send --to recipient@example.com --subject "資料" --body "添付をご確認ください" \
--attach report.pdf --attach data.xlsx
gog gmail reply <messageId> --body "了解しました"
ラベル管理:
gog gmail labels list
gog gmail labels create "Projects/Active"
gog gmail messages modify <messageId> --add "Projects/Active"
gog gmail thread modify <threadId> --add STARRED
整理・その他:
gog gmail archive <messageId>
gog gmail trash <messageId>
gog gmail mark-read <messageId>
gog gmail unread <messageId>
gog gmail drafts list
gog gmail drafts create --to recipient@example.com --subject "下書き" --body "内容"
gog gmail drafts send <draftId>
⚠️ drafts delete のデータ消失注意: CLI で作った下書きを Gmail Web 画面から送信すると孤立ドラフトが残り、その draft-id を gog gmail drafts delete すると送信済みメールごと完全削除されます(ゴミ箱にも残らない)。drafts update が Message not a draft を返したら「送信済み」のサインなので削除しないこと。詳細は references/troubleshooting.md 参照。
設定(filters/vacation/delegates 等は settings 配下):
gog gmail settings filters list
gog gmail settings vacation get
gog gmail settings vacation update --enable --subject "不在のお知らせ" --body "現在不在です"
gog gmail settings delegates list
Calendar
イベント管理:
gog calendar events --today
gog calendar events --days 7
gog calendar events --week
gog calendar events --from 2026-02-01 --to 2026-02-28 --all
gog calendar create primary --summary "ミーティング" \
--from "2026-02-01T10:00:00" --to "2026-02-01T11:00:00" \
--attendees "a@example.com,b@example.com" --with-meet
gog calendar update primary <eventId> --summary "更新後のタイトル"
gog calendar delete primary <eventId>
gog calendar event primary <eventId>
スケジュール管理:
gog calendar calendars
gog calendar conflicts --from 2026-02-01 --to 2026-02-07
gog calendar freebusy --cal a@example.com --cal b@example.com \
--from "2026-02-01T09:00:00Z" --to "2026-02-07T18:00:00Z"
gog calendar respond primary <eventId> --status accepted
特殊イベント:
gog calendar focus-time --from "2026-02-01T09:00:00+09:00" --to "2026-02-01T12:00:00+09:00"
gog calendar out-of-office --from "2026-02-10T00:00:00+09:00" --to "2026-02-14T23:59:59+09:00"
gog calendar create primary --summary "Weekly Standup" \
--from "2026-02-03T09:00:00" --to "2026-02-03T09:30:00" \
--rrule "RRULE:FREQ=WEEKLY;BYDAY=MO"
Chat [Workspace Only]
gog chat spaces list
gog chat messages list <spaceId>
gog chat messages send <spaceId> --text "メッセージ内容"
gog chat dm send colleague@company.com --text "Hi!"
詳細は references/communication_services.md を参照。
Core Services -- Productivity
Drive
gog drive ls
gog drive ls --query "name contains 'report'"
gog drive ls --parent <folderId>
gog drive search "quarterly report"
gog drive download <fileId>
gog drive download <fileId> --format pdf --out ./downloads/report.pdf
gog drive upload report.pdf --parent <folderId>
gog drive upload notes.md --convert-to doc
gog drive mkdir "Project Documents"
gog drive tree --parent <folderId>
gog drive share <fileId> --to user --email user@example.com --role writer
gog drive permissions <fileId>
gog drive drives
Sheets
gog sheets get <spreadsheetId> "Sheet1!A1:D10"
gog sheets get <spreadsheetId> "Sheet1!A:A" --render FORMULA
gog sheets update <spreadsheetId> "Sheet1!A1" "Hello" "World"
gog sheets update <spreadsheetId> "Sheet1!A1:B2" --values-json '[["a","b"],["c","d"]]'
gog sheets append <spreadsheetId> "Sheet1!A1" "New" "Row" "Data"
gog sheets create "New Spreadsheet"
gog sheets metadata <spreadsheetId>
gog sheets export <spreadsheetId> --format csv --out data.csv
Sheets は書式・チャート・条件付き書式・テーブル・名前付き範囲など多数のサブコマンドがあります。詳細は references/productivity_services.md を参照。
Docs & Slides
v0.27 では Docs / Slides がフル編集に対応しています。
gog docs create "新規ドキュメント"
gog docs cat <docId>
gog docs export <docId> --format pdf --out doc.pdf
gog docs find-replace <docId> "旧称" "新称"
gog slides create-from-markdown "プレゼン" --content-file deck.md
gog slides export <presentationId> --format pptx --out deck.pptx
Tasks
gog tasks lists list
gog tasks list <tasklistId>
gog tasks add <tasklistId> --title "タスク名" --due 2026-02-15
gog tasks done <tasklistId> <taskId>
gog tasks undo <tasklistId> <taskId>
gog tasks delete <tasklistId> <taskId>
gog tasks clear <tasklistId>
Keep [Workspace + Service Account]
gog keep list
gog keep create --title "メモ" --text "本文"
gog keep search "キーワード"
詳細は references/productivity_services.md を参照。
Core Services -- People & Admin
People & Contacts
gog people me
gog people search "John Smith"
gog contacts search "Jane"
gog contacts create --given Jane --family Doe --email jane@example.com --phone "+1-555-0100"
gog contacts list
gog contacts other list
Groups & Admin
gog groups list
gog groups members <groupEmail>
gog admin users list
gog admin groups list
Classroom
gog classroom courses list
gog classroom roster <courseId>
gog classroom coursework list <courseId>
gog classroom submissions list <courseId> <courseworkId>
詳細・新サービス(Forms, Meet, Maps, YouTube, Photos, Sites, Analytics, Search Console, Apps Script, Zoom)は references/workspace_admin_services.md を参照。
Output Formats & Global Flags
Output Formats
gog gmail search "in:inbox"
gog gmail search "in:inbox" --json
gog gmail search "in:inbox" --json | jq '.[] | .subject'
gog gmail search "in:inbox" --plain
gog drive ls --json --results-only
gog drive ls --json --select "id,name"
gog drive ls --json 2>/dev/null | jq '.[] | .name'
Global Flags
| フラグ | 説明 |
|---|
-a, --account <email|alias|auto> | 使用するアカウントを選択 |
--client <name> | OAuth クライアントを選択 |
--access-token <token> | アクセストークンを直接指定(リフレッシュトークンをバイパス、約1hで失効) |
-j, --json | JSON 出力 |
-p, --plain | TSV 出力 |
--results-only | JSON で主要結果のみ出力(envelope を除外) |
--select <csv> | JSON で指定フィールドのみ出力 |
--wrap-untrusted | 取得テキストを untrusted-content マーカーで囲む |
--color <auto|always|never> | カラー出力制御 |
-n, --dry-run | 変更を行わず実行予定だけ表示 |
-y, --force | 確認プロンプトをスキップ |
--no-input | プロンプト時にエラー終了(CI向け) |
--gmail-no-send | Gmail 送信操作をブロック(エージェント安全) |
--enable-commands <csv> | 使用可能コマンドを前方一致で制限(サンドボックス) |
--enable-commands-exact <csv> | 使用可能コマンドを完全一致で制限(親コマンドを許可しても子は許可されない) |
--disable-commands <csv> | 指定コマンドを無効化 |
--home <dir> | config/data/state/cache のルートを上書き |
-v, --verbose | 詳細ログ出力 |
Environment Variables
| 変数 | 説明 |
|---|
GOG_ACCOUNT | デフォルトアカウント |
GOG_CLIENT | デフォルトOAuthクライアント |
GOG_ACCESS_TOKEN | アクセストークンの直接指定 |
GOG_JSON | デフォルトJSON出力(1 or true) |
GOG_PLAIN | デフォルトプレーン出力(1 or true) |
GOG_COLOR | カラーモード |
GOG_TIMEZONE | タイムゾーン(IANA名, UTC, local) |
GOG_HOME | config/data/state/cache のルート |
GOG_ENABLE_COMMANDS | コマンド許可リスト |
GOG_KEYRING_BACKEND | キーリングバックエンド(auto/keychain/file) |
GOG_KEYRING_PASSWORD | 暗号化キーリングのパスワード |
Zoom を使う場合は Server-to-Server OAuth 認証情報を gog zoom auth setup で登録するか、環境変数 GOG_ZOOM_ACCOUNT_ID / GOG_ZOOM_CLIENT_ID / GOG_ZOOM_CLIENT_SECRET で渡します。
Configuration
Config File
gog config path
gog config keys
gog config list
gog config get default_timezone
gog config set default_timezone "Asia/Tokyo"
gog config unset default_timezone
config.json の例:
{
keyring_backend: "auto",
default_timezone: "Asia/Tokyo",
account_aliases: {
work: "user@company.com",
personal: "user@gmail.com"
},
account_clients: {
"user@company.com": "work"
},
client_domains: {
"company.com": "work"
}
}
Common Patterns
1. 日次メールダイジェスト
gog gmail search "is:unread newer_than:1d" --json | \
jq -r '.[] | "\(.from) | \(.subject)"'
2. 今日のスケジュール確認
gog calendar events --today
gog calendar events --today --json | jq -r '.[] | "\(.start) - \(.summary)"'
3. チームの空き時間検索
gog calendar freebusy \
--cal alice@company.com --cal bob@company.com --cal carol@company.com \
--from "2026-02-03T09:00:00Z" --to "2026-02-03T18:00:00Z"
4. ファイルの一括ダウンロード
gog drive ls --parent <folderId> --json | \
jq -r '.[].id' | \
xargs -I{} gog drive download {} --out ./downloads/
5. Sheets データのCSVエクスポート
gog sheets export <spreadsheetId> --format csv --out data.csv
6. サンドボックス実行(エージェント用)
gog --enable-commands calendar,tasks calendar events --today
gog --gmail-no-send gmail search "in:inbox"
gog --dry-run calendar delete primary <eventId>
export GOG_ENABLE_COMMANDS=gmail,drive
7. CI/CD パイプラインでの使用
export GOG_KEYRING_BACKEND=file
export GOG_KEYRING_PASSWORD='secure-password'
export GOG_ACCOUNT=ci-bot@company.com
export GOG_JSON=1
gog --no-input gmail send --to team@company.com \
--subject "Build Report" --body "Build #123 passed"
8. MCP サーバとして公開(読み取り専用がデフォルト)
gog mcp --allow-tool "gmail.*,drive_get"
gog mcp --list-tools
Security Best Practices
Least Privilege Authentication
gog auth add user@gmail.com --services gmail,calendar
gog auth add user@gmail.com --readonly
gog auth add user@gmail.com --drive-scope file
Command Sandboxing
エージェントや自動化スクリプトに gogcli を使わせる場合:
export GOG_ENABLE_COMMANDS=calendar,tasks
Credential Management
- OS キーリング(
auto or keychain)を推奨
file バックエンドはパスワード保護必須
- CI 環境では
GOG_KEYRING_PASSWORD を安全に管理
- クレデンシャル JSON は安全な場所に保管し、バージョン管理に含めない
- サービスアカウントキーは定期的にローテーション
Multi-Account Security
- 本番環境と開発環境でアカウントを分離
--account を明示指定して誤操作を防止
- 環境変数
GOG_ACCOUNT でデフォルトアカウントを明確に設定
Troubleshooting
Quick Reference
| 症状 | 原因 | 対策 |
|---|
keyring connection timed out after 10s | バイナリ更新で macOS Keychain が許可を再要求 | ターミナルで gog auth list を実行し「常に許可」。または GOG_KEYRING_BACKEND=file + GOG_KEYRING_PASSWORD |
token has been expired or revoked | リフレッシュトークン失効 | gog auth add <email> で再認証。gog auth doctor --check で診断 |
insufficient permission / 403 | スコープ不足 | gog auth add <email> --services <svc> --force-consent |
Refusing to load formula ... untrusted tap | Homebrew の tap 信頼未承認 | brew trust openclaw/tap |
| コマンドがブロックされる | --enable-commands 制限 | 環境変数 GOG_ENABLE_COMMANDS を確認 |
| タイムゾーンが違う | 未設定 | gog config set default_timezone "Asia/Tokyo" |
| サービスアカウントエラー | 委任未設定 | Workspace 管理コンソールでスコープを許可 |
drafts update が Message not a draft | その下書きは送信済み(孤立ドラフト) | drafts delete しない。delete すると送信済みメールごと完全削除される |
詳細なトラブルシューティングは references/troubleshooting.md を参照。
Resources
このスキルには以下のリファレンスが含まれます:
| ファイル | 内容 |
|---|
references/quick_reference.md | 全サービスのコマンドチートシート |
references/communication_services.md | Gmail/Calendar/Chat の詳細ガイド |
references/productivity_services.md | Drive/Sheets/Docs/Slides/Tasks/Keep の詳細ガイド |
references/workspace_admin_services.md | Groups/Admin/Classroom/People/Contacts + 新サービス群の詳細 |
references/troubleshooting.md | トラブルシューティング詳細ガイド |
公式リポジトリ: https://github.com/openclaw/gogcli