To harden AI-generated changes in a large, legacy SaaS codebase before an engineering review, the consensus from experienced practitioners (as discussed in recent technical forums) emphasizes shifting focus from "generating more code" to "verifying and documenting" what has already been built.
Since you are preparing for an engineering review, your goal is to provide maximum transparency and confidence to the reviewer. Here is a prioritized approach:
### 1. Solidify the "Source of Truth" (Architecture Documentation)
The most critical asset for an engineer reviewing AI-generated code is a clear, accurate architectural blueprint.
* **Update the Architecture Document:** Ensure it is comprehensive and reflects the *actual* state of the prototype, not just the initial plan. It should cover data models, API design, service interactions, and security roles.
* **Version Control:** Treat this document as a living artifact. When the engineer reviews the code, they need to know exactly what the design intent was to distinguish between "intentional design" and "AI hallucination/error."
### 2. Prioritize Extensive QA and Regression Testing
Since you cannot rely on deep technical intuition to catch subtle bugs, you must rely on rigorous, objective testing.
* **Documented Regression Testing:** Beyond your standard CI pipeline, create a dedicated suite of regression tests that specifically target the new AI-generated features.
* **Evidence-Based Reporting:** Document the results of these tests (pass/fail) clearly. Providing a report that says, "Feature X passed these 20 edge-case scenarios," gives the reviewer concrete evidence of stability.
* **"What Can Go Wrong" Analysis:** Instead of asking, "Is this production-ready?", use AI to perform a "pre-mortem." Ask the AI to act as a security auditor or a legacy-code maintainer to identify potential failure modes, race conditions, or performance bottlenecks specific to your legacy environment.
### 3. Improve Reviewability for the Engineer
Make the reviewer’s job as easy as possible by reducing the cognitive load required to understand the changes.
* **Clean Up the PRs:** If the AI generated messy, iterative commits, consider squashing them into logical, atomic commits that are easier to review.
* **Highlight Assumptions:** Explicitly list the assumptions the AI made during development. If the AI had to make a trade-off (e.g., "I chose this library because it was compatible with the legacy C# version"), document it.
* **Focus on "Why" not "What":** Ensure the code has clear comments explaining the *intent* behind complex logic, especially where it interacts with legacy code.
### 4. Strategic Use of AI for Verification
* **Independent Verification:** Use a different, high-capability model (e.g., if you used Claude, try using a different model like GPT-4o or a specialized coding model) to perform a "blind" review of the code. Ask it to specifically look for security vulnerabilities, performance issues, or deviations from the architecture document.
* **Test-Implementation Separation:** While some debate the necessity of separate agents for tests, the core principle holds: ensure the tests are robust and not just "passing" because the implementation is weak. Verify the validity of the test cases manually.
### Summary of Priorities
If you have only a few weeks, prioritize in this order:
1. **Architecture Documentation:** Ensure it is accurate and comprehensive.
2. **Regression Testing:** Build and document a clear pass/fail report for the new features.
3. **Risk Assessment:** Use AI to identify "what can go wrong" and document those risks for the reviewer.
4. **Reviewer Experience:** Clean up the PRs and provide a summary of design decisions and trade-offs.
**Final Note:** The most valuable thing you can do is provide the engineer with a clear map of what you built, how you verified it, and where the known risks are. This allows them to focus their limited time on high-value architectural validation rather than basic debugging.
1searchharden AI changes to legacy SaaS before review
2searchsite:news.ycombinator.com "How would you harden AI changes to a 1M-line legacy"
3navigatehttps://news.ycombinator.com/item?id=49045271
4get_text