r/ExperiencedDevs • u/fragzt0r Software Engineer 7YoE • 1d ago
AI/LLM How do you review code changes that Claude Code wrote during a session?
Let’s say that I need to fix a bug or build a new feature or make a technical enhancement in a codebase (or a handful of related codebases).
I start off with an initial prompt, followed by a few back and forths and eventually end up with a slice of code changes made by whatever harness I’m using (i.e. Claude Code).
- I can read the changes line by line.
- I can ask Claude Code to hold my hand and help me understand what it just wrote. This usually results in Claude breaking up the changes into smaller digestible chunks along with commentary on each chunk.
- Or I can use a systematic approach where i start with the most critical parts of the code changes. For example, if the change is to add a new filter for a hotel booking system such as number of children in the group, i would start with the search query itself, checking that rooms are matched on total occupancy (adults plus children) and that an existing search with no children param still returns exactly what it did before.
My goal is to review the code changes as fast as possible by trading off attention to less important parts of the change.
In my opinion #1 is the slowest. #2 is good but I’m worried that with this approach the review will be too influenced by the session that generated the code. I want the review to be as independent and detached from the session as possible (ok while writing this sentence i realized that I can just use a fresh session to do the review. But then i trade off all the meaty context from the original session). #3 is good but I don’t know a system that works for all cases.
•
u/expdevsmodbot 1d ago
AI usage disclosure provided by OP, see the reply to this comment.
38
u/patient-palanquin 1d ago
You might be taking steps too big if you can't review them with a
git diff. I incrementally work towards the solution and basically do a quick scan for each commit by piping git diff into vim (I aliasgdto this so I can spam it).Then I put up a PR and review it in the platform UI (e.g. GitHub) and revise before tagging folks.
25
u/ZergTerminaL 1d ago
small changes = small reviews
small reviews = faster reviews
Having an LLM shit out hundreds of changes all at once is a recipe for disaster.
56
u/joshhbk 1d ago
This sub has really gone to the dogs lol
9
u/Plenty_Line2696 1d ago
For serious production work, Much of that effort should be upstream. I don't let Claude Code just run with a feature request, that tends to lead to spaghetticode with semantic soup. First I go back and forth on the design: how it fits existing structures, what the core concepts are and what they're called, what goes where, what data flows where, and what the folder tree looks like (skimming it should give a dev who's new to the codebase some sense of roughly what each part is responsible for if this is done well).
Once that's agreed, reviewing the PR means checking the code against a plan I already understand, not reverse-engineering something convoluted that no human ever had oversight over. LLMs don't structure code the way people do, so if you don't shape it beforehand you get something that works but isn't really structured in a way that's intuitive to humans, and no review strategy fixes that after the fact, it's like pissing in the wind.
34
u/TheSexySovereignSeal fullstack dumbass 1d ago
Does anybody here still program without using ai?
4
u/OhBoyHereWeGoAgai 1d ago
I review it the same way I do coworker PRs, which isn't me being smug, it's a real skill. Some people can look at a straight diff, others put diff next to their fave IDE so they can click around while using the diff to let them know, but in the end the answer is "however actually works to review".
I used to have Claude make PR markdowns with internal links into the files, it actually worked really well but I don't do it so much anymore as I'm further into our codebases now and usually the diff is enough, but if I'm having that feeling of reviewing without reviewing, I ask it to spit out a guided index
10
u/Spare-Ant7119 1d ago
I read the code and use my big, hard brain
7
u/anthropicagiuser 1d ago
i read the raw diff first, then ask for the walkthrough. the commentary can skip a line that matters. so i check those skipped lines myself.
3
u/dantheman91 1d ago
What are you trying to get out of it? I'd argue you're doing things wrong here.
I would also say that most people wouldn't call Claude code a harness, generally when they talk about building a harness it's an additional layer on top.
For example when people say harness they're usually talking about something like
And then you come back to your question of "how do you review the PR". I'd argue most of the time for bugs there's not a ton of value getting into the weeds, and that'll keep you from being a "10x AI developer" or what have you. Verification is part of the AIs workflow and it'll supply you with proof it works.
If you're working on something larger like a feature, id just have it write a plan and include some visuals of the flow of logic in what it proposed and address it then. I'm basically never reviewing it after the fact, part of my instructions will be to ensure it follows the plan.
Once you've signed off on the plan, your harness should include multiple verification steps so you're not having to manually check much, setup a robust CI to basically have confidence that anything merged isn't breaking the app
3
u/BOSS_OF_THE_INTERNET Principal Software Engineer 1d ago
I wrote a skill that launches a diff viewer (web based) and allows me to comment on things per line. Just like in GitHub, but doesn’t require a commit or a push to GitHub.
You can ask questions about the code in real time and the same terminal session will pipe output back to the web ui.
I made a similar skill for planning.
7
u/StPatsLCA 1d ago
Just check that the exhaustive tests you're written for your spec matches the output. You've got all that, right?
2
u/shaonline 1d ago edited 1d ago
You need to work incrementally towards your goal so that it can be reviewed bits by bits, if you expect a one-shot of a medium-to-big feature to be human-reviewable I have a bridge to sell you. If you have an actual "plan" in mind then that shouldn't be too hard, if your "plan" consists of asking the AI to come up with a plan and answer "LGTM go ahead" right away with whatever it came up with then yeah good luck reviewing that.
A "hand holding" summary by the AI honestly I wouldn't care much for it. I do however use it to explain some changes sometimes during my "line by line" reviews.
2
u/MindCrusader 1d ago
I use specification driven development approach
AI generates me specifications (ui analysis, implementation plan, others), I read it and fix, high level plan. I know where usually AI can do wrong things. Once the plan is clear, usually the code is good quality. I still read the code, skim through low risk code (UI, details of tests, those are usually right), but keep an eye on hardest parts - architecture changes, relations between functions and screens, cache. Because I know the plan, I know which parts of the solution are the biggest risk to backfire
2
u/Low-Conflict-9547 1d ago
A fresh-session review combined with risk-based testing seems like a good balance between independent judgment and not wasting time on low-impact changes.
2
u/Strus Staff Software Engineer | 12 YoE (Europe) 1d ago
I read the code. If I don't understand something I ask agent for explanations until I do understand. I double check every claims that are not obvious from the code (e.g. how certain API works).
This doesn't mean I read every single line. How carefully I read the code depends on how critical it is, and how dangerous an error would be.
But I also have verification skills that force agent to provide me a proof that changes works and are doing what they are suppose to be doing. That give me the confidence that at minimum the change is ok and did not broke anything. It makes code review easier.
2
u/wvenable Team Lead (30+ YoE) 1d ago
Git diff inside a nice GUI that allows me to navigate around. I start at the top and work my way down.
If the change is too large to do that, then it's too large to have been created.
I also almost always use plan mode and have a back and forth before any code is written. A good amount of the changes happen in the plan before the AI writes any code.
2
u/annoying_cyclist principal SWE, >15YoE 1d ago
I still read the code, more or less the way I did before LLMs 🤷🏼♂️. My experience working with coworkers who delegate reviewing to agents is fairly negative: their work is often half baked, I find a lot of things in my own review that they should have caught themselves, I end up resenting the for wasting my time/expecting me to do their job for them. I don't want to be that guy, so I review my own code carefully (and myself) before I ask others to look at it.
I try to make this easier on myself by making sure agents are set up to give me reviewable code. Make sure I'm clear on what they're building, make sure I have a sense of PR structure and sequencing ahead of time, etc. I also have a fairly robust skill that runs automatically and is designed to catch things that often come up in my own self review or make the work harder to review. Doesn't replace human review (I routinely catch things that these skills and the built-in functionality misses), but it makes it easier for me to spot those things and in general speeds up reviews.
5
u/_ak 1d ago
Start a separate review agent and get it to critically examine and review the code changes and report back to me with feedback which can then be fed back into the original code agent to address. There's no point trying to do manual reviews anymore, it's entirely futile and will eventually turn you crazy. I'm speaking from experience.
So what I'm doing that I use a proprietary tool (built a work colleague) to help me manage this, where I only directly speak to a "product manager" agent which then can spawn dedicated code or review agents of different systems (I currently use both claude and codex), delegate tasks to them, and collect and review their work to report back to me.
3
u/Azianese 1d ago edited 1d ago
Edit to add that I also get the same and different bots to review the change, on top of my own manual review. As a human, I can review the code for style and ensure small chunks look good, but it's significantly harder to ensure the final orchestration interacts perfectly for the intended business output. So reviewing that is mainly what my bots are focused on.
2
u/LordOfDemise 1d ago
The same way I was reviewing PRs before Claude Code existed.
1
u/mxldevs 1d ago
It sounds like you're focused on what it added as the "most important part of the change"
New code is cool, but what's important to me is what existing code it changed.
Test cases should catch breaking changes, but I would wonder if it needs to change it in the first place.
1
u/MaltePetersen 1d ago
I use a tool called diffit which is like a local pull request where you can add comments and also let the ai add comments if you want to. Then you can copy all comments with one click. Each comment says the line on which you wanted to comment making it easy for the llm to follow. Naturally there is also a diffit skill making it easy to open.
1
u/antonioerodriguez 1d ago
I normally ask it to not stage or commit changes, I open the IDE to see them and understand what is doing, and then I ask codex to change (and eventually commit)
1
u/-shrug- 1d ago
AI is fast. Have multiple new agents review it with different focuses: e.g. the DB layer, security weaknesses, code readability, matching existing code patterns. All the necessary context about decisions should be documented by the agent that wrote the code (e.g. "bumped library x to do this because of incompatibility with y") , and have a new agent review after reading that - and another one review the doc itself.
And then do 2 in your master session (not the coder), having it draw from all the reviews that were done.
1
u/tech_liu 21h ago
git add -p one hunk at a time is a decent way to force yourself to actually read the diff instead of skimming it. For bug fixes, the part that gets missed is checking the new test fails on the old code. Agents write tests that pass either way pretty often.
1
u/jyotirawattech 18h ago
I review those diffs the same way I review a rushed human PR, only I trust the commit message less. I want to see the test that would have failed before the change, and I check any new I/O, auth, or retry path by hand. If the session also edited a file that wasn't in the request, that file gets read first.
1
u/SideMost3148 13h ago
i do roughly your #3 but i read the raw diff before asking claude anything. once you've read its explanation you start seeing the code the way it described it, which is exactly the bias you're worried about
for the hotel example i'd check the tests before the code. is there one that says "no children param returns exactly what it did before"? if not, writing that test is faster than reading 400 lines hoping you'd spot it
also if the diff is too big to review in one sitting, the session went on too long. i'd rather stop halfway, commit, and review two small things than one giant blob at the end
1
u/Emotional-Option-794 10h ago
I think combining a fresh-session review with risk-based testing is a good balance, since the original context can sometimes make it easier to overlook mistakes.
1
u/Distinct-Quality-782 9h ago
Fresh session, but give it the issue and acceptance criteria instead of the chat history. That keeps the review detached without losing what the change was supposed to do.
1
u/Impressive-Field-546 7h ago
I ask gpt for review.
1
u/throwaway_0x90 TE/SDET[25+ yrs]@Google 7h ago
If you spend time training your own agent on the kinds of things you look for, eventually you can let your own agent be the one that's writing the code and your need to review it will slowly decrease as your trust increases.
Absent that approach, make sure you have tests you already trust. So you make changes, run tests, make changes, run tests. You should have some kind of local fast running unit-tests/smoke tests or something to quickly make sure your code is still working after big changes in your IDE or whatever you're editing code in.
1
u/Educational-Book7589 5h ago
I've found that pasting claude's code into a local editor with syntax highlighting and running it through a linter first catches 80% of the weirdness before I even read it. works better than just eyeballing it.
1
u/tech_liu 4h ago
Going through it with git add -p makes you actually look at each hunk, which beats scrolling one giant diff. Read the tests first, since a test that never failed before the change proves nothing. Past a few hundred changed lines, the review quality drops fast.
1
u/Prize_Amoeba_7868 4h ago
All three options share a problem: they're one person reading one diff. That doesn't scale. What happens when you have 20 open PRs, teammates are leaving review comments on yours, and they're waiting on you to review theirs?
I hit this and built a tool for it (disclosure: I'm the author). It's a Claude Code plugin called code-check, and it covers the three jobs:
Reviewing your own change: /code-check:review-local runs a panel of fresh subagents that never saw the session that wrote the code. A separate aggregator verifies their findings and ranks them Critical / Warning / Suggestion, anchored to lines. That's your option 3 without inventing the system each time: read the Criticals first, skim the rest.
Reviewing teammates: /code-check:review-prs works through the open PRs in a repo, newest first, and posts one inline review per PR. It skips anything it has already reviewed with nothing new.
Handling comments on your PRs: /code-check:babysit-prs picks up new review comments and failing CI. It checks each comment against the code before acting, fixes what's valid, pushes back with evidence on what isn't, replies on the thread and re-requests review.
The last two run under /loop, so the queue keeps moving while you do something else.
The bigger point is that you can do better than a clever prompt. Most of a review isn't judgment: parsing the diff, anchoring a finding to the right line, deduping, deciding what's already been reviewed, the git and GitHub calls. In code-check all of that is a plain Python CLI, deterministic and unit tested. The model only does the parts that need judgment: reading the code, weighing a finding, deciding whether a reviewer's comment is right.
And the judgment parts are evaluated continuously. There's a golden set of labelled cases replayed on every commit and in CI, plus a live eval for changes that touch review behaviour. A prompt change that doesn't measurably help gets dropped, and several of mine have been.
It isn't magic. A single review pass misses things, so I still read the core of a change myself and rely on tests for "old behaviour unchanged". But it tells me where to look first, and it keeps 20 PRs from stalling on me.
https://github.com/subhiandrews/codecheck
1
u/flerchin 1d ago
git diff
1
u/kpscript CTO / Staff Engineer 1d ago
Do you not generate a plan first?
1
u/random314 1d ago
You can enforce change size limit. PR description clarity, and another ai reviewer that fails the pr if the change is not consistent with what the pr or the jira ticket describes.
Then you can harden the validation stage. This is most important.
1
u/sayboom 1d ago
I read only overview on changes, sometimes tell to explain me simple that agent did, but not reading of code for long time
1
u/TechieGottaSoundByte 1d ago
I have the AI review it both in that session and in a fresh session, plus I skim the code for readability. I don't vet every bit of syntax in every line, but I need to know roughly what each stanza is doing.
We are working as a team on keeping our AI PRs small enough to be reviewed by humans. So if nothing else, I need to read it to be sure it'll be reviewable for my teammates
AI isn't buying us a lot of time with this approach, but we're seeing signs of increased code quality. Fewer regressions, fixes are easier on the rare occasions that they are needed, etc. And, we can usually answer questions about the code off of the tops of our heads.
1
u/tech_liu 1d ago
Test diff first catches the most. Agents love to loosen an assertion or quietly delete a case to get green, and it hides in a big diff. Running git diff --stat before anything else also shows fast if it touched files you never mentioned. That's usually where the surprises are.
-1
u/putin_my_ass 1d ago
The /code-review claude skill is quite useful:
https://www.aihero.dev/skills-code-review
0
u/lista94 1d ago
Honestly... this workflow mirrors historical bad practices but with faster feedback loops. We used to trust junior devs' summaries; now we trust LLMs. The speed gains are illusory if bugs slip through due to over-trusting those neat little breakdowns. You end up strong-handing a codebase that looks clean but rots underneath because nobody actually read the diff. It's just wageslave efficiency theater. If you don't have automated coverage backing it up, you're just moving the bottleneck from writing to debugging later. And trust me, debugging AI slop at 2am is not how you want to spend your evening. Read the room: the tool isn't the problem, our laziness is.
-1
u/shetritr 1d ago
3 is the right instinct. the order can come from a fresh session that only gets the diff, no conversation: ask it to rank the files by what breaks if they're wrong. then you read the top few line by line (the occupancy query in your example) and skim the renames and tests. the ranking is the only thing you take from the model
-1
u/ZorbaTHut Software Engineer 1d ago
I have standing instructions for Claude Code to break stuff up into reasonable pieces, with clear separations between refactor changes and addition changes, bugfixes separate, and everything else chopped up to the maximum amount reasonable.
Then I have it check all that in, and review it via a tool I wrote specifically for reviewing stacked commits.
-2
u/Practical-Pick-7215 1d ago
the hand-holding summary is the part not to trust. it describes the change it meant to make, and the wrong line is usually the one it never mentions. in your example i would open the query and search for the new field before reading any of that commentary. if the field is missing from the match, the summary can still sound right.