AgentSkillsCN

ni

使用 ni (@antfu/ni) 执行包管理器操作。重要提示:在 JavaScript/TypeScript 项目中,无论何时运行 npm、yarn、pnpm、bun、npx 或任何包管理器命令,都必须使用此技能。这包括:安装依赖(npm install、yarn add、pnpm add)、运行脚本(npm run、yarn run)、执行包(npx、pnpm dlx、bunx)、更新或移除包,以及运行 CI 安装。此外,当用户要求添加包、运行构建/测试/代码检查脚本,或执行任何 Node.js 工具时,也应触发该技能。切勿直接运行 npm/yarn/pnpm/bun/npx——务必先咨询此技能,以使用 ni 的等效功能。

SKILL.md
--- frontmatter
name: ni
description: 'Use ni (@antfu/ni) for package manager operations. IMPORTANT: This skill MUST be used whenever you are about to run npm, yarn, pnpm, bun, npx, or any package manager command in a JavaScript/TypeScript project. This includes: installing dependencies (npm install, yarn add, pnpm add), running scripts (npm run, yarn run), executing packages (npx, pnpm dlx, bunx), updating or removing packages, or running CI installs. Also trigger when the user asks to add a package, run a build/test/lint script, or execute any Node.js tooling. Never run npm/yarn/pnpm/bun/npx directly - always consult this skill first to use the ni equivalent.'

ni - Package Manager Agnostic Commands

JavaScript/TypeScript プロジェクトでパッケージマネージャー操作を行う際は、npm, yarn, pnpm, bun などを直接使用せず、@antfu/ni のコマンドを使用すること。

ni はプロジェクトの lockfile を自動検出し、適切なパッケージマネージャーコマンドに変換する。

コマンド対応表

ni コマンド用途npm 相当
ni依存関係のインストールnpm install
ni <pkg>パッケージ追加npm install <pkg>
ni -D <pkg>devDependencies に追加npm install -D <pkg>
nr <script>スクリプト実行npm run <script>
nlx <pkg>パッケージ実行npx <pkg>
nu依存関係の更新npm update
nun <pkg>パッケージ削除npm uninstall <pkg>
nciクリーンインストールnpm ci

使用例

bash
# 依存関係をインストール
ni

# パッケージを追加
ni axios

# devDependencies に追加
ni -D typescript @types/node

# スクリプト実行
nr build
nr test
nr lint

# npx 相当
nlx eslint --fix .
nlx prettier --write .

# パッケージ削除
nun lodash

# クリーンインストール
nci

重要: nr を優先して使うこと

  • npx vite buildnlx eslint --fix . のようにパッケージを直接実行する前に、まず package.jsonscripts に対応するスクリプトがないか確認すること
  • 対応するスクリプトがあれば nr build, nr lint など nr <script> を使うこと
  • nlxpackage.jsonscripts に対応するものがない場合にのみ使用すること

注意事項

  • ni は mise でグローバルインストール済み (config/mise/home-config.toml)
  • lockfile が存在しないプロジェクトでは、ni はデフォルトで npm を使用する
  • nr でスクリプトを実行する際、引数は -- なしでそのまま渡せる