Cursor rule
.cursor/rules/publish-package.mdcPackage registry publishing for npm, crates.io, PyPI, and Homebrew. Verifies prerequisites, runs the publish command, confirms success, and surfaces actionable error hints on failure.
Cursor rules
Quality
70/100
Scores the file, not the repository.Length
1,309 words
51 headings · 12 code blocksRepository
119
— · pushed 1 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Publish Package78> **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.9>10> **HARD GATE** — Always run `--dry-run` first. Package registries are append-only — a bad publish cannot be fully undone on most registries.1112Publish 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.1314## Process1516### 1. Detect package type1718Read the project root for manifest files to determine the package type:1920| Manifest | Registry | Publish command |21|----------|----------|----------------|22| `package.json` | npm | `npm publish --access public` |23| `Cargo.toml` | crates.io | `cargo publish` |24| `setup.py` / `pyproject.toml` | PyPI | `twine upload dist/*` or `flit publish` |25| `Formula/<name>.rb` | Homebrew | `brew bump-formula-pr` |26| Multiple detected | Polyglot | Error: specify registry with `--registry <npm|crates.io|pypi|brew>` |2728If no manifest is found, prompt the user to specify the type or pass `--type <npm|crates.io|pypi|brew>`.2930### 2. Verify prerequisites3132Before attempting any publish, run all applicable checks:3334**npm (`package.json`):**35See [REFERENCE.md](REFERENCE.md)3637**crates.io (`Cargo.toml`):**38See [REFERENCE.md](REFERENCE.md)3940**PyPI (`setup.py` / `pyproject.toml`):**41See [REFERENCE.md](REFERENCE.md)4243### 3. Run publish4445After all prerequisite checks pass, run the registry-specific command:4647See [REFERENCE.md](REFERENCE.md)4849### 4. Verify publish success5051After publish, confirm the version appears on the registry:5253See [REFERENCE.md](REFERENCE.md)5455### 5. Error handling5657On failure, surface actionable hints:5859See [REFERENCE.md](REFERENCE.md)6061### 6. Dry-run mode (`--dry-run`)6263Run `--dry-run` to verify all prerequisites without actually publishing:6465See [REFERENCE.md](REFERENCE.md)6667### 7. Dry-run mode per registry6869See [REFERENCE.md](REFERENCE.md)7071## Verify7273→ verify: `test -f skills/publish-package/SKILL.md && test -f package.json`74→ verify: `grep -q publish-package SKILL-INDEX.md`7576---7778# Publish Package — Reference7980## Navigation8182| Lines | Section |83|-------|---------|84| 1 | Title |85| 3–23 | Navigation |86| 24–35 | Options |87| 36–37 | Examples |88| 38–51 | Publish an npm package |89| 52–59 | Publish a Rust crate |90| 60–69 | Missing token scenario |91| 70–80 | Integration with release-branch |92| 81–121 | Reference block 1 |93| 122–143 | Reference block 2 |94| 144–162 | Reference block 3 |95| 163–180 | Reference block 4 |96| 181–195 | Reference block 5 |97| 196–230 | Reference block 6 |98| 231–248 | Reference block 7 |99| 249–260 | Reference block 8 |100101## Options102103| Flag | Description |104|------|-------------|105| `--dry-run` | Verify prerequisites and show publish command without executing |106| `--registry <type>` | Force registry type (skip auto-detection) |107| `--otp <code>` | One-time password for npm 2FA |108| `--no-verify` | Skip prerequisite checks (use with caution) |109110111---112113## Examples114115### Publish an npm package116117```bash118# Verify first119publish-package --dry-run120121# Publish122publish-package123124# Output:125# [npm] Publishing my-package v0.4.0...126# OK: npm publish confirmed (my-package@0.4.0 on registry)127```128129### Publish a Rust crate130131```bash132export CARGO_REGISTRY_TOKEN=<token>133publish-package --dry-run134publish-package135```136137### Missing token scenario138139```bash140$ publish-package141FAIL: NPM_TOKEN not set. Set via: export NPM_TOKEN=<token> or add to .npmrc142```143144145---146147## Integration with release-branch148149When wired into `release-branch`, add a step after git push:150151```1526a. Run publish-package to publish to package registries153 → verify: publish-package --dry-run && publish-package154```155156---157158## Reference block 1159160```bash161# Check auth token exists162if [ -z "${NPM_TOKEN:-}" ]; then163 if [ ! -f ~/.npmrc ] || ! grep -q "_authToken" ~/.npmrc; then164 echo "FAIL: NPM_TOKEN not set. Set via: export NPM_TOKEN=<token> or add //registry.npmjs.org/:_authToken=<token> to .npmrc"165 exit 1166 fi167fi168169# Check version not already published170PACKAGE_NAME=$(node -p "require('./package.json').name")171CURRENT_VER=$(node -p "require('./package.json').version")172if npm view "$PACKAGE_NAME@$CURRENT_VER" version 2>/dev/null; then173 echo "FAIL: Version $CURRENT_VER already published for $PACKAGE_NAME. Bump version first."174 exit 1175fi176177# Check build artifacts are fresh178if [ -d dist ] || [ -d lib ]; then179 LATEST_BUILD=$(find dist lib 2>/dev/null -name "*.js" -o -name "*.cjs" -o -name "*.mjs" | xargs ls -t 2>/dev/null | head -1)180 PACKAGE_MODIFIED=$(stat -f %m package.json 2>/dev/null || stat -c %Y package.json 2>/dev/null)181 if [ -n "$LATEST_BUILD" ] && [ -n "$PACKAGE_MODIFIED" ]; then182 BUILD_TIME=$(stat -f %m "$LATEST_BUILD" 2>/dev/null || stat -c %Y "$LATEST_BUILD" 2>/dev/null)183 if [ "$BUILD_TIME" -lt "$PACKAGE_MODIFIED" ]; then184 echo "WARNING: Build artifacts may be stale (package.json modified after last build). Run npm run build first."185 fi186 fi187fi188189# Check CHANGELOG is updated190if [ -f CHANGELOG.md ]; then191 if ! grep -q "$CURRENT_VER" CHANGELOG.md 2>/dev/null; then192 echo "WARNING: Version $CURRENT_VER not found in CHANGELOG.md. Update changelog before publish."193 fi194fi195```196197---198199## Reference block 2200201```bash202# Check auth token exists203if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then204 if [ ! -f ~/.cargo/config.toml ] || ! grep -q "token" ~/.cargo/config.toml; then205 echo "FAIL: CARGO_REGISTRY_TOKEN not set. Set via: export CARGO_REGISTRY_TOKEN=<token> or add to ~/.cargo/config.toml"206 exit 1207 fi208fi209210# Check version not already published211CRATE_NAME=$(grep '^name' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')212CURRENT_VER=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')213if cargo search "$CRATE_NAME" 2>/dev/null | grep -q "^${CRATE_NAME}.*\"$CURRENT_VER\""; then214 echo "FAIL: Version $CURRENT_VER already published for $CRATE_NAME. Bump version in Cargo.toml first."215 exit 1216fi217```218219---220221## Reference block 3222223```bash224# Check auth token exists225if [ -z "${TWINE_PASSWORD:-}" ] && [ -z "${POETRY_PYPI_TOKEN_PYPI:-}" ]; then226 if [ ! -f ~/.pypirc ]; then227 echo "FAIL: PyPI token not configured. Set TWINE_PASSWORD or create ~/.pypirc"228 exit 1229 fi230fi231232# Check for build artifacts233if [ ! -d dist ] || [ -z "$(ls dist/*.whl 2>/dev/null)" ]; then234 echo "WARNING: No .whl files found in dist/. Run: python -m build"235fi236```237238---239240## Reference block 4241242```bash243# npm244npm publish --access public245246# crates.io247cargo publish248249# PyPI250python -m twine upload dist/* # or: poetry publish251252# Homebrew (opens PR, does not publish directly)253brew bump-formula-pr --url=<tarball-url> <formula-name>254```255256---257258## Reference block 5259260```bash261# npm262npm view "$PACKAGE_NAME" versions --json 2>/dev/null | grep -q "\"$CURRENT_VER\"" && echo "OK: npm publish confirmed"263264# crates.io265cargo search "$CRATE_NAME" 2>/dev/null | grep -q "^${CRATE_NAME}.*\"$CURRENT_VER\"" && echo "OK: crates.io publish confirmed"266267# PyPI268pip index versions "$PACKAGE_NAME" 2>/dev/null | grep -q "$CURRENT_VER" && echo "OK: PyPI publish confirmed"269```270271---272273## Reference block 6274275```bash276# Generic failure handler277if [ $? -ne 0 ]; then278 case "$REGISTRY" in279 npm)280 echo "FAIL: npm publish failed."281 echo " Common causes:"282 echo " - NPM_TOKEN not set in secrets: add to GitHub repo secrets"283 echo " - Version already published: bump version in package.json"284 echo " - Two-factor auth required: use --otp=<code> flag"285 echo " - Package scoped but not public: add --access public"286 ;;287 crates.io)288 echo "FAIL: cargo publish failed."289 echo " Common causes:"290 echo " - CARGO_REGISTRY_TOKEN not configured: see ~/.cargo/config.toml"291 echo " - Version already published: bump version in Cargo.toml"292 echo " - Local changes not committed: cargo publish requires clean working tree"293 ;;294 pypi)295 echo "FAIL: PyPI publish failed."296 echo " Common causes:"297 echo " - TWINE_PASSWORD not configured: set env var or ~/.pypirc"298 echo " - Build artifacts missing: run python -m build first"299 echo " - Version conflict: version already exists on PyPI"300 ;;301 esac302 exit 1303fi304```305306---307308## Reference block 7309310```bash311# Example output312$ publish-package --dry-run313314[DRY-RUN] Detected package type: npm315[DRY-RUN] Package: my-package v0.4.0316[DRY-RUN] Checking NPM_TOKEN... OK317[DRY-RUN] Checking version 0.4.0 not already published... OK318[DRY-RUN] Checking build artifacts... WARNING: package.json modified after build319[DRY-RUN] Checking CHANGELOG... OK320[DRY-RUN] Would run: npm publish --access public321[DRY-RUN] Exiting without publishing.322```323324---325326## Reference block 8327328```bash329# npm dry-run330npm publish --access public --dry-run331332# crates.io dry-run (cargo does not have a publish dry-run; use --dry-run flag for validation only)333cargo package --list 2>/dev/null334335# PyPI dry-run336python -m twine upload --repository testpypi dist/* # test.pypi.org337```338
Also in danielvm-git/bigpowers
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| danielvm-git/bigpowers.cursor/rules/align-grid.mdc · 119 | Cursor rules | lint-formatdo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/assess-impact.mdc · 119 | Cursor rules | testtesting-strategydeployment | 66/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/audit-code.mdc · 119 | Cursor rules | setuptestlint-formatstyle+4 | 66/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/audit-plan.mdc · 119 | Cursor rules | buildteststylegit | 74/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/build-epic.mdc · 119 | Cursor rules | buildgit | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/change-request.mdc · 119 | Cursor rules | no sections | 48/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/commit-message.mdc · 119 | Cursor rules | lint-formatstyletypesgit+3 | 82/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/compose-workflow.mdc · 119 | Cursor rules | styledo-notagent-behaviour | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/context7-mcp.mdc · 119 | Cursor rules | style | 54/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deepen-architecture.mdc · 119 | Cursor rules | testtesting-strategydo-not | 57/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/define-language.mdc · 119 | Cursor rules | lint-formatdo-not | 65/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/delegate-task.mdc · 119 | Cursor rules | git | 62/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/deploy.mdc · 119 | Cursor rules | setupbuildtestdeployment | 77/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/develop-tdd.mdc · 119 | Cursor rules | teststylearchtesting-strategy+5 | 85/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/diagnose-root.mdc · 119 | Cursor rules | no sections | 39/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/dispatch-agents.mdc · 119 | Cursor rules | git | 54/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/edit-document.mdc · 119 | Cursor rules | no sections | 39/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/elaborate-spec.mdc · 119 | Cursor rules | test | 58/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/enforce-first.mdc · 119 | Cursor rules | no sections | 50/100 | 3 days ago | |
| danielvm-git/bigpowers.cursor/rules/evolve-skill.mdc · 119 | Cursor rules | no sections | 50/100 | 3 days ago |
Diff against .cursor/rules/align-grid.mdc Diff against .cursor/rules/assess-impact.mdc Diff against .cursor/rules/audit-code.mdc Diff against .cursor/rules/audit-plan.mdc Diff against .cursor/rules/build-epic.mdc Diff against .cursor/rules/change-request.mdc Diff against .cursor/rules/commit-message.mdc Diff against .cursor/rules/compose-workflow.mdc Diff against .cursor/rules/context7-mcp.mdc Diff against .cursor/rules/deepen-architecture.mdc Diff against .cursor/rules/define-language.mdc Diff against .cursor/rules/delegate-task.mdc Diff against .cursor/rules/deploy.mdc Diff against .cursor/rules/develop-tdd.mdc Diff against .cursor/rules/diagnose-root.mdc Diff against .cursor/rules/dispatch-agents.mdc Diff against .cursor/rules/edit-document.mdc Diff against .cursor/rules/elaborate-spec.mdc Diff against .cursor/rules/enforce-first.mdc Diff against .cursor/rules/evolve-skill.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
