Script Property Keys For Prompt

Ask Co-Pilot for a script that calls your CRM and it will invent CRM_KEY when you already have HUBSPOT_TOKEN in Script Properties. scriptPropertyKeysForPrompt(opts) lists the key names in Script Properties as a paste-ready block, with an instruction to read those keys instead of inventing new ones. It never includes values, so tokens and passwords stay out of your brief.

When to use

  • At the top of a Co-Pilot brief for a project that already has config in Script Properties
  • Handover notes: “these are the settings this script reads”
  • Checking for stale keys nobody uses any more

How to use this snippet

/** * List Script Property KEY NAMES (never values) for a Co-Pilot brief. * * @param {Object=} opts { exclude: RegExp, title: string, instruction: string } * @return {string} */ function scriptPropertyKeysForPrompt(opts) { opts = opts || {}; var keys = PropertiesService.getScriptProperties().getKeys().sort(); if (opts.exclude) keys = keys.filter(function (k) { return !opts.exclude.test(k); }); var lines = [(opts.title || 'Script Properties already set (names only)') + ':']; if (!keys.length) lines.push('- (none)'); keys.forEach(function (k) { lines.push('- `' + k + '`'); }); lines.push(''); lines.push(opts.instruction || 'Read config from these keys with PropertiesService.getScriptProperties().getProperty(name). ' + 'Do not invent new key names or hardcode values. If you need a new key, name it and tell me to add it.'); return lines.join('\n'); }

Example

function logPropertyKeysForBrief() { // Hide bookkeeping keys such as daily counters and cursors console.log(scriptPropertyKeysForPrompt({ exclude: /^(MAIL_SENT_|_)/ })); } // Script Properties already set (names only): // - `CRM_BASE_URL` // - `HUBSPOT_TOKEN` // - `OPERATOR_EMAIL` // // Read config from these keys with PropertiesService.getScriptProperties().getProperty(name). ...

Tips:

  • Only getKeys() is called, so no value is ever read into the output. Still glance at the Log before pasting, in case a key name itself says something private.
  • Use exclude for noisy keys like daily send counters or saved cursors.
  • Pair it with requireScriptProperty so a missing key fails with a clear message instead of null.

Tip: paste the Log at the top of your NitroGAS Co-Pilot brief, next to your sheet's header map, so the draft reads the config you already have.

Happy Coding!

NitroGAS Chrome Extension

Want this snippet handy inside the Apps Script editor? NitroGAS gives you free themes and snippets — plus optional Co-Pilot when you want a boost (1-week, 1-month, or yearly passes — no subscription). Happy Coding!

Get the Extension