npx skills add ...
npx skills add jezweb/claude-skills --skill google-apps-script
Build Google Apps Script automation for Sheets and Workspace. Custom menus, triggers (onEdit / time-driven / form submit), dialogs, sidebars, email batches, PDF export, external API. Use whenever the user wants to automate a Google Sheet, build a Sheets menu / sidebar / dialog, hit a Sheets row from email or a webhook, schedule a Sheets workflow, or asks 'how do I script this in Sheets'.
npx skills add jezweb/claude-skills --skill google-apps-script
Build automation scripts for Google Sheets and Workspace apps. Scripts run server-side on Google's infrastructure with a generous free tier.
Ask what the user wants automated. Common scenarios:
Follow the structure template below. Every script needs a header comment, configuration constants at top, and onOpen() for menu setup.
All scripts install the same way:
Each user gets a Google OAuth consent screen on first run. For unverified scripts (most internal scripts), users must click:
Advanced > Go to [Project Name] (unsafe) > Allow
This is a one-time step per user. Warn users about this in your output.
Every script should follow this pattern:
Functions ending with _ (underscore) are private and CANNOT be called from client-side HTML via google.script.run. This is a silent failure -- the call simply doesn't work with no error.
Also applies to: Menu item function references must be public function names as strings.
Read/write data in bulk, never cell-by-cell. The difference is 70x.
Always use getRange().getValues() / setValues() for bulk reads/writes.
V8 is the only runtime (Rhino was removed January 2026). Supports modern JavaScript: const, let, arrow functions, template literals, destructuring, classes, async/generators.
NOT available (use Apps Script alternatives):
| Missing API | Apps Script Alternative |
|---|---|
setTimeout / setInterval | Utilities.sleep(ms) (blocking) |
fetch | UrlFetchApp.fetch() |
FormData | Build payload manually |
URL | String manipulation |
crypto | Utilities.computeDigest() / Utilities.getUuid() |
Call SpreadsheetApp.flush() before returning from functions that modify the sheet, especially when called from HTML dialogs. Without it, changes may not be visible when the dialog shows "Done."
| Feature | Simple (onEdit) | Installable |
|---|---|---|
| Auth required | No | Yes |
| Send email | No | Yes |
| Access other files | No | Yes |
| URL fetch | No | Yes |
| Open dialogs | No | Yes |
| Runs as | Active user | Trigger creator |
Use simple triggers for lightweight reactions. Use installable triggers (via ScriptApp.newTrigger()) when you need email, external APIs, or cross-file access.
Functions used as =MY_FUNCTION() in cells have strict limitations:
@customfunction JSDoc tag| Resource | Free Account | Google Workspace |
|---|---|---|
| Script runtime | 6 min / execution | 6 min / execution |
| Time-driven trigger runtime | 30 min | 30 min |
| Triggers total daily runtime | 90 min | 6 hours |
| Triggers total | 20 per user per script | 20 per user per script |
| Email recipients/day | 100 | 1,500 |
| URL Fetch calls/day | 20,000 | 100,000 |
| Properties storage | 500 KB | 500 KB |
| Custom function runtime | 30 seconds | 30 seconds |
| Simultaneous executions | 30 | 30 |
Block user interaction during long operations with a spinner that auto-closes. Use for any operation taking more than a few seconds.
Pattern: menu function > showProgress() > dialog calls action function > auto-close
HTML panel on the right. Use google.script.run to call server functions.
onEdit (simple trigger) -- limited permissions but no auth needed:
Installable triggers -- create via script, run setup function once manually:
Non-obvious URL construction -- export parameters are undocumented:
Three scopes: PropertiesService.getScriptProperties() (shared), .getUserProperties() (per user), .getDocumentProperties() (per spreadsheet). All use .setProperty(key, value) / .getProperty(key). 500 KB limit.
Move rows with "Complete" status to an Archive sheet. Processes bottom-up to avoid shifting row indices.
Pattern: read column with getValues(), track seen values in an object, highlight both the original and duplicate rows with setBackground('#f4cccc'). Process all data in one getValues() call, then set backgrounds individually (unavoidable for scattered highlights).
Key pattern: check MailApp.getRemainingDailyQuota() before sending, mark status per row, wrap each send in try/catch.
Pattern: loop numbered weekly tabs (01-52), read summary cells from each, write aggregated rows into a Summary sheet. Use ss.getSheetByName(tabName) to iterate, ss.insertSheet('Summary') if it doesn't exist, summary.autoResizeColumns() at end, flush() before return.
Always wrap external calls in try/catch. Use muteHttpExceptions: true to handle HTTP errors yourself. Re-throw for dialog error handlers.
| Mistake | Fix |
|---|---|
| Dialog can't call function | Remove trailing _ from function name |
| Script is slow on large data | Use getValues()/setValues() batch operations |
| Changes not visible after dialog | Add SpreadsheetApp.flush() before return |
onEdit can't send email | Use installable trigger via ScriptApp.newTrigger() |
| Custom function times out | 30s limit -- simplify or move to regular function |
setTimeout not found | Use Utilities.sleep(ms) (blocking) |
| Script exceeds 6 min | Break into chunks, use time-driven trigger for batches |
| Auth popup doesn't appear | User must click Advanced > Go to (unsafe) > Allow |
SpreadsheetApp.flush() called before returning from modifying functionssheet.hideRows(), showRows(), isRowHiddenByUser()setBackground(), setFontWeight(), setBorder(), setNumberFormat(), conditional formattingrange.protect(), setUnprotectedRanges(), editor managementgetSheetByName(), looping numbered tabs, copyTo(), insertSheet()onEdit trigger to auto-number column A when column B is editedchat.googleapis.com with JSON payload