The Theatre of Pull Requests and Code Review

(meks.quest)

106 points | by todsacerdoti 5 hours ago ago

165 comments

  • herval 19 minutes ago ago

    I find the sort of opinions on this post quite common on a subset of engineers - namely mid levels with some time in the career, who start to consider themselves senior engineers and want everyone to follow the same set of strict rules they decided make sense. It’s the same mindset that makes people pedantically apply DRY to every situation or forcing others to TDD basic apps.

    In practice:

    - smaller PRs aren’t necessarily easier to review (and this arbitrary obsession almost always leads to PR overload in chunks that don’t make any sense, reducing code quality as a result)

    - nobody reads intermediate commit messages one by one on a PR, period. I worked on a team where the lead was adamant about this and started to write messages in the vein of “if you’re reading this message, I’ll give u $5”. I never paid anyone a dollar. Don’t waste your time writing stuff for no one.

    - “every commit must compile” - again, unnecessary overzealousness. Every commit on the MAIN branch definitely should compile. Wasting your time with this in a branch, as you work towards a solution, is focusing on the wrong thing

    You want PRs because they help others absorb what you’re doing (they’ll have to read that same code sooner or later). You don’t want to create a performance theater.

    • MoreQARespect 9 minutes ago ago

      The "mid levels who consider themselves senior" are the exact type of people who I see saying what you're saying, i.e.

      * Yes, TDD on production code is nice in theory, but it doesnt work in my case.

      * Yes, short PRs are nice in theory, but it doesnt work in my case.

      In virtually every case it means "I dont know how to do it".

      When I say "if you dont think it works in your case, come to me, Ill show you how to make it work" they often demur.

      In practice Ive never seen a long PR that wouldnt have benefitted from being broken up, but every other day I see one that should have been.

      • BobbyJo 2 minutes ago ago

        > Yes, TDD on production code is nice in theory, but it doesnt work in my case...

        Parent said something more along the lines of "they don't work in every case, and trying to force it in every case is misguided".

        I agree that too big is more common than too small with respect to PR size, but you aren't putting forward much of an argument against parents "there are no absolutes" argument by straw manning them.

      • herval 6 minutes ago ago

        Sure.

    • leetrout 12 minutes ago ago

      My simple suggestion to my teams:

      PRs are emails to your team and to your future self.

      Framed in that context it's easier to carry the correct tone and think about scoping / what's important.

      ---

      > pedantically apply DRY to every situation

      I swear DRY has done more damage to the software industry from the developer side than it has done good because it has manifested into this big stick with which to bludgeon people without taking context into account.

  • jvanderbot 4 hours ago ago

    PR review is probably at least a little performative.

    But I trust my colleagues to do good reviews when I ask them to, and to ignore my PRs when I don't. That's kind of the way we all want it.

    I regularly ask for a review of specific changes by tagging them in a comment on the lines in question, with a description of the implications and a direct question that they can answer.

    This, "throw the code at the wall for interpretation" style PR just seems like it's doomed to become lower priority for busy folks. You can add a fancy narrative to the comments if you like, but the root problem is that presenting a change block as-is and asking for a boolean blanket approval of the whole thing is an expensive request.

    There's no substitute for shared understanding of the context and intent, and that should come out-of-band of the code in question.

    • vinnymac 2 hours ago ago

      For any PR above a few line change, if a developer has not done a self review, I don’t review it all.

      Instead I request that it is self reviewed with context added, prior to requesting re-review.

      I also tend to ask the question, “are any of these insights worth adding as comments directly to the code?”

      9/10 the context they wrote down should be well thought out comments in the code itself. People are incredibly lazy sometimes, even unintentionally so. We need better lint tools to help the monkey brain perform better. I wish git platforms offered more UX friendly ways to force this kind of compliance. You can kind of fake it with CI/CD but that’s not good enough imo.

      • tcoff91 an hour ago ago

        By self review, you mean that the developer adds comments in the code review tool? that is a great idea, I want to try this.

        • nicksergeant an hour ago ago

          Yep. Self-reviewing your own PRs is a large boost to both yourself and the team, and often one of the first things I encourage new-ish developers to do.

          - 90% of the time when you self-review your own PR, you're going to spot a bug or some incorrect assumption you made along the way. Or you'll see an opportunity to clean things up / make it better.

          - Self-reviewing and annotating your reasons/thought process gives much more context to the actual reviewer, who likely only has a surface level understanding of what you're trying to do.

          - It also signals to your team that you've taken the time to check your assumptions and verify you're solving the problem you say you are in the PR description.

          • t-writescode 8 minutes ago ago

            Even when I worked for myself and had CodeRabbit help me do MRs, I still did a self-review before pushing any change to main.

            Self-review is very, very helpful.

        • goosejuice an hour ago ago

          I thought everyone did this. I review twice. For each commit with -v and finally in GH/GL after I open the PR/MR. I often catch something on that last one.

          It's rubber ducking.

          • manwe150 an hour ago ago

            What is `-v` mean here? I was assuming `git show`, but that doesn't seem to have a `-v` parameter.

            • ljosa 29 minutes ago ago

              `git commit` has a `-v` option that adds the diff to the bottom of the commit message template so you can see it while you write the message.

        • ljm an hour ago ago

          I do it quite often and it's great, because it helps contextualise some changes that might not seem to be intuitive.

          You could argue this is what commits are for, but given how people use GitHub and PRs, it gives some extra visibility.

          And if you're going to use AI to assist you when writing the code I would argue this self-review step is 100% mandatory.

        • disgruntledphd2 33 minutes ago ago

          I've done this and strongly recommend.

        • Fishkins an hour ago ago

          Yeah, I never send a PR out without reviewing each commit myself and adding GitHub comments when I think it's relevant. Sometimes a PR is clear enough that I don't feel the need to add comments, though.

        • DerArzt an hour ago ago

          I've been doing this as part of my workflow for a few years now. My coworkers have expressed appreciation around that effort.

          A nice side effect is that going through a self review and adding comments to the PR has helped me catch innumerable things that my coworkers never had to call me on.

    • xmcqdpt2 3 hours ago ago

      This is a huge pet peeve of mine. At work I'm an expert on part of the code base that sees a fair number of contributions.I get many private IMs from colleagues asking me to "Approve please" or something like that with a dump of 100s of lines, of which maybe 10 lines are relevant to me (touch files or behaviour that I'm an expert on, hence why they need my approval.)

      Minimally, I would like context for the change, why it required a change to this part of the codebase, and the thought process behind the change. Sometimes but not often enough I send the review back and ask them for this info.

      IMO many software developers are just not fast enough at writing or language so providing an explanation for their changes is a lot of work for them. Or they are checked out and they just followed the AI or IDE until things worked, so they don't have explanations to provide. People not taking the time is what makes reviews performative.

      • dijksterhuis 2 hours ago ago

        > Minimally, I would like context for the change, …

        … the why is important

        > IMO many software developers … don't have explanations to provide. People not taking the time is what makes reviews performative.

        … a lot of developers only consider the how.

        i’ve had a lot of experiences of “once my PR is submitted that’s my work/ticket finished” kind of attitude.

        i spent a year mentoring some people in a gaming community to become dev team members. one of the first things i said about PRs was — a new PR is just your first draft, there is still more work to do.

        it helped these folks were brand spanking new to development and weren’t sullied by some lazy teacher somewhere.

        • stronglikedan an hour ago ago

          > … the why is important > … a lot of developers only consider the how.

          The why is someone else's job, so the developers should just ask them for a blurb to put in the PR for context, along with a note to the reviewer to ask that person for even more context if necessary.

          • pas 26 minutes ago ago

            I think there's a why with regard to the code. Why this "how" and not some other "how". (Why did you pick this algorithm, this pattern, this solution to the bigger business why.)

      • ambicapter an hour ago ago

        > IMO many software developers are just not fast enough at writing or language

        I think this is the overwhelming factor, software engineering doesn't select for communication skills (and plenty of SEs will mock that as a field of study), or at least most SEs don't start out with them.

        • goosejuice an hour ago ago

          > SEs will mock that as a field of study

          Who are these people? I've never encountered that. In my experience engineers who aren't great at communication freely own up to it.

      • scuff3d an hour ago ago

        Commit descriptions are criminally under used for this purpose. You can add so much more context if you don't limit yourself to just the short commit message.

    • balamatom 4 hours ago ago

      >that should come out-of-band of the code in question.

      Ideally, yes. After a decade and something' under ZIRP, seems a lot of workers never had incentive to remain conscious of their intents in context long enough to conduct productive discourse about them. Half of the people I've worked with would feel slighted not by the bitterness the previous sentence, but by its length.

      There's an impedance mismatch between what actually works, and what we're expected to expect to work. That's another immediate observation which people to painfully syntaxerror much more frequently than it causes them to actually clarify context and intent.

      In that case the codebase remains the canonical representation of the context and intent of all contributors, even when they're not at their best, and honestly what's so bad about that? Maybe communicating them in-band instead of out-of-band might be a degraded experience. But when out-of-band can't be established, what else is there to do?

      I'd be happy to see tools that facilitate this sort of communication through code. GitHub for example is in perfect position to do something like that and they don't. Git + PRs + Projects implement the exact opposite information flow, the one whose failure modes people these days do whole conference talks about.

    • pards 4 hours ago ago

      > and to ignore my PRs when I don't

      PRs should be optional, IMHO. Not all changes require peer review, and if we trust our colleagues then we should allow them to merge their branch without wasting time with performative PRs.

      • t-writescode 6 minutes ago ago

        SOX compliance audit looks suspiciously at this comment.

        No single person being able to make changes to a system is a tenant of that.

      • fidotron 4 hours ago ago

        There is a difference between a code review and approval to merge/release.

        Part of the difference is the idea you can catch all problems with piecemeal code review is nonsense, so you should have at least some sweeping QA somewhere.

      • flir 3 hours ago ago

        I always appreciate an extra pair of eyeballs, even on a one-liner. Everyone's an idiot sometimes.

        • eCa 11 minutes ago ago

          I’m firmly in this boat too. If it’s a small change I can likely get it reviewed within minutes, if it isn’t small it should have a review regardless.

      • gagabity an hour ago ago

        Yes! I once read a great article I can no longer find that talked about 3 types of PRs. Simple ones that you self approve. Ones that you tag someone because you want to spread the knowledge of what has been done. And ones that need actual review. Everything being reviewed is simply unnecessary and exhausting.

      • comprev 2 hours ago ago

        Trust, but verify. We're only human after all :-)

        At $DAY_JOB we need approvals from peers due to industry regulation.

        • goosejuice an hour ago ago

          In my experience, US healthcare, that box can be checked at later stages, namely deployment to production. It's a choice to add it earlier.

          • eCa 7 minutes ago ago

            If it is for checking a box, sure. If it is part of a process that aspires to deliver projects with quality and with somewhat predictable release dates, that seems way too late, imho.

            • t-writescode a minute ago ago

              And a great way to end up leaking customer data from a SQL injection or other error that could have easily been caught during a more piece-wise analysis and vetting of the related code nearer to time of writing.

            • goosejuice 2 minutes ago ago

              Sadly it often is box checking, code review or not. I'm only stating that there is no requirement in US healthcare that I'm aware of that requires approvals before merging code. Maybe that's not true in other industries. But most regulatory frameworks that I'm aware of are flexible, ambiguous, on implementation details by design.

              If you find that outcomes are the same by making approvals optional at that stage, then do so with accompanied justification.

  • roblh 21 minutes ago ago

    Maybe I'm just a scrub, but something that I find makes it harder to do smaller commits is that I frequently rely on being able to see which lines I've changed directly inline in my editor. When you commit, vscode now stops highlighting all of those lines, and that makes it much more difficult for me to orient myself relative to what I've already done. The individual lines, and the git pane that shows which files have been changed, act as waypoints for me while I'm working on stuff. It's particularly important on more complicated features that span more files, and I'll often intentionally commit stuff I feel like I'm not likely to touch again to reduce some visual noise.

    • t-writescode 13 minutes ago ago

      This sounds like a real and valid incompatibility with a high frequency commit cadence.

      If you’re interested in trying these strategies anyway, does your editor of choice have an inline “git blame”? In IntelliJ, I can see who and when committed the most recent change in the line around the one I’m working on.

      It doesn’t resolve the “which files have I worked on” issue; but it might help the others? Not as nice as a different colored line like uncommitted code would otherwise be highlighted, but it could be enough of a step in that direction?

    • crazygringo 13 minutes ago ago

      That's really interesting.

      Seems like it would be even better if VS Code provided a way to highlight all lines changed relative to a particular commit like the start of a branch. Maybe it's worth filing a feature request?

      (I don't use VS Code this way so I'm assuming it doesn't already have this.)

    • rd 13 minutes ago ago

      you could probably write an extension to accomplish this in a couple of days with GPT-5 now

    • hypeatei 14 minutes ago ago

        git add --patch
      
      ...is your friend if you want to leave all your changes unstaged for awhile then break it out into multiple commits later.
      • t-writescode 10 minutes ago ago

        To add, when I’m breaking my changes down into multiple parts for review, I tend to:

          * squash everything I’ve done into one commit
          * create a new branch off main/master that will be the “first commit”
          * cherry-pick changes (easy from some git guis) that represent a modular change.
          * push and make an MR from the new branch
          * rebase “the big commit” on top of the partial change.
          * wash, rinse and repeat for each change, building each MR off its requisite branch.
        
        The squashing part is vital because otherwise you enter merge conflict hell with the rebase.
  • davedx 3 hours ago ago

    It's a very common refrain but I don't really agree with it:

    "How do you create a PR that can be reviewed in 5-10 minutes? By reducing the scope. A full feature should often be multiple PRs. A good rule of thumb is 300 lines of code changes - once you get above 500 lines, you're entering unreviewable territory."

    The problem with doing this is if you're building something a lot bigger and more complex than 500 lines of code, splitting that up across multiple PR's will result in:

    - A big queue of PR's for reviewers to review

    - The of the feature is split across multiple change sets, increasing cognitive load (coherence is lost)

    - You end up doing work on branches of branches, and end up either having to become a rebase ninja or having tons of conflicts as each PR gets merged underneath you

    The right answer for the size of a PR is NOT in lines of code. Exercise judgement as to what is logically easier to review. Sometimes bigger is actually better, it depends. Learn from experience, communicate with each other, try to be kind when reviewing and don't block things up unnecessarily.

    • vault_ 2 hours ago ago

      > - A big queue of PR's for reviewers to review

      This is a feature. I would infinitely prefer 12 PRs that each take 5 minutes to review than 1 PR that takes an hour. Finding a few 5-15 minute chunks of time to make progress on the queue is much easier than finding an uninterrupted hour where it can be my primary focus.

      > - The of the feature is split across multiple change sets, increasing cognitive load (coherence is lost)

      It increases it a little bit, sure, but it also helps keep things focused. Reviewing, for example, a refactor plus a new feature enabled by that refactor in a single PR typically results in worse reviews of either part. And good tooling also helps. This style of code review needs PRs tied together in some way to keep track of the series. If I'm reading a PR and think "why are they doing it like this" I can always peek a couple PRs ahead and get an answer.

      > - You end up doing work on branches of branches, and end up either having to become a rebase ninja or having tons of conflicts as each PR gets merged underneath you

      This is a tooling problem. Git and Github are especially bad in this regard. Something like Graphite, Jujutsu, Sapling, git-branchless, or any VCS that supports stacks makes this essentially a non-issue.

    • sebk 2 hours ago ago

      I agree with this. One way to keep changes small but still compose them into a coherent PR is to make each commit in the final PR independently meaningful, rather than what actually transpired during local development. TFA touches on this somewhat, contradicting the bit you quoted.

      A trivial example would be adding the core logic and associated tests in the first commit, and all the remaining scaffolding and ceremony in subsequent commits. I find this technique especially useful when an otherwise additive change requires refactoring of existing code, since the things I expect will be reviewed in each and the expertise it takes are often very different.

      I don't mind squashing the branch before merging after the PR has been approved. The individual commits are only meaningful in the context of the review, but the PR is the unit that I care about preserving in git history.

      • scuff3d an hour ago ago

        The problem that I find myself in is that I almost always run into stuff I didn't expect. Some integration that I thought would be minor turns out to slowly get out of hand, and before I know it I've made way more changes than I meant to. And then it all gets tangled together.

        Maybe it's just a me problem, maybe I need to be more disciplined. Not sure but it catches me quite often.

        • roguecoder 20 minutes ago ago

          That's one of the challenges with making changes all at once: it is a lot easier for one thing going wrong to suddenly result in thousands of lines of changes.

          One technique I use when I find that happening is to check out a clean branch, and first make whatever structural change I need to avoid that rabbit hole. That PR is easy to review, because it doesn't change any behavior and there are tests that verify none of my shuffling things around changed how the software behaves (if those tests don't exist, I add them first as their own PR).

          Once I've made the change I need to make easy, then the PR for the actual change is easy to review and understand. Which also means the code will be easy to understand when someone reads it down the line. And the test changes in that PR capture exactly how the behavior of the system is changed by the code change.

          This skill of how to take big projects and turn them into a series of smaller logical steps is hard. It's not one that gets taught in college. But it lets us grow even large, complex code bases that do complex tasks without getting overwhelmed or lost or tangled up.

          • scuff3d 9 minutes ago ago

            That makes sense. Reading your comment got me thinking some of the issue might be that I have always worked on somewhat immature projects. Either R&D or greenfield projects. Which is super nice in a whole lot of ways, but a lot of times I don't know what the final shape of the changes to the rest of the system are going to be, because that part of the system itself isn't well established yet. So it evolves throughout whatever I'm doing. Which would make it difficult to break them off and work them in a different branch.

            Maybe there's a partial solution if I can keep those commits clean and separate in the tree. And then when I'm done reorder things such that those all happen as a block of contiguous commits.

    • frankc 39 minutes ago ago

      I also feel like what gets lost in this is not everything you are building is a bite size feature in large existing project. Sometimes you are adding an entire subsystem that is large to something relatively greenfield. if you broke that down into features, you will need 20 PRs and if you wait for review, or even don't wait but have to circle back to integrate lots of requested changes, what might be a couple of weeks of work turns into 2 to 3 months of work. That just does not work unless you are in a massive enterprise that is ok with moving like molasses. Do you wind up with something not as high quality? Probably. But that is just the trade-off with shipping faster.

      • roguecoder 9 minutes ago ago

        If you are the only developer who ever going to work on something, maybe. Even then, I will argue you are more likely to deliver successfully if you are cutting your work into smaller pieces instead of not delivering anything at all for weeks at a time.

        But for the company, having two people capable of working on a system is better than one, and usually you want a team. Which means the code needs to be something your coworkers understand, can read and agree with. Those changes they ask for aren't frivolous: they are an important part of building software collaboratively. And it shouldn't be that much feedback forever: after you have the conversation and you understand and agree with their feedback, the next time you can take that consideration into account when you are first writing the code.

        If you want to speed that process up, you can start by pair programming and hashing out disagreements in real time, until you get confident you are mostly on the same page.

        Professional programming isn't about closing tickets as fast as possible. It is about delivering business value as a team.

    • roguecoder 26 minutes ago ago

      It's not about splitting up the PR: it is about splitting up the _work_.

      If you don't have feature flags, that is step one. Even if you don't have a framework, you can use a Strategy or a configuration parameter to enable/disable the new feature, and still have automated testing with and without your changes.

    • scuff3d an hour ago ago

      > You end up doing work on branches of branches, and end up either having to become a rebase ninja or having tons of conflicts as each PR gets merged underneath you

      This shouldn't matter unless you are squashing commits further back in the tree before the PR or other people are also merging to main.

      If a lot of people are merging back to main so you're worried about those causing problems, you could create a long life branch off main, branch from that and do smaller PRs back to it as you go, and then merge the whole thing back to main when your done. That merge might 2k lines of code (or whatever) but it's been reviewed along the way.

      I don't necessarily disagree with you. Just pointing out that there are ways to manage it.

    • CuriouslyC 2 hours ago ago

      100%. I think the right answer is to break features into atomic commits, but keep PRs at the feature level. This reduces the PR friction, while letting reviewers easily view change sets for specific features, and if a specific feature needs a patch you don't need to do any rebase gymnastics, just add a patch commit.

      AI agents like frequent checkpoints because the git diff is like a form of working memory for a task, and it makes it easy to revert bad approaches. Agents can do this automatically so there isn't much of an excuse not to do it, but it does require some organization of work before prompting.

    • nerdponx an hour ago ago

      Here's an alternative approach: Discuss the design with your team beforehand, and have active ongoing discussions, sanity checks, and even pair programming during the development process. That way the review is not an exhaustive end-to-end review with the reviewer coming in cold. It's instead the final approval step in a long chain of decisions that have already been discussed and agreed upon.

      Of course that won't work for all projects/teams/organizations. But I've found that it works pretty well in the kinds of projects/teams/organizations I've personally been a part of and contributed to.

    • tcoff91 2 hours ago ago

      A stack of PRs is much better for reviewers than a single massive PR.

      Use jujutsu and then stacking branches is a breeze

    • computronus 2 hours ago ago

      I do agree with the common refrain, actually, and disagree with the idea that work can be so big and complex that it has to be in one pull request.

      > A big queue of PR's for reviewers to review

      Yes, yes please. When each one is small and understandable, reviewers better understand the changes, so quality goes up. Also, when priorities change and the team has to work on something else, they can stop in the middle, and at least some of the benefits from the changes have been merged.

      The PR train doesn't need to be dumped out in one go. It can come one at a time, each one with context around why it's there and where it fits into the grander plan.

      > The [totality] of the feature is split across multiple change sets, increasing cognitive load (coherence is lost)

      A primary goal of code review is to build up the mental map of the feature in the reviewers' brains. I argue it's better for that to be constructed over time, piece by piece. The immediate cognitive load for each pull request is lower, and over time, the brain makes the connections to understand the bigger picture.

      They'll rarely achieve the same understanding of the feature that you have, you who created and built it. This is whether they get the whole shebang at once or piecemeal. That's OK, though. Review is about reducing risk, not eliminating it.

      > You end up doing work on branches of branches, and end up either having to become a rebase ninja or having tons of conflicts as each PR gets merged underneath you

      I've learned not to charge too far ahead with feature work, because it does get harder to manage the farther you venture from the trunk. You will get conflicts. Saving up all the changes into one big hunk doesn't fix that.

      A big benefit of trunk-based development, though, is that you're frequently merging back into the mainline, so all these problems shrink down. The way to do that is with lots of small changes.

      One last thing: It is definitely more work, for you as the author, to split up a large set of changes into reviewable pieces. It is absolutely worth it, though. You get better quality reviews; you buy the ability to deprioritize at any time and come back later; most importantly for me, you grasp more about what you made during the effort. If you struggle to break up a big set of changes into pieces that others can understand, there's a good chance it has deeper problems, and you'll want to work those out before presenting them to your coworkers.

    • yunohn 2 hours ago ago

      > You end up doing work on branches of branches, and end up either having to become a rebase ninja or having tons of conflicts as each PR gets merged underneath you

      +100 to this. My job should be thoughtfully building the solution, not playing around with git rebase for hours.

      • tcoff91 2 hours ago ago

        Just use jj instead of git and cut your rebasing time by 95%.

        Suddenly rebasing a stack of branches becomes 1 command.

  • arnorhs 6 minutes ago ago

    This idea of every PR being a small chunk that you can review in 5-10 minutes is completely ridiculous. It is reasonable for bug fixes or small improvements, but the review time you should expect for a PR should reflect the size and impact of a feature, not some arbitrary number.

    Yes, everybody would love it if every PR was small enough. In reality that is not a good way to build substantial features.

    Often, fully building out a substantial feature, causes you to change your mind and completely changing your approach the further along you are. You don't want to be muddying up the PR pipeline with a bunch of half-assed changes.

    Doing that just makes reviewers less inclined to give good feedback on a PR, because they "know it's going to change so much anyways".

    If you are building a substantial feature, it is reasonable that the PR is large and reviewers will have to dedicate substantial time to reviewing it. Reviewing it is work on its own and hopefully your engineers have dedicated time to review substantial features.

    Of course, you should make sure your substantial feature is as minimal as possible, for whatever is needed to ship the feaure - but not any less than that.

  • WorldMaker an hour ago ago

    I wish GitHub's PR UI was better at walking through a PR one commit at a time. As someone who does try to make good commits, and as someone who does try to read PRs sometimes a commit at a time, GitHub's UI gets in the way and keeps trying to drive you back to "whole PR" reviews.

    It is very telling in the article itself there is a screenshot of the commits tab in the PR workflow that many don't realize even exists and/or never think to use.

    In the Files tab the commit picker has gotten better in recent years, but it is still overly focused on selecting ranges of commits over individual ones, and there's no shortcuts to easily jump Next or Previous commit, you have to remember your place and interact with the full pulldown every time. Also, it's hard to read the full descriptions of commits in the Files view and I find I often have to interrupt my flow to open the commit in another browser tab or flip back and forth between the Commits tab and the Files tab in the PR. The Commits tab also defaults to hiding most of the commit descriptions, so it's still not a particularly great reading experience.

    It feels like a bit of a bad feedback loop that GitHub's UI doesn't make commit-by-commit reviewing clean/easy because GitHub themselves don't expect most developers to write good commits, but a lot of developers don't write good commits today simply because GitHub's PR interface is bad at reviewing individual commits and developers don't see as much of a point in it if they aren't going to be reviewed in that way.

    • DenisM 20 minutes ago ago

      Graphite addressees this issue in a different way - it lets the author split a pr into several smaller prs, so one can review it piece by piece, but still see the whole super-pr in one place. It does a decent job rebasing stacked prs as well.

    • arcanemachiner 20 minutes ago ago

      If faced with this issue, I would probably just pull the remote/branch locally and step through it, commit by commit, using my preferred Git manager (Lazygit).

    • candiddevmike an hour ago ago

      Can you describe a little more about why you walk through individual commits instead of just reviewing the latest commit only?

      • XorNot 43 minutes ago ago

        Because the idea is that each commit that you submit is a coherent unit of work. That's why we have commit messages.

  • CraigJPerry 14 minutes ago ago

    Pair programming > PR reviews.

    I've heard people scoff at the $$ cost of "mob programming". I think that view is totally myopic, for appropriate problems there's just no faster nor higher bandwidth way to transfer code knowledge in a group.

    Plenty of people dislike pair programming, i don't dislike it but i do find it mentally intense, tiring. I really really enjoy that it's an accelerator for getting to done - not just i wrote the code but the code is correct - sooner.

    Long way to say don't rely on pull requests when you could be doing pairing for the important stuff.

  • danielfalbo 2 hours ago ago

    Jane Street implements an awesome code review system: https://janestreet.com/tech-talks/janestreet-code-review

    > [...] Telling a Story with Commits [...]

    > [...] it should take the average reviewer 5-10 minutes [...]

    Jane Street code review system kinda solves this problem by

    - making each commit a branch,

    - stacking branches on top of each other (gracefully handling rebases and everything that comes with it), and

    - reviewing one iteration at a time

    So one reviews single commits independently (takes probably around 5mins), and "forces" the reviewer to re-live the story that led to the bigger diff.

    I do not work at Jane Street but I frequently find myself pondering on how broken the common code review system/culture is. I've heard of tools like graphite.dev that build on top of git to provide a code review system similar to the Jane Street one, but I'm not an active user yet (I just manually stack PRs, keep them small and ask for review to one at a time to my colleagues, and handle the rebasing etc. manually myself for now).

    • maleldil 44 minutes ago ago

      > handle the rebasing etc. manually myself for now

      jj[1] is helpful for this. If you have a chain of commits like A -> B -> C, and you make a change to A, the rest of the chain is automatically rebased.

      [1] https://jj-vcs.github.io/

  • bob1029 2 hours ago ago

    I see the primary value of a pull request being the simple awareness of what is being worked on. I aggressively sync my local changes to PRs that are marked draft in GitHub. Other developers I work with do the same. Throughout the day we asynchronously check in on the scope of the others' work. If there is something that looks like it might conflict, we call a meeting.

    The actual code review phase for me is more about making sure the checkin is clean and that what I am intending to work on wont get caught up in a conflicting mess. The code review is NOT a recurring opportunity to purity test my teammates. Presumably, the reason they are working with us in the first place is because they already succeeded at this. "Trust but verify" is a fun trope if you are working somewhere the consequences of a mistake are one-way and measured in millions of dollars. However, a bad commit can be reverted in 10 seconds. Builds of software can be easily recreated. Deploying to production is still sensitive, but why get all weird about rapidly iterating through dev or QA environments?

    • roguecoder 5 minutes ago ago

      Why do you see feedback as "purity test"ing?

      Newspaper reporters are professionals and they still have editors. We've all seen the disaster that results when an author gets too famous to edit. And we don't have to go in and work with their prose later.

      Code reviews are where "my" code becomes "our" code: I want my coworkers to feel comfortable with and fully understand and be happy to support the changes I am proposing to our software.

  • ekidd 4 hours ago ago

    A lot depends on your goals for your code reviews. And your goals might even be different for different parts of the code base.

    - Are you trying to make sure that more than one human has seen the code? Then simply reading through a PR in 10 minutes and replying with either a LGTM or a polite version of WTF can be fine. This works if you have a team with good taste and a lot of cleanly isolated modules implementing clear APIs. The worst damage is that one module might occasionally be a bit marginal, but that can be an acceptable tradeoff in large projects.

    - Does every single change need to be thoroughly discussed? Then you may want up-front design discussions, pairing, illustrated design docs, and extremely close reviews (not just of the diffs, but also re-reviewing the entire module with the changes in context). You may even want the PR author to present their code and walk throuh it with one or more people. This can be appropriate for the key system "core" that shapes everything else in the system.

    - Is half your code written by an AI that doesn't understand the big picture, that doesn't really understand large-scale maintainability, and that cuts corners and _knowingly_ violates your written policy and best practices? Then honestly you're probably headed for tech debt hell on the express train unless your team is willing to watch the AI like hawks. Even one clueless person allowing the AI to spew subtlety broken code could create a mess that no number of reviewers could easily undo. In which case, uh, maybe keep everything under 5,000 lines and burn it all down regularly, or something?

    • pm215 3 hours ago ago

      I think the other thing that often muddies the waters in discussions of code review is that open source projects and internal codebases are generally in rather different situations. An internal codebase is usually worked on by a fairly small group of experienced people, who are both creating and also reviewing PRs for it. So:

      - the baseline "can I assume this person knows what they're doing?" level is higher

      - making the "create PR" process take longer in order to make the review process faster is only a tradeoff of the time within the team

      - if something is wrong with the committed code, the person who wrote it is going to be around to fix it

      But in open source projects, there are much more often contributions by people outside the "core" long-term development team, where:

      - you can't make the same assumptions that the contributor is familiar with the codebase, so you need to give things extra scrutiny

      - there are often many fewer people doing the code review than there are submitting changes, so a process that requires more effort from the submitter in order to make the reviewer's job easier makes sense

      - if there's a problem with the code, there's no guarantee that the submitter will be available or interested in fixing it once it's got upstream, so it's more important to catch subtle problems up front

      and these tend to mean that the code-review process is tilted more towards "make it easy for reviewers, even if that requires more work from the submitter".

      • bonzini 2 hours ago ago

        > - if there's a problem with the code, there's no guarantee that the submitter will be available or interested in fixing it once it's got upstream, so it's more important to catch subtle problems up front

        It's also more important to have good tools to analyze subtle problems down the line, thus increasing the importance of bisection and good commit messages.

        An underrated benefit of "make it easy for reviewers" is that when a bug is found, everybody becomes a potential reviewer. Thus the benefit does not finish when the PR is merged.

  • Dan42 an hour ago ago

    I see posts like this one pop up from time to time. I love it. Based on my 30y of exp that's also the workflow I converged on. It seems to me like every experienced and skilled developer is converging on this. jujutsu is entirely built to accommodate this workflow.

    There are no silver bullets or magical solutions, but this is as close to one as I've ever seen. A true "best practice" distilled from the accumulated experience of our field, not from someone with something to sell.

  • KronisLV 30 minutes ago ago

    > This makes logical sense, but it's challenging to implement because it can feel like admitting we're not smart enough to understand the code. However, saying "I don't understand this enough to approve it" is far more valuable than pretending with an empty "LGTM".

    Sounds nice but I’m sure that there are projects out there that are like constantly being in the trenches, testing in prod and the original developers being long gone, where the devs manage to barely keep alive this WH40kesque monstrosity. Where all of the code has a lot of incidental complexity that will just never be resolved.

    Alternatively, there’s probably countries and companies out there where that attitude would get you flagged as someone who is slowing down the velocity and get you fired - because there’s an oversaturation of devs in the local market and you’re largely an expendable cog.

    Surely there’s other methods, formal or LLM driven that could be used to summarize changes and help explore everything bit by bit (especially when there’s just one big commit that says “fix” as a part of the PR).

    Sometimes I get too caught up with coming up with contrived scenarios where “best effort” just will never happen but I bet someone out there is living that reality right now.

  • conartist6 3 hours ago ago

    If your goal is to lower the velocity of your organization, e.g. because in practice code churn or poor quality are major problems, then by all means do this.

    If you still need to move fast, then don't.

    This is the "don't run in the hallways" version of software culture, but I would contend that you should choose your pace based on your situation. It's just like gradient descent really. The be efficient sometimes you need to make big hops, sometimes small ones.

    • gorgoiler 3 hours ago ago

      Your comment includes capital letters and punctuation! These are skills we all learn to ensure our writing is as legible as possible to the reader. Quotes, periods, commas, clauses, paragraphs etc. are all stylistic decisions that support the underlying text and message.

      I contend that learning the art of story telling through a stack of patches is just as important and, once learned, comes just as naturally as utilizing vocabulary, grammar, syntax and style with the written word.

  • epage 4 hours ago ago

    Agree with the overall sentiment but disagree with

    > A good rule of thumb is 300 lines of code changes - once you get above 500 lines, you're entering unreviewable territory.

    I've found LoC doesn't matter when you split up commits like they suggest. What does matter is how controversial a change is. A PR should ideally have one part at most that generates a lot of discussion. The PR that does this should ideally also have the minimal number of commits (just what dossn't make sense standalone). Granted this take experience generally and experience with your reviewers which is where metrics like LoC counts can come in handy.

    • padjo 4 hours ago ago

      It’s often an inverse correlation in well functioning environments. Controversial changes and bug fixes are small and targeted and are deeply reviewed for unintended side effects, while large change sets are often new work that’s been discussed upfront and follows well established patterns and gets waved through.

    • stillworks 3 hours ago ago

      In some parts of the industry number of CRs and revisions-per-cr is tracked as a performance metric.

      Many people learn to game this to make their "numbers" appear good i.e. high number of CRs and low revisions per CR.

      • osigurdson 3 hours ago ago

        Easy and fun to put metrics around random things. I'll start to squirm if you ask me to draw the connection between these metrics and NPV.

        • stillworks an hour ago ago

          The interesting phenomenon is the discovery of gamification of such metrics.

          I do see the value in breaking down larger chunks of work into logically smaller units of work and then produce multiple pull requests where needed.

          But some people are really clever and influential and manage to game these numbers into "apparent success".

    • SOLAR_FIELDS 4 hours ago ago

      Good luck getting 90% of devs to commit (har har) to this level of history surgery. Of the ones that actually know how to do it (a small fraction of your typical engineer) an even smaller fraction of that is going to have the patience to do it correctly. You’ll tell devs to do this kind of thing and you’ll either have their eyes glaze over from lack of understanding, annoyance at the extra work, or nodding then apathetical disregard. The one top engineer will do it then be frustrated that the rest of the org doesn’t do proper commit hygiene.

      It’s not really something you can easily enforce with automation, so basically unachievable unless you are like Netflix and only hiring top performers. And you aren’t like Netflix.

      • StilesCrisis 3 hours ago ago

        You also need tools that support the workflow. I love small self-explanatory commits. In git, it's easy to do. Recently I switched to a Perforce organization and it's a disaster. P4 doesn't support stacked CLs and it dramatically hurts engineering quality. Everyone lands mega-CLs because it's the only supported workflow.

  • osigurdson 3 hours ago ago

    The PR type approach comes from the Linux kernel where there is essentially a hierarchy of gatekeepers with increasing trust and responsibility. It is a very individualistic type approach (i.e. if you merged it into your branch, it's on you and speed is a non-goal for the most part). This is often different from many software projects as it is like a collective where often, no one really has individual responsibility for anything (it is more like collective responsibility), speed is everything and there are certainly no gate keepers - maybe the review actually doesn't matter that much in this context.

    • g-b-r an hour ago ago

      If security or bugs don't matter much for your project, sure

  • roguecoder 29 minutes ago ago

    You are going to have to read the code again later, at 3am, when something has gone wrong. So if anything, the feedback from code reviews is unrealistically relaxed: our code should be easily understood and extended under significantly _more_ pressure.

    Giving good code reviews takes practice and courage. Accepting the feedback with grace takes practice and courage. But when it is done well, when each pull request is either a behavior change or a structural change but not both and the feedback engages in aesthetics and design and architecture and technique, code reviews can make for massively better software.

  • dakiol 4 hours ago ago

    There’s a fine difference between a) splitting a big feature in parts that interact with each other via well defined interfaces, and b) splitting a big feature in parts that are suitable for PRs

    You can split a big feature in N MRs and that doesn’t necessarily mean the N MRs are easier to understand (and so to review) than a single big MR. Taking into account the skills of the average software engineer, I prefer to review a single big MR than N different and not very well connected MRs (the classic example is that MR number N looks good and innocent, but then MR number N+1 looks awful… but since MR number N was already approved and merged the incentives are not there to redo the work)

  • nenenejej 4 hours ago ago

    300 LOC in 10 minutes. Or 2 sec per loc. Or for average 30 char line, 600wpm reading speed.

    OK.

    There is little you can review properly in 10 minutes unless you were already pairing on it. You might have time to look for really bad production-breaking red flags maybe.

    Remember the underlying reasons for PR. Balance between get shit done and operational, quality and tech debt concerns. Depending on what your team needs you can choose anything from no review at all to 3x time reviewing than coding. What is right depends on your situation. PR is a tool.

    • enlyth 4 hours ago ago

      I like to actually checkout the branch I'm reviewing and run the code myself to observe if it does what is claimed, that usually takes up at least 10 minutes in itself, sometimes more.

      From my experience most of the issues I find are actually from this type of observation rather than actually reading the code and imagining what it does in my head.

      • qiine 3 hours ago ago

        the mind remains a poor compiler ;p

    • rustybolt 4 hours ago ago

      Agreed, 300 lines will take me a lot more than 10 minutes to review properly!

      Depends on the specific changes of course, but generally speaking.

      • whstl 3 hours ago ago

        Also depends on the codebase.

        300 lines is nothing in some boilerplate-heavy codebases I've worked at.

        After seeing the same patterns for the hundredth time, it's easy to detect deviations. Not to mention linters and typing helps a lot too.

        Not a fan of those but oh well.

    • franktankbank 4 hours ago ago

      Your linter/tests are for catching real errors. Review is to understand the shape of it mostly IMO. I could probably fairly easily review 300 loc if its not a particularly confused shape.

      • tcoff91 2 hours ago ago

        It all depends on the lines. It can take a long time to review a 1 line change to a critical function that is used everywhere in the app and it can take minutes to review 1000 lines of declarative UI code.

  • javier_e06 24 minutes ago ago

    I see Pull Requests and Code Reviews the same way as making a sandwich for someone else. My team wants for me prepare a sandwich ASAP.

    They, the reviewers, have to eat it, not me.

    Some reviewers want wonder bread bread with a slice of spam.

    Some want hand-made spreads with home-grown vegetables.

    Is easier to fix a sandwich than a wedding cake.

    The take-away

    Don't do wedding cakes.

  • necrotic_comp an hour ago ago

    My preferred way of doing PRs/Code Review echoes some of the statements below, but also requires the engineer to do the following:

    1) Each PR (even if it's part of a larger whole) can be committed and released independently. 2) Each PR has a description of what it's doing, why it's doing what it's doing, and if it's part of a larger whole, how it fits into the broader narrative. 3) PRs are focused - meaning that QOL or minor bugfixes should not be part of a change that is tackling something else. 4) PRs are as small as possible to cover the issue at hand. 5) All PRs are tested and testing evidence is presented. 6) When a PR is committed to master, the final narrative in step 1) is the Git commit, along with the testing evidence, includes the JIRA ticket number in the headline, and the reviewer in the body of the git commit.

    This way we have a clean, auditable, searchable history with meaningful commit history that can help reconstruct the narrative of a change and be used as a guide when looking at a change in, say, a year.

  • williamcotton 2 hours ago ago

    Pro tip:

    Get your potential code reviewers involved before you even start coding. Keep them abreast of the implementation. When it comes time for a review they should be acquainted with your work.

    • ed_blackburn 2 hours ago ago

      This. Absolutely this. The PR should be the final step in the process. Never the first. Ambushing people with PRs and then demanding their attention is a massive time and mood sink. It is ineffective and counter-productive. You may as well just commit to main, and honestly, in so many situations I think that's perfectly rational thing to do, so much about PR culture is theatre.

  • dvcoolarun 29 minutes ago ago

    It’s a challenge: you put the craftsmanship into a PR, but the reviewer might not share that dedication—they just want to give an LGTM bypass to clear their queue. That's why working at a company that truly values these practices is essential.

  • ValleZ 4 hours ago ago

    If you split all the changes for a feature this way not only you hide the way all changes interact with each other but also make the development at least 10x longer because an average approval time is often more than a day.

    • fidotron 4 hours ago ago

      This will be accompanied by the sort of dev manager that thinks a KPI for "number of PRs merged" won't in any way be gamed or backfire.

      I don't know what they're doing where you can do code reviews in 5-10 minutes, but in my decades doing this that only works for absolutely trivial changes.

      • StilesCrisis 3 hours ago ago

        The goal here is to make almost all CLs trivial enough that they can be reviewed quickly. You can compose almost any feature out of many small simple changes.

        • fidotron 3 hours ago ago

          > You can compose almost any feature out of many small simple changes.

          You can?

          • SAI_Peregrinus an hour ago ago

            Yes, and you can waste a ton of a coworker's time doing it.

            Say you're upgrading to a new library, it has a breaking change to an API. First, add `#if`s or similar around each existing change to the API that check for the existing library vs the new version, and error if the new version is found. No behavior change, one line of code, trivial PR. One PR per change. Bug your coworker for each.

            Next, add calls to the new API, but don't actually change to use them (the `#if`s won't hit that condition). Another stack of trivial PRs. Your coworker now hates you.

            Finally, swap the version over. Hopefully you tested this. Then make a final PR to do the actual upgrade.

            For something less trivial than a single breaking upgrade, you can do the same shit. Conditionally compile so that your code doesn't actually get used in the version you do the PR in, you can split out to one PR per character changed! It'll be horrible, everyone will hate you, but you can split changes down to ridiculously small sizes.

          • StilesCrisis 2 hours ago ago

            Follow these guidelines and you'll be surprised how far you can go.

            https://google.github.io/eng-practices/review/developer/smal...

            • fidotron 2 hours ago ago

              So you want code added in 100 line sections behind one feature flag which we then suddenly turn on?

              Isn't that exactly how Google's latest big cloud outage happened?

              EDIT: referring to https://news.ycombinator.com/item?id=44274563

              I should add that the idea complexity relates to LoC is also nonsense. Everyone that's been doing this for a while knows that what kills people are those one line errors which make assumptions about the values they are handling due to the surrounding code.

    • viraptor 4 hours ago ago

      > only you hide the way all changes interact with each

      Splitting the change does not prevent you from looking at diffs of any combination of those commits. (Including whole pr) You're not losing anything.

      > at least 10x longer because an average approval time is often more than a day.

      Why do you think it would take longer to review? Got any evidence?

      • eigencoder 7 minutes ago ago

        I think approval time would take much longer. The issue is that while actual time spent in review may be shorter, there's a lot of context-switching time costs that increase with the number of PRs submitted.

        No one on the team is just sitting there refreshing the list of PRs, ready to pick one up immediately. There's a delay between when the PR is marked as ready and when someone can actually get to it. Everyone is trying to get work done and have some time daily in flow state.

        Imagine you have a change; you could do it as one PR that takes 1 hour to review, or 3 small PRs that each take 15 mins to review. The time spent in review may even be shorter for the small PRs, but if each PR has a delay of 1 hour before a reviewer can get to it, then the 3 PRs will take almost 4 hours before they're done, as opposed to just 2 hours for one big PR.

  • manoDev 2 hours ago ago

    Code review is a good way to ensure 1) the team has context 2) double-check the approach taken 3) keep conceptual integrity high. For that, you should make atomic PRs (not focus on minimal LoC, but rather a coherent patch set for a feature/bugfix), agree with your team that reviewing code is work and set appropriate time aside for it.

    Also, code review should be ego free: 1) criticize the code, not the author 2) don’t be too attached to code written, the objective is the product and not number of LoC contributed 3) it’s okay to start from scratch after learning about a better approach, or even make more than one and compare approaches.

    Where most teams fail is treating it as a gatekeeping process rather than context sharing, make PRs too small to be meaningful or only waste time arguing about code style and other minutiae.

  • iamleppert 2 hours ago ago

    I've tried his advice several times and it's been a complete failure. Splitting up a PR into a bunch of little PR's causes more problems than it solves, and it makes it 10x harder for the reviewer, no matter how much they complain about long PR's. Now they need to suss out some kind of ordering of the PR's, and navigate between multiple change sets for changes that depend on one another. It doesn't matter how well you can isolate the "concerns" a frontend depends on backend API, etc.

    You end up creating more work for the reviewer, and most people just simply won't do the work of a proper review. You also don't have the advantage of any CI or tests running across the entire set of changes, so you also have separate CI reports to review. All this adds up for more places for bugs to hide or happen. All the same risks are still there, and you've also added a few more points of failure in the splitting process.

    And for what? To end up, most likely merging in one PR after the next, for a feature that should just be all logically grouped together, or just squashing and merging the PR's together anyway.

    • jghn 2 hours ago ago

      This. I have colleagues who helpfully break things into small PRs, but more often than not I wish they hadn’t. I usually want to review things in context of the big picture and that gets lost.

      Usually what I do is check out their last PR, figure out what I want to say, and then identify the appropriate place to leave a comment in their stack of PRs. Which is a lot more work for me. And this assumes that they’ve even finished all their PRs instead of expecting them to merge in one at a time

      • tcoff91 2 hours ago ago

        What I find helps with stacked PRs is it helps with getting code review incrementally as the various changes for a larger effort come together.

  • parpfish an hour ago ago

    i don't know how people can build something and leave behind a coherent series of commits that tell a nice story of progressively building a thing.

    my commits include lots of false-starts that get abandoned and "i need to commit this interim state because i deprioritized this and will come back later".

    the sequence of events that i used to build the thing isn't necessarily the best sequence of events to tell the story of what the final thing is.

    sometimes you can get a good story by stacking PRs, but if the stack gets too deep you can end up with some rebase nightmares.

    • Master_Odin an hour ago ago

      I'm a strong believer that PRs should be merged via a "squash and merge" strategy, with the singular commit being descriptive of the overall change and having a link back to the PR for deeper story analysis as needed. I'm also a staunch believer at this point that PRs should really focus on one thing as well. If when working on a bug you discover another semi-related bug? Open two PRs.

      Let main be the story of how code got from point A to B, and PRs be the story of how each incremental step was made.

      • g-b-r an hour ago ago

        PRs only live on GitHub, what happens if it gets shut down or it accidentally loses some data?

  • jmull 2 hours ago ago

    I think a more fundamental and important aspect to this is developing a shared understanding of the design the change is ultimately intended to accomplish and the roadmap to achieving that.

    Shared between the implementer and the reviewers, that is, which means design brainstorming, design formalization of some kind (writing the significant aspects down, or recording them in some other way), and a review process.

    I should also say: this process doesn't have to be any larger or more heavy-weight than the change itself. And changes that don't have a design aspect can skip it entirely. But this article is talking about building a story with commits, and at that level you're almost surely talking about a significant design aspect.

  • 2sk21 4 hours ago ago

    Reviewing someone else's large pull request is like having a second task in parallel with what you are working on yourself!

    • eterm 2 hours ago ago

      So don't do it in parallel.

      Completely park other tasks, spend time on the review and record that time appropriately.

      There's nothing wrong with saying you spent the previous day doing a large review. It's a part of the job, it is "what you're working on".

      • sexyman48 an hour ago ago

        You might as well go into HR. Everyone knows reviewing other people's PRs is like nurturing their kids at the expense of your own.

        • mystifyingpoi 7 minutes ago ago

          Well, then just don't play the game. Make a decision in the team, that everyone accepts everyone's PR immediately without any review. At least you won't have to wait.

        • eterm an hour ago ago

          I don't understand what you're trying to say.

    • chrisweekly 4 hours ago ago

      It's not "like" another task, it IS another task!

      • osigurdson 3 hours ago ago

        Yeah but it is just a quick look, "yep", "yep", "oh what about this"?, "wow we dodged a bullet there". Its like self managed error correction that the collective does on its own. Fast, simple and produces good results. The less software you write the more this resonates.

  • gagabity an hour ago ago

    I never read the commit messages always straight to changed files.

    Also find doing it like this either incredibly hard or have to do a ton of git magic after I'm done to get commits into this state which is very frustrating.

    I think it might be the codebase I work on but who knows.

  • Illniyar 15 minutes ago ago

    I disagree with practically everything suggested.

    Reducing scope and splitting a single task into multiple PRs each small but part of a bigger picture makes it very hard to see the bigger picture.

    You should try to make PRs small, but if a PR is big, then you just have to spend more time to review it.

    Formatting commits as a story is a huge hurdle for the one making the changes. And unless every PR is meticulously prepared - going over the commits by the reviewer is a waste of time.

    I agree you should return PRs you don't understand though. Or don't feel comfortable reviewing for whatever reason.

  • gjgtcbkj 3 hours ago ago

    Every developer I know who applies this sort of “highly documented development” approach where they “work through their thought process openly.” Is only doing it because their thought processes are already so funky and counterintuitive that reviewers actively reject their work unless have written evidence that the developer didn’t just entirely change the scope of their assignment to justify the bizarre decisions.

    • watwut 28 minutes ago ago

      That is 100% not my experience. People who do that tend to be perfectionists trying to cross all the ts.

      Confused developers are just unable to create such reasoning.

    • g-b-r an hour ago ago

      You only know poor developers then, I guess

  • Supermancho 4 hours ago ago

    > Story-Telling Commit Messages

    No thank you. Talking to future ME, I don't need to know how I got to what I want me to look at.

    A squashed ticket-by-ticket set of merges is enough for me.

    • smashedtoatoms 3 hours ago ago

      I'm editing this to be nicer. I'm really trying to be nicer. Consider the possibility you're not the only one in the codebase and that the git history might provide the why to the code's what.

      • leoedin 3 hours ago ago

        I do think commit messages should give some reference to what they're changing.

        However, in more than a decade of software development, I don't think I've ever got much use out of commit messages. The only reason I'd even look at them is if git blame showed a specific commit introduced a bug, or made some confusing code. And normally the commit message has no relevant information - even if it's informative, it doesn't discuss the one line that I care about. Perhaps the only exception would be one line changes - perhaps a change which changes a single configuration value alongside a comment saying "Change X to n for y reason".

        Comments can be a bit better - but they have the nasty habit of becoming stale.

        • g-b-r an hour ago ago

          > However, in more than a decade of software development, I don't think I've ever got much use out of commit messages.

          > normally the commit message has no relevant information

          Maybe that's why you've never got much use of them?

          If your colleagues or yourself wrote better commits, they could have been of use.

          An easily readable history is most important in open source projects, when ideally random people should be able to verify what changed easily.

          But it can also be very useful in proprietary projects, for example to quickly find the reason of some code, or to facilitate future external security reviews (in the very rare case where they're performed).

      • Supermancho 3 hours ago ago

        > Consider the possibility you're not the only one in the codebase and that the git history might provide the why to the code's what.

        I can't win with HN critics. If I talk about someone else looking, then I'm assuming. If I talk about myself, then I'm being too self-centered (in the oblique sense you reference). I am very aware of how this works across teams of people, not just myself, since I'm in industry.

      • ziml77 3 hours ago ago

        As a reviewer, I don't care how you got to the end result. I want to see the final code. If you settled on something in your code that was unintuitive, because you tried simpler ideas that didn't work, then note that in a comment. Comments provide the info inline and don't require someone reviewing the code now or working on the code 15 years later to read your "commit story" to understand it.

        • bonzini an hour ago ago

          You confuse "include all the broken work-in-progress commits" with "split the independent parts that get you from A to B".

      • whstl 3 hours ago ago

        As someone who dives in the commit story often:

        If it's a pristine, linear, commit story, sure.

        If it includes merges commits, "fix" commits, commits that do more than one thing, detours, side-quests, unrelated refactors then squashing is 100x better.

        • g-b-r an hour ago ago

          Merge commits allow you to nest series of commits, they're far from always bad

  • stack_framer 2 hours ago ago

    My manager recently told our team that "AI usage" would be added to our engineering competencies, and we would all be expected to "use AI more."

    When I said my top preference for AI usage, by far, would be to eliminate human code reviews, the response was basically, "Oh, not like that."

    • meesles 2 hours ago ago

      That's a bummer! At my company we've started investing in what I'm calling 'semantic linting', which is basically running GPT over a PR with a set of rules that we iterate on. Already I'm finding huge value for style/pattern comments that linters can't easily catch, dropping warnings for common DB migration footguns, or notifying people of changing patterns/new ways of doing things. Been great so far!

    • CuriouslyC 2 hours ago ago

      Don't worry, if you actually increase AI usage your team will be forced to automate code review, either explicitly or implicitly.

    • Entelligence25 2 hours ago ago

      Rn 70% of ai is being used only for code review documentation purpose, i think we really need entire engg workflows to be ai automated for better team insights, better team performace , sprint assesment etc and track entire engg lifecycle.

      Vision should not be AI code, but it should be AI beyond code.

  • niko_dex an hour ago ago

    This post came up at a perfect time for me. I'd been feeling like my commits were too small, littering the activity pane on GitLab.

    I guess I was worried that nobody would want to read the commits, but I really like the thought that what I've been providing is a simple narrative thread to help guide a reader through my train of thought.

  • osigurdson 3 hours ago ago

    Unless you have a broader context, reviewing 300 line PRs in 5 minutes is going to be surface level at best. Plus that time comes with an expensive context switch so the actual cost is likely more like 20 - 30 minutes. At this point, I think a reasonable question is why not just use AI for shallow reviews like this? This would free up bandwidth in situations where you really want code reviewed by someone else.

  • karel-3d 2 hours ago ago

    If you want to let the review in, you need to make some obvious issues - typo or space/tab thing - so you give the reviewer some bone so they feel like they did something and accept your request otherwise.

  • markus_zhang 2 hours ago ago

    Story from friend but I can relate:

    Some teams and code are pretty much unreviewable and the best thing is to add CI for simple tests and lgtm if there is no glaring mistakes.

    My team only has 3 including the manager, so, eh, each one holds a lot of knowledge that only he or she knows. Documentation? Yeah that’s a good idea, but I don’t have time to read them because “We want to ship as fast as possible”. So I just put up a precommit for testing and plug in the same tests for the CI and call it a day. If you pass the CI I’ll take a cursory look and LGTM.

    Some code is unreviewable. I work as a DE and it’s all business logic entangled. Why is there a specific id excluded? What is the purpose of this complex join? I mean, the reviewer is not supposed to know everything, right? So the best thing, again, is to only look at the technical things (is the join done properly), let the CI figure out the weird stuffs and LGTM.

    • g-b-r an hour ago ago

      I mean, the reviewer is not supposed to know everything, right?

      Uhm he kind of is, if you want a proper review...

  • surgical_fire 4 hours ago ago

    Can't relate. I take code reviews as possibly the most important part of my job as a developer. Suggesting extra tests, thinking about unintended side effects, and yes, aiming for consistency and readability, without being picky on style choices.

    I trust my colleagues to do the same (and they often do).

    I can't imagine working in an environment where this is a theater.

    • gjgtcbkj 3 hours ago ago

      It sounds like a good job where the most important part is finding other people’s mistakes.

      Though I do appreciate the shoutout to adding tests in CR. But returning a PR solely because it doesn’t have tests, is effective, but a little performative too. It kind of like publicly executing someone, theirs gotta be some performance for it to be a deterrent. If something doesn’t have tests my review is going to be a very short performance where I pretend read the rest of the code. Then immediately send it back.

      • surgical_fire 2 hours ago ago

        > It sounds like a good job where the most important part is finding other people’s mistakes.

        And reviews are not that. Systems are complex, and having a mental model of complex systems is difficult. Everyone has blind spots. A fresh pair of eyes can often spot what who was coding would not.

        > But returning a PR solely because it doesn’t have tests, is effective, but a little performative too.

        And this is not what I said. I spoke of suggesting extra tests. A scenario that wasn't covered, for example.

  • octo888 3 hours ago ago

    What I've often found is that people only really accept feedback from the Tech Lead, and peers are dismissed (not outright and not obviously - kind of sealioning etc). Peer-to-peer code reviews are another instance implementing a thing that pretends hierarchy does not exist.

    You can only get basic tweaks accepted. The sunk-cost fallacy is a huge force.

    Maybe I've only worked at crappy places

    • gjgtcbkj 2 hours ago ago

      Allen Iverson got criticized by the media for “letting down his teammates” for skipping a few practices. He famously said “We’re talking about practice, practice! not the game! How is MY going to practice gonna make THEM better?!” He got flack for those comments, but what he said was accurate. If we’re talking about outcomes you’re beholden to the person who is seen as the difference maker, all the teamwork in the world isn’t going to improve an individual’s the lack of ability.

      • sexyman48 an hour ago ago

        Every company depends on 3-5 guys for their competitive advantage. While the other thousand guys are interchangeable, they're just as necessary (and needful) to the company's survival.

  • kaapipo 5 hours ago ago

    I mean, stacked PRs are a thing for a reason

    • keriati1 4 hours ago ago

      I can also recommend rather to use the stacked PR approach. We have it since years, PR review "issues" are not a thing for us.

      I still encourage do to a lot of small commits with good commit messages, but don't submit more then 2-3 or 4 commits in a single PR...

    • epage 4 hours ago ago

      I see stacked PRs as independent of this. PRs are a good unit of cohesion of changes, particularly changes that only make sense if later changes are also merged.

  • btreecat 4 hours ago ago

    My guide to good PRs:

    - Keep PR messages short and to the point. - use as many commits as you need, it's all the same branch. Squash if you want, I think it hides valuable meta. - put the ticket in the branch name. Non negotiable. - Update your ticket with progres. Put as much details as you can, as if you were writing to someone who's picking up the task after you. - add links to your ticket. Docs, readme, o11y graphs, etc. - Link ticket in PR for easy access to additional info - Admit if you don't understand what your looking at. Better to pair and keep moving forward. - if you request changes, stay available for conversation and approval for the next few hours. - punt the review if you don't feel like you can legitimately engage with the content right now. Make sure you communicate it though. - Avoid nits. This causes a loss in momentum and v rarely is worth changing.

  • devmor an hour ago ago

    I actually didn't ever realize that some people dreaded code reviews. To me, PRs are one of the most exciting parts of the process. That's where you have the most potential to learn from your colleagues and/or teach them something you know.

  • rjmunro 4 hours ago ago

    Another tip: Use `git log --first-parent` and `git log --merges` to hide the intermediate commits. `--first-parent` also works with `blame` in modern git. These mean you don't have to look at all the small commits when browsing history, only when you want to dive in deeper.

  • saghm 2 hours ago ago

    I feel like quite a lot of the pain is best solved for both sides by inverting the expectations a little towards the author of the PR like this mentions, but around communication, not the substance of the changes itself. Over the years I've built up a bit of a reputation on some teams I've worked on for crafting PRs that are disproportionately easy to review relative to the scope, and it pretty much is entirely from just spending a bit of extra time explaining things in the review comments itself. In addition to the top-level description (which in practice I've doing found often is something people who are understandably busy will just glance through quickly if not skip it entirely to jump right into the diff), I always go through my own code in the review tool without publishing and tend to add a fairly high number of comments explaining things that might stick out as odd in the context of the diff specifically (with comments in the code making more sense for things that will stick out regardless of context). My experience is that for a lot of potential review comments, it's not particularly hard to anticipate just from looking at the diff from the perspective of the reviewer, and it takes far less time as the author to look through and add comments explaining those cases than it does as a reviewer to go through and write up comments on all of those places (especially given that as a reviewer, I do think it makes sense to be thoughtful about how exactly to phrase comments on a PR given how easily tone can be misunderstood over text). My perception is that even going a bit overkill with the self-review doesn't hurt too much; often I'll notice that certain comments get a "thumbs-up" reaction compared to others that don't, which is a nice quick way for reviewers to signify that they understand what I've said and find it reasonable (compared to the comments with no reaction that I assume didn't end up being necessary to address a potential concern).

    I picked up this habit from an early teammate (and manager, who eventually went back to just being a teammate because he didn't love being a manager) who recommended it, and in places I've worked where they've had struggles with their review culture, I've had colleagues express to me how much they love that they do this and mention to me that they've sometimes started asking other teammates to do it for certain changes (e.g. "some of this code looks like it might have gotten moved around without changing, but it's not obvious from the diff, do you think you could go through and note wherever that happened?").

    At the end of the day, teams will function best when there's mutual good faith and respect for each other's time. (Obviously some teams are lacking this to various degrees, but at that point I don't don't think code review is really the larger problem, but just symptom of the larger underlying dynamic that either needs to somehow be addressed or the team will never work well). Recognizing where you can save your team time overall by spending some of your own is a pretty useful with that in mind, and code review ends up having quite a lot of low-hanging fruit in this regard both because the context that the PR author has tends to make the amount of effort needed to preemptively help the reviewers understand things is quite low compared to the reviewer needing to ask, and because the return on time spent by the author scaling with the number of reviewers.

  • vdupras 4 hours ago ago

    A while ago at a past job, I was working on OpenERP (now called Odoo I think). This "community" had instated this kind of "mandatory community review" policy so that each change had to be reviewed by X developers from other organizations. I kind of virtuous web of review.

    But the thing is: this code is terrible and huge chunks of it are a unholy mix and match of code written for very specific purpose for this or that client, with this very weird "falsely generalized" code. I don't know how to call that: you have some very specific code, but you insert useless and probably buggy indirections everywhere so that it can be considered "general". The worst kind of code.

    Anyways, I was asked by my boss to do such a review. I look at it and I realize that building a database setup to be able to properly run that code is going to take me weeks because I'm going to have to familiarize myself with tons and tons of modules I don't know about.

    So I write down my estimate in our tracker: 1 month.

    He comes back to me, alarmed. A whole month? Well yeah, otherwise I can't even run the code.

    All you have to do is look at the code! What? No way, that ain't a review. Well, I ask you to do it as such. I'm not writing LGTM there.

    So I was never asked to do reviews there again (in fact, I stopped working on OpenERP at all), but I could see "LGTM" popping up from my colleagues. By the way, on OpenERP tracker, all you ever saw in review logs was "LGTM" and minor style suggestions. Nothing else. What a farce.

    So yeah, as the article says, there are some "LGTM-inducing" type of PRs, but the core of the problem is developers accepting to do this "LGTM-stamping" in the first place. Without them, there would only be reviewable PRs.

  • mtlynch 3 hours ago ago

    I love code reviews and blog posts about them, but I vehemently disagree with all of this advice.

    >His example PR[0] adds just 152 lines of code, removes 2 lines, but uses 13 thoughtful commits.

    >While some developers might understand those 152 lines from the final diff alone, I couldn't confidently approve it without the commit story.

    This is ridiculous!

    You absolutely can and should review a PR without demanding its "commit story."

    Go read the PR under discussion here.[0] There's nothing about it that's hard to understand or that demands you go read the 13 intermediate steps the developer took to get there.

    The unit of change in a code review is the PR itself, not the intermediate commits. Intermediate commits are for the author's benefit, not the reviewer's. If the author rewrote the code in FORTRAN to help them understand the problem, then converted it back to the codebase's language, that's 100% okay and is not something the reviewer needs to care about.

    The PR should squash the individual PRs at merge time. The linked PR[0] is a perfect example, as the relevant change in the permanent commit history should be "Measure average scheduler utilization" and not "Collect samples" or "Mock sampling."

    When you need to communicate extra context outside of the code, that should go in the PR description.[1] Your reviewer shouldn't have to go scour dozens of separate commit messages to understand your change.

    >How do you create a PR that can be reviewed in 5-10 minutes? By reducing the scope. A full feature should often be multiple PRs. A good rule of thumb is 300 lines of code changes - once you get above 500 lines, you're entering unreviewable territory.

    5-10 minute reviews are so low that it's basically thoughtless rubber-stamping.

    If someone spent 5-10 hours making a change, the reviewer should definitely think about it for more than 5 minutes. If all the reviewer is doing is spot checking for obvious bugs, it's a waste of a code review. The reviewer should be looking for opportunities to make the code simpler, clearer, or more maintainable. 5-10 minutes is barely enough time to even understand the change. It's not enough time to think deeply about ways to improve it.

    [0] https://github.com/sasa1977/hamlet/pull/3

    [1] https://refactoringenglish.com/chapters/commit-messages/

    • tantalor 2 hours ago ago

      Hard agree.

      Commits are not important. As an author, you should not waste your time on this. As a reviewer, just ignore them.

    • g-b-r 28 minutes ago ago

      > Intermediate commits are for the author's benefit, not the reviewer's.

      I don't even know how could commits only benefit the author; if they're poor they won't help him either, if not as a log of how much work he's done.

      Unless you make a PR for every insignificant change, PRs will most often be composed of series of changes; the individual commits, if crafted carefully, will let you review every step of the work of the author quickly.

      And if you don't eschew merges, with commits you can also group series of related modifications.