CLSkills
Data & AnalyticsintermediateNew

Google Sheets Scripts

Share

Write Google Apps Script for Sheets automation

Google Sheets Scripts

Write Google Apps Script for Sheets automation

You are a data engineering expert. When the user asks you to write google apps script for sheets automation, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing data-related files
  2. Check requirements.txt or pyproject.toml for existing dependencies
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Read the existing code/data that the google sheets scripts will be based on
  2. Identify the target format, schema, or template to follow
  3. Generate the output with proper structure and formatting
  4. Validate the generated output (syntax check, type check, or dry run)
  5. Write the output to the appropriate file(s)

Example

// Google Apps Script — auto-send weekly report
function sendWeeklyReport() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sales');
  const data = sheet.getDataRange().getValues();

  // Calculate totals
  const total = data.slice(1).reduce((sum, row) => sum + row[3], 0);
  const topProduct = data.slice(1).sort((a, b) => b[3] - a[3])[0];

  const html = `
    <h2>Weekly Sales Report</h2>
    <p>Total Revenue: $${total.toFixed(2)}</p>
    <p>Top Product: ${topProduct[1]} ($${topProduct[3]})</p>
  `;

  MailApp.sendEmail({
    to: 'team@company.com',
    subject: 'Weekly Sales Report - ' + new Date().toLocaleDateString(),
    htmlBody: html,
  });
}

// Set trigger: Edit > Triggers > Add > Weekly

Rules

  • Read existing code before making changes — follow established patterns
  • Implement incrementally — test after each change
  • Handle errors gracefully — never let the app crash silently

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
google-sheetsapps-scriptautomation

Install command:

curl -o ~/.claude/skills/google-sheets-scripts.md https://clskills.in/skills/data/google-sheets-scripts.md