agentleFS
ai-analyst-labai-analyst-lab/ai-analyst/.claude/skills/chart-to-drive/SKILL.md

chart-to-drive

Skill304 starsChanged 2 months agoMITView on GitHub

Standardized workflow for uploading local chart PNGs to Google Drive and making them available for insertion into Google Docs and Slides. Use this skill whenever you need to insert charts into Google Docs or Google Slides, when the google-doc-creator or google-slides-creator agents need chart URLs, when building presentations or reports with embedded visualizations, when user asks to "upload charts", "add images to the doc", "put charts in slides", "make charts available for Google", or any time you have chart PNG files that need to be referenced in Google Workspace documents. One standard flow for upload, permissions, and URL construction, with no public file hosts involved. Always use this skill before calling insert_doc_image or createImage APIs — those require public Drive URLs, which this skill produces. Also use when you see errors like "image URL not accessible" or "permission denied" during doc/slide creation — those usually mean charts weren't properly uploaded to Drive first.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When building Google Docs via the python-docx → upload workflow (that embeds images in the .docx file, no Drive URLs needed)

    line 27
  2. Very specific:

    Use the Google Docs MCP upload_image_to_drive tool with the LOCAL file path.

    line 45
  3. Very specific:

    If that tool is unavailable, upload with the Drive API from Python using local credentials (files().create with MediaFileUpload), then set …

    line 56
  4. Distinctive:

    Optional: Create a "{dataset_name} - Charts" folder first and pass its ID as the parent so uploads stay organized.

    line 59
  5. Very specific:

    For Google Docs: Use drive_url (permanent, works with insert_doc_image)

    line 76
  6. Very specific:

    For Google Slides: Use drive_url (permanent, works with createImage)

    line 77
  7. Distinctive:

    Drive only, always: Never upload charts to public file hosts (tmpfiles, imgur, postimages, or similar).

    line 93
  8. Distinctive:

    Batch uploads in a single Python script: Don't make separate Bash calls per chart — one script handles all uploads efficiently.

    line 100
  9. Distinctive:

    Print the chart map: Always output the full filename → drive_id mapping so subsequent agents can reference charts by name.

    line 103
  10. Distinctive:

    Check for existing uploads: Before re-uploading, search Drive for files with the same name in the expected folder.

    line 106
  11. Distinctive:

    If the MCP upload tool fails or is missing:

    line 115
  12. Distinctive:

    If no Drive access works at all: stop, keep the charts local, tell the user which files need manual upload.

    line 118
  13. Distinctive:

    If a Drive upload returns "permission denied" or "authentication failed":

    line 121
  14. Distinctive:

    Verify Google Workspace MCP authentication status

    line 122
  15. Very specific:

    Run mcp__google-docs__authorize_google_docs() to re-authenticate

    line 123

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Chart-to-Drive Uploader

Purpose

Standardized workflow for uploading local chart PNGs to Google Drive and making them available for insertion into Google Docs and Slides. One standard flow for upload, permissions, and URL construction, with no public file hosts involved.

When to Apply

Automatically whenever:

  • Chart PNGs need to be inserted into Google Docs or Google Slides
  • The google-doc-creator or google-slides-creator agent needs chart URLs
  • User asks to "upload charts" or "add images to the doc/slides"
  • User encounters "permission denied" or "image URL not accessible" errors when building Google Workspace documents — this usually means charts weren't uploaded to Drive first

When NOT to use this skill:

  • For single-image uploads where you just need one Drive URL (use mcp__google-docs__upload_image_to_drive directly)
  • When building Google Docs via the python-docx → upload workflow (that embeds images in the .docx file, no Drive URLs needed)

Workflow

Step 1: Collect chart files

Identify all chart PNGs that need uploading. Standard location: outputs/charts/.

import os
chart_dir = "outputs/charts"
charts = [(f, os.path.join(chart_dir, f)) for f in sorted(os.listdir(chart_dir)) if f.endswith('.png')]

Step 2: Upload each chart to Drive directly

Use the Google Docs MCP upload_image_to_drive tool with the LOCAL file path. It uploads straight to the user's Drive and sets just enough link access for the Docs/Slides APIs to fetch the image. No public file host is involved at any point; never route charts through one (the analysis may contain confidential numbers).

for each (filename, filepath) in charts:
    mcp__google-docs__upload_image_to_drive(image_path=filepath)
    # Returns the Drive file ID; record it in the chart map

If that tool is unavailable, upload with the Drive API from Python using local credentials (files().create with MediaFileUpload), then set reader link access.

Optional: Create a "{dataset_name} - Charts" folder first and pass its ID as the parent so uploads stay organized.

Step 3: Build the URL map

Return a mapping of chart filename to both URL formats:

chart_map = {
    "01_height_crossover.png": {
        "drive_id": "1abc...",
        "drive_url": "https://drive.google.com/uc?id=1abc...&export=download"
    },
    ...
}

For Google Docs: Use drive_url (permanent, works with insert_doc_image) For Google Slides: Use drive_url (permanent, works with createImage)


URL Format Reference

TargetURL FormatNotes
Google Docs insert_doc_imagehttps://drive.google.com/uc?id={ID}&export=downloadMust be public
Google Slides createImagehttps://drive.google.com/uc?id={ID}&export=downloadMust be public
Direct Drive viewhttps://drive.google.com/file/d/{ID}/viewNot for API insertion

Rules

  1. Drive only, always. Never upload charts to public file hosts (tmpfiles, imgur, postimages, or similar); the user's Drive is the only image host.
  2. Set public permissions immediately. Google Docs/Slides API cannot access private Drive files. The MCP upload_image_to_drive tool automatically sets public access — no additional permission call needed.
  3. Batch uploads in a single Python script. Don't make separate Bash calls per chart — one script handles all uploads efficiently.
  4. Print the chart map. Always output the full filename → drive_id mapping so subsequent agents can reference charts by name.
  5. Check for existing uploads. Before re-uploading, search Drive for files with the same name in the expected folder. If you find existing files with matching names uploaded in the last 24 hours, reuse those Drive IDs instead of creating duplicates. Only re-upload if the file is missing or very old.

Error Recovery

If the MCP upload tool fails or is missing:

  • Upload with the Drive API from Python using local credentials (files().create + MediaFileUpload), then set reader link access.
  • If no Drive access works at all: stop, keep the charts local, tell the user which files need manual upload. Never fall back to a public file host.

If a Drive upload returns "permission denied" or "authentication failed":

  • Verify Google Workspace MCP authentication status
  • Run mcp__google-docs__authorize_google_docs() to re-authenticate
  • Retry the upload after successful auth

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.