agentleFS
dirtybitsdirtybits/agent-skills/skills/npm-publish/SKILL.md

npm-publish

Skill2 starsChanged 6 months agoMITView on GitHub

Use when publishing Node/npm packages from a repository or monorepo, especially scoped public packages, beta/latest dist-tags, workspace publishing, npm 2FA, publish verification, local tarball smoke tests, and debugging npm publish/install errors such as E403, E404, ENOVERSIONS, ELOOP, or pack destination failures.

  • Reads credentials
  • Installs packages

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 10 are distinctive, and 9 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this workflow when preparing, publishing, or verifying an npm package.

    line 23
  2. Very specific:

    Check existing versions: npm view <package> versions dist-tags --json.

    line 31
  3. Distinctive:

    Use the repo's normal quality gates, usually format, tests, and build.

    line 33
  4. Distinctive:

    If a repo-wide build fails for local env state, diagnose before assuming package failure.

    line 34
  5. Distinctive:

    Create the pack destination first.

    line 36
  6. Very specific:

    Use --tag beta for beta/devnet/prerelease packages.

    line 39
  7. Very specific:

    Use latest only when the package should be the default install.

    line 40
  8. Distinctive:

    Verify package document, dist-tags, access, tarball metadata, and install from a clean npm config or a deliberate security-guard override.

    line 43
  9. Distinctive:

    After publish, inspect tags:

    line 78
  10. Very specific:

    If users should install the package by default without a tag, intentionally move latest:

    line 84
  11. Very specific:

    Do not move latest automatically.

    line 90
  12. Distinctive:

    Use several independent checks:

    line 94
  13. Very specific:

    If the user's npm config intentionally sets a before date as a supply-chain safety guard, keep it.

    line 112
  14. Very specific:

    If npm install reports ENOVERSIONS while npm view shows versions, check:

    line 118
  15. Distinctive:

    If a pre-publish build fails with a message like:

    line 130
  16. Distinctive:

    Check whether the env file is a self-referential symlink:

    line 136
  17. Distinctive:

    If npm prompts for an OTP, use a fresh 2FA code immediately:

    line 164
  18. Very specific:

    If publish reaches Publishing to https://registry.npmjs.org/ and then fails with PUT ...

    line 174
  19. Very specific:

    If the registry document shows the version but install says no versions are available, suspect a local before security guard:

    line 187

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Npm Publish

Operating Pattern

Use this workflow when preparing, publishing, or verifying an npm package. Treat publishing as a release operation: package versions are immutable, registry state can lag or be filtered by local config, and npm auth errors can look unrelated to the tarball.

  1. Confirm package scope and working directory.
    • In a monorepo, publish from the repo root with npm publish --workspace <workspace-name> ....
    • From the package directory, omit --workspace.
    • Confirm package.json has the intended name, version, license, bin, files, engines, publishConfig, and dependencies.
  2. Confirm the version is new.
    • npm versions are immutable. Any republish requires a version bump.
    • Check existing versions: npm view <package> versions dist-tags --json.
  3. Run release checks before publishing.
    • Use the repo's normal quality gates, usually format, tests, and build.
    • If a repo-wide build fails for local env state, diagnose before assuming package failure.
  4. Pack and smoke-test the exact artifact.
    • Create the pack destination first; npm does not create it.
    • Install the generated tarball globally or in a temp project and run the package's CLI/help/version smoke tests.
  5. Publish with intentional dist-tags.
    • Use --tag beta for beta/devnet/prerelease packages.
    • Use latest only when the package should be the default install.
  6. Verify registry state and installability.
    • A successful publish prints + <package>@<version>.
    • Verify package document, dist-tags, access, tarball metadata, and install from a clean npm config or a deliberate security-guard override.

Recommended Command Skeleton

For a workspace package from the repository root:

git switch main
git pull

npm run format:check
npm run test --workspace <workspace-name>
npm run build

mkdir -p /private/tmp/npm-release
npm pack --workspace <workspace-name> --pack-destination /private/tmp/npm-release

npm uninstall -g <package-name>
npm install -g /private/tmp/npm-release/<tarball-name>.tgz
<binary-name> --version
<binary-name> --help

npm whoami
npm publish --workspace <workspace-name> --tag beta --access public

For @agentvouch/cli, the publish command is:

npm publish --workspace @agentvouch/cli --tag beta --access public

Dist-Tag Policy

  • Publish beta/devnet releases with --tag beta.
  • After publish, inspect tags:
npm view <package> dist-tags versions --json
  • If users should install the package by default without a tag, intentionally move latest:
npm dist-tag add <package>@<version> latest

Do not move latest automatically. Report the current tag state and ask whether the package should become the default install when that is a product decision.

Verification Commands

Use several independent checks:

npm view <package> dist-tags versions engines bin --json
npm access get status <package>
npm owner ls <package>
npm access list collaborators <package>
mkdir -p /private/tmp/npm-verify
npm pack <package>@<tag-or-version> --pack-destination /private/tmp/npm-verify

Then install and smoke-test from the registry in an environment that can see fresh packages:

npm install -g <package>@<tag-or-version>
<binary-name> --help

If the user's npm config intentionally sets a before date as a supply-chain safety guard, keep it. Do not tell them to delete it as the default fix. For fresh-release verification, use one of:

  • a separate clean environment or user config;
  • direct registry reads such as npm view <package> ...;
  • an explicit --before=<future ISO date after the publish time> override for the one verification command.

If npm install reports ENOVERSIONS while npm view shows versions, check:

npm config get before

A before date earlier than the publish timestamp hides the new version from install resolution.

Error Triage

ELOOP loading env during repo build

If a pre-publish build fails with a message like:

ELOOP: too many symbolic links encountered, stat '<repo>/web/.env.local'

Check whether the env file is a self-referential symlink:

ls -l web/.env.local

Move the broken symlink out of the app directory and recreate .env.local as a real file if needed. Do not treat this as an npm packaging failure.

npm pack --pack-destination returns ENOENT

npm pack --pack-destination <dir> does not create <dir>. Create it first:

mkdir -p /private/tmp/npm-release
npm pack --workspace <workspace-name> --pack-destination /private/tmp/npm-release

E403 requiring 2FA or bypass token

The tarball may be fine; npm is rejecting registry write auth. Refresh auth and retry:

npm logout
npm login --auth-type=web
npm whoami
npm publish --workspace <workspace-name> --tag beta --access public

If npm prompts for an OTP, use a fresh 2FA code immediately:

npm publish --workspace <workspace-name> --tag beta --access public --otp <code>

Recovery codes can satisfy npm's OTP prompt, but they are one-time backup factors. If a recovery code is used or exposed in logs/chat, treat it as spent and regenerate recovery codes after publishing.

PUT ... 404 Not found during publish

If publish reaches Publishing to https://registry.npmjs.org/ and then fails with PUT ... 404, the tarball built but npm did not accept the registry write. Check:

npm config get registry
npm whoami
npm owner ls <package>
npm access get status <package>

For scoped public packages, keep --access public. Re-login with npm login --auth-type=web if the current session or token lacks publish rights.

ENOVERSIONS after publish

If the registry document shows the version but install says no versions are available, suspect a local before security guard:

npm config get before
npm view <package> time dist-tags versions --json

Compare the package publish time to the configured before date. Preserve the guard unless the user explicitly wants it removed.

Completion Criteria

Report:

  • the package name, version, and dist-tags;
  • whether latest changed;
  • package access status;
  • tarball file count/size when available;
  • CLI smoke-test output or exact failure;
  • any local npm guardrail such as before that affected verification.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.