Skip to main content
skill CX Codex

bun-package-manager — Claude Code skill: what it does, how to install

Bun package manager reference for commands, monorepos, and pnpm migrations. It guides agents on installation flags and lockfile conversions.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add secondsky/claude-skills --skill bun-package-manager -a claude-code
Open on GitHub

What bun-package-manager does

The skill teaches coding assistants how to operate the Bun package manager. It covers core dependency commands (bun install, bun add, bun update), lockfile handling with the text-based bun.lock, and version pinning via overrides or resolutions in package.json.

It also details workspace setups and monorepo filtering with --filter. Starting with Bun 1.3, workspaces use the strict isolated linker by default to block undeclared transitive dependencies, while single-package projects remain on the traditional hoisted layout.

Bun disables lifecycle scripts for dependencies by default to protect the build pipeline. Any package that needs to execute post-install steps must be explicitly listed in trustedDependencies.

What it helps with

  • migrate a project from npm, yarn, or pnpm to Bun
  • configure workspace filter runs in monorepos
  • pin nested dependency versions with overrides
  • enable post-install scripts for trusted packages via trustedDependencies

Example prompts for the agent

  • Convert our binary bun.lockb to text bun.lock without upgrading packages
  • Set up isolated workspace dependencies in bunfig.toml
  • Add a GitHub repository dependency as a dev package using bun add

How to install bun-package-manager

1Skills CLI (Vercel)

npx skills add secondsky/claude-skills --skill bun-package-manager -a claude-code

2Manually: put the files in place

~/.claude/skills/bun-package-manager/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/bun-package-manager/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about bun-package-manager

How do I install bun-package-manager in Claude Code?

Run npx skills add secondsky/claude-skills --skill bun-package-manager -a claude-code.

What does the bun-package-manager skill do?

It teaches coding tools proper Bun syntax for dependency operations, lockfile conversions, workspace filtering, and package migrations.

How does Bun handle post-install scripts?

Bun blocks lifecycle scripts from dependencies by default. You have to specify allowed packages in trustedDependencies inside package.json.

Source text

SKILL.md · MIT
---
name: bun-package-manager
description: Bun package manager commands (install, add, remove, update), workspaces, lockfiles, npm/yarn/pnpm migration. Use for dependency management with Bun.
license: MIT
---

# Bun Package Manager

Bun's package manager is a dramatically faster replacement for npm, yarn, and pnpm. Up to **25x faster** than npm install.

## Quick Start

```bash
# Install all dependencies
bun install

# Add packages
bun add react react-dom
bun add -D typescript @types/react

# Remove packages
bun remove lodash

# Update packages
bun update

# Run package binaries
bunx create-next-app
```

## Core Commands

| Command | Description |
|---------|-------------|
| `bun install` | Install all dependencies |
| `bun add <pkg>` | Add dependency |
| `bun add -D <pkg>` | Add dev dependency |
| `bun add -O <pkg>` | Add optional dependency |
| `bun add --peer <pkg>` | Add peer dependency |
| `bun remove <pkg>` | Remove dependency |
| `bun update [pkg]` | Update dependencies |
| `bunx <pkg>` | Run package binary |
| `bun pm cache rm` | Clear cache |

## Installation Flags

```bash
# Production mode (no devDependencies)
bun install --production

# Frozen lockfile (CI/CD)
bun install --frozen-lockfile
bun ci  # shorthand

# Dry run
bun install --dry-run

# Verbose/Silent
bun install --verbose
bun install --silent

# Force reinstall
bun install --force

# Global packages
bun install -g cowsay
```

## Lockfile

Bun uses `bun.lock` (text-based since v1.2):

```bash
# Generate text lockfile
bun install --save-text-lockfile

# Upgrade from binary bun.lockb
bun install --save-text-lockfile --frozen-lockfile --lockfile-only
rm bun.lockb
```

## Workspaces (Monorepos)

```json
{
  "name": "my-monorepo",
  "workspaces": ["packages/*", "apps/*"]
}
```

Run commands across workspaces:

```bash
# Run in matching packages
bun run --filter 'pkg-*' build

# Run in all workspaces
bun run --filter '*' test

# Install for specific packages
bun install --filter 'pkg-a'
```

## Lifecycle Scripts

Bun does **not** run lifecycle scripts from dependencies by default (security). Whitelist trusted packages:

```json
{
  "trustedDependencies": ["my-trusted-package"]
}
```

```bash
# Skip all lifecycle scripts
bun install --ignore-scripts

# Concurrent scripts
bun install --concurrent-scripts 5
```

## Overrides & Resolutions

Force specific versions for nested dependencies:

```json
{
  "overrides": {
    "lodash": "4.17.21"
  }
}
```

