| name | gogcli-expert |
| description | gogcli(gog コマンド)の専門家スキル。Google Workspaceの13サービス(Gmail, Calendar, Drive, Sheets, Docs, Slides, Contacts, Tasks, Chat, Groups, Keep, Classroom, People)をターミナルから操作する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の13サービスをターミナルから操作するGoベースのCLIツールです。steipete/gogcli リポジトリで開発されています。
対応サービス:
| カテゴリ | サービス |
|---|
| Communication | Gmail, Calendar, Chat [Workspace only] |
| Productivity | Drive, Sheets, Docs, Slides, Tasks, Keep [Workspace + SA only] |
| Workspace Admin | Groups [Workspace only], Classroom, People, Contacts |
| Utility | Time(UTC/ローカル時刻表示) |
主要特徴:
- OAuth2 + サービスアカウント認証
- マルチアカウント・マルチクライアント対応
--json / --plain 出力(パイプライン統合に最適)
- OSキーリングまたは暗号化ファイルによる認証情報の安全な保管
- シェル補完(Bash, Zsh, Fish, PowerShell)
Prerequisites
このスキルを使用する前に以下を準備してください:
-
gogcli のインストール
- macOS/Linux:
brew install steipete/tap/gogcli
- または GitHub からソースビルド
-
Google Cloud Console でのセットアップ
- Google Cloud プロジェクト(作成済みまたは新規)
- 必要な API の有効化(Gmail API, Calendar API, Drive API 等)
- OAuth 同意画面の設定(テストユーザー追加)
- OAuth2 クライアント ID(デスクトップアプリケーションタイプ)の作成
- クレデンシャル JSON のダウンロード
-
初期認証
gog auth credentials <path-to-json> でクレデンシャル登録
gog auth add <email> でアカウント認証
Workflow
gogcli を使った基本的なワークフロー:
1. セットアップ
└─> gog auth credentials ~/client_secret.json
└─> gog auth add user@gmail.com
└─> gog auth status # 認証確認
2. 日常操作
├─> Gmail: gog gmail threads / gog gmail send
├─> Calendar: gog calendar events --today
├─> Drive: gog drive list / gog drive download
└─> Sheets: gog sheets get <id>
3. 自動化・スクリプト統合
└─> --json 出力 + jq でパース
└─> CI/CD: GOG_KEYRING_PASSWORD + --no-input
4. マルチアカウント管理
└─> gog auth alias set work user@company.com
└─> gog --account work <command>
When to Use This Skill
このスキルを使用するタイミング:
- gogcli(gog コマンド)のインストール・セットアップ方法を知りたい
- Google Workspace サービスをCLIから操作したい
- Gmail の検索・送信・ラベル管理をターミナルで行いたい
- Calendar のイベント管理・空き時間確認をCLIで行いたい
- Drive のファイル操作・権限管理をCLIで自動化したい
- Sheets の読み書き・書式設定をスクリプトで行いたい
- OAuth2 認証やサービスアカウントの設定方法を知りたい
- マルチアカウント環境の設定方法を知りたい
- gogcli のエラーやトラブルを解決したい
Example triggers:
- "gog コマンドで Gmail を検索するには?"
- "gogcli でカレンダーのイベントを作成したい"
- "Drive のファイルをダウンロードするコマンドは?"
- "Sheets のデータを読み取るには?"
- "gogcli の認証設定を教えて"
- "gog コマンドでメール送信したい"
- "Google Workspace の CLI ツールを使いたい"
- "How do I search Gmail with gogcli?"
- "How to set up gogcli service account?"
Installation
brew install steipete/tap/gogcli
git clone https://github.com/steipete/gogcli.git
cd gogcli && make
./bin/gog --help
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 ~/Downloads/client_secret.json
gog auth add user@gmail.com
gog auth list
gog auth status
Scope Control
認証時にサービスを限定できます(最小権限の原則):
gog auth add user@gmail.com --services drive,calendar
gog auth add user@gmail.com --readonly
gog auth add user@gmail.com --drive-scope full
gog auth add user@gmail.com --drive-scope readonly
gog auth add user@gmail.com --drive-scope file
Adding Services Later
後からサービスを追加する場合、--force-consent が必要なことがあります:
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 ~/work-client-secret.json
gog --client personal auth credentials ~/personal-client-secret.json
gog --client work auth add user@company.com
gog --client personal auth add user@gmail.com
ドメインマッピング(config.json):
{
account_clients: { "user@company.com": "work" },
client_domains: { "company.com": "work" }
}
Service Account (Workspace Only)
ドメイン全体の委任(Domain-Wide Delegation)を使用する場合:
gog auth service-account set admin@domain.com --key ~/service-account.json
gog auth list
前提条件:
- Google Cloud Console でサービスアカウントを作成
- キーファイル(JSON)をダウンロード
- Workspace 管理コンソールでドメイン全体の委任を設定
- 必要なスコープを許可リストに追加
Keyring Configuration
gog auth keyring
gog auth keyring auto
gog auth keyring keychain
gog auth keyring file
export GOG_KEYRING_PASSWORD='your-secure-password'
Core Services -- Communication
Gmail
スレッド・メッセージ検索:
gog gmail threads
gog gmail threads --query "from:boss@company.com subject:report"
gog gmail threads --query "is:unread after:2025/01/01"
gog gmail threads --query "has:attachment filename:pdf"
gog gmail messages --thread-id <thread-id>
gog gmail message <message-id>
メール送信:
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>Details...</p>"
gog gmail send --to recipient@example.com --subject "資料" --body "添付をご確認ください" \
--attach report.pdf --attach data.xlsx
gog gmail send --to recipient@example.com --body-html "<p>Hi</p>" --track
ラベル管理:
gog gmail labels
gog gmail label create "Projects/Active"
gog gmail label apply <message-id> --label "Projects/Active"
その他の機能:
gog gmail drafts
gog gmail draft create --to recipient@example.com --subject "下書き" --body "内容"
gog gmail filters
gog gmail vacation --enable --subject "不在のお知らせ" --body "現在不在です"
gog gmail vacation --disable
gog gmail delegates
Calendar
イベント管理:
gog calendar events --today
gog calendar events --from 2025-02-01 --to 2025-02-28
gog calendar events --next 7d
gog calendar event create --summary "ミーティング" \
--start "2025-02-01T10:00:00" --end "2025-02-01T11:00:00" \
--attendees "a@example.com,b@example.com"
gog calendar event update <event-id> --summary "更新後のタイトル"
gog calendar event delete <event-id>
スケジュール管理:
gog calendar conflicts --from 2025-02-01 --to 2025-02-07
gog calendar freebusy --emails "a@example.com,b@example.com" \
--from 2025-02-01 --to 2025-02-07
gog calendar list
特殊イベント:
gog calendar event create --summary "Focus Time" --event-type focusTime \
--start "2025-02-01T09:00:00" --end "2025-02-01T12:00:00"
gog calendar event create --summary "OOO" --event-type outOfOffice \
--start "2025-02-10" --end "2025-02-14"
gog calendar event create --summary "Weekly Standup" \
--start "2025-02-03T09:00:00" --end "2025-02-03T09:30:00" \
--recurrence "RRULE:FREQ=WEEKLY;BYDAY=MO"
Chat [Workspace Only]
gog chat spaces
gog chat messages --space <space-id>
gog chat send --space <space-id> --text "メッセージ内容"
gog chat dm --email colleague@company.com --text "Hi!"
Core Services -- Productivity
Drive
ファイル操作:
gog drive list
gog drive list --query "name contains 'report'"
gog drive download <file-id>
gog drive download <file-id> --output ./downloads/
gog drive upload report.pdf
gog drive upload report.pdf --folder <folder-id>
gog drive export <file-id> --mime application/pdf
gog drive export <file-id> --mime text/csv
フォルダ管理:
gog drive folder create "Project Documents"
gog drive folder create "Subfolder" --parent <parent-folder-id>
gog drive list --folder <folder-id>
権限管理:
gog drive permissions <file-id>
gog drive share <file-id> --email user@example.com --role writer
gog drive share <file-id> --email user@example.com --role reader
gog drive shared-drives
Sheets
データ読み取り:
gog sheets get <spreadsheet-id>
gog sheets get <spreadsheet-id> --range "Sheet1!A1:D10"
gog sheets get <spreadsheet-id> --range "Sheet1!A:A"
gog sheets get <spreadsheet-id> --range "Sheet1!A1:D10" --json
データ書き込み:
gog sheets update <spreadsheet-id> --range "Sheet1!A1" --values "Hello,World"
gog sheets append <spreadsheet-id> --range "Sheet1!A1" --values "New,Row,Data"
シート管理:
gog sheets create --title "New Spreadsheet"
gog sheets list <spreadsheet-id>
Docs & Slides
Docs と Slides は主に Drive 経由のエクスポートで利用します:
gog drive export <doc-id> --mime application/pdf
gog drive export <doc-id> --mime application/vnd.openxmlformats-officedocument.wordprocessingml.document
gog drive export <slides-id> --mime application/pdf
gog drive export <slides-id> --mime application/vnd.openxmlformats-officedocument.presentationml.presentation
Tasks
gog tasks lists
gog tasks list <tasklist-id>
gog tasks add <tasklist-id> --title "タスク名" --due 2025-02-15
gog tasks done <tasklist-id> <task-id>
gog tasks undo <tasklist-id> <task-id>
gog tasks delete <tasklist-id> <task-id>
gog tasks clear <tasklist-id>
Core Services -- Workspace Admin
Groups [Workspace Only]
gog groups list
gog groups members <group-email>
Classroom
gog classroom courses
gog classroom roster <course-id>
gog classroom coursework <course-id>
gog classroom submissions <course-id> <coursework-id>
gog classroom announcements <course-id>
People & Contacts
gog people me
gog people search "John Smith"
gog contacts search "Jane"
gog contacts create --name "Jane Doe" --email jane@example.com --phone "+1-555-0100"
gog contacts other
Output Formats & Global Flags
Output Formats
gog gmail threads
gog gmail threads --json
gog gmail threads --json | jq '.[] | .subject'
gog gmail threads --plain
gog drive list --json 2>/dev/null | jq '.[] | .name'
Global Flags
| フラグ | 説明 |
|---|
--account <email|alias|auto> | 使用するアカウントを選択 |
--client <name> | OAuth クライアントを選択 |
--json | JSON 出力 |
--plain | TSV 出力 |
--color <auto|always|never> | カラー出力制御 |
--force | 確認プロンプトをスキップ |
--no-input | プロンプト時にエラー終了(CI向け) |
--verbose | 詳細ログ出力 |
--enable-commands <csv> | 使用可能コマンドを制限(サンドボックス) |
Environment Variables
| 変数 | 説明 |
|---|
GOG_ACCOUNT | デフォルトアカウント |
GOG_CLIENT | デフォルトOAuthクライアント |
GOG_JSON | デフォルトJSON出力(1 or true) |
GOG_PLAIN | デフォルトプレーン出力(1 or true) |
GOG_COLOR | カラーモード |
GOG_TIMEZONE | タイムゾーン(IANA名, UTC, local) |
GOG_ENABLE_COMMANDS | コマンド許可リスト |
GOG_KEYRING_BACKEND | キーリングバックエンド |
GOG_KEYRING_PASSWORD | 暗号化キーリングのパスワード |
Configuration
Config File
gog config path
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 threads --query "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 \
--emails "alice@company.com,bob@company.com,carol@company.com" \
--from "2025-02-03T09:00:00" --to "2025-02-03T18:00:00"
4. ファイルの一括ダウンロード
gog drive list --folder <folder-id> --json | \
jq -r '.[].id' | \
xargs -I{} gog drive download {} --output ./downloads/
5. Sheets データのCSVエクスポート
gog sheets get <spreadsheet-id> --range "Sheet1!A1:Z100" --plain > data.tsv
6. サンドボックス実行(エージェント用)
gog --enable-commands calendar,tasks calendar events --today
export GOG_ENABLE_COMMANDS=gmail,drive
gog gmail threads
gog calendar events
7. CI/CD パイプラインでの使用
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. マルチアカウント切り替え
gog auth alias set work work@company.com
gog auth alias set personal personal@gmail.com
gog --account work gmail threads
gog --account personal gmail threads
GOG_ACCOUNT=work gog calendar events --today
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
| 症状 | 原因 | 対策 |
|---|
token has been expired or revoked | リフレッシュトークン失効 | gog auth add <email> で再認証 |
insufficient permission / 403 | スコープ不足 | gog auth add <email> --services <svc> --force-consent |
| コマンドがブロックされる | --enable-commands 制限 | 環境変数 GOG_ENABLE_COMMANDS を確認 |
| キーリングエラー | バックエンド問題 | gog auth keyring auto でリセット |
| タイムゾーンが違う | 未設定 | gog config set default_timezone "Asia/Tokyo" |
| サービスアカウントエラー | 委任未設定 | Workspace 管理コンソールでスコープを許可 |
詳細なトラブルシューティングは references/troubleshooting.md を参照。
Resources
このスキルには以下のリファレンスが含まれます:
| ファイル | 内容 |
|---|
references/quick_reference.md | 全13サービスのコマンドチートシート |
references/communication_services.md | Gmail/Calendar/Chat の詳細ガイド |
references/productivity_services.md | Drive/Sheets/Docs/Slides/Tasks/Keep の詳細ガイド |
references/workspace_admin_services.md | Groups/Classroom/People + サービスアカウント詳細 |
references/troubleshooting.md | トラブルシューティング詳細ガイド |
公式リポジトリ: https://github.com/steipete/gogcli