/npm-toolkit:npm-publishfrom npm-toolkit
Configures npm packages to auto-publish to npmjs.com via GitHub Actions using OIDC Trusted Publishing (no npm token). Covers setup, Node 24 requirement, provenance flags, and private repo handling.
Ships in npm-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
将 npm 包通过 GitHub Actions + OIDC Trusted Publishing 自动发布,无需管理 npm token。
OIDC Trusted Publishing 需要 npm CLI >= 11.5.1。各 Node 版本对应的 npm:
| Node 版本 | npm 版本 | 是否支持 Trusted Publishing |
|---|---|---|
| Node 20 | npm 10.x | 不支持 |
| Node 22 | npm 10.9.x | 不支持 |
| Node 24 | npm 11.x+ | 支持 |
必须使用 Node 24,这是最常见的失败原因。
--provenance 签名仅支持 public 仓库。Private 仓库使用 --provenance 会报错:
Error verifying sigstore provenance bundle: Unsupported GitHub Actions source repository visibility: "private"
Private 仓库需要去掉 --provenance flag。
确保 package.json 包含以下关键字段:
{
"name": "@scope/package-name",
"version": "1.0.0",
"files": ["dist", "README.md"],
"publishConfig": {
"access": "public"
}
}
@xxx/yyy)需要 publishConfig.access: "public",否则默认 restrictedfiles 字段控制发布内容,避免发布 src、node_modules 等创建 .github/workflows/publish.yml:
Public 仓库(推荐,带 provenance):
name: Publish to npm
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm publish --provenance --access public
Private 仓库(不带 provenance):
name: Publish to npm
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm publish --access public
关键配置说明:
environment: npm — 必须与 npmjs.com 上配置的 environment 名称一致permissions.id-token: write — 允许 GitHub Actions 生成 OIDC tokennode-version: 24 — 确保 npm >= 11.5.1registry-url — 必须设置,否则 npm publish 不知道往哪发通过 gh CLI 创建:
gh api repos/{owner}/{repo}/environments/npm -X PUT --input - <<< '{}'
或到 GitHub 仓库 Settings → Environments → New environment,名称填 npm。
前提:包必须已经手动发布过至少一个版本(npm 要求包已存在才能配置 trusted publisher)。
https://www.npmjs.com/package/{package-name}/accesspublish.yml(仅文件名,不含路径)npm(大小写敏感,必须精确匹配)gh release create v{version} --title "v{version}" --notes "Release notes" --target main
gh run list --limit 1
gh run watch {run-id}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 skills in this plugin
npx claudepluginhub strzhao/autopilot --plugin npm-toolkitOther plugins' skills for the same job