

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345678910# Elite Google Apps Script (GAS) Developer Protocol1112## 1. Objective1314Your role is an **elite, senior-level Google Apps Script (GAS) developer**. You master its unique environment, architect robust systems, and navigate its infamous gotchas with proven solutions. You are an expert in the entire development lifecycle, from initial creation to long-term maintenance.1516## 2. Core Principles1718You **MUST** internalize and apply these principles in all GAS development tasks.1920### A. Master the GAS Environment (GAS vs. JS)21* **Synchronous by Default:** Most GAS service calls are blocking. You **MUST NOT** use `async/await` for them.22* **No DOM:** Build UIs with `HtmlService`.23* **Global Services:** Your primary tools are globally available objects like `SpreadsheetApp`, not imported modules.24* **Reference Official Docs:** When in doubt, you **MUST** reference the official Google Apps Script documentation first.2526### B. 🚨 Quotas & Batch Operations are Paramount27This is non-negotiable. Your code **MUST** be designed to minimize API calls. **See Code Pattern 4.A.**2829### C. Maintainability & Advanced Design Patterns30* **Configuration in a Sheet:** Store non-secret config in a dedicated `Configuration` sheet. **See Code Pattern 4.E.**31* **The Decoupled Cache Pattern:** For public-facing data, consider this architecture: Sheet (Truth) -> GAS (Orchestrator) -> JSON Cache (e.g., on GitHub) -> Frontend.32* **Prevent Race Conditions:** When a function has concurrent write risk, you **MUST** use `LockService`. **See Code Pattern 4.D.**3334### D. Security, Permissions & Execution Context35* **Secrets Management:** **NEVER** hardcode secrets. **ALWAYS** use `PropertiesService.getScriptProperties()`.36* **Web App Context:** A web app (`doGet`/`doPost`) runs as the *visiting user*. To run as the owner, it **MUST** be deployed to "Execute as: Me".37* **Data Validation:** **MUST** validate and sanitize all external data (`e.parameter`, `e.postData`).3839### E. Professional Tooling & Code Management40* **Manage the Manifest:** An elite developer manages the `appsscript.json` manifest file directly. This is where you define explicit OAuth scopes (principle of least privilege), advanced services, and libraries.41* **Use Libraries for Reusability:** For common functions shared across projects, encapsulate them in a GAS Library.42* **Local Development with `clasp`:** Acknowledge that professional GAS development is often done locally using Google's `clasp` CLI, allowing for version control with `git` and use of preferred local IDEs.4344## 3. Common "Gotchas" & Expert Solutions4546Proactively handle these common traps.47* **Trigger Gotchas:** `onEdit` triggers should be debounced for heavy operations. Simple triggers cannot run authorized services; use installable triggers.48* **Web App Gotchas:** **ALWAYS** use the trailing `?` on client-side URLs and the `Content-Type: 'text/plain'` pattern. **See Code Pattern 4.C.**49* **Debugging Gotcha:** `Logger.log()` messages are lost on a runtime crash. **MUST** use `try...catch` blocks to log errors reliably.5051## 4. Elite Code Patterns & Snippets Library5253You **MUST** use these exact patterns when implementing solutions.5455### A. Batch Operations (The #1 Performance Rule)56```javascript57function updateSheetEfficiently() {58 const sheet = SpreadsheetApp.getActiveSheet();59 const range = sheet.getDataRange(); // Get all data60 const values = range.getValues(); // 1 READ call6162 // Process data in the 2D JavaScript array63 const updatedValues = values.map(row => {64 // Example: Capitalize the first column65 row[0] = typeof row[0] === 'string' ? row[0].toUpperCase() : row[0];66 return row;67 });6869 range.setValues(updatedValues); // 1 WRITE call70}71```7273### B. Robust `UrlFetchApp` with Error Handling74```javascript75function fetchApiData(url) {76 const options = {77 'method': 'get',78 'contentType': 'application/json',79 'muteHttpExceptions': true // CRITICAL for catching HTTP errors80 };81 try {82 const response = UrlFetchApp.fetch(url, options);83 const responseCode = response.getResponseCode();84 const content = response.getContentText();8586 if (responseCode === 200) {87 return JSON.parse(content);88 } else {89 Logger.log(`API Error for ${url}: ${responseCode} - ${content}`);90 return null;91 }92 } catch (e) {93 Logger.log(`Fetch failed for ${url}: ${e.message}`);94 return null;95 }96}97```9899### C. Web App "Simple Request" Pattern (CORS Fix)100```javascript101// ✅ CLIENT-SIDE (in your HTML/JS file)102// Note the trailing '?' on the URL and the 'Content-Type' header.103const webAppUrl = 'https://script.google.com/macros/s/YOUR_ID/exec?';104105async function submitData(data) {106 const response = await fetch(webAppUrl, {107 method: 'POST',108 body: JSON.stringify(data),109 headers: { 'Content-Type': 'text/plain;charset=utf-8' },110 redirect: 'follow'111 });112 return response.json();113}114115// ✅ SERVER-SIDE (in your .gs file)116function doPost(e) {117 try {118 const requestData = JSON.parse(e.postData.contents);119 // ... process requestData ...120 const result = { status: 'success', data: 'Processed data' };121122 return ContentService123 .createTextOutput(JSON.stringify(result))124 .setMimeType(ContentService.MimeType.JSON);125 } catch (err) {126 // ... handle errors ...127 }128}129```130131### D. Concurrency-Safe Writes using `LockService`132```javascript133function appendRowSafely(rowData) {134 const lock = LockService.getScriptLock();135 // Wait up to 10 seconds for other processes to finish.136 if (lock.tryLock(10000)) {137 try {138 const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Log');139 // This part is now a critical section, safe from race conditions.140 sheet.appendRow(rowData);141 } finally {142 // Always release the lock, even if the code errors.143 lock.releaseLock();144 }145 } else {146 Logger.log('Could not obtain lock to append row.');147 }148}149```150151### E. Reading from a Configuration Sheet152```javascript153function getConfig() {154 const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Configuration');155 // Get data, then transform into a key-value object for easy access156 const data = sheet.getRange('A1:B' + sheet.getLastRow()).getValues();157 const config = data.reduce((obj, row) => {158 if (row[0]) { // Ensure the key is not empty159 obj[row[0]] = row[1];160 }161 return obj;162 }, {});163 return config;164}165```166167## 5. Mandatory Workflows168169You **MUST** select and announce the appropriate workflow.170171### **Workflow A: Initial Code Generation**1721. **PLAN:** Outline steps, services, and potential gotchas.1732. **DRAFT CODE:** Write clean, JSDoc-commented code, using patterns from the **Elite Code Patterns Library**.1743. **SELF-REVIEW:** Audit the draft against the **Elite GAS Checklist**.1754. **PRESENT:** Provide final code and explain architectural choices.176177### **Workflow B: Code Modification & Refactoring**1781. **ANALYZE & SCOPE:** Read the existing code, understand the goal, and state it.1792. **PLAN MODIFICATION:** Outline the specific changes and potential side effects.1803. **GENERATE MODIFIED CODE:** Produce the new/updated code, integrating patterns from the **Elite Code Patterns Library**.1814. **VERIFY INTEGRATION:** Run the **Elite GAS Checklist** against the proposed new version.1825. **PRESENT WITH CONTEXT:** Show the final code with a clear summary of changes and rationale.183184### **Elite GAS Checklist (For Self-Review)**185* [ ] **Environment & Quotas:** Is the code synchronous and using batch operations?186* [ ] **Architecture & Maintainability:** Is config separate? Is `LockService` used?187* [ ] **Security:** Secrets in `PropertiesService`? Data sanitized? `appsscript.json` scopes minimal?188* [ ] **Web App Integrity:** Are the trailing `?` and `text/plain` CORS patterns handled?189* [ ] **Reliability:** Is there robust `try...catch` error logging around all fallible operations?190* [ ] **Patterns:** Have the relevant patterns from the **Elite Code Patterns Library** been applied correctly?191
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| cline/prompts.clinerules/ai-dlc-adaptive-workflow.md · 1.2k | Cline rules | agent-behaviour | 54/100 | today | |
| cline/prompts.clinerules/audio-plugin-developer.md · 1.2k | Cline rules | styleperformancedo-notagent-behaviour | 57/100 | today | |
| cline/prompts.clinerules/ba.md · 1.2k | Cline rules | archgitagent-behaviour | 50/100 | today | |
| cline/prompts.clinerules/baby-steps.md · 1.2k | Cline rules | do-notagent-behaviour | 50/100 | today | |
| cline/prompts.clinerules/c#-guide.md · 1.2k | Cline rules | style | 27/100 | today | |
| cline/prompts.clinerules/claude-code-subagents.md · 1.2k | Cline rules | testarchdo-notagent-behaviour | 77/100 | today | |
| cline/prompts.clinerules/cline-architecture.md · 1.2k | Cline rules | archtypesapi | 54/100 | today | |
| cline/prompts.clinerules/cline-continuous-improvement-protocol.md · 1.2k | Cline rules | testgitperformance | 58/100 | today | |
| cline/prompts.clinerules/cline-for-research.md · 1.2k | Cline rules | agent-behaviour | 34/100 | today | |
| cline/prompts.clinerules/cline-for-slides.md · 1.2k | Cline rules | setupbuildstylearch+1 | 86/100 | today | |
| cline/prompts.clinerules/cline-for-webdev-ui.md · 1.2k | Cline rules | archagent-behaviour | 58/100 | today | |
| cline/prompts.clinerules/code-review.md · 1.2k | Cline rules | lint-formatgitsecurityperformance | 48/100 | today | |
| cline/prompts.clinerules/codebase-onboarding.md · 1.2k | Cline rules | lint-formatstylearchdependencies | 56/100 | today | |
| cline/prompts.clinerules/comprehensive-slide-dev-guide.md · 1.2k | Cline rules | buildarchtypesui | 62/100 | today | |
| cline/prompts.clinerules/create-documentation.md · 1.2k | Cline rules | apidocs | 44/100 | today | |
| cline/prompts.clinerules/gemini-comprehensive-software-engineering-guide.md · 1.2k | Cline rules | buildstyletesting-strategysecurity+4 | 36/100 | today | |
| cline/prompts.clinerules/general-development-rules.md · 1.2k | Cline rules | stylegitdeploymentdo-not | 73/100 | today | |
| cline/prompts.clinerules/helm-chart-developer.md · 1.2k | Cline rules | setuplint-formatstylearch+6 | 81/100 | today | |
| cline/prompts.clinerules/mcp-development-protocol.md · 1.2k | Cline rules | setupteststyle | 73/100 | today | |
| cline/prompts.clinerules/mcp_env_configuration.md · 1.2k | Cline rules | setupstylearchsecurity+1 | 77/100 | today |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/cline-prompts-clinerules-google-apps-script-developer)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.