| name | bun-lockfile-hygiene |
| description | Keep Bun installs reproducible: commit bun.lock (or migrate bun.lockb), frozen CI with bun ci / --frozen-lockfile, single package-manager story, workspace lock fidelity, and lock-diff review. Use when bun.lock, bun.lockb, bun install, bun ci, frozen-lockfile, Bun workspaces, lockfile migration, text lockfile, mixed npm/yarn/pnpm locks with Bun, or CI lock drift are in scope — hand multi-ecosystem pin/Renovate policy to dependency-pinning-strategies, npm lifecycle trust to npm-supply-chain-hygiene, and registry confusion to dependency-confusion.
|
Bun Lockfile Hygiene
Own Bun lockfile fidelity and install reproducibility: authoritative lock
file, frozen CI, and package.json sync without mixed generators. Does not own
org-wide pin bots, SBOM gates, or full npm lifecycle policy.
When To Use
- Adding, reviewing, or repairing
bun.lock / legacy bun.lockb
- CI fails with lockfile had changes, but lockfile is frozen / InvalidLockfile
- Migrating binary → text lock (
bun.lockb → bun.lock) or Bun major bumps
- Choosing
bun ci vs bun install vs --frozen-lockfile / --lockfile-only
- Mixed trees:
package-lock.json, yarn.lock, or pnpm-lock.yaml beside Bun
- Workspaces, catalogs/overrides, or lock diffs after dep bumps
- Mentions: Bun lockfile, frozen lock, bun.lockb, reproducible bun install
Do not use as primary for: multi-ecosystem pins → dependency-pinning-strategies;
npm lifecycle deep-dive → npm-supply-chain-hygiene; registry confusion →
dependency-confusion; SBOM → sbom-and-supply-chain / sbom-ci-enforcement;
pipeline caches → ci-cd-pipeline-patterns; tokens → secrets-management-hygiene.
Repo Config First
Repo and org package policy outrank defaults below.
- Installer story: Bun-only vs accidental npm/yarn/pnpm on the same tree
- Lockfile present: prefer committed
bun.lock (text, Bun ≥1.2 default); note any bun.lockb
- Manifests: root and workspace
package.json; workspaces; packageManager / engines
- CI install:
bun ci or bun install --frozen-lockfile; Bun version pin (oven-sh/setup-bun, .bun-version)
- Registry / auth: project
.npmrc scopes; no tokens in git
- Lifecycle policy: Bun
trustedDependencies (and any ignore-scripts stance)
- Neighbors: Dependabot/Renovate, SCA job, Docker/
bun install layers, monorepo scripts
Precedence: Follow committed Bun lock + CI flags. Flag dual lockfiles, CI that runs bare bun install and rewrites the lock, or binary/text dual-commit without a migration plan.
Workflow
1. Inventory
- List every
package.json (workspaces) and which lock file(s) exist at roots.
- Classify lock state:
| State | Signal | Action |
|---|
| Healthy text | Only bun.lock committed; CI frozen | Maintain |
| Legacy binary | bun.lockb only | Plan migrate to bun.lock |
| Dual / mixed | Both Bun locks or npm/yarn/pnpm locks too | Pick one manager; delete others after regenerate |
| Missing lock | Install mutates freely | Generate + commit for apps/services |
| Drift | Manifest ≠ lock; frozen CI fails | Regenerate lock intentionally; review diff |
- Note Bun version local vs CI (lock format and resolve can differ across majors).
2. One lock, one installer
- Commit the Bun lock for every deployable and product CI build.
- Prefer
bun.lock (text): readable diffs, better review. Migrate with team Bun version, e.g. regenerate via documented Bun flags (--save-text-lockfile / install path per current docs), then delete bun.lockb so only one Bun lock remains.
- Do not keep
package-lock.json / yarn.lock / pnpm-lock.yaml as a second source of truth on a Bun project—mixed generators corrupt trees and CI.
- Never “fix” frozen CI by deleting the lock; regenerate on a controlled Bun version and commit with the manifest change.
3. Install and CI freeze
| Command | Role |
|---|
bun install | Dev resolve; may update lock when manifests change |
bun install --frozen-lockfile | Install exact lock; fail if lock would change |
bun ci | CI-friendly frozen path (equivalent intent to frozen install) |
bun install --lockfile-only | Refresh lock without needing a full local node_modules tree |
Rules:
- CI / release / image build:
bun ci or bun install --frozen-lockfile only.
- Pin Bun version in CI to match the lock-producing toolchain when possible.
- Cache keys must include lockfile hash + Bun/OS; a miss must still freeze from lock.
- After any
package.json bump, run install locally (or bot) so lock updates in the same PR; never land manifest-only changes that break frozen CI.
- Do not hand-edit lock JSON/text for “quick fixes”—regenerate with Bun.
4. Review lock diffs
On every lock-touching PR, check:
- New packages and unexpected transitive jumps
- Resolved hosts / registry URLs (scope should match project
.npmrc)
- Integrity / hash changes without intentional upgrades
- Git/HTTP/
file: deps moving without a pin review
- Lifecycle-bearing packages; align with Bun
trustedDependencies policy when installs run scripts
Wide ranges in the manifest are fine only if the lock freezes what ships (apps always lock).
5. Verify
- Clean
bun ci (or frozen install) with cache miss: exit 0, lock unchanged.
- Deliberately desync a dep range vs lock → frozen install fails.
- Fresh clone on CI Bun version builds/tests green.
- After text migration: only
bun.lock remains; binary gone; frozen path still green.
- No registry tokens or machine-local paths committed in lock/config.
Routing
| Situation | Primary | Helper |
|---|
| bun.lock / bun.lockb, bun ci, frozen install, Bun-only tree | This skill | — |
| Cross-ecosystem pins / Renovate schedule | dependency-pinning-strategies | this for Bun lock commands |
| npm lifecycle / postinstall malware deep-dive | npm-supply-chain-hygiene | this if tree is Bun-managed |
| Registry namespace confusion | dependency-confusion | this for Bun + npmrc hosts |
| SBOM / CVE gates | sbom-ci-enforcement | frozen install first |
| CI topology / lock-keyed caches | ci-cd-pipeline-patterns | this for install step body |
| Secrets in npmrc / CI | secrets-management-hygiene | this for lock auth surfaces |
| Manifest/CI quality | code-quality-standards | always on config changes |
Keep this skill primary until the Bun lock and frozen install path are correct; then hand off pins, SBOM, or lifecycle policy as needed.
Output Checklist