Rain Lag

The Pre-Commit Pause: A 90-Second Ritual That Stops Messy Code Before It Lands in Git

How a simple 90-second pre-commit ritual, combined with small atomic commits and automated pre-commit checks, can dramatically improve your team’s code quality and Git history.

The Pre-Commit Pause: A 90-Second Ritual That Stops Messy Code Before It Lands in Git

Modern development moves fast. Feature branches, pull requests, continuous deployment—everything is designed to ship code quickly. But speed without discipline leads to a familiar chaos: messy commit histories, broken tests in main, “quick fixes” that spiral into production incidents.

One tiny habit can dramatically reduce that chaos: the pre-commit pause.

It’s a simple, 90-second ritual you perform before every git commit. You stop, review, and sanity-check your changes—backed by a quick checklist and automated tools—so broken or sloppy code never makes it into your repository in the first place.

This isn’t about slowing you down. It’s about making every commit count.


What Is the Pre-Commit Pause?

The pre-commit pause is a deliberate, short ritual—around 90 seconds—right before you run git commit. During this pause, you:

  1. Review what you’re about to commit
  2. Run a quick mental (or written) checklist
  3. Optionally run automated checks, or let a pre-commit hook run them for you
  4. Confirm the commit is small, atomic, and clearly described

The goal is not a deep code review. It’s a sanity check: is this commit safe, focused, and understandable to someone who reads it later (including future you)?

Pair this habit with pre-commit checklists and Git pre-commit hooks that run formatting, linting, and tests, and you get a lightweight quality gate before your changes touch the shared repository.


Why Bother? The Cost of Skipping the Pause

Skipping this step seems harmless—until you zoom out:

  • You push a commit that accidentally includes debug logging, commented-out blocks, or half-baked code.
  • A trivial formatting or lint issue breaks CI, blocking the whole team.
  • Tests fail only after code hits the shared branch, forcing noisy rollbacks and hotfixes.
  • Your commit history becomes a graveyard of messages like fix, oops, really fix, wip, and final final actually working.

None of those problems are hard individually, but together they slow teams down and erode trust in the codebase.

The pre-commit pause is a tiny, systematic defense against this mess.


Principle #1: Small, Atomic Commits

The pre-commit pause starts with one simple question:

“Is this commit a single, logical change?”

An atomic commit does exactly one thing:

  • Add a new function
  • Fix a specific bug
  • Refactor a module
  • Update dependencies

What it does not do:

  • Fix a bug, refactor unrelated code, and update docs all at once
  • Mix formatting changes with behavioral changes
  • Bundle “while I was here” cleanups from random parts of the codebase

Why atomic commits matter

  • Easier reviews: It’s simpler to reason about one change at a time.
  • Simpler debugging: git bisect and blame are more useful when each commit is focused.
  • Safer rollbacks: You can revert a single commit without unintended side effects.

A quick atomicity checklist

Before committing, ask:

  • Can I describe this change in one sentence without “and” or “also”?
  • If this commit is reverted, does it leave the codebase in a consistent state?
  • Did I sneak in unrelated changes (like drive-by renames or formatting)?

If the answer is no, consider splitting the changes into multiple smaller commits.


Principle #2: Commit Messages That Explain Why, Not Just What

Most commit messages are too vague to be useful:

  • update code
  • fix bug
  • changes

They say something changed, but not why.

Future readers (including you) need context. They’ll ask:

  • What problem was this solving?
  • Why was this approach chosen?
  • Is this behavior intentional or accidental?

A better commit message formula

Think of a commit message as “a short narrative for a small change”.

A simple pattern:

<short summary in imperative mood> Optional body explaining: - The reason for the change (the “why”) - Any trade-offs or caveats - Links to tickets/issues if relevant

Examples:

Fix incorrect tax calculation for discounted orders Previously, tax was calculated on the full price before applying discounts, leading to overcharging. This change applies tax after discounts, matching our documented policy and legal requirements.
Refactor user service to decouple from ORM models Introduces a repository layer to isolate persistence logic. This will make it easier to switch to a new database provider next quarter.

During the pre-commit pause, ask:

  • If I read only this commit message and its diff a year from now, would I understand it?

If not, spend 20–30 extra seconds improving the message. It pays you back many times over.


Principle #3: The Pre-Commit Checklist (Manual + Automated)

