Pnpm

From Mindrally/skills · View interactive version

Pnpm is an AI agent skill from the GitHub repository Mindrally/skills. Best practices for pnpm package manager, workspace management, and monorepo configuration

How to use this skill

Skill file

pnpm Development

You are an expert in pnpm, the fast, disk space efficient package manager for JavaScript and TypeScript projects.

Core Principles

Installation and Setup

```json

{

"packageManager": "pnpm@9.0.0"

}

```

Workspace Configuration

Create pnpm-workspace.yaml for monorepo setup:

packages:
  - 'apps/*'
  - 'packages/*'
  - 'tooling/*'

Dependency Management

```bash

pnpm add lodash --filter @org/my-app

pnpm add -D typescript --filter @org/my-lib

```

```json

{

"dependencies": {

"@org/shared-utils": "workspace:*",

"@org/ui": "workspace:^"

}

}

```

Filtering Commands

Run commands in specific packages:

pnpm --filter @org/my-app dev
pnpm --filter "./apps/*" build
pnpm --filter "...@org/my-lib" test  # Include dependents
pnpm --filter "@org/my-lib..." build  # Include dependencies

Scripts and Task Running

```bash

pnpm -r run build # Run in all packages

pnpm -r --parallel run dev # Run in parallel

pnpm -r --stream run test # Stream output

```

```json

{

"scripts": {

"build": "pnpm -r run build",

"dev": "pnpm --filter @org/web dev",

"lint": "pnpm -r run lint",

"test": "pnpm -r run test"

}

}

```

Dependency Hoisting

Configure hoisting in .npmrc:

# Strict mode - no hoisting
hoist=false

# Selective hoisting
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*

# Shamefully hoist everything (not recommended)
shamefully-hoist=true

Peer Dependencies

Configure peer dependency handling in .npmrc:

auto-install-peers=true
strict-peer-dependencies=false

Overrides and Resolutions

Override dependencies in root package.json:

{
  "pnpm": {
    "overrides": {
      "lodash": "^4.17.21",
      "foo@1.x": "npm:bar@^2.0.0"
    }
  }
}

Publishing Workspaces

Performance Optimization

```dockerfile

COPY pnpm-lock.yaml ./

RUN pnpm fetch

COPY . ./

RUN pnpm install --offline

```

Best Practices

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.