Reviewing What You Didn't Write
AI-generated code has specific, consistent failure patterns — not random errors, but predictable categories of things it gets wrong or underweights. Knowing what these are makes your review faster and more reliable. This module builds the review discipline that makes AI-assisted development actually safe to ship.
AI's consistent failure patterns — what to look for first
Reviewing AI-generated code isn't the same as reviewing code written by a colleague. A colleague makes mistakes based on misunderstandings, time pressure, or gaps in their specific knowledge. AI makes mistakes based on its training — which means it has predictable, consistent failure patterns that you can learn to look for systematically.
Knowing these patterns doesn't mean you trust AI less — it means you review faster and more effectively, because you know where to concentrate your attention. The areas where AI is reliably strong (structure, syntax, naming, boilerplate) need less of your time. The areas where AI is consistently weak need more.
// But filterByStatus() doesn't exist on PolicyPeriodPaymentPlans
// Actual: policyPeriod.ActivePaymentPlans.where(\pp -> pp.Status == "current")
// AI often generates: if (age < 25) → wrong: misses 24.999...
// Or: if (age <= 24) → also wrong if dob-based calculation rounds differently
// Always trace: what happens at exactly age 25? Day before? Day of birthday?
// var primaryDriver = policy.Drivers.first()
// Will throw exception if Drivers is empty — possible during policy creation flow
// Better: policy.Drivers.HasElements ? policy.Drivers.first() : null
// Always verify generated Guidewire API calls against your version's
// Studio API documentation before assuming the pattern is current
// } catch (Exception e) { log.error("Failed", e); }
// Missing: retry logic, circuit breaker, graceful degradation,
// structured error response that the calling workflow can act on
// or assumes committed state when working with draft PolicyPeriods
// Always ask: does this code run in a bundle? What's the commit point?
// What happens if the operation fails mid-way?
Security considerations AI consistently underweights
AI generates secure-looking code. The problem is that it generates plausible security patterns without consistently applying them, and without understanding the specific threat model of your environment. In insurance IT systems that hold personal health information, financial data, and policy records, security gaps aren't just technical debt — they're regulatory and reputational exposure.
Input validation gaps
AI validates obvious cases but frequently misses context-specific injection risks. Any input that flows through to a database query, file path, or external API call needs validation that AI may not generate. Review every external input path — especially in Guidewire integration handlers where external systems send data into your policy or claims workflow.
Credential and secret handling
AI will sometimes generate code with hardcoded credentials, connection strings, or API keys as examples — and these sometimes make it into codebases. Review every generated file for any string that looks like a credential. All secrets belong in environment configuration, not in code.
Logging sensitive data
AI generates logging that is often too verbose for production insurance systems — potentially including personal information, financial data, or credentials in log output. Review every log statement: what data is included? Who has access to these logs? Does it comply with your client's data handling requirements?
Authorisation gaps
AI implements authentication patterns better than authorisation. Generated code may authenticate a user correctly but then allow them to access resources without checking whether they're authorised for that specific operation. In Guidewire systems, this intersects with the ACL and permission framework — AI-generated bypass paths can be subtle.
Dependency security
When AI suggests adding a dependency — a library, a package, a utility — it doesn't perform security assessment on that dependency. Any AI-suggested dependency needs a vulnerability scan and an assessment of whether it's approved for use in your client's environment before it enters the codebase.
Data at rest and in transit
AI will implement encryption when you ask for it explicitly. It will frequently omit it when the requirement is implied or when it's not the primary focus of the prompt. Any code that handles personal information, financial data, or credentials should be reviewed specifically for whether data is appropriately protected at rest and in transit.
The AI code review checklist
A checklist doesn't replace judgment — but it prevents the selective attention problem that makes reviews unreliable. When you're working fast, you unconsciously skip sections you feel less concerned about. A checklist enforces systematic coverage. Use this as a starting point and adapt it to your specific environment and client's requirements.
calculateProRataRefund() — that uses an approach you don't fully understand. You're on a deadline. What should you do?Using AI to review AI — a legitimate technique with limits
Using AI to critique its own output is a legitimate and useful technique — with important limits. AI can catch certain categories of its own errors when prompted to look for them specifically. What it cannot reliably do is catch domain-specific logic errors in insurance business rules it doesn't deeply understand, or identify security gaps that require knowledge of your specific environment and threat model.
AI self-review reliably catches: obvious null risks, some boundary condition issues, hardcoded values, structural problems. It reliably misses: whether the business logic is actually correct for your specific insurance product and jurisdiction, whether the code complies with your client's specific regulatory environment, Guidewire version-specific API differences, and security gaps that require knowledge of your deployment environment. AI self-review is a useful first pass — it doesn't replace your professional review.
Module summary
Know the failure patterns
Invented API methods, boundary condition errors, null handling gaps, outdated patterns, incomplete error handling, transaction blindness. Systematic review concentrates on these — they're predictable, not random.
Security is your job
AI generates plausible-looking security patterns but doesn't know your environment, your client's data handling requirements, or your regulatory context. Personal data in logs, hardcoded credentials, authorisation gaps — you find these, not AI.
Systematic checklist, not selective attention
A checklist prevents the "I was confident so I skimmed it" failure mode. Apply it to every AI-generated function before submission. Adapt it to your specific environment. The "can I explain every line" test is the final gate.
AI self-review: useful first pass only
Run it — it catches some things fast. But "AI found nothing" does not complete your review obligation. Business rule boundary conditions and domain-specific logic errors require your judgment. AI self-review assists; it doesn't certify.
Module 03 — Debugging and Root Cause — covers the other direction: using AI to diagnose problems in code that already exists. Interpreting Guidewire server logs, tracing integration failures, identifying root cause in complex multi-system environments faster than reading through logs manually.
Reviewing What You Didn't Write is done. Continue to Module 03: Debugging and Root Cause.