包发布
danielvm-git2026-10-28查看 912复制 1644
针对 npm、crates.io、PyPI 和 Homebrew 的包注册表发布。验证前置条件,运行发布命令,确认成功,并在失败时给出可操作的错误提示。
📘如何使用这个技能
- 1复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
- 2打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
- 3粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
- 4直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景
💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。
SKILL.md2468 chars
--- name: publish-package description: "Package registry publishing for npm, crates.io, PyPI, and Homebrew. Verifies prerequisites, runs the publish command, confirms success, and surfaces actionable error hints on failure." model: sonnet effort: standard --- # Publish Package > **HARD GATE** — Do not attempt to publish without verifying prerequisites. Missing auth tokens, stale builds, or duplicate versions cause CI failures that are hard to debug post-push. > > **HARD GATE** — Always run `--dry-run` first. Package registries are append-only — a bad publish cannot be fully undone on most registries. Publish packages to language-specific registries. Detects package type from manifest files, verifies publish prerequisites, runs the registry-specific publish command, and confirms the version appears on the registry. ## Process ### 1. Detect package type Read the project root for manifest files to determine the package type: | Manifest | Registry | Publish command | |----------|----------|----------------| | `package.json` | npm | `npm publish --access public` | | `Cargo.toml` | crates.io | `cargo publish` | | `setup.py` / `pyproject.toml` | PyPI | `twine upload dist/*` or `flit publish` | | `Formula/<name>.rb` | Homebrew | `brew bump-formula-pr` | | Multiple detected | Polyglot | Error: specify registry with `--registry <npm|crates.io|pypi|brew>` | If no manifest is found, prompt the user to specify the type or pass `--type <npm|crates.io|pypi|brew>`. ### 2. Verify prerequisites Before attempting any publish, run all applicable checks: **npm (`package.json`):** See [REFERENCE.md](REFERENCE.md) **crates.io (`Cargo.toml`):** See [REFERENCE.md](REFERENCE.md) **PyPI (`setup.py` / `pyproject.toml`):** See [REFERENCE.md](REFERENCE.md) ### 3. Run publish After all prerequisite checks pass, run the registry-specific command: See [REFERENCE.md](REFERENCE.md) ### 4. Verify publish success After publish, confirm the version appears on the registry: See [REFERENCE.md](REFERENCE.md) ### 5. Error handling On failure, surface actionable hints: See [REFERENCE.md](REFERENCE.md) ### 6. Dry-run mode (`--dry-run`) Run `--dry-run` to verify all prerequisites without actually publishing: See [REFERENCE.md](REFERENCE.md) ### 7. Dry-run mode per registry See [REFERENCE.md](REFERENCE.md) ## Verify → verify: `test -f skills/publish-package/SKILL.md && test -f package.json` → verify: `grep -q publish-package SKILL-INDEX.md`