Yarn-style resolutions also supported:

```json
{
  "resolutions": {
    "lodash": "4.17.21"
  }
}
```

## Non-npm Dependencies

```json
{
  "dependencies": {
    "dayjs": "git+https://github.com/iamkun/dayjs.git",
    "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
    "zod": "github:colinhacks/zod",
    "react": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
    "bun-types": "npm:@types/bun"
  }
}
```

## Installation Strategies

> **Bun 1.3+ default flip**: Starting in Bun 1.3, **`isolated` is the default for workspaces** (packages can no longer reach undeclared deps through the hoisted root `node_modules`). `hoisted` is now the **legacy opt-out** — only use it when a workspace package depends on a transitive dep that it doesn't declare.

### Hoisted (legacy opt-out; still the default for single non-workspace packages)

Traditional flat node_modules:

```bash
bun install --linker hoisted
```

### Isolated (default for workspaces in Bun 1.3+)

pnpm-like strict isolation:

```bash
bun install --linker isolated
```

Isolated prevents "phantom dependencies" - packages can only access declared dependencies. To make this explicit or restore it after an opt-out, set it in `bunfig.toml`:

```toml
[install]
linker = "isolated"   # default for workspaces in Bun 1.3+
# linker = "hoisted"  # legacy opt-out
```

## CI/CD

```yaml
# GitHub Actions
- uses: oven-sh/setup-bun@v2
- run: bun ci  # frozen lockfile
```

## Platform-Specific

```bash
# Install for different platform
bun install --cpu=x64 --os=linux
```

## Secure Installation

When installing packages, follow supply chain security best practices:

- **Block post-install scripts** — Bun disables them by default; allow specific packages via `trustedDependencies` in `package.json`
- **Cooldown period** — Configure `minimumReleaseAge` in `bunfig.toml` to wait 7 days for new versions
- **Audit before installing** — Run `socket package score npm <pkg>` or use `socket npm install <pkg>` to check packages before they reach your project

Load the `dependency-upgrade` skill for full security configuration including Socket CLI integration, cooldown setup, lockfile validation, and CI enforcement.

## Common Errors

| Error | Cause | Fix |
|-------|-------|-----|
| `Cannot find module` | Missing dependency | Run `bun install` |
| `Lockfile mismatch` | package.json changed | Run `bun install` |
| `Peer dependency` | Missing peer | `bun add` the peer |
| `Lifecycle script failed` | Untrusted package | Add to `trustedDependencies` |

## Migration from Other Package Managers

### From pnpm

Bun automatically migrates `pnpm-lock.yaml`:

```bash
bun install  # Auto-converts to bun.lock
```

Workspace config moves to package.json:

```json
{
  "workspaces": {
    "packages": ["apps/*", "packages/*"],
    "catalog": {
      "react": "^18.0.0"
    }
  }
}
```

### From npm/Yarn

Simply run `bun install` - Bun reads `package-lock.json` and `yarn.lock`.

## When to Load References

Load `references/cli-commands.md` when:
- Need complete CLI flag reference
- Working with advanced options

Load `references/workspaces.md` when:
- Setting up monorepos
- Configuring workspace filters

Load `references/migration.md` when:
- Migrating from npm/yarn/pnpm
- Converting lockfiles

© secondsky · MIT · secondsky/claude-skills

Similar skills

All skills for DevOps and infrastructure →

From the same set116

bun-hono-integration A skill that tells the agent how to build Hono APIs on Bun: routes, middleware, Zod validation, RPC client. Useful when your project already runs on Bun. CX Codex +1 452installs test-quality-analysis Spots overmocking, brittle selectors, and flaky tests in test suites. The skill guides test reviews and verifies coverage thresholds across codebases. CX Codex +1 449installs tanstack-router Configures type-safe file-based routing in React SPAs and resolves integration issues with TanStack Query or Cloudflare Workers. CX Codex +1 445installs interaction-design A skill for designing interface feedback: loading states, errors, empty screens, animation timing and accessibility. Useful when you need to plan how UI behaves, not just how it looks. CX Codex +1 441installs api-error-handling The skill sets a standard error response shape, an ApiError class and a circuit breaker. Useful once your API hits production. CX Codex +1 440installs security-headers-configuration Sets up HTTP security headers against XSS, clickjacking and MIME sniffing. Useful when hardening an app or preparing for an audit. CX Codex +1 438installs internationalization-i18n Sets up multi-language workflows using i18next, gettext, or native Intl APIs. Useful when building apps with plural forms, locale formatting, and RTL layouts. CX Codex +1 433installs mutation-testing Mutates your code and reruns the tests to see which ones notice. Surviving mutants point at assertions that would let a real bug through. CX Codex +1 432installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor