gogcli について
gogcliは、Google Workspaceを操作するコマンドラインツールです。Gmail、Calendar、Drive、Tasks、Contacts、Sheets、Docs、Slides、Chatを扱い、JSON出力を解析やスクリプト処理に利用できます。
主な機能
- 01Gmailの検索とメール管理
- 02カレンダー予定と空き時間の確認
- 03Driveファイルの検索、アップロード、ダウンロード
- 04タスクと連絡先の管理
- 05Sheets、Docs、Slidesの読み取りと更新
- 06Workspace Chatへのアクセス
活用シーン
- 01メールを絞り込み、本文を要約用に抽出
- 02予定の確認や空き時間の検索
- 03ターミナルからファイルを検索・管理
- 04スプレッドシートデータの一括読み取りや更新
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ joelhooks/ joelclaw --skill gogcliインストール後、Claude Code で/gogcliを入力して読み込まれたか確認します。
詳細
gogcli — ターミナルで使う Google Workspace
gog は、Google Workspace スイート全体に対応した、高速で JSON を優先する CLI です。結果を解析する場合は、常に --json を使用して構造化出力を取得してください。
環境
export [email protected]
export GOG_KEYRING_PASSWORD=$(secrets lease gog_keyring_password )
どちらの変数も、すべての gog コマンドで必須です。使用前に agent-secrets からキーリングのパスワードを取得してください。
クイックリファレンス
Gmail
# Search (default: threads)
gog gmail search 'newer_than:1d' --max 10 --json
gog gmail search 'is:unread' --max 20 --json
gog gmail search 'from:[email protected] newer_than:7d' --max 10 --json
# Message-level search with bodies
gog gmail messages search 'is:unread' --max 5 --include-body --json
# Read thread
gog gmail thread get <threadId> --json
# Send
gog gmail send --to [email protected] --subject "Subject" --body "Body text"
gog gmail send --to [email protected] --subject "Hi" --body-html "<p>Hello</p>"
# Labels
gog gmail labels list --json
gog gmail thread modify <threadId> --add STARRED --remove INBOX
カレンダー
# Today / this week
gog calendar events primary --today --json
gog calendar events primary --week --json
gog calendar events primary --tomorrow --json
gog calendar events primary --days 7 --json
# All calendars
gog calendar events --all --today --json
# Search
gog calendar search "meeting" --today --json
# Create event
gog calendar create primary \
--summary "Meeting" \
--from 2025-01-15T10:00:00Z \
--to 2025-01-15T11:00:00Z \
--attendees "[email protected]"
# Check availability
gog calendar freebusy --calendars "primary" \
--from 2025-01-15T00:00:00Z --to 2025-01-16T00:00:00Z --json
# List calendars
gog calendar calendars --json
ドライブ
gog drive ls --max 20 --json
gog drive search "invoice" --max 20 --json
gog drive upload ./file.pdf --parent <folderId>
gog drive download <fileId> --out ./file.pdf
gog drive mkdir "New Folder"
タスク
gog tasks lists --json
gog tasks list <tasklistId> --max 50 --json
gog tasks add <tasklistId> --title "New task"
gog tasks done <tasklistId> <taskId>
連絡先
gog contacts search "Name" --max 10 --json
gog contacts list --max 50 --json
スプレッドシート
gog sheets metadata <spreadsheetId> --json
gog sheets get <spreadsheetId> 'Sheet1!A1:B10' --json
gog sheets update <spreadsheetId> 'A1' 'val1|val2,val3|val4'
gog sheets append <spreadsheetId> 'Sheet1!A:C' 'new|row|data'
ドキュメント/スライド
gog docs cat <docId> # Read doc as text
gog docs export <docId> --format pdf --out doc.pdf
gog slides export <presentationId> --format pdf --out deck.pdf
Chat(Workspace のみ)
gog chat spaces list --json
gog chat messages list spaces/<spaceId> --max 10 --json
gog chat dm send [email protected] --text "message"
出力モード
| フラグ | 用途 |
|---|---|
--json | 標準出力に構造化 JSON を出力します(解析には常にこちらを推奨) |
--plain | 安定した TSV(タブ区切り、色なし) |
| (なし) | 人が読みやすい表形式 |
エラーや進行状況は標準エラー出力に送られます。フィルタリングするには、--json の出力を jq にパイプで渡してください。
使用例
Gmail の検索結果をまとめて要約する
gog gmail messages search 'is:unread newer_than:1d' --max 20 --include-body --json | jq '.messages[] | {from, subject, body}'
次の空き時間を探す
gog calendar freebusy --calendars "primary" --from today --to tomorrow --json
今日の予定
gog calendar events primary --today --json | jq '.events[] | {summary, start: .start.dateTime, end: .end.dateTime}'
認証の設定(初回のみ)
gog が認証エラーを返す場合:
export GOG_KEYRING_PASSWORD=$(secrets lease gog_keyring_password )
gog auth add [email protected] --services user
# Complete OAuth in browser, then verify:
gog auth list --check
トラブルシューティング
- 「Secret not found」:キーリングのパスワードが設定されていません。
GOG_KEYRING_PASSWORDをエクスポートしてください。 - 「No auth for gmail」:
gog auth add <email> --services gmail(すべてのサービスの場合はuser)が必要です。 - 403 insufficient scopes:不足しているスコープを追加するには、
--force-consentを指定して再認証してください。 - Keychain locked:このシステムは
fileバックエンドを使用します。環境変数GOG_KEYRING_PASSWORDを設定してください。
コメント
Markdown 対応