Episode 6: AI-Ready Engineering: Reviewing AI-Generated Code Without Lowering the Bar
AI-generated code has one unfair advantage over a junior engineer: it never looks nervous. Ask an AI tool for a SuiteScript change, and it will hand you wrong code with the confidence of someone who already deployed it to production.
That confidence is the risk. AI-generated code usually looks good. The formatting is clean, the function names make sense, the explanation sounds reasonable, and there might even be comments.
In Episode 5, “Tests Are Instructions for Humans and AI,” we looked at how tests define correct behavior. This episode covers the human side of that check: reviewing AI-generated code without letting the bar slide.
What: Code Generation Got Easier, Accountability Did Not
AI can cut the time it takes to produce an implementation, and that's useful. It also brings a temptation: if the code looks reasonable and the tests pass, ship it.
But the AI won't own the production incident or join the customer call, and it won't explain why a script ran into a NetSuite limit everyone on the team should have known about. The responsibility stays with the team, and so does the review.
Why: Plausible Code Is Not the Same as Correct Code
AI tools are built to produce likely answers. NetSuite development is full of cases where the likely answer fails in context: a SuiteScript 1.0 nlapi call mixed into 2.x code, a module that only works in client scripts, a Map/Reduce stage that runs out of governance, or a saved search that's fast in sandbox and crawls on production volume.
Nobody watched the AI's reasoning develop line by line. The answer arrived fully formed, so its assumptions still need checking, at least as carefully as you'd check a teammate's.
This is why experienced engineers become more important when AI enters the workflow.
Writing syntax becomes cheaper, but judgment becomes more valuable. You need someone who can look at a perfectly reasonable implementation and say: “Wait, that won’t survive production data.”
Example: Clean Code, Wrong Assumptions
Here's the kind of user event script an AI tool might produce when asked to stamp a "last ordered" date on each item when a sales order is saved.
Before: AI-generated
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/record'], (record) => {
const afterSubmit = (context) => {
const so = context.newRecord;
const lines = so.getLineCount({ sublistId: 'item' });
for (let i = 0; i < lines; i++) {
const itemId = so.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i });
const item = record.load({ type: record.Type.INVENTORY_ITEM, id: itemId });
item.setValue({ fieldId: 'custitem_last_ordered', value: new Date() });
item.save();
}
};
return { afterSubmit };
});
It reads well, and it works on a three-line test order. Its hidden assumptions:
- every line is an inventory item, when kits, services, and description lines would make the load fail
- a load and save per line fits inside user event governance on a 200-line order
- it should run on every edit, not just on create
- saving each item, which also fires that item's own scripts and workflows, is fine
After: Reviewed
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/record', 'N/search', 'N/runtime', 'N/log'], (record, search, runtime, log) => {
const afterSubmit = (context) => {
if (context.type !== context.UserEventType.CREATE) return;
const so = context.newRecord;
const itemIds = new Set();
for (let i = 0; i < so.getLineCount({ sublistId: 'item' }); i++) {
itemIds.add(so.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }));
}
if (!itemIds.size) return;
// Only inventory items match this search; other line types are skipped
search.create({
type: search.Type.INVENTORY_ITEM,
filters: [['internalid', 'anyof', [...itemIds]]],
columns: ['internalid']
}).run().each((result) => {
if (runtime.getCurrentScript().getRemainingUsage() < 100) {
log.audit('Stopped early', 'Low governance; move large orders to Map/Reduce');
return false;
}
record.submitFields({
type: record.Type.INVENTORY_ITEM,
id: result.id,
values: { custitem_last_ordered: new Date() }
});
return true;
});
};
return { afterSubmit };
});
The reviewed version isn't much longer. The difference is that someone asked what the code assumed.
How: Review the Assumptions, Not Just the Diff
Traditional code review focuses on what changed. With AI-generated code, also review what the AI assumed.
Verify the API
Check that every API the code calls exists in SuiteScript 2.x and works in that script type. Hallucinated APIs are particularly difficult to catch because they often have excellent names. The method can look consistent with the rest of the codebase and still be unavailable or behave differently from the description.
Check platform constraints
Governance, permissions, execution context, concurrency, and timeouts all apply. AI can understand general programming well and still miss the one NetSuite constraint that makes a solution unsuitable, such as a deployment that runs as a role without access to the record it updates.
Look for the missing path
AI handles the obvious scenario well. Ask what happens when a search returns nothing, the script runs twice, an external service is down, a status changes halfway through, or the record already exists. The interesting bugs live just outside the happy path.
Review security separately
Clean code and secure code are separate checks. Give authentication, authorization, input handling, sensitive data, logging, and secrets their own pass. Treat generated code like any other code entering your account.
Read the code
The AI's explanation, the summary, and the green tests all help, but the code is what ships. If your name is on the review, understand what you approved.
Judgment Is the Job
AI can make us faster, but speed only matters when we are moving in the right direction. The biggest mindset change AI-assisted engineering asks for is about where the saved time goes. The goal isn't "use AI so we can review less." It's "use AI so we spend less time producing routine code and more time applying engineering judgment."
A beautifully generated wrong answer is still wrong. It just arrives faster.
At ATSOURCE, we build NetSuite teams that review AI-generated code as carefully as their own, so nothing ships that an engineer hasn't understood. Let's talk about what that looks like for your organization.
Meet the Author
Has over a decade of experience in SuiteCloud Development on the NetSuite platform. Specializes in implementing advanced solutions and led teams in creating high-quality software. Holds multiple certifications and awards like the Summit Award and Quality Champion Award. Off the clock, you'll find her on the tennis court, behind a drum kit, or building systems with AI just for the fun of it. She's still deciding which one is the most addictive.
Tags
Accelerate ERP Success with Expert Solutions
Ready to put what you've learned into practice? ATSOURCE delivers both the specialized talent and comprehensive NetSuite support you need to turn strategy into results.Connect with our experts today and move from planning to performance.






