← ClaudeAtlas

gas-best-practiceslisted

Google Apps Script best practices for production web apps and automation — project layout with clasp, Spreadsheet/Drive ops, LockService for concurrency, ScriptCache, web app RPC pattern with Thai error messages, PDF generation with placeholders, schema migrations, OAuth scopes, time-driven triggers, onFormSubmit, UrlFetchApp / LINE Messaging API, email quotas, deployment versioning (/dev vs /exec), and 6-minute limit workarounds. Use whenever working with .gs/.js files in clasp projects, when appsscript.json or .clasp.json exists, when code uses SpreadsheetApp / DriveApp / HtmlService / UrlFetchApp / doGet / doPost / onEdit / google.script.run, or when the user mentions Google Apps Script, GAS, clasp, Apps Script — including Thai phrasing such as "แอปสคริปต์", "สคริปต์ชีต", "ทำระบบด้วย Google Sheet", "ส่งเมลจากชีต", "แจ้งเตือน LINE จากชีต", or automating Google Sheets/Forms/Drive in any way.
kpcrmv4/gas-best-practices · ★ 4 · Data & Documents · score 75
Install: claude install-skill kpcrmv4/gas-best-practices
# Google Apps Script — Best Practices ใช้กฎเหล่านี้เมื่อทำงานกับ Google Apps Script (ตรวจสอบจาก `.clasp.json`, `appsscript.json`, ไฟล์ `.gs`, หรือผู้ใช้พูดถึง "Apps Script" / "clasp") ## วิธีอ่าน แต่ละไฟล์ใน `rules/` มีโครงสร้าง: - **Rule** — กฎข้อเดียวสั้น ๆ - **Why** — ทำไม (มักเป็น bug จริงที่เคยเจอ) - **✗ Bad** — โค้ดที่ทำให้พัง - **✓ Good** — แม่แบบที่ถูก - **Edge cases** — ข้อยกเว้น ถ้ามี ไฟล์ยาว (spreadsheet-ops, pdf-generation, external-frontend, drive-ops) มีสารบัญต้นไฟล์ — ข้ามไป rule ที่ตรงกับงานได้เลย ## เมื่อ trigger ใช้ rule ตามบริบทของ task (อ่านได้หลายไฟล์ถ้างานคาบเกี่ยว): | ผู้ใช้กำลังทำ | อ่านกฎเหล่านี้ | |---|---| | Setup โปรเจ็คใหม่, จัดไฟล์ | `rules/project-structure.md` | | Read/write Sheet, batch update | `rules/spreadsheet-ops.md` | | ทำ web app ที่เรียกผ่าน `google.script.run` | `rules/web-app-rpc.md` | | HTML head, viewport, partial include, template syntax | `rules/htmlservice-frontend.md` | | ใช้กล้อง/PWA/SW — frontend แยกไป GitHub Pages | `rules/external-frontend.md` | | สร้าง PDF จาก template | `rules/pdf-generation.md` | | จัดการ folder/file ใน Drive | `rules/drive-ops.md` | | operation ที่ user หลายคนอาจชนกัน | `rules/lock-service.md` | | query ที่ซ้ำบ่อย | `rules/cache-service.md` | | custom menu ใน Sheet | `rules/onopen-menu.md` | | dropdown ปี/เดือน/enum ที่ไม่ฟิกตายตัว | `rules/dynamic-dropdowns.md` | | auth, role check, OAuth scope | `rules/security.md` | | เพิ่มตาราง/คอลัมน์ใหม่ในระบบที่ ship แล้ว | `rules/schema-migrations.md` | |