/ai-analyst-plus:google-doc-exportfrom ai-analyst-plus
Creates properly formatted Google Docs via the Google Docs/Drive connector, preventing text/image overlap, broken heading hierarchy, and inconsistent formatting. Recommends .docx conversion for complex docs or direct connector calls for simple text-only docs.
Ships in ai-analyst-plus. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Requires the Google Docs connector enabled in Cowork.
Tool discovery. Exact tool names differ by environment; never hardcode them. Discover the connector's actual tools in-session and read each tool's own schema before calling it. This skill names capabilities (upload-file-to-Drive with Google Doc conversion, create document, append text, write formatted content, insert image, upload image to Drive, read document); the discovered tool's schema is the authority on names and parameters. If a needed capability has no tool, stop and tell the user to enable the connector; never fake the export. What a given environment's wrappers accept cannot be verified from this file without a live connector, which is exactly why you discover and read schemas in-session.
Create properly formatted Google Docs through the connector. Prevents common issues: text/image overlap, broken heading hierarchy, excessive whitespace, inconsistent formatting.
Step 1: What type of document are you creating?
.docx → Google Docs workflow (Section A), building the .docx with python-docx per the Analysis Readout rulesStep 2: Choose your approach based on document type:
When: Any doc with charts, tables, or complex formatting (analysis reports, writeups)
Why: Most reliable. Avoids index calculation errors, handles images/tables automatically, always creates local backup.
How:
# 1. Build the .docx locally with python-docx (see Section A Step 1)
# 2. Upload with the connector's upload-file-to-Drive capability, conversion flag on
<upload file to drive tool>(
file_path="<path to report.docx>",
convert_to_google_doc=True
)
# 3. Done! Returns Google Doc URL
Capability needed: upload a local file to the user's Drive with a convert-to-Google-Doc option (typical shape: file path + conversion flag, returning a file ID and Doc URL). Discover the exact tool and read its schema in-session.
When: Quick text-only docs with no images/tables (meeting notes, simple memos)
Capabilities to discover on the connector:
Note: Do not assume richer editing tools exist (older docs reference things like
batch-update, paragraph-style updates, text modification, table insertion, structure
inspection, or text formatting tools); many connectors ship none of them. If the discovered
toolset lacks a capability, use the .docx → Google Docs workflow instead.
This is the easiest and most reliable approach for complex documents.
Build the .docx with python-docx (pip install python-docx if not present).
When: Creating analysis reports, findings writeups, or any document following the Analysis Readout template (Context → Summary → Analysis → Next Steps → Resources).
Apply ALL of these mechanically when writing the python-docx code:
doc.add_picture(path, width=Inches(6))), each in its own paragraph, with an italic caption paragraph below itRequirements:
outputs/ directoryreport_[title]_[YYYYMMDD].docxUse python-docx directly with a clean heading hierarchy; the readout template does not apply.
Example:
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Add title
title = doc.add_heading('Document Title', level=1)
# Add content sections...
# Add charts
doc.add_picture('/path/to/chart.png', width=Inches(6))
# Save
doc.save('outputs/report_title_20260404.docx')
CRITICAL: The local .docx file IS your backup. Do not delete it.
result = <upload file to drive tool>(
file_path=docx_path,
convert_to_google_doc=True
)
# Returns: {"file_id": "...", "url": "https://docs.google.com/document/d/..."}
(Use the connector's upload-file-to-Drive tool discovered in-session; parameter names follow its schema.)
You now have TWO deliverables (always provide both to the user):
Live Google Doc - result["url"]
Local backup - docx_path
/outputs/ directoryGoogle's .docx converter handles:
No risk of index invalidation, no image timing issues, no expiring image links.
For simple text-only documents, you can call the connector's document tools directly (discovered in-session; the shapes below are typical, the tool schemas are the authority).
# 1. Create blank doc (create-document capability)
result = <create document tool>(title="Meeting Notes")
doc_id = result["document_id"]
# 2. Add formatted content (write-formatted-content capability)
content_blocks = [
{"type": "heading1", "text": "Meeting Notes\n"},
{"type": "body", "text": "Attendees: Alice, Bob\n\n"},
{"type": "heading2", "text": "Discussion Points\n"},
{"type": "body", "text": "We reviewed the Q1 results...\n"}
]
<write formatted content tool>(
document_id=doc_id,
content_blocks=json.dumps(content_blocks)
)
Data handling: chart images go only to the user's own Google Drive through
the connector, private by default. Never upload charts or data to public file
hosts; use the Drive file reference/URL from upload_image_to_drive.
# 1. Upload image to Drive first (upload-image-to-Drive capability)
image_result = <upload image to drive tool>(
file_path="<path to chart.png>"
)
image_url = image_result["url"]
# 2. Read doc to find insertion index (read-document capability)
doc_content = <read document tool>(document_id=doc_id)
# Find the index where you want the image
# 3. Insert image with BOTH width and height (insert-image capability)
<insert image tool>(
document_id=doc_id,
image_url=image_url,
width_pts=400,
height_pts=300 # REQUIRED - calculate from aspect ratio if needed
)
Critical: Always specify BOTH width_pts and height_pts. Omitting height causes API error.
Use this structure for analysis reports:
H1: [Document Title]
[Subtitle — scope, date, author]
H2: Executive Summary
[3-5 sentence overview]
[Numbered key findings — max 3]
[Bottom line statement]
H2: Section 1: [Topic]
[Chart image — centered, 400pt wide]
[The Insight: bold label + finding]
[Supporting evidence paragraphs]
[Why this matters for product: bold label + implication]
H2: Section 2: [Topic]
... (repeat pattern)
H2: Data Quality and Limitations
[Outlier investigation]
[Sample size notes]
[Methodology caveats]
H2: Recommendations
[Numbered list of actionable recommendations]
[Each with a bold title + explanation paragraph]
H2: Appendix
[Summary statistics tables]
After H1: 2 empty paragraphs
After H2: 1 empty paragraph
Before chart: 1 empty paragraph
After chart: 1 empty paragraph
Before table: 1 empty paragraph
After table: 1 empty paragraph
Between sections: 2 empty paragraphs (includes the pre-H2 spacing)
Between paragraphs: 0 empty paragraphs (natural paragraph spacing)
After bullet list: 1 empty paragraph
After H1: 2 empty paragraphs
After H2: 1 empty paragraph
Before chart: 1 empty paragraph
After chart: 1 empty paragraph
Before table: 1 empty paragraph
After table: 1 empty paragraph
Between sections: 2 empty paragraphs
Between paragraphs: 0 empty paragraphs (natural spacing)
After bullet list: 1 empty paragraph
These phrases should always be bold when they appear at the start of a paragraph:
Standard chart: width=400, height=300 (4:3 ratio)
Wide chart: width=500, height=280 (16:9 ratio)
Square chart: width=350, height=350 (1:1 ratio)
Small inline: width=250, height=200 (for side notes)
Always specify both width and height. If only one dimension is known, calculate the other from the image's aspect ratio.
| Pitfall | What happens | Prevention |
|---|---|---|
| Use a public file-host URL | Link expires and the chart leaves the user's Drive | Upload to the user's Drive via the connector, or use .docx embed |
| Omit height in insert_image | API error: "height must be greater than 0" | Always specify both width AND height |
| Assume a tool name instead of discovering it | Tool not found error | Discover the connector's tools in-session (Section F capabilities) |
| No local backup | Doc only exists in Google's cloud | Use .docx → Google Docs conversion |
| Complex doc via API calls | Index errors, image placement failures | Use .docx conversion instead |
| Too many empty paragraphs | Excessive whitespace, unprofessional | Max 2 consecutive empty paragraphs |
| Stub headings with no body | Orphaned headings confuse readers | Only insert headings that have content beneath |
Discover the exact tool for each capability in-session; the shapes below are the typical contract, and each tool's own schema is the authority on names and parameters.
# Document operations
create document (title) → {"document_id": ...}
read document (document_id) → content
append text (document_id, text) → status
write formatted content(document_id, content_blocks) → status
# Image operations
insert image (document_id, image_url, width_pts, height_pts) → status
upload image to Drive (file_path, file_name) → {"file_id": ..., "url": ...}
# File operations (RECOMMENDED for complex docs)
upload file to Drive (file_path, convert_to_google_doc) → {"file_id": ..., "url": ...}
Capabilities you should NOT count on existing (older docs reference them; many connectors ship no such tools): document batch-update, paragraph-style updates, in-place text modification/formatting, table insertion, and document-structure inspection/debugging.
If you need these features, use the .docx → Google Docs workflow (Section A).
When creating analysis documents with findings, embed provenance data at three levels:
Every finding paragraph must include a data stamp inline, immediately after the finding title or key claim:
**Finding 1: Mobile converts at half the rate of desktop**
[50K rows | Jan-Mar 2026 | EVENTS | Confidence: B (82/100)]
Build the data stamp yourself in this exact format:
[{rows} rows | {date range} | {PRIMARY_TABLE} | Confidence: {grade} ({score}/100)]
50K; 1,200,000 → 1.2M)[50K rows | Jan-Mar 2026 | EVENTS]In the .docx workflow, render data stamps as a small italic paragraph below each finding heading. In direct connector mode, insert as body text with 9pt font and muted gray color.
For Tier 2+ analyses, add citation markers and a provenance appendix.
Two-pass approach:
Pass 1 — Build content:
For each finding, insert a citation marker [F1] after the data stamp
At the end of the document (before any existing Appendix), add:
H2: Provenance Appendix
H3: F1: Mobile converts at half the rate
**Data:** [50K rows | Jan-Mar 2026 | EVENTS | Confidence: B (82/100)]
**Methodology:** segmented comparison, COUNT by device
**SQL:**
```sql
SELECT device, COUNT(*) FROM events GROUP BY device
Cross-verification: Type B: Parts-to-whole — Verified (PASS, diff 0.2%)
H3: F2: ...
Pass 2 — Link citations (.docx workflow only):
When building the .docx, create:
H3 in the Provenance Appendix (named F1, F2, etc.)[F1] markers in the body to the corresponding bookmarkpython-docx has no high-level bookmark API: insert the w:bookmarkStart/w:bookmarkEnd
elements on the appendix headings and wrap each [F1] marker in a w:hyperlink element
with w:anchor="F1" via the paragraph's XML.
For direct connector mode, citation links are not possible (the API doesn't support internal bookmarks). Use the [F1] text markers without hyperlinks; the reader can scroll to the appendix.
For Tier 3 analyses, add a link to the analysis receipt at the bottom of the document:
H2: Analysis Receipt
Full audit trail with all queries, methodology, and reproducibility data:
→ outputs/analysis_receipt_{DATASET}_{DATE}.md
Assemble the provenance blocks yourself, one per finding, from the analysis run's own artifacts:
Render each block as the appendix entry format shown in Pass 1 above.
[F1], [F2] appear after each data stamp (Tier 2+).docx output (Tier 2+)What SKILL.md sets; muted values are Claude Code's defaults
47 skills in this plugin
/always-compareNever present a metric or number in isolation; anchor every number to a comparison (prior period, benchmark, or another segment) or state that none is available. Use every time you show a number: rates, counts, revenue, averages, query results, chart labels, summary stats. Trigger on output containing "the rate is", "we saw", "total", "average", "conversion", "revenue", "users", "sessions", "churn", "AOV", "NPS", or any figure pulled from data./analysis-designTurn a vague hunch or stakeholder request into a rigorous analysis plan via a staged pipeline (hypothesis sharpening, confound scan, V1, feedback, V2 redesign). Trigger on "I think X caused Y", "design an analysis for", "what's driving", "V2 after feedback", "stakeholder comments", "redesign the analysis". Vs question-framing (the lightweight framing gate before every analysis): use THIS only for a real hunch, confound scan, or V1 to V2 redesign./analyst-coreOperating rules for every data analysis. Apply for ANY data-analysis intent: "analyze", "investigate", "why did X change", "compare", "report on", "dashboard", "metrics", "funnel", "retention", "revenue", "conversion", "trend", "segment", "forecast", "how are we doing", "dig into", "break down", or any question about data, a metric, a CSV, or a table. Sets the method and routes to the other skills; load before any analytical question.npx claudepluginhub ai-analyst-lab/ai-analyst-plugin --plugin ai-analyst-plusOther plugins' skills for the same job