Pm Guard
Description
Never accidentally npm install in a pnpm project again — guards npm, yarn, pnpm, bun, and deno.
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
pm-guard — Never accidentally `npm install` in a pnpm project again
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
PreToolUsehook - Zero dependencies — pure bash, no jq or node required
Quick Start
Add the marketplace:
/plugin marketplace add udonc/pm-guardInstall the plugin:
/plugin install pm-guard@pm-guardThat'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:
- Extracts the command from the tool input JSON
- Determines the allowed package manager (see Configuration)
- Strips content inside quotes (both single and double) so that strings like
grep "npm" package.jsondon't trigger
Related Skills
Awesome Go
A curated list of awesome Go frameworks, libraries and software
Development next.js
| The React Framework | 138360 | 1503 | 1 |
Development sharing-skills
skill for guidance.
Development root-cause-tracing
Use when errors occur deep in execution and you need to trace back to find the original trigger.
Development Template Skill
Minimal skeleton for a new skill project structure.
Development Third-party Notices
THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THI
Development