# ワークフロー例
Claude Codeと組み合わせた実践的なワークフロー例です。
## 1. Gmail要約 → Sheets転記
未読メールを検索し、要約をスプレッドシートに記録します。
### ステップ
```
あなた: 未読メールを5件取得して、件名と送信者をスプレッドシートに記録して
Claude:
1. gmail_search_messages で未読メールを検索
2. 各メールから件名と送信者を抽出
3. sheets_append_values でスプレッドシートに追記
```
### 必要なツール呼び出し
```javascript
// 1. メール検索
gmail_search_messages({
query: "is:unread",
maxResults: 5
})
// 2. 各メールの詳細取得
gmail_get_message({
messageId: "xxx",
format: "metadata"
})
// 3. スプレッドシートに追記
sheets_append_values({
spreadsheetId: "abc123",
range: "Sheet1!A:C",
values: [
["2024-01-15", "田中太郎", "会議の件"],
["2024-01-15", "山田花子", "資料送付"]
]
})
```
## 2. メール送信・返信
### 新規メール送信
**注意**: `GMAIL_SEND_ENABLED=true` が必要です。
```javascript
gmail_send_message({
to: ["recipient@example.com"],
subject: "会議のご案内",
body: "お疲れ様です。\n\n来週の会議についてご連絡します。\n\n日時: 1月20日 14:00\n場所: 会議室A\n\nよろしくお願いいたします。",
cc: ["cc@example.com"]
})
```
### メール返信
```javascript
// 1. 元のメールを取得
gmail_get_message({
messageId: "original-msg-id",
format: "full"
})
// 2. 返信を送信
gmail_reply_message({
messageId: "original-msg-id",
body: "ご連絡ありがとうございます。\n\n承知いたしました。",
replyAll: false // 全員に返信する場合は true
})
```
### 下書き作成
確認後に送信したい場合は下書きを作成できます:
```javascript
gmail_create_draft({
to: ["recipient@example.com"],
subject: "【確認】契約書の件",
body: "お世話になっております。\n\n契約書を添付いたします。ご確認ください。"
})
// → { id: "draft-id", message: { id: "msg-id", threadId: "..." } }
// Gmail の下書きフォルダで確認・編集・送信できます
```
## 3. 週次レポートの自動生成
カレンダーから今週の予定を取得し、Docsにレポートを作成します。
### ステップ
```
あなた: 今週のカレンダーを確認して、週次レポートのドキュメントを作成して
Claude:
1. calendar_list_events で今週の予定を取得
2. docs_create_document で新しいドキュメントを作成
3. docs_insert_text でレポート内容を挿入
4. docs_format_text で見出しを装飾
```
### 必要なツール呼び出し
```javascript
// 1. 今週のイベント取得
calendar_list_events({
timeMinISO: "2024-01-15T00:00:00+09:00",
timeMaxISO: "2024-01-21T23:59:59+09:00",
maxResults: 50
})
// 2. ドキュメント作成
docs_create_document({
title: "週次レポート 2024/01/15-21",
parentFolderId: "reports-folder-id"
})
// 3. 内容挿入
docs_insert_text({
documentId: "new-doc-id",
index: 1,
text: "週次レポート\n\n今週の予定\n- 月曜日 10:00 チームMTG\n- 水曜日 14:00 クライアント打ち合わせ\n"
})
// 4. 見出しを太字に
docs_format_text({
documentId: "new-doc-id",
startIndex: 1,
endIndex: 9,
bold: true,
fontSize: 18
})
```
## 4. ミーティングのスケジュール調整(Dry-Run)
新しいミーティングをdry-runで確認してから作成します。
### ステップ
```
あなた: 来週月曜の10時から1時間、「プロジェクトキックオフ」を設定して
Claude:
1. まずdry-runで確認
2. ユーザーの承認後に実際に作成
```
### 必要なツール呼び出し
```javascript
// 1. Dry-run で確認
calendar_create_event({
event: {
summary: "プロジェクトキックオフ",
startISO: "2024-01-22T10:00:00+09:00",
endISO: "2024-01-22T11:00:00+09:00",
location: "会議室A",
attendeesEmails: ["team@example.com"]
},
dryRun: true // デフォルトでtrue
})
// → { planned: { summary: "プロジェクトキックオフ", ... } }
// 2. ユーザー確認後、実際に作成
calendar_create_event({
event: {
summary: "プロジェクトキックオフ",
startISO: "2024-01-22T10:00:00+09:00",
endISO: "2024-01-22T11:00:00+09:00",
location: "会議室A",
attendeesEmails: ["team@example.com"]
},
dryRun: false
})
// → { created: { id: "xxx", url: "https://..." } }
```
### 空き時間の検索
会議を設定する前に参加者の空き時間を確認:
```javascript
calendar_get_free_busy({
timeMinISO: "2024-01-22T09:00:00+09:00",
timeMaxISO: "2024-01-22T18:00:00+09:00",
calendars: ["user1@example.com", "user2@example.com"]
})
// → { calendars: { "user1@example.com": { busy: [...] }, ... } }
```
## 5. Driveファイルの整理
特定のファイルを検索し、新しいフォルダに整理します。
### ファイル検索とコピー
```javascript
// 1. ファイル検索
drive_search_files({
q: "name contains '2023年度'",
pageSize: 100
})
// 2. フォルダ作成
drive_create_folder({
name: "2023年度アーカイブ",
parentFolderId: "archive-root-id"
})
// 3. 各ファイルをコピー
drive_copy_file({
fileId: "file-id-1",
parentFolderId: "new-archive-folder-id"
})
```
### ファイルのアップロード
```javascript
// Base64エンコードされた内容をアップロード
drive_upload_file({
name: "report.txt",
mimeType: "text/plain",
content: "SGVsbG8gV29ybGQh", // Base64
parentFolderId: "folder-id"
})
```
### ファイルのダウンロード
```javascript
drive_download_file({
fileId: "file-id"
})
// → { content: "Base64エンコードされた内容", mimeType: "..." }
```
### ファイルの移動
```javascript
drive_move_file({
fileId: "file-id",
newParentFolderId: "destination-folder-id"
})
```
## 6. スプレッドシートのデータ分析
データを取得し、集計結果を別シートに書き込みます。
### データ取得と書き込み
```javascript
// 1. データ取得
sheets_get_values({
spreadsheetId: "xxx",
range: "売上データ!A2:D100"
})
// 2. 結果書き込み
sheets_update_values({
spreadsheetId: "xxx",
range: "サマリー!A1:C5",
values: [
["項目", "合計", "平均"],
["売上", 1500000, 150000],
["費用", 800000, 80000],
["利益", 700000, 70000]
],
valueInputOption: "USER_ENTERED"
})
```
### 新しいシートの追加
```javascript
sheets_add_sheet({
spreadsheetId: "xxx",
title: "2024年1月集計"
})
```
### セルの書式設定
```javascript
sheets_format_cells({
spreadsheetId: "xxx",
sheetId: 0,
range: { startRowIndex: 0, endRowIndex: 1, startColumnIndex: 0, endColumnIndex: 5 },
format: {
backgroundColor: { red: 0.2, green: 0.4, blue: 0.8 },
textFormat: { bold: true, foregroundColor: { red: 1, green: 1, blue: 1 } }
}
})
```
## 7. メールのラベル整理
特定の条件のメールにラベルを付けます。
**注意**: この操作には `GMAIL_MODIFY_LABELS_ENABLED=true` が必要です。
### ラベル付与
```javascript
// 1. ラベル一覧取得
gmail_list_labels()
// → { labels: [{ id: "Label_1", name: "経理" }, ...] }
// 2. メール検索
gmail_search_messages({
query: "請求書",
maxResults: 50
})
// 3. ラベル付与
gmail_modify_labels({
messageId: "msg-id",
addLabelIds: ["Label_1"]
})
```
## 8. 添付ファイルの取得
メールの添付ファイルをダウンロードします。
```javascript
// 1. メール詳細取得(添付ファイル情報を含む)
gmail_get_message({
messageId: "msg-id",
format: "full"
})
// → { attachments: [{ attachmentId: "...", filename: "資料.pdf", mimeType: "application/pdf" }] }
// 2. 添付ファイルダウンロード
gmail_get_attachment({
messageId: "msg-id",
attachmentId: "attachment-id"
})
// → { data: "Base64エンコードされた内容", size: 12345 }
```
## 9. ドキュメントへの画像挿入
```javascript
// 1. ドキュメント作成
docs_create_document({
title: "画像付きレポート"
})
// 2. テキスト挿入
docs_insert_text({
documentId: "doc-id",
index: 1,
text: "レポートタイトル\n\n"
})
// 3. 画像挿入(URLから)
docs_insert_image({
documentId: "doc-id",
index: 20,
uri: "https://example.com/image.png",
width: 300,
height: 200
})
```
## ベストプラクティス
1. **段階的に確認**: 大量操作の前にまず少数でテスト
2. **Dry-runを活用**: Calendar操作は必ずdry-runで確認
3. **下書きを活用**: 重要なメールは下書きで確認してから送信
4. **エラーハンドリング**: 各ステップでエラーを確認
5. **ログの確認**: 実行後に `logs/` を確認