A pre-commit checklist turns your 90-second ritual into a repeatable habit. You can keep it in your head, on a sticky note, in your editor, or in documentation.

Example manual checklist (human checks)

Before committing, quickly:

  1. Review the diff:
    • Are there any debug prints, TODOs, or commented-out blocks you don’t want committed?
    • Are there files you didn’t intend to include (e.g., .env, temporary scripts)?
  2. Check scope:
    • Is this commit limited to one logical change?
    • Did I avoid mixing refactors and behavior changes?
  3. Verify behavior:
    • Did I run the relevant tests or at least smoke-test locally?
    • Does the code build and run in my environment?
  4. Document when needed:
    • Is there any new behavior that should be documented or mentioned in a changelog?
  5. Write/validate the commit message:
    • Does it clearly explain why this change exists?

Even this quick scan catches a surprising amount of “whoops” moments.

Automating the checklist with Git pre-commit hooks

You do not need to run everything manually. Git pre-commit hooks can automatically:

  • Run linters (e.g., flake8, eslint)
  • Apply formatters (e.g., black, prettier)
  • Check import sorting (e.g., isort)
  • Run a small, fast subset of tests
  • Block commits that violate basic rules (e.g., secrets in code, failing linters)

This is where tools like pre-commit shine.


Principle #4: Using pre-commit and pre-commit.ci

pre-commit is a framework for managing and running pre-commit hooks in multiple languages, not just Python.

How it works (high level)

  1. You create a .pre-commit-config.yaml file in your repo that lists hooks to run.
  2. Developers install pre-commit locally and run pre-commit install once.
  3. pre-commit runs your configured hooks automatically on the files you’re about to commit.

Example pre-commit config for a Python project:

repos: - repo: https://github.com/psf/black rev: 24.4.2 hooks: - id: black - repo: https://github.com/pycqa/flake8 rev: 7.1.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: - id: prettier files: '\\.(js|ts|jsx|tsx|json)$'

With this in place, every commit automatically:

  • Formats Python code with black
  • Lints Python with flake8
  • Formats JavaScript/TypeScript/JSON with prettier

If any hook fails, the commit is blocked until you fix the issues.

pre-commit.ci: Running checks in the cloud

pre-commit.ci is a hosted service that:

  • Runs your pre-commit hooks in CI on every pull request
  • Auto-fixes issues and pushes updates back to the branch when possible
  • Ensures that even contributors who haven’t installed hooks locally still get consistent checks

This combo—local pre-commit hooks plus pre-commit.ci—creates a consistent safety net:

  • You catch issues before committing during your pre-commit pause.
  • The service catches anything that slips through or comes from external contributors.

Putting It All Together: A 90-Second Flow

Here’s what a realistic pre-commit pause looks like in practice:

  1. Stage your changes

    git add <files>
  2. Review the diff (30–40 seconds)

    git diff --cached
    • Remove stray debug prints or commented code
    • Unstage unrelated changes if needed
  3. Sanity-check behavior (20–30 seconds)

    • Run a small, relevant test suite, or quickly run the feature you changed
  4. Let pre-commit run (automatic, often under 30 seconds)

    git commit
    • Hooks format and lint your code
    • If something fails, follow the instructions, fix, and re-run
  5. Write a clear commit message (10–20 seconds)

    • One-line summary + optional short explanation of why

Total time: about 90 seconds. Often less.

In return, you get:

  • Cleaner commit history
  • Fewer broken builds
  • Higher confidence when merging and deploying

Conclusion: Discipline in 90-Second Doses

Code quality is not just about clever algorithms or fancy architectures. It’s about small, consistent habits. The pre-commit pause is one of the simplest, most impactful habits you can adopt:

  • Pause for ~90 seconds before every commit.
  • Keep commits small and atomic—one logical change at a time.
  • Write commit messages that explain why, not just what changed.
  • Use pre-commit checklists and automated hooks to catch issues early.
  • Leverage tools like pre-commit and pre-commit.ci to make this effortless across your team.

You do not need a giant process overhaul to improve code quality. You need a tiny, reliable ritual that happens dozens of times a day.

Start with your next commit. Take 90 seconds. Pause. Review. Commit with intention.

Your future self—and your teammates—will thank you when they read your Git history.

The Pre-Commit Pause: A 90-Second Ritual That Stops Messy Code Before It Lands in Git | Rain Lag