Home › Google Apps Script › Google Apps Script Copilot instructions

Google Apps Script Copilot instructions

Copilot instructions for Google Apps Script projects with clasp: V8 runtime, batch Sheets operations, quotas and the 6-minute limit, PropertiesService secrets, and triggers.

GitHub CopilotGoogle Apps Script

How to use

Save this as .github/copilot-instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/copilot-instructions.mdDownload  
# Copilot instructions — Google Apps Script

## Workflow
- Code is synced with clasp: `clasp push` uploads local files, `clasp pull` downloads. `.clasp.json` holds the script ID; `appsscript.json` holds the manifest. Don't run `clasp push` or `clasp deploy` unless asked.
- TypeScript (if used) compiles locally before push; keep the `@types/google-apps-script` package current.

## Runtime rules
- V8 runtime (`"runtimeVersion": "V8"`): modern JS is fine, but there are no Node modules, `require`, `fetch` or DOM. Use `UrlFetchApp`, `Utilities`, and the Google services.
- Batch everything: read a range once with `getValues()`, transform in memory, write once with `setValues()`. Never call `getValue()`/`setValue()` inside loops.
- Executions stop at about 6 minutes (shorter for custom functions). For long jobs, process in chunks, save progress in `PropertiesService`, and schedule a continuation with a time-based trigger.
- Use `CacheService` for repeated lookups and `LockService` around code that can run concurrently (form submits, triggers).
- Custom functions (`=MYFUNC()`) must be fast and pure: no services that need authorization, no side effects.

## Security and scopes
- Secrets and config in `PropertiesService.getScriptProperties()`, never in source.
- Declare the narrowest `oauthScopes` in `appsscript.json` (e.g. `spreadsheets.currentonly` instead of full Drive) and list any added scope in the PR.
- `UrlFetchApp.fetch(url, { muteHttpExceptions: true })` and check `getResponseCode()`; never log tokens or full responses with personal data.
- Web apps: set `executeAs` and `access` deliberately; validate every `doGet`/`doPost` parameter.

## Triggers and UI
- Installable triggers are created by a setup function that first deletes duplicates; document them in the README.
- Menus via `onOpen(e)` with `SpreadsheetApp.getUi().createMenu(...)`; long actions show a toast or sidebar progress instead of freezing.
- Wrap entry points in try/catch and log with `console.error` (Cloud Logging) including the function name.

More: all Google Apps Script rules · all GitHub Copilot rules

Related rules

C# / .NET Copilot path instructions

Path-specific Copilot instructions for C# files on .NET 10: nullable types, async, records, and logging.

GitHub Copilot.NET / ASP.NET Core

ASP.NET Core Copilot instructions

Copilot instructions for ASP.NET Core on .NET 9/10: minimal APIs, EF Core, nullable types, and xUnit tests.

GitHub Copilot.NET / ASP.NET Core

Go Copilot path instructions

Path-specific Copilot instructions (.instructions.md) for Go 1.27 code: errors, context, stdlib routing, and tests.

GitHub CopilotGo

Java + Gradle Copilot path instructions

Path-specific Copilot instructions for Java 25 LTS code built with Gradle: records, null safety, and JUnit 5 tests.

GitHub CopilotJava

Laravel Copilot instructions

GitHub Copilot instructions for Laravel 11+ apps with Eloquent, Pest, and Form Requests.

GitHub CopilotLaravel

Modern PHP Copilot path instructions

Path-specific Copilot instructions for PHP 8.4 code: strict types, typed properties, enums, readonly, and PSR-12.

GitHub CopilotPHP

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.