Using LLMs for Code Review: A Practical Cheat Sheet
LLM Code Review Cheat Sheet
With a top model like Argon in high thinking mode, you can instruct it to perform specific logic checks that eliminate the main tedium of diff checking:
- Control Flow: Check logic control flow across relevant modules, focusing on the most recent changes made.
- Regressions: Check for any code that may have been broken by the recent changes.
- Compatibility: Check for any existing code that is incompatible with the recent changes and needs to be updated.
- Swallowed Exceptions: Check for exceptions or errors trapped in nested scopes that do not bubble up properly (e.g., a
catchblock that suppresses an error). - Object Contracts: Check for objects passed across the target call hierarchy that are not forwarded properly, and flag code that needs updating to handle the latest object structure.
- Async Execution: Check for any unawaited
asyncmethods. - Timing & Initialization: Check for timing errors—especially code that needs to wait or check for other resources to initialize first. Make sure all consumed resources and objects are verified for valid values.
- Signatures & Values: Check for improperly used input parameters, incorrect function arity, or nonsensical values passed into calls.
(I do not trust tools like TypeScript to catch all of that!)
Heuristics & Verbose Logging
Beyond standard checks, I maintain a reusable set of debug and analysis prompts for reviews.
Most importantly, I require all generated code to write verbose logging to a file (or files) whenever a global flag is set. I have had great success solving truly complicated bugs by handing the LLM just three items:
- The latest relevant source code modules
- The dominant error message
- The verbose debug log(s) from the last test run
Instruct the LLM that for all generated code, it must check the global logging flag and, if enabled:
- Write a log message before every significant operation.
- Write a log message afterwards reporting the result.
- Add solid logging inside every
catchblock in case an unhandled exception prevents the completion message from firing.
This gives the LLM an exact execution footprint so you can guide its focus straight to the root issue.
Doing this in the past without an LLM was a massive headache and pure drudgery. Now, once your prompts are dialed in, it is (almost) effortless.

Comments
Post a Comment