udonc

PM Guard — Development skill for Claude Code

Development community

Never accidentally npm install in a pnpm project again — guards npm, yarn, pnpm, bun, and deno.

How to install PM Guard

This entry records only its repository, not the path inside it, so there is no exact command to give. Open udonc/pm-guard and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What PM Guard does

Never accidentally npm install in a pnpm project again — guards npm, yarn, pnpm, bun, and deno.

Alternatives in Development

  • npm 71.9k ★
  • Again — PUA Again — 用于再试试、换个方法、别放弃、为什么还不行、同一路径失败多次;要求停止微调同一思路,改用本质不同方案 19.5k ★
  • 01 Install Bun And Deps — Prompt 01: Install Bun Runtime & Dependencies 2.3k ★

README

pm-guard — Never accidentally `npm install` in a pnpm project again

[ English | 日本語 ]

A [Claude Code](https://docs.anthropic.com/en/docs/claude-code) plugin that prevents Claude from using the wrong package manager.

What It Does

  • Guards npm, yarn, pnpm, bun, and deno (including npx, pnpx, bunx)
  • Auto-detects the project's package manager from env var, package.json, or lockfiles
  • Blocks disallowed commands before execution via PreToolUse hook
  • Zero dependencies — pure bash, no jq or node required

Quick Start

  1. Add the marketplace:

    /plugin marketplace add udonc/pm-guard
  2. Install the plugin:

    /plugin install pm-guard@pm-guard
  3. That's it. pm-guard auto-detects your package manager from lockfiles or `package.json` — no configuration needed.

If Claude tries to use the wrong package manager, the command is blocked:

This project uses pnpm. Use pnpm commands instead of npm.

Configuration

The allowed package manager is detected with the following priority:

1. `PM_GUARD_ALLOWED` environment variable (highest priority)

PM_GUARD_ALLOWED=pnpm claude

2. `packageManager` field in `package.json`

{
  "packageManager": "pnpm@9.15.4"
}

The version suffix is ignored — only the package manager name is used.

3. Lockfile detection (lowest priority)

Lockfile Detected PM
pnpm-lock.yaml pnpm
yarn.lock yarn
package-lock.json npm
bun.lock / bun.lockb bun
deno.lock deno

How It Works

pm-guard registers a `PreToolUse` hook on the `Bash` tool. When Claude attempts to run a shell command, the hook:

  1. Extracts the command from the tool input JSON
  2. Determines the allowed package manager (see Configuration)
  3. Strips content inside quotes (both single and double) so that strings like grep "npm" package.json don't trigger