Skip to content

Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.

refactor: inline critical references into google-apps-script SKILL.md

Marcus Webbb8d4a7903f3b
diff --git a/plugins/integrations/skills/google-apps-script/SKILL.md b/plugins/integrations/skills/google-apps-script/SKILL.md
index fe489952..ed855b57 100644
--- a/plugins/integrations/skills/google-apps-script/SKILL.md
+++ b/plugins/integrations/skills/google-apps-script/SKILL.md
@@ -90,7 +90,7 @@ function myFunction() {
### Public vs Private Functions
-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.
+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.
```javascript
// WRONG - dialog can't call this, fails silently
@@ -176,65 +176,64 @@ function MY_FUNCTION(input) {
---
+## Quotas and Limits
+
+| 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 |
+
+---
+
## Modal Progress Dialog
-Block user interaction during long operations with a spinner that auto-closes. This is the recommended pattern for any operation taking more than a few seconds.
+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**
```javascript
function showProgress(message, serverFn) {
const html = HtmlService.createHtmlOutput(`
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- body {
- font-family: 'Google Sans', Arial, sans-serif;
- display: flex; flex-direction: column;
- align-items: center; justify-content: center;
- height: 100%; margin: 0; padding: 20px;
- box-sizing: border-box;
- }
- .spinner {
- width: 36px; height: 36px;
- border: 4px solid #e0e0e0;
- border-top: 4px solid #1a73e8;
- border-radius: 50%;
- animation: spin 0.8s linear infinite;
- margin-bottom: 16px;
- }
- @keyframes spin { to { transform: rotate(360deg); } }
- .message { font-size: 14px; color: #333; text-align: center; }
- .done { color: #1e8e3e; font-weight: 500; }
- .error { color: #d93025; font-weight: 500; }
- </style>
- </head>
- <body>
- <div class="spinner" id="spinner"></div>
- <div class="message" id="msg">${message}</div>
- <script>
- google.script.run
- .withSuccessHandler(function(result) {
- document.getElementById('spinner').style.display = 'none';
- var m = document.getElementById('msg');
- m.className = 'message done';
- m.innerText = 'Done! ' + (result || '');
- setTimeout(function() { google.script.host.close(); }, 1200);
- })
- .withFailureHandler(function(err) {
- document.getElementById('spinner').style.display = 'none';
- var m = document.getElementById('msg');
- m.className = 'message error';
- m.innerText = 'Error: ' + err.message;
- setTimeout(function() { google.script.host.close(); }, 3000);
- })
- .${serverFn}();
- </script>
- </body>
- </html>
+ <style>
+ body { font-family: 'Google Sans', Arial, sans-serif; display: flex;
+ flex-direction: column; align-items: center; justify-content: center;
+ height: 100%; margin: 0; padding: 20px; box-sizing: border-box; }
+ .spinner { width: 36px; height: 36px; border: 4px solid #e0e0e0;
+ border-top: 4px solid #1a73e8; border-radius: 50%;
+ animation: spin 0.8s linear infinite; margin-bottom: 16px; }
+ @keyframes spin { to { transform: rotate(360deg); } }
+ .message { font-size: 14px; color: #333; text-align: center; }
+ .done { color: #1e8e3e; font-weight: 500; }
+ .error { color: #d93025; font-weight: 500; }
+ </style>
+ <div class="spinner" id="spinner"></div>
+ <div class="message" id="msg">${message}</div>
+ <script>
+ google.script.run
+ .withSuccessHandler(function(r) {
+ document.getElementById('spinner').style.display = 'none';
+ var m = document.getElementById('msg');
+ m.className = 'message done';
+ m.innerText = 'Done! ' + (r || '');
+ setTimeout(function() { google.script.host.close(); }, 1200);
+ })
+ .withFailureHandler(function(err) {
+ document.getElementById('spinner').style.display = 'none';
+ var m = document.getElementById('msg');
+ m.className = 'message error';
+ m.innerText = 'Error: ' + err.message;
+ setTimeout(function() { google.script.host.close(); }, 3000);
+ })
+ .${serverFn}();
+ </script>
`).setWidth(320).setHeight(140);
-
SpreadsheetApp.getUi().showModalDialog(html, 'Working...');
}
@@ -253,9 +252,232 @@ function doTheWork() {
---
+## Common Patterns
+
+### Toast Notifications
+
+```javascript
+SpreadsheetApp.getActiveSpreadsheet().toast('Operation complete!', 'Title', 5);
+// Arguments: message, title, duration in seconds (-1 = until dismissed)
+```
+
+### Alert and Prompt Dialogs
+
+```javascript
+const ui = SpreadsheetApp.getUi();
+
+// Yes/No confirmation
+const response = ui.alert('Delete this data?', 'This cannot be undone.',
+ ui.ButtonSet.YES_NO);
+if (response === ui.Button.YES) { /* proceed */ }
+
+// Prompt for input
+const result = ui.prompt('Enter your name:', ui.ButtonSet.OK_CANCEL);
+if (result.getSelectedButton() === ui.Button.OK) {
+ const name = result.getResponseText();
+}
+```
+
+### Sidebar Apps
+
+HTML panel on the right. Use `google.script.run` to call server functions.
+
+```javascript
+function showSidebar() {
+ const html = HtmlService.createHtmlOutput(`
+ <h3>Quick Entry</h3>
+ <select id="worker"><option>Craig</option><option>Steve</option></select>
+ <input id="suburb" placeholder="Suburb">
+ <button onclick="submit()">Add Job</button>
+ <script>
+ function submit() {
+ google.script.run.withSuccessHandler(function() { alert('Added!'); })
+ .addJob(document.getElementById('worker').value,
+ document.getElementById('suburb').value);
+ }
+ </script>
+ `).setTitle('Job Entry').setWidth(300);
+ SpreadsheetApp.getUi().showSidebar(html);
+}
+
+function addJob(worker, suburb) { // MUST be public (no underscore)
+ SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().appendRow([new Date(), worker, suburb]);
+}
+```
+
+### Triggers
+
+**onEdit (simple trigger)** -- limited permissions but no auth needed:
+
+```javascript
+function onEdit(e) {
+ const sheet = e.source.getActiveSheet();
+ if (sheet.getName() !== 'Data') return;
+ if (e.range.getColumn() !== 3) return;
+ // Auto-timestamp when column C is edited
+ sheet.getRange(e.range.getRow(), 4).setValue(new Date());
+}
+```
+
+**Installable triggers** -- create via script, run setup function once manually:
+
+```javascript
+function createTriggers() {
+ // Time-driven: run every day at 8am
+ ScriptApp.newTrigger('dailyReport')
+ .timeBased().atHour(8).everyDays(1).create();
+
+ // On edit with full permissions (can send email, fetch URLs)
+ ScriptApp.newTrigger('onEditFull')
+ .forSpreadsheet(SpreadsheetApp.getActive()).onEdit().create();
+
+ // On form submit
+ ScriptApp.newTrigger('onFormSubmit')
+ .forSpreadsheet(SpreadsheetApp.getActive()).onFormSubmit().create();
+}
+```
+
+### Email from Sheets
+
+```javascript
+function emailWeeklySchedule() {
+ const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
+ const data = sheet.getRange('A2:E10').getDisplayValues();
+ let body = '<h2>Weekly Schedule</h2><table border="1" cellpadding="8">';
+ body += '<tr><th>Job</th><th>Suburb</th><th>Time</th><th>Price</th></tr>';
+ for (const row of data) {
+ if (row[0]) body += '<tr>' + row.map(c => '<td>' + c + '</td>').join('') + '</tr>';
+ }
+ body += '</table>';
+ MailApp.sendEmail({ to: '[email protected]',
+ subject: 'Schedule - Week ' + sheet.getName(), htmlBody: body });
+}
+```
+
+### PDF Export
+
+Non-obvious URL construction -- export parameters are undocumented:
+
+```javascript
+function exportSheetAsPdf() {
+ const ss = SpreadsheetApp.getActiveSpreadsheet();
+ const url = ss.getUrl().replace(/\/edit.*$/, '')
+ + '/export?exportFormat=pdf&format=pdf&size=A4&portrait=true'
+ + '&fitw=true&sheetnames=false&printtitle=false&gridlines=false'
+ + '&gid=' + ss.getActiveSheet().getSheetId();
+ const blob = UrlFetchApp.fetch(url, {
+ headers: { 'Authorization': 'Bearer ' + ScriptApp.getOAuthToken() }
+ }).getBlob().setName('report.pdf');
+ MailApp.sendEmail({ to: '[email protected]', subject: 'Weekly Report PDF',
+ body: 'Attached.', attachments: [blob] });
+}
+```
+
+### External API Calls
+
+```javascript
+// GET
+function fetchData() {
+ const r = UrlFetchApp.fetch('https://api.example.com/data', {
+ headers: { 'Authorization': 'Bearer ' + getApiKey() } });
+ return JSON.parse(r.getContentText());
+}
+
+// POST (muteHttpExceptions to handle errors yourself)
+function postData(payload) {
+ const r = UrlFetchApp.fetch('https://api.example.com/submit', {
+ method: 'post', contentType: 'application/json',
+ payload: JSON.stringify(payload), muteHttpExceptions: true });
+ if (r.getResponseCode() !== 200) throw new Error('API error: ' + r.getContentText());
+ return JSON.parse(r.getContentText());
+}
+```
+
+### Data Validation Dropdowns
+
+```javascript
+// Dropdown from list
+const rule = SpreadsheetApp.newDataValidation()
+ .requireValueInList(['Option A', 'Option B', 'Option C'], true)
+ .setAllowInvalid(false).setHelpText('Select an option').build();
+sheet.getRange('C3:C50').setDataValidation(rule);
+
+// Dropdown from range (e.g. a Lookups sheet)
+const rule2 = SpreadsheetApp.newDataValidation()
+ .requireValueInRange(ss.getSheetByName('Lookups').getRange('A1:A100')).build();
+sheet.getRange('B3:B50').setDataValidation(rule2);
+```
+
+### Properties Service (Persistent Storage)
+
+Three scopes: `PropertiesService.getScriptProperties()` (shared), `.getUserProperties()` (per user), `.getDocumentProperties()` (per spreadsheet). All use `.setProperty(key, value)` / `.getProperty(key)`. 500 KB limit.
+
+---
+
+## Recipes
+
+### Auto-Archive Completed Rows
+
+Move rows with "Complete" status to an Archive sheet. Processes bottom-up to avoid shifting row indices.
+
+```javascript
+function archiveCompleted() {
+ const ss = SpreadsheetApp.getActiveSpreadsheet();
+ const source = ss.getSheetByName('Active');
+ const archive = ss.getSheetByName('Archive');
+ const data = source.getDataRange().getValues();
+ const statusCol = 4; // column E (0-indexed)
+
+ for (let i = data.length - 1; i >= 1; i--) {
+ if (data[i][statusCol] === 'Complete') {
+ archive.appendRow(data[i]);
+ source.deleteRow(i + 1); // +1 for 1-indexed rows
+ }
+ }
+ SpreadsheetApp.flush();
+}
+```
+
+### Duplicate Detection and Highlighting
+
+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).
+
+### Batch Email Sender
+
+Key pattern: check `MailApp.getRemainingDailyQuota()` before sending, mark status per row, wrap each send in try/catch.
+
+```javascript
+function sendBatchEmails() {
+ const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Recipients');
+ const data = sheet.getRange('A2:C' + sheet.getLastRow()).getValues(); // Email, Name, Status
+ const remaining = MailApp.getRemainingDailyQuota();
+ if (remaining < data.length) {
+ SpreadsheetApp.getUi().alert('Only ' + remaining + ' emails left. Need ' + data.length);
+ return;
+ }
+ let sent = 0;
+ for (let i = 0; i < data.length; i++) {
+ const [email, name, status] = data[i];
+ if (!email || status === 'Sent') continue;
+ try {
+ MailApp.sendEmail({ to: email, subject: 'Your Weekly Update',
+ htmlBody: '<p>Hi ' + name + ',</p><p>Here is your update...</p>' });
+ sheet.getRange(i + 2, 3).setValue('Sent'); sent++;
+ } catch (e) { sheet.getRange(i + 2, 3).setValue('Error: ' + e.message); }
+ }
+ SpreadsheetApp.flush();
+}
+```
+
+### Summary Dashboard Generator
+
+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.
+
+---
+
## Error Handling
-Always wrap external calls in try/catch. Return meaningful messages to dialogs.
+Always wrap external calls in try/catch. Use `muteHttpExceptions: true` to handle HTTP errors yourself. Re-throw for dialog error handlers.
```javascript
function fetchExternalData() {
@@ -264,14 +486,10 @@ function fetchExternalData() {
headers: { 'Authorization': 'Bearer ' + getApiKey() },
muteHttpExceptions: true
});
- if (response.getResponseCode() !== 200) {
+ if (response.getResponseCode() !== 200)
throw new Error('API returned ' + response.getResponseCode());
- }
return JSON.parse(response.getContentText());
- } catch (e) {
- Logger.log('Error: ' + e.message);
- throw e; // re-throw for dialog error handler
- }
+ } catch (e) { Logger.log('Error: ' + e.message); throw e; }
}
```
@@ -285,24 +503,41 @@ function fetchExternalData() {
| 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 |
+| 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 |
-## Common Pattern Index
+## Debugging
+
+- **Logger.log()** / **console.log()** -- View > Execution Log in Apps Script editor
+- **Run manually** -- select function in editor dropdown > Run
+- **Executions tab** -- shows all recent runs with errors and stack traces
+- **Trigger failures** -- script.google.com > My Projects > Executions
+- **Always test on a copy** of the sheet before deploying
+
+## Deployment Checklist
-See `references/patterns.md` for complete code examples:
+- [ ] All functions called from HTML dialogs are public (no trailing underscore)
+- [ ] `SpreadsheetApp.flush()` called before returning from modifying functions
+- [ ] Error handling (try/catch) around external API calls and MailApp
+- [ ] Configuration constants at the top of the file
+- [ ] Header comment with install instructions
+- [ ] Tested on a copy of the sheet
+- [ ] Considered multi-user behaviour (different permissions, different active sheet)
+- [ ] Long operations use modal progress dialogs
+- [ ] No hardcoded sheet names -- use configuration constants
+- [ ] Checked email quota before batch sends
+
+---
-| Pattern | When to Use |
-|---------|-------------|
-| Custom menus | Adding actions to the spreadsheet toolbar |
-| Sidebar apps | Forms and data entry panels |
-| Triggers | Automated reactions to edits, time, or form submissions |
-| Email from sheets | Sending reports, notifications, schedules |
-| PDF export | Generating and emailing sheet as PDF |
-| Data validation | Creating dropdowns from lists or ranges |
+## Optional Patterns (not inlined)
-See `references/recipes.md` for complete automation recipes (archive rows, highlight duplicates, auto-number, dashboards).
+Omitted to keep this file focused. Reconstruct from Apps Script docs if needed:
-See `references/quotas.md` for execution limits, email quotas, and debugging tips.
+- **Row/Column show/hide** -- `sheet.hideRows()`, `showRows()`, `isRowHiddenByUser()`
+- **Formatting** -- `setBackground()`, `setFontWeight()`, `setBorder()`, `setNumberFormat()`, conditional formatting
+- **Data protection** -- `range.protect()`, `setUnprotectedRanges()`, editor management
+- **Multiple sheets** -- `getSheetByName()`, looping numbered tabs, `copyTo()`, `insertSheet()`
+- **Auto-numbering rows** -- `onEdit` trigger to auto-number column A when column B is edited
+- **Google Chat webhooks** -- POST to `chat.googleapis.com` with JSON payload
diff --git a/plugins/integrations/skills/google-apps-script/references/patterns.md b/plugins/integrations/skills/google-apps-script/references/patterns.md
deleted file mode 100644
index b8038997..00000000
--- a/plugins/integrations/skills/google-apps-script/references/patterns.md
+++ /dev/null
@@ -1,361 +0,0 @@
-# Common Patterns
-
-Code examples for Google Apps Script patterns. Load when a specific pattern is needed.
-
-## Custom Menus
-
-```javascript
-function onOpen() {
- const ui = SpreadsheetApp.getUi();
- ui.createMenu('Reports')
- .addItem('Generate Weekly Report', 'generateReport')
- .addItem('Email Report to Team', 'emailReport')
- .addSeparator()
- .addSubMenu(ui.createMenu('Settings')
- .addItem('Configure Recipients', 'configureRecipients'))
- .addToUi();
-}
-```
-
-- `onOpen()` runs every time the sheet is opened/refreshed
-- Menu items reference function names as strings — must be public (no underscore)
-- Emojis work in menu titles
-- Each menu item requires a unique, named, public function
-
-## Toast Notifications
-
-Quick, non-blocking messages:
-
-```javascript
-SpreadsheetApp.getActiveSpreadsheet().toast('Operation complete!', 'Title', 5);
-// Arguments: message, title, duration in seconds (-1 = until dismissed)
-```
-
-## Alert Dialogs
-
-```javascript
-const ui = SpreadsheetApp.getUi();
-
-// Simple alert
-ui.alert('Operation complete!');
-
-// Yes/No confirmation
-const response = ui.alert('Delete this data?', 'This cannot be undone.',
- ui.ButtonSet.YES_NO);
-if (response === ui.Button.YES) {
- // proceed
-}
-
-// Prompt for input
-const result = ui.prompt('Enter your name:', ui.ButtonSet.OK_CANCEL);
-if (result.getSelectedButton() === ui.Button.OK) {
- const name = result.getResponseText();
-}
-```
-
-## Sidebar Apps
-
-HTML panel on the right side of the sheet. Use `google.script.run` to call server functions.
-
-```javascript
-function showSidebar() {
- const html = HtmlService.createHtmlOutput(`
- <h3>Quick Entry</h3>
- <select id="worker">
- <option>Craig</option>
- <option>Steve</option>
- </select>
- <input id="suburb" placeholder="Suburb">
- <button onclick="submit()">Add Job</button>
- <script>
- function submit() {
- const worker = document.getElementById('worker').value;
- const suburb = document.getElementById('suburb').value;
- google.script.run
- .withSuccessHandler(function() { alert('Added!'); })
- .addJob(worker, suburb);
- }
- </script>
- `)
- .setTitle('Job Entry')
- .setWidth(300);
-
- SpreadsheetApp.getUi().showSidebar(html);
-}
-
-// MUST be public (no underscore) for sidebar to call it
-function addJob(worker, suburb) {
- const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
- sheet.appendRow([new Date(), worker, suburb]);
-}
-```
-
-## Triggers
-
-### onEdit (Simple Trigger)
-
-Limited permissions but no auth needed:
-
-```javascript
-function onEdit(e) {
- const sheet = e.source.getActiveSheet();
- const range = e.range;
-
- // Only act on specific sheet
- if (sheet.getName() !== 'Data') return;
-
- // Only act on specific column (C = 3)
- if (range.getColumn() !== 3) return;
-
- // Auto-timestamp when column C is edited
- sheet.getRange(range.getRow(), 4).setValue(new Date());
-}
-```
-
-### Installable Triggers (Full Permissions)
-
-Create via script — run the setup function once manually:
-
-```javascript
-function createTriggers() {
- // Time-driven: run every day at 8am
- ScriptApp.newTrigger('dailyReport')
- .timeBased()
- .atHour(8)
- .everyDays(1)
- .create();
-
- // On edit with full permissions (can send email, fetch URLs)
- ScriptApp.newTrigger('onEditFull')
- .forSpreadsheet(SpreadsheetApp.getActive())
- .onEdit()
- .create();
-
- // On form submit
- ScriptApp.newTrigger('onFormSubmit')
- .forSpreadsheet(SpreadsheetApp.getActive())
- .onFormSubmit()
- .create();
-}
-```
-
-## Email from Sheets
-
-```javascript
-function emailWeeklySchedule() {
- const ss = SpreadsheetApp.getActiveSpreadsheet();
- const sheet = ss.getActiveSheet();
-
- // Build HTML email body from sheet data
- const data = sheet.getRange('A2:E10').getDisplayValues();
- let body = '<h2>Weekly Schedule</h2><table border="1" cellpadding="8">';
- body += '<tr><th>Job</th><th>Suburb</th><th>Time</th><th>Price</th></tr>';
-
- for (const row of data) {
- if (row[0]) { // skip empty rows
- body += '<tr>' + row.map(cell => '<td>' + cell + '</td>').join('') + '</tr>';
- }
- }
- body += '</table>';
-
- MailApp.sendEmail({
- subject: 'Your Schedule - Week ' + sheet.getName(),
- htmlBody: body
- });
-}
-
-// Check remaining email quota
-function checkQuota() {
- const remaining = MailApp.getRemainingDailyQuota();
- Logger.log('Emails remaining today: ' + remaining);
-}
-```
-
-## PDF Export
-
-Non-obvious URL construction — the export parameters are undocumented:
-
-```javascript
-function exportSheetAsPdf() {
- const ss = SpreadsheetApp.getActiveSpreadsheet();
- const sheet = ss.getActiveSheet();
-
- const url = ss.getUrl()
- .replace(/\/edit.*$/, '')
- + '/export?exportFormat=pdf'
- + '&format=pdf'
- + '&size=A4'
- + '&portrait=true'
- + '&fitw=true' // fit to width
- + '&sheetnames=false'
- + '&printtitle=false'
- + '&gridlines=false'
- + '&gid=' + sheet.getSheetId();
-
- const token = ScriptApp.getOAuthToken();
- const response = UrlFetchApp.fetch(url, {
- headers: { 'Authorization': 'Bearer ' + token }
- });
-
- // Email as attachment
- MailApp.sendEmail({
- subject: 'Weekly Report PDF',
- body: 'Please find attached the weekly report.',
- attachments: [response.getBlob().setName('report.pdf')]
- });
-}
-```
-
-## Row/Column Show/Hide
-
-```javascript
-sheet.hideRows(startRow, numRows);
-sheet.showRows(startRow, numRows);
-const isHidden = sheet.isRowHiddenByUser(rowNumber);
-
-// Same for columns
-sheet.hideColumns(startCol, numCols);
-sheet.showColumns(startCol, numCols);
-```
-
-## Formatting and Colours
-
-```javascript
-// Background and text colour
-sheet.getRange('A1:Z1').setBackground('#9fc5e8');
-sheet.getRange('A1').setFontColor('#ffffff');
-
-// Font styles
-sheet.getRange('A1:D1').setFontWeight('bold');
-sheet.getRange('A1:D1').setFontSize(12);
-
-// Borders
-sheet.getRange('A1:D10').setBorder(true, true, true, true, true, true);
-
-// Number format
-sheet.getRange('D2:D100').setNumberFormat('$#,##0.00');
-
-// Alignment and merge
-sheet.getRange('A1:D1').setHorizontalAlignment('center');
-sheet.getRange('A1:D1').merge();
-
-// Conditional formatting
-const rule = SpreadsheetApp.newConditionalFormatRule()
- .whenNumberGreaterThan(1000)
- .setBackground('#b6d7a8')
- .setRanges([sheet.getRange('D2:D100')])
- .build();
-sheet.setConditionalFormatRules([rule]);
-```
-
-## Data Protection
-
-```javascript
-// Protect a range
-const protection = sheet.getRange('A1:D10')
- .protect()
- .setDescription('Header row - do not edit');
-
-// Allow specific editors
-protection.addEditor('[email protected]');
-protection.removeEditors(protection.getEditors());
-
-// Protect entire sheet, unprotect specific ranges
-const sheetProtection = sheet.protect().setDescription('Protected Sheet');
-sheetProtection.setUnprotectedRanges([
- sheet.getRange('B3:B50'),
- sheet.getRange('C3:C50')
-]);
-```
-
-## Data Validation Dropdowns
-
-```javascript
-// Dropdown from list
-const rule = SpreadsheetApp.newDataValidation()
- .requireValueInList(['Option A', 'Option B', 'Option C'], true)
- .setAllowInvalid(false)
- .setHelpText('Select an option')
- .build();
-sheet.getRange('C3:C50').setDataValidation(rule);
-
-// Dropdown from range
-const rule2 = SpreadsheetApp.newDataValidation()
- .requireValueInRange(ss.getSheetByName('Lookups').getRange('A1:A100'))
- .build();
-sheet.getRange('B3:B50').setDataValidation(rule2);
-```
-
-## Properties Service (Persistent Storage)
-
-```javascript
-// Script-level (shared by all users)
-const scriptProps = PropertiesService.getScriptProperties();
-scriptProps.setProperty('lastRun', new Date().toISOString());
-const lastRun = scriptProps.getProperty('lastRun');
-
-// User-level (per user)
-const userProps = PropertiesService.getUserProperties();
-
-// Document-level (per spreadsheet)
-const docProps = PropertiesService.getDocumentProperties();
-```
-
-## Working with Multiple Sheets
-
-```javascript
-// Get specific sheet by name
-const sheet = ss.getSheetByName('Week 01');
-
-// Loop through numbered tabs
-for (let i = 1; i <= 52; i++) {
- const tabName = String(i).padStart(2, '0');
- const sheet = ss.getSheetByName(tabName);
- if (sheet) {
- // process each tab
- }
-}
-
-// Copy and create sheets
-const newSheet = sheet.copyTo(ss);
-newSheet.setName('New Sheet Name');
-const created = ss.insertSheet('My New Tab');
-```
-
-## External API Calls
-
-```javascript
-// GET request
-function fetchData() {
- const response = UrlFetchApp.fetch('https://api.example.com/data', {
- headers: { 'Authorization': 'Bearer ' + getApiKey() }
- });
- return JSON.parse(response.getContentText());
-}
-
-// POST request
-function postData(payload) {
- const response = UrlFetchApp.fetch('https://api.example.com/submit', {
- method: 'post',
- contentType: 'application/json',
- payload: JSON.stringify(payload),
- muteHttpExceptions: true // don't throw on 4xx/5xx
- });
-
- if (response.getResponseCode() !== 200) {
- throw new Error('API error: ' + response.getContentText());
- }
- return JSON.parse(response.getContentText());
-}
-
-// Post to Google Chat webhook
-function notifyChat(message) {
- UrlFetchApp.fetch('https://chat.googleapis.com/v1/spaces/XXX/messages?key=YYY', {
- method: 'post',
- contentType: 'application/json',
- payload: JSON.stringify({ text: message })
- });
-}
-```
diff --git a/plugins/integrations/skills/google-apps-script/references/quotas.md b/plugins/integrations/skills/google-apps-script/references/quotas.md
deleted file mode 100644
index f6678e3a..00000000
--- a/plugins/integrations/skills/google-apps-script/references/quotas.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Quotas, Limits, and Debugging
-
-## Quotas
-
-| 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 |
-| Calendar events created/day | 5,000 | 10,000 |
-| Spreadsheets created/day | 250 | 250 |
-
-## Debugging
-
-- **Logger.log()** / **console.log()** — view in Apps Script editor: View > Execution Log
-- **Run manually** — select function in editor dropdown > click Run
-- **Executions tab** — in Apps Script editor, shows all recent runs with errors and stack traces
-- **Trigger failures** — check at script.google.com > My Projects > select project > Executions
-- **Test on a copy** — always test scripts on a copy of the sheet before deploying
-
-## Deployment Checklist
-
-Before deploying to end users:
-
-- [ ] All functions called from HTML dialogs are public (no trailing underscore)
-- [ ] `SpreadsheetApp.flush()` called before returning from modifying functions
-- [ ] Error handling (try/catch) around external API calls and MailApp
-- [ ] Configuration constants at the top of the file
-- [ ] Header comment with install instructions
-- [ ] Tested on a copy of the sheet
-- [ ] Considered multi-user behaviour (different permissions, different active sheet)
-- [ ] Long operations use modal progress dialogs
-- [ ] No hardcoded sheet names — use configuration constants
-- [ ] Checked email quota before batch sends
diff --git a/plugins/integrations/skills/google-apps-script/references/recipes.md b/plugins/integrations/skills/google-apps-script/references/recipes.md
deleted file mode 100644
index a2dc5872..00000000
--- a/plugins/integrations/skills/google-apps-script/references/recipes.md
+++ /dev/null
@@ -1,148 +0,0 @@
-# Recipes
-
-Complete automation recipes ready to adapt.
-
-## Auto-Archive Completed Rows
-
-Move rows with "Complete" status to an Archive sheet. Processes bottom-up to avoid shifting row indices.
-
-```javascript
-function archiveCompleted() {
- const ss = SpreadsheetApp.getActiveSpreadsheet();
- const source = ss.getSheetByName('Active');
- const archive = ss.getSheetByName('Archive');
- const data = source.getDataRange().getValues();
- const statusCol = 4; // column E (0-indexed)
-
- // Process bottom-up to avoid shifting rows
- for (let i = data.length - 1; i >= 1; i--) {
- if (data[i][statusCol] === 'Complete') {
- archive.appendRow(data[i]);
- source.deleteRow(i + 1); // +1 for 1-indexed rows
- }
- }
- SpreadsheetApp.flush();
-}
-```
-
-## Duplicate Detection and Highlighting
-
-Scan a column and highlight duplicate values in light red.
-
-```javascript
-function highlightDuplicates() {
- const sheet = SpreadsheetApp.getActiveSheet();
- const data = sheet.getRange('A2:A' + sheet.getLastRow()).getValues();
- const seen = {};
-
- for (let i = 0; i < data.length; i++) {
- const val = data[i][0];
- if (val === '') continue;
- if (seen[val]) {
- sheet.getRange(i + 2, 1).setBackground('#f4cccc'); // light red
- sheet.getRange(seen[val], 1).setBackground('#f4cccc');
- } else {
- seen[val] = i + 2; // store row number
- }
- }
-}
-```
-
-## Auto-Numbering Rows
-
-Automatically number column A when column B is edited.
-
-```javascript
-function onEdit(e) {
- const sheet = e.source.getActiveSheet();
- if (sheet.getName() === 'Data' && e.range.getColumn() === 2) {
- if (e.value && e.value !== '') {
- const row = e.range.getRow();
- const above = sheet.getRange(2, 1, row - 1, 1).getValues()
- .filter(r => r[0] !== '').length;
- sheet.getRange(row, 1).setValue(above + 1);
- }
- }
-}
-```
-
-## Summary Dashboard Generator
-
-Create a Summary sheet aggregating data from numbered weekly tabs.
-
-```javascript
-function generateSummary() {
- const ss = SpreadsheetApp.getActiveSpreadsheet();
- const summary = ss.getSheetByName('Summary') || ss.insertSheet('Summary');
- summary.clear();
-
- summary.getRange('A1').setValue('Weekly Summary')
- .setFontSize(16).setFontWeight('bold');
- summary.getRange('A3:D3')
- .setValues([['Week', 'Total Jobs', 'Revenue', 'Avg Price']])
- .setFontWeight('bold')
- .setBackground('#4a86c8')
- .setFontColor('#ffffff');
-
- let row = 4;
- for (let w = 1; w <= 52; w++) {
- const tabName = String(w).padStart(2, '0');
- const sheet = ss.getSheetByName(tabName);
- if (!sheet) continue;
-
- const jobs = sheet.getRange('D1').getDisplayValue();
- const revenue = sheet.getRange('E55').getDisplayValue();
- const avg = jobs > 0
- ? (parseFloat(revenue.replace(/[^0-9.]/g, '')) / jobs)
- : 0;
-
- summary.getRange(row, 1, 1, 4).setValues([[
- 'Week ' + tabName, jobs, revenue, '$' + avg.toFixed(0)
- ]]);
- row++;
- }
-
- summary.autoResizeColumns(1, 4);
- SpreadsheetApp.flush();
-}
-```
-
-## Batch Email Sender
-
-Send personalised emails to a list of recipients from sheet data.
-
-```javascript
-function sendBatchEmails() {
- const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Recipients');
- const data = sheet.getRange('A2:C' + sheet.getLastRow()).getValues();
- // Columns: A=Email, B=Name, C=Status
-
- const remaining = MailApp.getRemainingDailyQuota();
- if (remaining < data.length) {
- SpreadsheetApp.getUi().alert(
- 'Only ' + remaining + ' emails left today. Need ' + data.length + '.');
- return;
- }
-
- let sent = 0;
- for (let i = 0; i < data.length; i++) {
- const [email, name, status] = data[i];
- if (!email || status === 'Sent') continue;
-
- try {
- MailApp.sendEmail({
- to: email,
- subject: 'Your Weekly Update',
- htmlBody: '<p>Hi ' + name + ',</p><p>Here is your update...</p>'
- });
- sheet.getRange(i + 2, 3).setValue('Sent');
- sent++;
- } catch (e) {
- sheet.getRange(i + 2, 3).setValue('Error: ' + e.message);
- }
- }
-
- SpreadsheetApp.flush();
- SpreadsheetApp.getActiveSpreadsheet().toast('Sent ' + sent + ' emails', 'Done', 5);
-}
-```