Google Apps Script
Build Google Apps Script automation for Sheets and Workspace apps. Produces scripts with custom menus, triggers, dialogs, email automation, PDF export
Category: development Source: jezweb/claude-skills
Build Google Apps Script automation for Sheets and Workspace apps. Produces scripts with custom menus, triggers, dialogs, email automation, PDF export
Category: development Source: jezweb/claude-skillsonOpen() function for menu setup. Here’s a basic example of a script that adds a custom menu to Google Sheets: javascript /** * Custom Menu Example: Sends email with sheet summary * Author: Claude Code Skill */ const EMAIL_RECIPIENT = 'user@example.com'; function onOpen() { SpreadsheetApp.getUi() .createMenu('Automation') .addItem('Send Sheet Summary', 'sendSheetSummary') .addToUi(); } function sendSheetSummary() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const data = sheet.getDataRange().getValues(); const rowCount = data.length; const colCount = data[0].length; const body = `Sheet "${sheet.getName()}" has ${rowCount} rows and ${colCount} columns.`; MailApp.sendEmail(EMAIL_RECIPIENT, 'Sheet Summary', body); SpreadsheetApp.getUi().alert('Summary email sent.'); } 3. Install the Script - Open your Google Sheet. - Go to Extensions > Apps Script. - Delete any existing code in the editor. - Paste the generated script. - Click Save. - Close the Apps Script tab. - Reload your spreadsheet (the custom menu will appear). 4. Authorize the Script The first time you run a script that accesses sensitive data or external services, Google will prompt you to review and authorize the required permissions. ## Key Features The Claude Code skill for Google Apps Script empowers users with a wide range of features to enhance Google Workspace automation: - Custom Menus and UI Elements: Add personalized menus, dialogs, and sidebars to Google Sheets, making workflows more accessible and user-friendly. - Automated Triggers: Set up scripts to run on events such as opening a document (onOpen), editing a cell (onEdit), submitting a form, or at scheduled intervals. - Email Automation: Send automated email reports or notifications based on sheet data or workflow events. - PDF Export: Programmatically generate and distribute PDFs from sheet contents or templates. - External API Integration: Connect Google Sheets with third-party services, fetch and update data, or trigger external workflows. - Data Processing: Automate data cleaning, transformation, and analysis tasks. ## Best Practices To ensure reliability and maintainability, consider these best practices when building Apps Script automations: - Use clear naming conventions for functions and configuration constants. - Centralize configuration (such as email addresses or API keys) at the top of the script. - Leverage built-in triggers for automating routine tasks, but avoid excessive use of real-time triggers that may hit execution limits. - Test scripts in a copy of your document before deploying to production. - Add descriptive comments and documentation for each function. - Handle errors gracefully using try...catch blocks and user notifications. - Limit the scope of permissions requested by the script to only what is necessary. ## Important Notes