Skip to content

Engineering habits · Part 2 of 10

Writing good commit messages and pull requests

A commit message explains why a change was made, and a good pull request is small, described and easy to review. Practical templates included.

· 2 min read

engineeringgit

Code shows what the program does. Only the commit message and the pull request can tell the next person why it changed, and that is usually the part they need.

Anatomy of a commit message

  • A summary line of about 50 characters, in the imperative mood: "Add retry to payment client", not "Added" or "Adding".
  • A blank line.
  • A body, wrapped near 72 characters, saying why the change was needed, what approach was taken and what alternatives were rejected.
Code
Retry payment requests on timeout

Card provider calls time out a few times a day. Without a retry the
customer sees an error even though the charge usually succeeds a few
seconds later.

Retry up to twice with exponential backoff, only for idempotent
requests that carry an idempotency key.

Habits that help

  1. Make one logical change per commit, so each can be understood, reverted or cherry-picked alone.
  2. Do not mix refactoring with behaviour changes in the same commit.
  3. Reference the issue or ticket, but still explain the reason in words.
  4. Avoid messages like "fix", "wip" or "changes". Future you will not know what they meant.

Small pull requests

Reviews work best below a few hundred changed lines. Large pull requests get skimmed, and skimmed reviews miss bugs. Split work into steps that each leave the system working: prepare the refactor, add the feature behind a flag, then enable it.

A useful pull request description

  1. What changed, in a sentence or two.
  2. Why: the problem or the goal, with a link to the ticket.
  3. How to test: commands or steps, and what you verified.
  4. Risks and rollout: migrations, flags, anything that needs care.
  5. Screenshots for visible changes.

Be reviewer-friendly

Review your own diff first and remove debug code. Point reviewers at the risky parts. Answer comments politely, and prefer follow-up commits during review, squashing at the end if your team prefers it.

Takeaway

Write for the person who will read this in a year: say why, keep changes small and describe how to verify them.

A knowledge article, drafted with AI assistance and checked with automated tests. It is general background, not a description of my own experience or of any client's work.

Comments

Leave a comment

No account or email needed. Comments appear after review. A one-way hash of your IP address is kept for 30 days to fight spam, then erased.