Your project already has rowsToObjects, withScriptLock and retryUrlFetch. Ask Co-Pilot for a new job and it writes its own versions of all three, slightly different, right next to the originals. snippetCatalogForPrompt(entries, opts) turns a list of { name, intent } into a paste-ready bullet list with an instruction line telling Co-Pilot to call these helpers instead of rewriting them. Call it with no arguments and you get a short default list of real helpers from the Bootstrapping Tools snippet library.
When to use
- At the top of a Co-Pilot brief for a project that already has helpers
- Handover notes: “these exist, use them”
- Code reviews, as a checklist of what should have been reused
How to use this snippet
/**
* Build a paste-ready "helpers you can call" block for a Co-Pilot brief.
*
* @param {{name: string, intent: string}[]=} entries helpers in your project (default: a few common BT snippets)
* @param {Object=} opts { title: 'Helpers already in this project', instruction: '...' }
* @return {string}
*/
function snippetCatalogForPrompt(entries, opts) {
opts = opts || {};
entries = entries && entries.length ? entries : [
{ name: 'rowsToObjects', intent: 'turn getValues() rows into objects keyed by header' },
{ name: 'objectsToRows', intent: 'turn objects back into rows for setValues()' },
{ name: 'withScriptLock', intent: 'run a function under LockService.getScriptLock()' },
{ name: 'retryUrlFetch', intent: 'UrlFetchApp.fetch with retries and backoff on 429/5xx' },
{ name: 'claimNextQueueRow', intent: 'claim the next pending row in a sheet queue' },
{ name: 'jsonOk / jsonErr', intent: 'return ContentService JSON from a web app' }
];
var lines = [(opts.title || 'Helpers already in this project') + ':'];
entries.forEach(function (e) {
lines.push('- `' + e.name + '`' + (e.intent ? ': ' + e.intent : ''));
});
lines.push('');
lines.push(opts.instruction ||
'Call these helpers by name instead of rewriting them. Do not redefine them. ' +
'If one is missing something you need, say so instead of writing a new version.');
return lines.join('\n');
}
Example
function logBriefHelpers() {
console.log(snippetCatalogForPrompt([
{ name: 'rowsToObjects', intent: 'rows → objects by header' },
{ name: 'sendEmailWithBudget', intent: 'send one email without going over the daily budget' },
{ name: 'appendDeadLetterRow', intent: 'park a failed row on the DeadLetter tab' }
]));
}
// Helpers already in this project:
// - `rowsToObjects`: rows → objects by header
// - `sendEmailWithBudget`: send one email without going over the daily budget
// - `appendDeadLetterRow`: park a failed row on the DeadLetter tab
//
// Call these helpers by name instead of rewriting them. ...
Tips:
- List only helpers that are really in the project. A name Co-Pilot can't find is worse than no list.
- One line of intent per helper is plenty. Include the argument order if it's easy to get wrong.
- Pair it with the sheet header map from sheetSchemaForPrompt so the brief covers both data and code.
Tip: the NitroGAS snippet search shows the exact helper names, so building the list takes a minute. Paste it at the top of your Co-Pilot brief.
Happy Coding!
