Community程式設計與開發github.com

steipete/npm

npm 註冊表操作:登入、身份確認、套件名稱查詢、發佈;使用 1Password 與 tmux。

npm 是什麼?

此技能專門為 AI 代理(如 Claude Code)設計,用於自動化 npm 註冊表操作,包括登入、套件可用性檢查、套件預留、發佈、組織檢查以及身份驗證除錯。它主要依賴 1Password(優先使用「Molty」帳戶,並以 `OP_SERVICE_ACCOUNT_TOKEN` 運作,無需桌面解鎖)來安全地擷取和管理 npm 憑證(包含註冊表工作階段、使用者名稱/密碼/TOTP)。所有與 npm 相關的身份驗證工作都在一個持久的 tmux 工作階段中執行,身份驗證資訊儲存在暫存的 npmrc 檔案中,並在操作完成後清理。該技能支援 macOS(因使用 tmux 和 1Password CLI 而隱含支援)平台,並透過提供專用腳本(`scripts/npm-auth.sh`、`scripts/npm-service.sh`、`publish-package.sh`、`reserve-packages.sh`)來簡化工作流程,以避免與 npm 11 CLI 提示管線相關的脆弱性,並將錯誤處理(如身份驗證失敗、套件名稱衝突、範圍套件檢查延遲)的邏輯封裝起來。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/steipete/agent-scripts/tree/main/skills/npm

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

npm 是做什麼的?

用於 npm 註冊表/帳戶任務:npm whoami、套件可用性、套件預留、發佈、組織檢查以及身份驗證除錯。

身份驗證

  • 首先使用 one-password 處理秘密規則。
  • 絕不直接在 shell 工具中執行 op。
  • 主要項目:Molty 中的 npm Registry - steipete - Release Automation。
  • 預設使用 OP_SERVICE_ACCOUNT_TOKEN;無需桌面解鎖。該項目包含有效的註冊表工作階段(registry_token)以及使用者名稱/密碼/TOTP 備用方案。
  • 桌面 npmjs 備用方案僅在明確指定時使用:當 Molty 不可用且使用者想要使用備用方案時,傳遞 --account my.1password.com。明確的 release/publish 請求即同意其解鎖提示。
  • 若出現以下情況,請停下來詢問:項目遺失、帳戶/保管庫不明確、憑證格式錯誤、npm 拒絕套件存取,或請求的套件/版本與儲存庫發佈目標不符。
  • 在一個持久的 tmux 工作階段內執行 npm 身份驗證工作。失敗時重複使用該工作階段。
  • 將 npm 身份驗證資訊保存在暫存的 npmrc 中;命令執行後將其刪除。
  • 所有輔助腳本共用 scripts/npm-auth.sh:優先使用已儲存的 registry_token 工作階段,然後使用 scripts/npm-auth-login.mjs 透過全新的六位數 OTP 進行註冊表登入;成功的備用工作階段會快取回同一個項目。不要手動提取欄位、執行註冊表登入或寫入快取。
  • 憑證選擇優先使用標準欄位 id,然後是 purpose,最後是唯一標籤;僅匹配重複標籤的請求會被拒絕(舊版 npmjs 可能保留相同標籤的欄位)。
  • 對於臨時性需身份驗證的註冊表命令,使用 scripts/npm-service.sh -- <npm args...>;對於本地套件,使用 publish-package.sh。
  • npm 11 的提示管線很脆弱;避免使用 printf ... | npm login --auth-type=legacy。
  • 除非必要,避免對 npm 登入使用 expect;日誌可能會回顯提示,且容易出錯。
  • 對於自動化操作,優先使用輔助腳本的註冊表 API 登入路徑(npm-profile loginCouch)。
  • 如果身份驗證形式不明確或 npm whoami 失敗,請停下來詢問確切的欄位標籤/憑證修正。不要探查更多 1Password 項目或啟動新的 tmux 工作階段。

套件發佈

在套件根目錄下,於相同的身份驗證 tmux 工作階段內執行:

/Users/steipete/Projects/agent-scripts/skills/npm/scripts/publish-package.sh

輔助腳本會驗證身份、拒絕已存在的套件版本、使用全新的 OTP 發佈、重試一次過期的 OTP、驗證註冊表可見性,並清理身份驗證檔案。

套件預留

在相同的 tmux 工作階段內使用 scripts/reserve-packages.sh:

/Users/steipete/Projects/agent-scripts/skills/npm/scripts/reserve-packages.sh package-one package-two

功能:

  • 經由 op 讀取一次 Molty 的 release-automation 項目
  • 重複使用已儲存的註冊表工作階段,或透過使用者名稱/密碼/TOTP 建立一個新的工作階段
  • 使用通用 README 發佈 0.0.0 佔位套件
  • 在每個套件發佈失敗後繼續執行
  • 在日誌中編輯掉令牌/OTP
  • 清理暫存的 npmrc/工作目錄

注意事項:

  • npm 可能拒絕與已發佈套件名稱過於相似的名稱。請將其視為註冊表政策結果,而非身份驗證失敗。
  • npm CLI 提示管線在 npm 11 上很脆弱。對於腳本化的 npm login,請優先使用輔助腳本的註冊表 API 登入路徑。
  • 對於範圍套件,npm view 可能延遲或回傳 404,即使套件已存在。請檢查 npm access get status <pkg>;狀態為 public 或發佈失敗訊息為 previously published versions 表示該名稱已被預留。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

steipete/agent-transcript

GitHub PR/issue agent transcripts: redact, preview, and insert safely.

steipete/beeper

Beeper cache: contact hints, room lookup, WhatsApp/iMessage traces, FTS.

steipete/browser-use

Existing Chrome automation: Chrome plugin first, mcporter fallback.

steipete/clawsweeper-status

ClawSweeper status: URLs, workflow health, active workers, ops snapshot.

steipete/clickclack

ClickClack ops: chat app, Hetzner deploy, DNS/docs/app, Docker rollout.

steipete/cloudflare-registrar

Cloudflare Registrar: domain availability, prices, registration via mcporter.

steipete/codex-debugging

Codex debugging: codex-rs core/tui/exec/cli/app-server/config.

steipete/create-cli

CLI UX/spec: args, flags, help, output, errors, config, dry-run.

steipete/discord-clawd

Discord-backed OpenClaw agent/session relay; not archive search.

steipete/domain-dns-ops

DNS/domain ops: registrars, zones, redirects, DNS/HTTP verify, manager truth.

steipete/frontend-design

Frontend UI: pages, apps, components, polished non-generic design.

steipete/github-author-context

GitHub contributor context: identity, activity, trust, company/team signal.

steipete/github-cache-hygiene

GitHub quota/cache hygiene: gh, ghx, xcache, gitcrawl, mirrors, limits.

steipete/github-deep-review

GitHub deep review: bugs, PRs, best fix, stale-or-real, read code first.

steipete/github-project-triage

GitHub issue/PR triage: queues, CI, blockers, risk, proof, next actions.

steipete/hopper-debugger

Hopper debugging: macOS/iOS binaries, ObjC/Swift symbols, dyld, LLDB.

steipete/instruments-profiling

Instruments/xctrace profiling: macOS/iOS traces, binaries, args, exports.

steipete/mac-maintenance

Mac upkeep: brew update/upgrade, pull clean repos, empty Trash.

steipete/maintainer-orchestrator

Open-source maintainer orchestration: Codex app workers, work recovery, dependencies, vision, releases.

steipete/markdown-converter

Markdown conversion: PDF, Office, HTML, data, OCR, audio, ZIP, YouTube.

相關技能