Release an npm, pnpm, or bun package: version bump, validation, tag, and publish, with approval before anything is pushed. Not for the edloidas/skills repo — that is skills-release.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Npm Release?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/edloidas-npm-release)
---
name: npm-release
description: >
Release an npm, pnpm, or bun package: version bump, validation, tag, and publish, with
approval before anything is pushed. Not for the edloidas/skills repo — that is skills-release.
when_to_use: >
"release this", "publish a new version", "bump the version", "tag a release", "ship it". Also
when a JS package has merged changes waiting for a published version.
license: MIT
compatibility: Claude Code, Codex, OpenCode, Pi
allowed-tools: Bash Read Glob AskUserQuestion
argument-hint: "[major, minor, or patch]"
metadata:
tier: auto
---
# pnpm / Bun / npm Package Release Workflow
This skill **writes to external services**. It edits `package.json` and the lockfile, creates a
commit and a signed tag locally, then pushes both to the git remote — and that push publishes
the version, to the npm registry through CI or directly on the manual-publish path. npm does
not allow a published version to be replaced. Steps 0-7 are local and undoable; Step 8 is not.
## Package manager detection
`release-prepare.sh` detects the manager — lockfile first (pnpm → bun → npm), then tool
availability — and prints `Package manager: <name>`. Use that manager in every later step — command blocks below
list pnpm, bun, then npm; run only the detected one's line. A
lockfile whose tool is missing is an error; never switch managers to get past it.
## Bundled Scripts
Three helper bash scripts in this skill's `scripts/` directory. Run them from the project root
— they read `./package.json` and the current repo — and call them by path, with `<skill-dir>`
replaced by this skill's absolute directory. They work with any pnpm/bun/npm project and need no
project-specific setup. If the project already ships its own release scripts, use those instead
of these.
| Script | Does | Run at |
| ------ | ---- | ------ |
| `release-prepare.sh` | Checks the branch is the repo's default (or the one passed as `--branch <name>`) and the tree is clean, detects and prints the package manager, runs the project's `release:dry` script or, without one, the manager's own `publish --dry-run` | Step 1 |
| `release-analyze.sh` | Finds the last tag, lists and classifies commits since it, prints file-change stats and a bump recommendation | Step 3 |
| `release-execute.sh` | Reads the version from `package.json`, re-checks the branch and a clean tree, creates the tag if absent or verifies the existing one, **pushes** branch and tag atomically to the branch's upstream remote (else `origin`), confirms both on the remote | Step 8 only — it pushes, so never run it before the Step 7 approval |
```bash
bash <skill-dir>/scripts/release-prepare.sh
bash <skill-dir>/scripts/release-analyze.sh
bash <skill-dir>/scripts/release-execute.sh
```
Prerequisites: `jq` installed (used by `release-analyze.sh` and `release-execute.sh`), and a git
repository with at least one prior commit.
## Asking the User
Every question in this skill is written as `AskUserQuestion` options. Use that tool where
the host offers it, or the host's nearest structured-choice equivalent. Where the host has
neither, ask the same question in normal chat as a numbered list of 2–5 options —
recommended first, one short line of description each — and wait for the user to reply
with a number.
Questions occur at **Step 0** (ambiguous conventions), **Step 7** (release approval), and
**Manual Publishing** (publish approval). None is skippable on your own judgement: ask, and wait
for the reply before continuing.
Done means: Step 9 has reported the pushed release — and, with no publish workflow, Manual
Publishing has published it or been cancelled — or a gate is waiting on the user.
## Release Workflow
Follow these steps in order. Create an in-memory plan at the start.
### Step 0: Read Project Conventions
Read the project's instruction files first, so the release honors local conventions. Check, in order:
1. `CLAUDE.md` at the repo root
2. `AGENTS.md` at the repo root
3. `.agents/` or `.claude/` rule files if they exist
Extract and apply whatever applies to this release:
- **Release commit message format** — e.g. `chore: release v<version>` or a project-specific template. This overrides the default `Release v<version>` used in Step 5.
- **Pre-release prerequisites** — e.g. updating `CHANGELOG.md` via a separate skill, regenerating docs, running a project-specific validation script. Run these **before** bumping the version so the Step 2 dry run can gate on them.
- **Branch policy** — the default is the repo's default branch, whatever it is called. Some projects release from version branches (`x.y`) or restrict by environment; a release branch other than the default must be named by the project docs or the user, and is passed to Step 1 as `--branch <name>`.
- **Tag format** — the bundled scripts handle only `v<version>`. If the project documents another format, do Steps 3, 6, and 8 by their by-hand paths with that format instead of the scripts.
- **Dist-tag policy** — how prerelease versions are routed (`alpha`/`beta`/`rc`/`next`).
If `CLAUDE.md` / `AGENTS.md` doesn't exist or doesn't say anything about releases, fall back to the defaults below. If an instruction is ambiguous, ask the user, per **Asking the User**.
End the step with one line naming what you found, defaults included:
`Conventions: commit "chore: release v<version>", tag v<version>, master only, no CHANGELOG gate`.
### Step 1: Pre-flight Checks
```bash
bash <skill-dir>/scripts/release-prepare.sh
# or, for a release branch Step 0 or the user named:
bash <skill-dir>/scripts/release-prepare.sh --branch <name>
```
The script reads the default branch from `<remote>/HEAD` — the remote the branch tracks, else
`origin`, the same one Step 8 pushes to — then `gh repo view`, and refuses any
other branch unless it was passed with `--branch`. It refuses too when neither source answers;
the fix it prints is `git remote set-head <remote> --auto`. Never pass the current branch as
`--branch` just to get past the check.
Where the script cannot run, check by hand: `git branch --show-current` is the release branch
and `git status --porcelain` is empty.
If the branch is wrong or the tree is dirty, name which in one line, suggest `git stash && [retry]`
or committing first, and stop there. Do not stash, commit, or switch branches yourself to clear
the check.
End the step with one line: `Pre-flight: branch develop (default), tree clean, package manager pnpm`.
### Step 2: Validate Release Build
`release-prepare.sh` already ran the dry run — read its output rather than running it twice. To
run it alone, use the project's `release:dry` script if `package.json` has one
(`pnpm release:dry`, `bun run release:dry`, `npm run release:dry`), else the manager's own:
```bash
pnpm publish --dry-run --no-git-checks
# or
bun publish --dry-run
# or
npm publish --dry-run
```
If it fails, report the error and stop: no version bump, no commit, no tag. Fixing build, lint,
or type errors is separate work the user asks for.
End the step with one line: `Dry run passed: 42 files, 128 kB`.
### Step 3: Analyze Commits for Version Decision
```bash
bash <skill-dir>/scripts/release-analyze.sh
```
Where the script cannot run, `git log $(git describe --tags --abbrev=0)..HEAD --oneline` gives
the same commit list. With no tag at all this is a first release: ask the user for the
baseline — `v0.1.0` or `v1.0.0`.
| Bump | When |
| ---- | ---- |
| **Major** (x.0.0) | Breaking API changes, removal of public APIs, incompatible behavior changes — post-1.0 only |
| **Minor** (0.x.0) | New features, significant enhancements, API additions; also breaking changes while pre-1.0 |
| **Patch** (0.0.x) | Bug fixes, small improvements, documentation updates, refactoring |
If the commit subjects don't settle it, read the diffs of the files they touch:
```bash
git diff $(git describe --tags --abbrev=0)..HEAD -- [key-files]
```
The script counts only conventional-commit subjects (`type(scope)!:`) and `BREAKING CHANGE:`
footers. `MANUAL review needed` means none of them settled it — read the commit list and the diffs,
pick the bump yourself, and say so in the closing line.
End the step with one line: `12 commits since v0.15.3 (4 feat, 6 fix, 2 other) -> recommend minor`.
### Step 4: Bump Version
Update `package.json` version. Use the detected package manager; always pass the flag that disables the automatic commit/tag, so this step cannot create either by accident.
```bash
pnpm version <major|minor|patch> --no-git-tag-version
bun pm version <major|minor|patch> --no-git-tag-version
npm version <major|minor|patch> --no-git-tag-version
```
A prerelease (alpha/beta/rc) uses `prerelease` with an explicit preid:
`<manager> version prerelease --preid=alpha --no-git-tag-version` (`bun pm version` for bun).
Stop once `package.json` carries the new version. Commit, tag, and push belong to Steps 5, 6,
and 8 — do not run any of them here.
End the step with one line: `Bumped package.json to 0.16.0`.
### Step 5: Commit Version Bump
Use the **release commit message format captured in Step 0**. Only fall back to the generic `Release v<version>` if the project did not specify one.
```bash
# Stage package.json and only the lockfiles that exist — a missing pathspec aborts the whole add
git add -- package.json $(for f in pnpm-lock.yaml bun.lock bun.lockb package-lock.json; do [ -e "$f" ] && echo "$f"; done)
git diff --cached --name-only | grep -qx package.json && echo "Staged: package.json"
```
Commit only after that printed `Staged: package.json`. Without it, stop and report that the
version bump is not staged: a release commit without it tags the old version.
```bash
git commit -m "<Step 0 commit format, filled with {{VERSION}}>"
```
If the project uses a non-obvious template (commit body, trailers, sign-off), reproduce it exactly as documented. Never invent a format the project didn't specify.
End the step with one line: `Committed Release v0.16.0 (a1b2c3d)`. The tag is Step 6.
### Step 6: Create Git Tag
Tag the release commit with a **signed** tag — `-s` implies `-a`, and Step 8 refuses a tag that is not annotated:
```bash
git tag -s v{{VERSION}} -m "Release v{{VERSION}}"
```
Example: `git tag -s v0.16.0 -m "Release v0.16.0"`
If the user has no signing key configured, `git tag -s` fails with a gpg/ssh error. In that case, advise them to configure SSH or GPG signing (`user.signingkey`, `gpg.format`) before retrying.
The tag now exists locally only. Do not push it here — Step 7 gates the push.
End the step with one line: `Tagged v0.16.0 (not pushed)`.
### Step 7: User Review & Approval
Pushing the tag publishes the release and cannot be recalled: CI starts from the tag, and npm
refuses to replace a published version. Show the version and the tag, and wait for approval.
Skip this gate only when the user has already told you, in this session, to release without
stopping.
Present a summary, each item on its own line — the version, the bump type, the tag as it stands,
2-4 bullets of key changes from the Step 3 analysis, and what the push will do:
```
Version: v0.16.0
Bump: minor
Tag: v0.16.0 — created locally, not pushed
Changes:
- Adds `--watch` to the build command (4 commits)
- Fixes lockfile drift under pnpm 10 (#212)
- Removes the deprecated `legacy` export — pre-1.0, so minor rather than major
Next: atomic push of master + v0.16.0 to origin -> CI publishes @acme/widget@0.16.0 to npm
```
Ask for approval, per **Asking the User**:
1. `Yes` (Recommended) — Proceed with pushing and releasing
2. `No` — Cancel the release and keep local changes for review
**If user selects:**
- **Yes** → Proceed to Step 8
- **No** → Inform the user that the local commit and tag remain in place for review. Do not run cleanup automatically. If the user wants to undo the release prep, explain the cleanup steps and ask before performing any destructive git command.
- **Other** → Follow user's custom instructions
### Step 8: Push Release
Only after the user approves, passing the same `--branch <name>` Step 1 used, if any:
```bash
bash <skill-dir>/scripts/release-execute.sh [--branch <name>]
```
Before pushing, the script re-checks the branch and a clean tree, and refuses an existing tag
that is lightweight, not at HEAD, or unsigned while signing is configured. It pushes to the
remote the branch tracks, else `origin`, with `git push --atomic <remote> <branch> v<version>`
— the remote takes both refs or neither — then confirms both with `ls-remote`. A non-zero exit
means stop: report its error line. Never retag or switch remotes to get past a refusal.
Where the script cannot run, do the same by hand: confirm `git status --porcelain` is empty and
the branch is the Step 1 branch, run
`git push --atomic <remote> <branch> v<version>`, then `git ls-remote <remote> v<version>`.
Do not use `git push --follow-tags`: it pushes the branch anyway when the tag is missing.
End the step with one line: `Pushed master + v0.16.0`.
### Step 9: Confirm Completion
Report in one block:
- The release is pushed
- Whether CI publishes it. If the repo has no publish workflow under `.github/workflows/`, say
that publishing is still owed, and continue to **Advanced: Manual Publishing**, whose gate asks
- Links you can construct: GitHub release page, npm package page, any deployment URL
Then stop. Do not start a second release, and do not publish manually on top of a CI workflow
that is already running.
## Error Handling
A failing step ends the workflow where it stands: report the error and the corrective action,
one line each, and do not run the steps after it. Do not retry a failed command with different
flags to get past the failure.
## Advanced: Manual Publishing
Prefer CI/CD for publishing — it keeps the published artifact consistent and keeps the npm token
off local machines. Where CI is not configured, or the user asks for a manual publish, publish
only after Step 8 pushed the tag.
Publishing cannot be undone: npm refuses to replace a published version, and an unpublish is
limited and visible. Show the package name, the version, the dist-tag, the access level, and the
registry (`npm config get registry`), and wait for approval, per **Asking the User**: `Publish`
(Recommended) or `Cancel`. The Step 7 approval covers the push, not this.
- **Dist-tag:** `latest` for a stable version. For a prerelease, the Step 0 policy's tag, else
the version's preid (`1.2.0-beta.1` → `beta`).
- **Access:** `publishConfig.access` from `package.json` when set. Otherwise `public` for an
unscoped name; for a scoped name, ask — `public` publishes a package npm would keep private.
```bash
pnpm publish --access <access> --tag <dist-tag>
# or
bun publish --access <access> --tag <dist-tag>
# or
npm publish --access <access> --tag <dist-tag>
```
A prerelease version always carries its prerelease dist-tag — published without one it becomes
`latest` and every plain install picks it up.
End with one line: `Published @acme/widget@0.16.0 to https://registry.npmjs.org/ (latest)`.