Manage Google Docs and Google Drive with full document operations and file management. Includes Markdown support for creating formatted documents with headings, bold, italic, lists, tables, and checkboxes. Also supports Drive operations (upload, download, share, search).
Manage Google Docs documents and Google Drive files with comprehensive operations:
Google Docs:
Google Drive:
Integration: The drive_manager.rb script shares OAuth credentials with docs_manager.rb
📚 Additional Resources:
references/integration-patterns.md for complete workflow examplesreferences/troubleshooting.md for error handling and debuggingreferences/cli-patterns.md for CLI interface design rationaleUse this skill when:
📋 Discovering Your Documents: To list or search for documents, use drive_manager.rb:
# List recent documents
scripts/drive_manager.rb search \
--query "mimeType='application/vnd.google-apps.document'" \
--max-results 50
# Search by name
scripts/drive_manager.rb search \
--query "name contains 'Report' and mimeType='application/vnd.google-apps.document'"
Read full document content:
scripts/docs_manager.rb read <document_id>
Get document structure (headings):
scripts/docs_manager.rb structure <document_id>
Output:
Create new document (plain text):
echo '{
"title": "Project Proposal",
"content": "Initial plain text content..."
}' | scripts/docs_manager.rb create
Create document from Markdown (RECOMMENDED):
echo '{
"title": "Project Proposal",
"markdown": "# Project Proposal\n\n## Overview\n\nThis is **bold** and *italic* text.\n\n- Bullet point 1\n- Bullet point 2\n\n| Column 1 | Column 2 |\n|----------|----------|\n| Data 1 | Data 2 |"
}' | scripts/docs_manager.rb create-from-markdown
Supported Markdown Features:
#, ##, ### → Google Docs HEADING_1, HEADING_2, HEADING_3**text***text*`text` → Courier New with grey background- item or * item1. item- [ ] unchecked and - [x] checked---| col1 | col2 | (with separator row)Document ID:
Insert plain text at specific position:
echo '{
"document_id": "abc123",
"text": "This text will be inserted at the beginning.\n\n",
"index": 1
}' | scripts/docs_manager.rb insert
Insert formatted Markdown (RECOMMENDED):
echo '{
"document_id": "abc123",
"markdown": "## New Section\n\nThis has **bold** and *italic* formatting.\n\n- Item 1\n- Item 2",
"index": 1
}' | scripts/docs_manager.rb insert-from-markdown
Append text to end of document:
echo '{
"document_id": "abc123",
"text": "\n\nThis text will be appended to the end."
}' | scripts/docs_manager.rb append
Index Positions:
read command to see current contentstructure command to find heading positionsappend instead of calculating indexinsert-from-markdown, omit index to append at endSimple find and replace:
echo '{
"document_id": "abc123",
"find": "old text",
"replace": "new text"
}' | scripts/docs_manager.rb replace
Case-sensitive replacement:
echo '{
"document_id": "abc123",
"find": "IMPORTANT",
"replace": "CRITICAL",
"match_case": true
}' | scripts/docs_manager.rb replace
Replace all occurrences:
Format text range (bold):
echo '{
"document_id": "abc123",
"start_index": 1,
"end_index": 20,
"bold": true
}' | scripts/docs_manager.rb format
Multiple formatting options:
echo '{
"document_id": "abc123",
"start_index": 50,
"end_index": 100,
"bold": true,
"italic": true,
"underline": true
}' | scripts/docs_manager.rb format
Formatting Options:
bold: true/falseitalic: true/falseunderline: true/falseInsert page break:
echo '{
"document_id": "abc123",
"index": 500
}' | scripts/docs_manager.rb page-break
Use Cases:
Delete text range:
echo '{
"document_id": "abc123",
"start_index": 100,
"end_index": 200
}' | scripts/docs_manager.rb delete
Clear entire document:
# Read document first to get end index
scripts/docs_manager.rb read abc123
# Then delete all content (start at 1, end at last index - 1)
echo '{
"document_id": "abc123",
"start_index": 1,
"end_index": 500
}' | scripts/docs_manager.rb delete
Insert image from URL:
echo '{
"document_id": "abc123",
"image_url": "https://storage.googleapis.com/bucket/image.png"
}' | scripts/docs_manager.rb insert-image
Insert image with specific size:
echo '{
"document_id": "abc123",
"image_url": "https://storage.googleapis.com/bucket/image.png",
"width": 400,
"height": 300
}' | scripts/docs_manager.rb insert-image
Insert image at specific position:
echo '{
"document_id": "abc123",
"image_url": "https://storage.googleapis.com/bucket/image.png",
"index": 100
}' | scripts/docs_manager.rb insert-image
Image URL Requirements:
Sizing Tips:
width: 468 (points)Insert empty table:
echo '{
"document_id": "abc123",
"rows": 3,
"cols": 4
}' | scripts/docs_manager.rb insert-table
Insert table with data:
echo '{
"document_id": "abc123",
"rows": 3,
"cols": 2,
"data": [
["Header 1", "Header 2"],
["Row 1 Col 1", "Row 1 Col 2"],
["Row 2 Col 1", "Row 2 Col 2"]
]
}' | scripts/docs_manager.rb insert-table
Insert table at specific position:
echo '{
"document_id": "abc123",
"rows": 2,
"cols": 3,
"index": 100,
"data": [["A", "B", "C"], ["1", "2", "3"]]
}' | scripts/docs_manager.rb insert-table
Note: Tables can also be created via Markdown in create-from-markdown:
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Data 1 | Data 2 | Data 3 |
scripts/docs_manager.rb read abc123
echo '{
"title": "Meeting Notes",
"content": "Attendees: John, Sarah"
}' | scripts/docs_manager.rb create
echo '{
"document_id": "abc123",
"text": "\n\n## Next Steps\n\n- Review proposals\n- Schedule follow-up"
}' | scripts/docs_manager.rb append
echo '{
"document_id": "abc123",
"find": "Q3",
"replace": "Q4"
}' | scripts/docs_manager.rb replace
echo '{
"document_id": "abc123",
"start_index": 1,
"end_index": 50,
"bold": true
}' | scripts/docs_manager.rb format
Index System:
read to see current content and plan insertionsstructure to find heading positionsFinding Positions:
Example:
"Hello World\n\nSecond paragraph"
Index 1: "H" (start)
Index 11: "\n" (first newline)
Index 13: "S" (start of "Second")
Index 29: end of document
The drive_manager.rb script provides comprehensive Google Drive file management.
# Upload a file to Drive root
scripts/drive_manager.rb upload --file ./document.pdf
# Upload to specific folder
scripts/drive_manager.rb upload --file ./diagram.excalidraw --folder-id abc123
# Upload with custom name
scripts/drive_manager.rb upload --file ./local.txt --name "Remote Name.txt"
# Download a file
scripts/drive_manager.rb download --file-id abc123 --output ./local_copy.pdf
# Export Google Doc as PDF
scripts/drive_manager.rb download --file-id abc123 --output ./doc.pdf --export-as pdf
# Export Google Sheet as CSV
scripts/drive_manager.rb download --file-id abc123 --output ./data.csv --export-as csv
# List recent files
scripts/drive_manager.rb list --max-results 20
# Search by name
scripts/drive_manager.rb search --query "name contains 'Report'"
# Search by type
scripts/drive_manager.rb search --query "mimeType='application/vnd.google-apps.document'"
# Search in folder
scripts/drive_manager.rb search --query "'folder_id' in parents"
# Combine queries
scripts/drive_manager.rb search --query "name contains '.excalidraw' and modifiedTime > '2024-01-01'"
# Share with specific user (reader)
scripts/drive_manager.rb share --file-id abc123 --email [email protected] --role reader
# Share with write access
scripts/drive_manager.rb share --file-id abc123 --email [email protected] --role writer
# Make publicly accessible (anyone with link)
scripts/drive_manager.rb share --file-id abc123 --type anyone --role reader
# Share with entire domain
scripts/drive_manager.rb share --file-id abc123 --type domain --domain example.com --role reader
# Create a folder
scripts/drive_manager.rb create-folder --name "Project Documents"
# Create folder inside another folder
scripts/drive_manager.rb create-folder --name "Diagrams" --parent-id abc123
# Move file to folder
scripts/drive_manager.rb move --file-id file123 --folder-id folder456
# Get file metadata
scripts/drive_manager.rb get-metadata --file-id abc123
# Copy a file
scripts/drive_manager.rb copy --file-id abc123 --name "Copy of Document"
# Update file content (replace)
scripts/drive_manager.rb update --file-id abc123 --file ./new_content.pdf
# Delete file (moves to trash)
scripts/drive_manager.rb delete --file-id abc123
All commands return JSON with consistent structure:
{
"status": "success",
"operation": "upload",
"file": {
"id": "1abc...",
"name": "document.pdf",
"mime_type": "application/pdf",
"web_view_link": "https://drive.google.com/file/d/1abc.../view",
"web_content_link": "https://drive.google.com/uc?id=1abc...",
"created_time": "2024-01-15T10:30:00Z",
"modified_time": "2024-01-15T10:30:00Z",
"size": 12345
}
}
# Step 1: Create document (returns document_id)
echo '{"title":"Report"}' | scripts/docs_manager.rb create
# Returns: {"document_id": "abc123"}
# Step 2: Add content
echo '{"document_id":"abc123","text":"# Report\n\nContent here"}' | scripts/docs_manager.rb insert
# Step 3: Organize in folder
scripts/drive_manager.rb move --file-id abc123 --folder-id [folder_id]
# Step 4: Share with team
scripts/drive_manager.rb share --file-id abc123 --email [email protected] --role writer
scripts/drive_manager.rb download --file-id abc123 --output ./report.pdf --export-as pdf
For creating and managing Excalidraw diagrams, see the excalidraw-diagrams skill which integrates with drive_manager.rb for:
Shared with Other Google Skills:
~/.claude/.google/client_secret.json and ~/.claude/.google/token.jsonFirst Time Setup:
Re-authorization:
scripts/docs_manager.rb
Operations:
read: View document contentstructure: Get document headings and structureinsert: Insert plain text at specific indexinsert-from-markdown: Insert formatted markdown contentappend: Append text to endreplace: Find and replace textformat: Apply text formatting (bold, italic, underline)page-break: Insert page breakcreate: Create new document (plain text)create-from-markdown: Create document with formatted markdowndelete: Delete content rangeinsert-image: Insert inline image from URLinsert-table: Insert table with optional dataOutput Format:
status: 'success' or status: 'error'scripts/docs_manager.rb --helpreferences/docs_operations.md
references/formatting_guide.md
examples/sample_operations.md
Authentication Error:
{
"status": "error",
"code": "AUTH_ERROR",
"message": "Token refresh failed: ..."
}
Action: Guide user through re-authorization
Document Not Found:
{
"status": "error",
"code": "API_ERROR",
"message": "Document not found"
}
Action: Verify document ID, check permissions
Invalid Index:
{
"status": "error",
"code": "API_ERROR",
"message": "Invalid index position"
}
Action: Read document to verify current length, adjust index
API Error:
{
"status": "error",
"code": "API_ERROR",
"message": "Failed to update document: ..."
}
Action: Display error to user, suggest troubleshooting steps
structure command to find heading positionsappend for adding to end (simpler than calculating index)structure command to validate hierarchyRead document:
scripts/docs_manager.rb read <document_id>
Create document from Markdown (RECOMMENDED):
echo '{"title":"My Doc","markdown":"# Heading\n\nParagraph with **bold**."}' | scripts/docs_manager.rb create-from-markdown
Create document (plain text):
echo '{"title":"My Doc","content":"Initial text"}' | scripts/docs_manager.rb create
Insert formatted Markdown:
echo '{"document_id":"abc123","markdown":"## Section\n\n- Item 1\n- Item 2"}' | scripts/docs_manager.rb insert-from-markdown
Insert plain text at beginning:
echo '{"document_id":"abc123","text":"New text","index":1}' | scripts/docs_manager.rb insert
Append to end:
echo '{"document_id":"abc123","text":"Appended text"}' | scripts/docs_manager.rb append
Find and replace:
echo '{"document_id":"abc123","find":"old","replace":"new"}' | scripts/docs_manager.rb replace
Format text:
echo '{"document_id":"abc123","start_index":1,"end_index":50,"bold":true}' | scripts/docs_manager.rb format
Get document structure:
scripts/docs_manager.rb structure <document_id>
Insert table:
echo '{"document_id":"abc123","rows":3,"cols":2,"data":[["A","B"],["1","2"],["3","4"]]}' | scripts/docs_manager.rb insert-table
Insert image from URL:
echo '{"document_id":"abc123","image_url":"https://example.com/image.png"}' | scripts/docs_manager.rb insert-image
Create document with formatted content:
echo '{
"title": "Q4 Report",
"markdown": "# Q4 Report\n\n## Executive Summary\n\nRevenue increased **25%** over Q3 targets.\n\n## Key Metrics\n\n| Metric | Q3 | Q4 |\n|--------|-----|-----|\n| Revenue | $1M | $1.25M |\n| Users | 10K | 15K |\n\n## Next Steps\n\n- [ ] Finalize budget\n- [ ] Schedule review meeting\n- [x] Complete analysis"
}' | scripts/docs_manager.rb create-from-markdown
# Returns: {"document_id": "abc123"}
Add more content later:
echo '{
"document_id": "abc123",
"markdown": "\n\n## Appendix\n\nAdditional *details* and **notes** here."
}' | scripts/docs_manager.rb insert-from-markdown
Replace text if needed:
echo '{
"document_id": "abc123",
"find": "Q3",
"replace": "Q4"
}' | scripts/docs_manager.rb replace
Share with team:
scripts/drive_manager.rb share --file-id abc123 --email [email protected] --role writer
create-from-markdown, insert-from-markdown, insert-table commands. Supports headings, bold, italic, code, lists, checkboxes, tables, and horizontal rules.Dependencies: Ruby with google-apis-docs_v1, google-apis-drive_v3, googleauth gems (shared with other Google skills)