Week 49 · Phase 7 — The AI Hero
The Art of the Audit: Using your deep technical foundations to lead AI agents to victory.
AI is a phenomenal junior developer: fast, tireless, and broadly knowledgeable. But like any junior, it often lacks judgment. It might suggest a solution that is O(N²) when O(N) is required, or it might accidentally introduce a memory leak in a C++ bridge. This week is about shifting your mindset from writing to reviewing. You are now the Senior Architect.
AI models are trained on average code. Often, they suggest the "easiest" way to solve a problem, which isn't always the most efficient. Because you understand Big O notation (Week 30) and how the CPU cache works (Week 3), you can spot when an AI is about to tank your app's performance.
// AI Suggestion: Searching for a user in a large list every frame.
auto it = std::find_if(users.begin(), users.end(), [&](const User& u) {
return u.id == targetId;
});
// Senior Architect Review: "This is O(N) inside a 60FPS loop.
// We should use a std::unordered_map for O(1) lookups."
AI can be dangerously confident about memory management. When bridging C++ to Swift or C#, the AI might forget to free a buffer or might assume a pointer remains valid across an asynchronous call. Your knowledge of pointers (Week 17) and RAII (Week 24) allows you to audit these bridges for stability.
A senior architect doesn't just see the code that is there; they see the edge cases, the race conditions, and the memory leaks that aren't there yet.
Patterns that an LLM regularly slips past you, in roughly the order they cause trouble:
for over a list inside a render or per-frame call. Often fixable with a hash map populated outside the loop.std::string. The pointer dangles the moment the function returns.std::string from a literal, an std::vector::push_back in a tight loop without reserve. Each one looks innocent.const and missing noexcept. Both are contracts the rest of the codebase relies on. Their absence shows up as confusing compile errors elsewhere.extern "C" boundary. Returning std::optional from a function the caller assumes returns success codes. Mixing the two in one module.The audit isn't pessimism — it's the exact same mental pattern as code review for a junior teammate, just applied to a teammate that produces a hundred lines a minute.
AI tends to solve problems in isolation, often leading to "spaghetti code" over time. As the architect, you ensure the AI follows established design patterns (Week 23). You dictate the interfaces and the ownership models, and you force the AI to implement its logic within those guardrails.
// User instruction to AI:
// "Don't add the database logic to the View.
// Create a repository pattern where the View observes
// the ViewModel, and the ViewModel calls the Repository."
Auditing code is one thing; letting an AI autonomously solve complex tasks is another. Next week, we'll explore Agentic Workflows: how to set up multi-step AI systems that can research, implement, and test features with minimal intervention from you.
Week 50 is Agentic Workflows.
Answer: B. AI defaults to whatever shows up most in training data — often the simple-looking solution rather than the optimal one.
Answer: B. The pointer dangles the moment the function returns. Looks fine in tests; crashes in production.
Answer: B. Direction and verification — that's the irreplaceable human piece.