setup-pm

setup-pm is a command for Claude Code from xiaobei930/cc-best. It costs 16 tokens per session (768 once invoked), scanned A, original, MIT.

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 for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is node scripts/node/setup-package-manager.js --detect.

Part of the cc-best plugin — 19 skills, 44 commands, 8 agents, 20 hooks shipped together

Good fit 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.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
agentmods
npx agentmods add commands/xiaobei930/cc-best/setup-pm

Made for: Claude Code.

Or install cc-best, the plugin that ships this one along with the rest of its 19 skills, 44 commands, 8 agents, 20 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for setup-pm

README.md
[![agentmods](https://agentmods.dev/badge/commands/xiaobei930/cc-best/setup-pm/github.svg)](https://agentmods.dev/commands/xiaobei930/cc-best/setup-pm)
Your own site
<a href="https://agentmods.dev/commands/xiaobei930/cc-best/setup-pm"><img src="https://agentmods.dev/badge/commands/xiaobei930/cc-best/setup-pm/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for setup-pm

Your own site · 80×15
<a href="https://agentmods.dev/commands/xiaobei930/cc-best/setup-pm"><img src="https://agentmods.dev/badge/commands/xiaobei930/cc-best/setup-pm.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00016 $0.00768
Opus 5.5 $0.00006 $0.00307
Sonnet 5.5 $0.00003 $0.00154
Haiku 4.5 $0.00002 $0.00077

Measured 1mo ago against content hash 1ea8c8db1930, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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.json 的 packageManager 标准字段
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. 1mo 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 (48 stars, last pushed 4mo ago), licensed MIT. It adds 16 tokens to every session and 768 once invoked, about $0.0001 per session on Opus 5.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.