/iasiv5-skills:npm-name-claimfrom iasiv5-skills
抢注/占位发布 npm 包名:查名、搭 0.0.1 占位包、认证与发布的全流程,以及发布后配置 GitHub Actions OIDC Trusted Publishing(无 token 发版)。当用户想查 npm 包名是否被注册、想抢注/占位/保留(claim/reserve)npm package name、想把 npm 包升级为 OIDC/trusted publishing 发布、或 npm publish / npm trust 遇到认证与环境故障(E401、PUT 报 404、ENEEDAUTH、EOTP/2FA、静默失败 exit 1、镜像源发不出包)时使用。
Ships in iasiv5-skills. 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; scripts run unread.
npm 没有预留/停放机制:名字只有在第一次成功 publish 之后才真正归属。查完是空的就别拖,尽快发 0.0.1 占位版。
流程五步:查名 → 搭包 → 认证 → 发布 → 验证,外加卫生收尾。机械步骤由 scripts/claim.sh 承载(子命令用法看脚本内 USAGE),本文件只写决策点、交互协议和坑的原理。
用户报来一个或多个包名时,按序调用:
scripts/claim.sh check <name> [<name>...] # 批量逐行输出;短名自动 typosquat RISK 预筛;本地死刑名单命中报 DEAD
scripts/claim.sh scaffold <name> --dir BASE --desc ... --repo ... --homepage ... --author ...
scripts/claim.sh weblogin <pkgdir> # 已有可用 token 时跳过
scripts/claim.sh publish <pkgdir> # 用后台任务方式运行,见第 4 步
scripts/claim.sh verify <name> [--wait 180]
scripts/claim.sh cleanup <pkgdir> # 全部发完后做
scripts/claim.sh trust <pkgdir> --repo OWNER/REPO --file <wf.yml> # 可选:发包后配 OIDC 信任,见第 7 节
claim.sh check 返回判定:AVAILABLE / TAKEN / RISK / DEAD / INVALID / UNKNOWN。多名批量逐行输出;RISK 预筛批量照跑,近似名全列表仅单名输出。
dsh-k→dshk)做近似搜索,与已注册包编辑距离 ≤2 即报 RISK。存在假阳性——dsh-a≈sha(距离 1)实际发得出去。RISK 的价值是把「拼接心算」机械化,逼出第 4 步授权前的用户确认。~/.config/npm-claim/dead-names.txt(一行一个包名,# 后备注;路径可用环境变量 NPM_CLAIM_DEADLIST 覆盖)。名单属个人维护数据,不随 skill 分发;check 命中即报 DEAD,连 registry 都不必查。dsh-ip≈dship、dsh-op≈dshop(2026-10-09,连读成词);dsh-k≈sshpk、dsh-x≈shx、dsh-y≈tshy(2026-11-06,压缩串近似非词)。两批 check 均 AVAILABLE,publish 全部 403 永久关闭——单字母/短名是重灾区,早期能过属窗口宽松,不可复制。claim.sh scaffold 生成三件套(package.json / index.js / README.md)并自动做打包自检。
--desc 与 keywords 按用户项目主题写正常文案——占位包也是公开门面。--author iasiv5、--homepage https://www.npmjs.com/package/<name>、repo 留空;publishConfig.registry 由 scaffold 写死官方源。publishConfig.registry: https://registry.npmjs.org/。这是防翻车关键:很多机器默认源是镜像(腾讯/淘宝等),镜像只能装、发不了,发布必须显式指回官方源。token 的落点只有一个:<pkgdir>/.npmrc(chmod 600)。输出与聊天里只出现 token 长度;一旦出现明文,立即让用户去 npmjs.com 吊销该 token。
优先级从高到低:
claim.sh weblogin <pkgdir> 向 registry 发起 web 登录会话,输出 LOGIN_URL: 交给用户在浏览器打开并授权(有 2FA 就地完成),脚本轮询 doneUrl 拿到 token 后直写文件。npm config set '//registry.npmjs.org/:_authToken' <token>——token 经用户的手直达 ~/.npmrc,绕开对话。~/.npmrc 里可能已有 token。判定失效看失效签名:whoami 返回 401 且 publish 的 PUT 返回 404(registry 对无效 token 的写操作掩饰成 404)。命中签名就重走 weblogin,与网络和包名无关。~/.npmrc 本身可能位于只读挂载(沙箱/容器),所以 token 落点选包目录 .npmrc——npm 会加载包目录级配置。
完成标准:报出账号名,例如:
cd <pkgdir> && npm whoami --registry https://registry.npmjs.org --cache ../.npm-cache --logs-dir ../.npm-logs --userconfig .npmrc
注意:~/.npm 只读时 whoami 会报 EROFS: read-only file system——那是缓存目录崩溃,不是认证失败,把 --cache/--logs-dir 指到可写目录即可(同 publish 的坑,症状不同)。
先对症,再动手:
| 症状 | 根因 | 解法 |
|---|---|---|
npm publish / npm pack 静默 exit 1,无任何错误文本 | cache/logs 目录只读(如 ~/.npm 在只读挂载),npm 内部崩溃并吞掉报错 | --cache、--logs-dir 指到可写目录(claim.sh 已内置,落在包目录父目录下) |
| PUT 404 + whoami 401(命中失效签名) | token 失效 | 重走第 3 步 |
EOTP: This operation requires a one-time password | 账号 2FA 设为 auth-and-writes,写操作要二次验证 | 见下 |
npm trust 任意子命令(连 list 读操作)报 EOTP,错误通道里授权链接是打码的 *** | trust 属账号级敏感操作,auth-and-writes 账号一律二次验证,且 npm 把它走错误通道输出 | 与 publish 同一套伪 TTY + --browser=false(claim.sh trust 已内置);--browser 这个 flag 传不进去就改用环境变量 npm_config_browser=false |
npm trust ... --cache/--logs-dir <dir> 报 Unknown positional argument: <dir> | npm trust 的子命令用严格 flag 解析器,不认这些全局 flag 的空格分隔形式,值被当成了多余位置参数 | 相关配置全部改走 npm_config_* 环境变量(npm_config_cache / npm_config_logs_dir / npm_config_browser) |
PUT 403 Package name too similar to existing packages ... | npm typosquat 防护在发布时做相似度拦截(check 阶段看不到) | 该名对所有账号永久关闭,重试无意义;记入本地死刑名单(见第 1 步 DEAD);向用户说明并给替代:@scope/name(属自己账号,无抢注意义)或换名。实战例:dsh-ip≈dship、dsh-op≈dshop(连读成词);dsh-k≈sshpk、dsh-x≈shx、dsh-y≈tshy(压缩串近似同样中招) |
script: failed to create pseudo-terminal: Permission denied | 运行环境沙箱禁止创建伪终端,script 起不来、npm 根本没执行;后续可能跟着「$ts 输出文件不存在」的 bash 重定向报错 | 对该命令请求提权(如 danger-full-access)后重跑 publish。不要绕 claim.sh 直发:非 TTY 下 npm publish --auth-type=web 的 EOTP 授权链接是打码的 ***,没法交给用户(2026-11-12 实录:pty 被禁 → 静默 exit 1,误诊两轮才到根因) |
EOTP 核心技巧:伪造 TTY + 关闭浏览器。 具体命令在 claim.sh 的 publish 子命令里(script -qec 包一层伪终端,npm 加 --browser=false),这里写清楚它为什么有效——排障时据此推理:
--browser=false 让 opener 把真实授权链接打印到输出后立即返回——npm 打印 URL 的通道关闭了脱敏(错误通道里的 URL 是打码的 ***),并且弹浏览器、等回车两个动作都被跳过,适合 headless 环境。授权前置确认:typosquat 403 只能在真 PUT 时暴露,无法免费预试,而 auth-and-writes 账号每次 publish 都要先过 OTP。带 RISK 标记的名字发起 weblogin / publish 授权前,先向用户确认「publish 可能 403 永久关闭,这次授权可能白点」,点头再发起(2026-11-06 实录:k/x/y 三连 403,用户为注定失败的批次点了两次授权)。
交互协议:
claim.sh publish(bash 工具 run_in_background: true)——它会阻塞等待用户授权。AUTH_URL: https://www.npmjs.com/auth/cli/... 后立刻把链接发给用户,让用户完成登录 + 2FA + Authorize。PUBLISHED: 即完成。省事技巧:授权后有宽限窗口,短时间内同账号再发布其他包可复用授权、免二次 OTP。要抢多个包名时,把所有 scaffold 提前做好,认证+发布集中连着做,通常用户只点一次授权。
批量连发配方(实测:28 包一次授权、约 2 分钟发完 26 个):
cp <pkgdir>/.npmrc <其他包目录>/.npmrc && chmod 600 <其他包目录>/.npmrc 全批共用;for n in a b c; do
echo "=== PUBLISH dsh-$n start $(date +%T) ==="
bash scripts/claim.sh publish "/path/npm-packages/dsh-$n" 2>&1 \
| grep --line-buffered -E "PUBLISHED|AUTH_URL|https://www\.npmjs\.com/auth|npm error|ERROR:|FAILED:|script:|Permission denied"
echo "=== dsh-$n exit=${PIPESTATUS[0]} $(date +%T) ==="
done
三个管道坑(2026-10-09 全踩过,任中一个都会让授权链接不可见、整批假死):
--line-buffered:非 TTY 下 grep 块缓冲,已匹配的链接行会憋到进程退出才吐;https://www\.npmjs\.com/auth)——授权链接独立成行,只匹配 AUTH_URL/Authenticate 关键词会漏掉它。ERROR:/FAILED:/script:/Permission denied——claim.sh 与 script 的失败行不带 npm error 前缀,只匹配 npm 关键词会把失败吞成静默 exit 1(2026-11-12 实录);exit=1 且无匹配行 = 过滤吞了错误,先去掉过滤裸跑看全文再定位。完成标准:输出 PUBLISHED:。
claim.sh verify <name>:registry 返回 200 + 最新版本 + 发布者账号。把 https://www.npmjs.com/package/<name> 链接给用户,并告知:名字已锁定,以后发正式版就是改版本号后 npm publish。
0.0.0-stage 与分钟级延迟是正常现象,不要重发:全新包名首发成功后,registry 会先挂一条 0.0.0-stage("Temporary package placeholder for staged publishing")占位记录,真实版本几分钟内转正为 latest——实测为几分钟到 10 分钟量级(2026-11-11 两批:一批 ≤4 分钟、另一批 10 分钟后仍未转正),文档早前的「1–2 分钟」偏乐观;期间 verify 可能显示 LIVE: [email protected] 或 STAGED:,甚至在前几十秒短暂 404。publish 已受理,此时重发只会徒增失败;--wait 180 可能不够,转正确认可以事后补——包名此时已锁定,他人无法再注册。
完成标准:verify 输出 LIVE:(版本号为真实版本而非 0.0.0-stage)。
claim.sh cleanup <pkgdir> 删除包目录里的 token 文件。占位包发布完成后建议清掉;下次发版重走 weblogin(用户点一次链接的事)。.npmrc。占位包发完后,可顺手把包升级成 OIDC 信任发布:以后发版不再需要任何静态 token,CI 用短时凭据且自带 provenance。
claim.sh trust <pkgdir> --repo OWNER/REPO --file <workflow.yml>
(内部 npm trust github,需要 npm ≥ 11.10;workflow 只写文件名不带
路径)。等价于 npmjs.com 网站上的 Trusted Publisher 表单,但全程 CLI +
一次浏览器授权,无需登录网站;permissions: id-token: write;npm ≥
11.5.1(setup-node 装 node 24,npm install -g npm@latest 兜底);
npm publish --provenance --access public。触发用 on: push: tags: ['v*'],
另加 workflow_dispatch 方便重跑;npm version x.y.z && git push --tags,Actions 自动
发布。registry 元数据里发布者显示为 GitHub Actions 即 OIDC 生效
(claim.sh verify 会直接把它打出来)。实战样例(2026-09-18):@iasiv5/dsh-obmc-web,0.0.1 bootstrap → weblogin
→ trust 配信任 → cleanup 删 token → 推 v0.1.0 tag → Actions 发布。
bash、curl、node、npm、util-linux 的 script;trust 子命令额外要求
npm ≥ 11.10。换机器/新环境使用:整个 skill 目录拷贝到该环境的 skill 目录
即可,脚本无其他依赖。
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub iasiv5/skills --plugin iasiv5-skills34 skills in this plugin
/answer-me-with-htmlTurns an answer into a one-page visual HTML explainer: the model writes a short Markdown draft and the bundled CLI builds one page. Use it proactively and liberally in replies to the user, without being asked, whenever a page would help the reader more than plain text, even if plain text would also work: any explanation of how something works or how parts relate (flow, request path, architecture, code or folder structure, state machine, lifecycle, history); any comparison, trade-off or decision with pros and cons; any diagnosis, review or investigation, especially with several causes or findings to rank; any answer with a table, a numbered or ranked list, steps, branches or several sections; or when the user says "I don't get it / draw it / explain visually / 讲讲原理 / 没看懂 / 画个图". When in doubt, use it: a page is quick and cheap to make. Also for explainer videos ("make a video", "做个视频") and for changing its settings. Skip only for small talk, a trivial one-line answer, or when the user asks for plain text./architecture-diagramCreate polished dark-themed architecture diagrams as self-contained HTML+SVG files. Use when the user asks for system, infrastructure, cloud, security, or network topology diagrams./brainstorming在开始实现前,把需求澄清成设计文档。适用于新增功能、修改行为、组件设计、接口设计、流程改造、架构取舍和多方案比较。只要改动跨文件、改行为或涉及多方案取舍,就值得先做设计,无论体量大小;单点直改不必走本 skill。用户说'先想一下''先给方案''先规划一下''先比较两种做法'时优先使用这个 skill。/cleanup在任务完成后,对仓库内长期知识做深度整理、沉淀与规范审计。仅在用户明确要求 cleanup、最终沉淀、长期知识同步、收尾整理,或明确要求检查仓库规则执行情况时触发;不要用于中途续做、普通总结、状态同步或实现过程中的正常文档更新。默认保守触发,强制 cleanup 也不默认写入用户记忆。/codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./code-review代码审查助手。用户请求 review 代码、PR 或 commit,或寻找 bug 时使用。以 Spec(需求/规格符合性)与 Standards(项目规范符合性)双轨审查,覆盖 C/C++、嵌入式、BIOS/UEFI、BMC 专项。