setup-pm

A command for choosing the package manager used by a project or by default on your computer. A package manager installs and manages the libraries a software project needs.

In plain words
What is it for?
Use it to detect the current choice, set a project or global preference, list available package managers, or override the choice with an environment variable.
Why use it?
It avoids uncertainty about whether a project should use npm, pnpm, yarn, or bun, especially when several configuration sources disagree.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/xiaobei930/cc-best/setup-pm
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 768 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.00768
Opus 5 $0.00008 $0.00384
Sonnet 5 $0.00003 $0.00154
Haiku 4.5 $0.00002 $0.00077

Measured 3d ago against content hash 1ea8c8db1930, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

setup-pm scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/setup-pm.md · 106 lines

How it starts

The opening of the file, as written. The whole thing — 106 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/setup-pm - 包管理器配置

配置项目或全局的首选包管理器。

快速使用

# 检测当前配置
node scripts/node/setup-package-manager.js --detect

# 设置项目首选为 pnpm
node scripts/node/setup-package-manager.js --project pnpm

# 设置全局首选为 bun
node scripts/node/setup-package-manager.js --global bun

# 列出所有可用选项
node scripts/node/setup-package-manager.js --list

检测优先级

系统按以下顺序检测包管理器:

优先级 来源 说明
1 环境变量 CLAUDE_PACKAGE_MANAGER 最高优先级
2 项目配置 .claude/package-manager.json 项目级覆盖
3 package.jsonpackageManager 标准字段
4 Lock 文件检测 自动检测
5 全局配置 ~/.claude/package-manager.json 用户默认
6 回退 pnpm > bun > yarn > npm

配置文件格式

项目配置 (.claude/package-manager.json)

{
  "packageManager": "pnpm",
  "updatedAt": "2024-01-23T10:00:00.000Z"
}

全局配置 (~/.claude/package-manager.json)

{
  "packageManager": "bun",
  "updatedAt": "2024-01-23T10:00:00.000Z"
}

package.json 标准字段

{
  "name": "my-project",
  "packageManager": "[email protected]"
}

环境变量

设置 CLAUDE_PACKAGE_MANAGER 环境变量可覆盖所有配置:

# Windows PowerShell
$env:CLAUDE_PACKAGE_MANAGER = "pnpm"

# macOS/Linux
export CLAUDE_PACKAGE_MANAGER=pnpm

支持的包管理器

包管理器 Lock 文件 特点
npm package-lock.json Node.js 自带
pnpm pnpm-lock.yaml 快速、节省磁盘空间
yarn yarn.lock 稳定、广泛使用
bun bun.lockb 极快、新一代运行时

在 Hooks 中使用

Node.js hooks 会自动使用检测到的包管理器:

const { detect, getRunCommand } = require("./lib/package-manager");

const pm = detect();
console.log(`使用 ${pm.name} (来源: ${pm.source})`);

// 获取运行命令
const devCmd = getRunCommand("dev"); // -> "pnpm dev" 或 "npm run dev"
const testCmd = getRunCommand("test"); // -> "pnpm test" 或 "npm test"

Read the full file on GitHub · 106 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 106 lines · 16 tokens per session scan A 1ea8c8db1930

Subscribe to this mod's changes

setup-pm is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 16 tokens to every session and 768 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.