---
title: "Use lockfiles | PackageMaze docs"
description: "Why installs should come from a committed lockfile with artifact hashes, when not locking is fine, and how to lock npm, pnpm, Yarn, Bun, uv, Poetry, PDM, and pip projects."
canonical: https://www.packagemaze.com/docs/use-lockfiles/
---

> Documentation index: https://www.packagemaze.com/llms.txt

# Use lockfiles

Commit a lockfile and install from it. A lockfile records the exact version and artifact hash of every dependency, so every install gets the same bytes, and a replaced artifact fails the install instead of running.

## Why lock

- **The same install everywhere.** A laptop, CI, and a release build resolve the same versions. Without a lockfile, each install resolves again and can pick a newer version.
- **Replaced artifacts fail.** A registry can replace both a package and its advertised hash. The hash you committed lets your client catch that later substitution.
- **Minimum Age Policy works as intended.** A version enters your build only when you refresh the lock, and your Feed withholds versions younger than its Minimum Age, 24 hours by default. Without a lockfile, a version arrives in the next CI run the moment its hold ends, without anyone reviewing it.
- **Dependency changes are reviewable.** A lockfile diff in a pull request shows every version that changes.

A lockfile protects installs of what you already locked. New resolution still trusts the source used when you refresh the lock, which is why that source should be your Feed.

## When not locking is fine

Almost never. Two cases:

- A throwaway script or experiment that nothing else installs.
- A library's published dependency ranges. Consumers resolve those against their own lockfile, so keep ranges in the manifest. Still lock the library's own development and CI installs.

## With your agent

> Tell your connected agent: "Commit a lockfile for this project and make CI install from it."

## Lock each client

Create the lockfile once through your Feed and commit it. In CI, install with the command that refuses to change the lockfile.

### npm

**shell**

```
npm install   # writes package-lock.json
npm ci        # CI
```

### pnpm

**shell**

```
pnpm install                   # writes pnpm-lock.yaml
pnpm install --frozen-lockfile  # CI
```

### Yarn

**shell**

```
yarn install                   # writes yarn.lock
yarn install --immutable       # CI, Yarn modern
yarn install --frozen-lockfile # CI, Yarn Classic
```

### Bun

**shell**

```
bun install  # writes bun.lock
test -f bun.lock && bun install --frozen-lockfile  # CI
```

### uv

**shell**

```
uv lock            # writes uv.lock
uv sync --locked   # CI
```

### Poetry

**shell**

```
poetry lock  # writes poetry.lock
test -f poetry.lock && poetry check --lock && poetry sync  # CI, Poetry 2
```

### PDM

**shell**

```
pdm lock            # writes pdm.lock
pdm install --check  # CI
```

### pip

pip has no lockfile, and it checks hashes only for requirements that carry them. Prefer uv. To stay on pip, generate a fully pinned requirements file with hashes and install it in hash-checking mode.

**shell**

```
# requirements.in lists your direct dependencies, unpinned
uv pip compile --generate-hashes requirements.in -o requirements.txt
# or, with pip-tools:
pip-compile --generate-hashes requirements.in

pip install --require-hashes -r requirements.txt  # CI
```

## What a lockfile does not cover

> **Note:** Tool bootstraps and one-shot commands such as `npx`, `uvx`, and `pipx run` install outside the project lockfile, and so do Git and local dependencies. Pin one-shot tools to an exact version, or run them from locked dev dependencies. For stricter CI checks, see [Protect existing dependency hashes](https://www.packagemaze.com/docs/set-up-ci/#protect-existing-dependency-hashes).

Next: [Agent quickstart](https://www.packagemaze.com/docs/agent-quickstart/)

Related: [Set up CI](https://www.packagemaze.com/docs/set-up-ci/), [Set up pip, uv, and Poetry](https://www.packagemaze.com/docs/set-up-pip-uv-and-poetry/), [Set up npm and pnpm](https://www.packagemaze.com/docs/set-up-npm-and-pnpm/)
