Safeguard
Developer Tools•

What to check in a lockfile diff during code review

A lockfile change can hide a new dependency, a changed source or a swapped hash. Here is a short routine for reviewing one without reading every line.

Safeguard Security Team
3 min read

Do not read every line. Check three things: that the lockfile change matches the manifest change, that no new package sources or registries appeared, and that existing entries did not change their hash without a version bump. Anything else is noise you can skim.

Why reviewers skip it

Lockfile diffs are long and machine written, so people scroll past. That makes them a place to hide things. A reviewer who knows what to look for can clear most diffs in a couple of minutes.

Check 1: does it match the intent

The pull request says it upgrades one package. Does the lockfile show that package changing, plus the dependencies it legitimately pulls in? A large unrelated spread of changes suggests the tool regenerated the whole tree. Ask for a smaller change.

Check 2: new sources

In npm, each entry records a resolved location. Look for entries that point somewhere other than your normal registry, for example a git address or a raw tarball link. The lockfile documentation notes that resolved can be a registry tarball URL, a git URL with a commit SHA, or a link. A surprise there needs an explanation.

Check 3: same version, different hash

Each entry also carries an integrity hash that identifies the exact package contents. If the version number did not change but the hash did, stop. A published version should not change its bytes. It may be a mirror or a bad merge, but ask.

Check 4: new packages with install scripts

When a new package appears, look at it as you would any new dependency. Name, publisher, age and install scripts. A new transitive package you did not expect is worth a quick look.

Tools that help

A command that lists added and removed packages between two lockfiles turns a thousand lines into twenty. Run it in CI and post the result on the pull request.

Make it routine

Add a line to your pull request template: lockfile changes reviewed. It reminds people the file is not exempt.

Quick check

Do I need to review the lockfile if a bot opened the pull request?

Yes. Bots update and merge what upstream publishes, so the review is still yours.

What is the biggest red flag in a lockfile diff?

A hash that changed with no version change, or a package source you do not recognise.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.