Review a Co-Pilot-written script before it touches real data

TL;DR — A five-minute review checklist for Apps Script that NitroGAS Co-Pilot drafted: what it writes, which OAuth scopes it asks for, which triggers it creates, what it deletes or overwrites, and how to run it on staging or as a dry run first. Plus a reusable follow-up prompt that makes Co-Pilot answer those questions for you.

Co-Pilot handed you 80 lines that look right. The function names make sense, the comments are tidy, and the brief you wrote was good. It’s tempting to paste it in, press Run, click Allow, and see what happens.

On a sheet ops uses every day, “see what happens” is how you find out the script clears the tab before it rewrites it. Generated code isn’t worse than code you wrote at 11pm, but you didn’t write it, so you don’t know what it does yet. Five minutes of review fixes that.

This guide picks up where Brief NitroGAS Co-Pilot so you get working Apps Script leaves off: you have the draft, and now you check it before it touches anything real.

TL;DR

Before the first real run, answer five questions:

  1. What does it write? Which spreadsheet, which tabs, which ranges, and does it append or overwrite?
  2. Which OAuth scopes will it ask for? Do they match the job?
  3. Which triggers does it create? How many, how often, and does it check for existing ones?
  4. What does it delete or overwrite? clear(), deleteRows, setTrashed, removeEditor, setValues over existing data
  5. Where does it run first? A staging copy, or a dry run that logs instead of writing

If you can’t answer one, ask Co-Pilot with the follow-up prompt below.

Using the Apps Script editor a lot? NitroGAS drops free themes & snippets right into script.google.com — optional Co-Pilot when you want a boost.

What not to do

  • Don’t click Allow on the authorization screen without reading the scopes it lists
  • Don’t run a fresh draft against the live spreadsheet “just once to test”
  • Don’t run an install function twice to “make sure it worked”. That’s how you get duplicate triggers
  • Don’t accept a draft that hardcodes the production spreadsheet ID in three places
  • Don’t ask Co-Pilot to “make it safe” in general. Ask the specific questions

The checklist, with what to search for

1. What it writes

Use the editor’s find (Cmd/Ctrl+F) and look for every write:

Search for What it means
setValue / setValues Overwrites cells at that range
appendRow Adds rows at the bottom (slow in loops)
insertSheet / copyTo Creates tabs or copies
openById / openByUrl Touches a spreadsheet other than this one
GmailApp.send / MailApp Sends email as you
UrlFetchApp.fetch with post Sends data to an outside service

For each one, write down the tab and range. If a range is computed (getLastRow() + 1, getDataRange()), check what it resolves to on your real sheet.

2. OAuth scopes

The editor’s Overview page lists the project’s OAuth scopes (and appsscript.json lists them if the draft set oauthScopes explicitly). The authorization screen on your first staging run shows the same list in plain English. A row-formatting script that asks to “See, edit, create, and delete all your Google Drive files” or “Send email as you” is a red flag. Either the code does more than you asked for, or it uses a broad service where a narrow one would do. Ask why, and ask for a narrower version.

3. Triggers it creates

Search for ScriptApp.newTrigger. For each hit:

  • Is it inside an install… function you run once, or inside the job itself? (Inside the job = a new trigger every run.)
  • Does it check ScriptApp.getProjectTriggers() first?
  • How often does it fire, and does the handler exit quickly when there’s nothing to do?

Also search for deleteTrigger. A draft that deletes all project triggers to “reset” will take your other jobs down with it.

4. Deletes and overwrites

Search for clear, clearContents, deleteRow, deleteRows, deleteSheet, setTrashed, remove, and setValues on a range that already has data. For each, ask: if this runs on the wrong tab, or twice, what is lost? If the answer is “everything on Orders”, it needs a guard, an archive step, or a confirmation.

5. Staging or dry run first

Two good options, ideally both:

Run it on staging, compare the output with what you expected, then flip the pointer.

The reusable follow-up prompt

Paste this into Co-Pilot right after it hands you a draft. Edit the bracketed parts.

Before I run this, review the script you just wrote and answer in a short list: 1. Writes: every spreadsheet, tab, and range it writes to, and whether each write appends or overwrites existing data. 2. Scopes: the OAuth scopes it will request, and for each one, the line that needs it. If any scope is broader than the job needs, give me a narrower alternative. 3. Triggers: every trigger it creates or deletes, how often it fires, and whether it checks for an existing trigger first. 4. Destructive calls: every clear, delete, trash, remove, or overwrite, and what data is lost if it runs on the wrong tab or runs twice. 5. Safety: change it so the target spreadsheet comes from the Script Property [ACTIVE_SPREADSHEET_ID] and a [DRY_RUN] Script Property makes it log planned writes instead of writing. Default to dry run if the property is missing. Don't add features or refactor anything else. Only answer the questions and make the change in point 5.

The answers are your review notes. If an answer surprises you (“it also emails the client list”), stop there and re-brief.

When it fails anyway

Even reviewed code meets real data it didn’t expect. When a run fails, don’t start over. Grab the failed execution’s log and stack and follow Fix a failed execution by pasting the log into Co-Pilot for a minimal patch.

Soft Co-Pilot note

NitroGAS is free in the editor, snippets included. Co-Pilot is a pass when you want the draft. Either way, the review is your job, and the prompt above makes it quick.

Closing checklist

  • Every write listed with its tab and range (append vs overwrite)
  • Authorization scopes read and matched to the job
  • Triggers created only by an install-once function that checks first
  • Every clear / delete / trash / overwrite has a guard or an archive step
  • Spreadsheet opened through a staging pointer, dry run defaults to on
  • First run on staging matched expectations before switching to prod

Happy Coding!