agentleFS
metarhiametarhia/metaskills/skills/npm-publish/SKILL.md

npm-publish

Skill61 starsChanged 8 months agoMITView on GitHub

Prepare an npm package for publishing. Handles version bump, CHANGELOG update, typings check, test run, README refresh, package.json audit, and npm pack verification. Use when the user asks to prepare a release, bump version, publish a package, or do release prep.

  • Installs packages
  • Commits and pushes

6 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

26 rules. 0 are common, 14 are distinctive, and 12 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 12

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user (with the agent's question tool if it has one, otherwise in chat):

    line 13
  2. Very specific:

    Confirm changelog entries: ask if the [Unreleased] section in CHANGELOG is complete, or if the user wants to draft entries from recent …

    line 17
  3. Distinctive:

    If the user already specified intent (e.g.

    line 19
  4. Very specific:

    If npm test fails, stop and fix issues before continuing.

    line 32
  5. Very specific:

    Update "version" in package.json by editing the file directly (not npm version: the changelog is managed manually).

    line 46
  6. Very specific:

    Read the full CHANGELOG.md.

    line 61
  7. Distinctive:

    Create the new version section with today's date (ISO 8601):

    line 78
  8. Distinctive:

    Keep all existing links intact below.

    line 98
  9. Very specific:

    If .d.ts files exist:

    line 102
  10. Very specific:

    Run npx tsc (or the project's types script) — must pass with no errors

    line 104
  11. Very specific:

    Verify the .d.ts public API surface matches the actual exports:

    line 105
  12. Very specific:

    Read the main JS entry point's module.exports or export statements

    line 106
  13. Very specific:

    Read the .d.ts file

    line 107
  14. Very specific:

    If the release includes API changes, update the .d.ts accordingly

    line 110
  15. Distinctive:

    Usage examples: do they match the current API?

    line 118
  16. Distinctive:

    Badges: do version badge URLs point to the correct package name?

    line 119
  17. Distinctive:

    Configuration tables: do option names, types, and defaults match the source code?

    line 120
  18. Distinctive:

    API reference: if the README has an API section, verify it against actual exports

    line 121
  19. Distinctive:

    Only edit if something is factually wrong or outdated.

    line 123
  20. Distinctive:

    Check these fields are correct:

    line 129
  21. Distinctive:

    Test files, configs, CI files are excluded

    line 148
  22. Distinctive:

    No unexpected large files

    line 149
  23. Distinctive:

    Run the full test suite one more time after all edits:

    line 155
  24. Distinctive:

    Must exit 0. If it fails, fix and re-run.

    line 161
  25. Very specific:

    Do NOT run npm publish or git push automatically — always let the user do it or explicitly confirm.

    line 183
  26. Very specific:

    After all steps run to refresh package-lock.json:

    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 Preparation

Systematic workflow for preparing an npm package for a new release. Every step must pass before proceeding to the next.

Step 0: Gather Release Intent

Ask the user (with the agent's question tool if it has one, otherwise in chat):

  1. Version bump type: patch / minor / major / explicit version / prerelease tag
  2. Prerelease label (if any): e.g. alpha, beta, rc, prerelease
  3. Confirm changelog entries: ask if the [Unreleased] section in CHANGELOG is complete, or if the user wants to draft entries from recent commits

If the user already specified intent (e.g. "prepare 4.1.0 release"), skip the question and proceed.

Step 1: Pre-flight Checks

Run:

npm i             # install deps
npm test          # must exit 0 (lint + types + tests)

Then in parallel: npm outdated and npm audit (report to user).

If npm test fails, stop and fix issues before continuing.

Step 2: Version Bump

Read current version from package.json

Compute the new version based on user intent and semver rules:

  • patch: 1.2.3 -> 1.2.4
  • minor: 1.2.3 -> 1.3.0
  • major: 1.2.3 -> 2.0.0
  • prerelease: 1.2.3 -> 1.2.4-<label>.0, or 1.2.4-beta.0 -> 1.2.4-beta.1
  • Removing prerelease tag: 4.0.3-prerelease -> 4.0.3 (just strip the suffix)

Update "version" in package.json by editing the file directly (not npm version: the changelog is managed manually).

Step 3: Update CHANGELOG.md

The changelog uses:

  • Sections: ## [Unreleased] at top; ## [Version] - YYYY-MM-DD for releases (date in ISO 8601)
  • Order: newest first; every version gets an entry
  • Types of changes: Added, Changed, Deprecated, Removed, Fixed, Security. Group same-type changes under each
  • Entries: bullet lists; past tense; capitalise first letter; human-readable, curated (no raw git diffs)
  • Links: footnote-style link block at bottom: [unreleased]: ..., [version]: ... (GitHub compare URLs)
  • Principles: changelog is for humans; omit empty sections; call out breaking changes and deprecations clearly

3a: Detect changelog structure

Read the full CHANGELOG.md. Identify:

  • The [Unreleased] section
  • The previous version heading (to derive the comparison base)
  • The links block at the bottom of the file
  • The GitHub repo URL from the existing links

3b: Create the new version entry

Always draft entries from git log since the last tag (fallback to HEAD~20 if no tags):

git log $(git describe --tags --abbrev=0 2>/dev/null || echo "HEAD~20")..HEAD --oneline

Convert commits into changelog bullets: group by type (Added, Changed, Fixed, Removed, Deprecated, Security), past tense, capitalise. Merge with any existing [Unreleased] content if the user added manual entries.

Create the new version section with today's date (ISO 8601):

## [Unreleased][unreleased]

## [NEW_VERSION][] - YYYY-MM-DD

- Entry description
- Another entry

3c: Update comparison links

At the bottom of CHANGELOG.md, update the [unreleased] link and add the new version link:

[unreleased]: https://github.com/OWNER/REPO/compare/vNEW_VERSION...HEAD
[NEW_VERSION]: https://github.com/OWNER/REPO/compare/vPREVIOUS_VERSION...vNEW_VERSION

Keep all existing links intact below.

Step 4: TypeScript Declarations

If .d.ts files exist:

  1. Run npx tsc (or the project's types script) — must pass with no errors
  2. Verify the .d.ts public API surface matches the actual exports:
    • Read the main JS entry point's module.exports or export statements
    • Read the .d.ts file
    • Confirm every exported class, function, type, and method is declared
    • Confirm no private/internal fields leak into the declarations
  3. If the release includes API changes, update the .d.ts accordingly

Step 5: README & License Review

Update year in LICENSE and README.md (copyright line) to the current year if changed.

Scan README.md for staleness:

  1. Usage examples: do they match the current API? Especially constructor options, method signatures
  2. Badges: do version badge URLs point to the correct package name?
  3. Configuration tables: do option names, types, and defaults match the source code?
  4. API reference: if the README has an API section, verify it against actual exports

Only edit if something is factually wrong or outdated. Don't rewrite style or add unsolicited content.

Step 6: Package Audit

6a: Verify package.json fields

Check these fields are correct:

  • "main" / "module" / "exports" — points to existing files
  • "types" — points to the .d.ts file
  • "files" — includes all necessary files, excludes test/config files; cross-check with .npmignore if present
  • "engines" — matches the CI matrix (.github/workflows/)
  • "keywords" — no typos, relevant terms
  • "license", "repository", "homepage" — valid

6b: Dry-run pack

npm pack --dry-run

Review the file list:

  • Source files are included
  • Type definitions are included
  • Test files, configs, CI files are excluded
  • No unexpected large files

Report the packed size to the user.

Step 7: Final Verification

Run the full test suite one more time after all edits:

npm test

Must exit 0. If it fails, fix and re-run.

Step 8: Summary & Next Steps

Present a summary to the user:

Release preparation complete:
  Package:  <name>
  Version:  <old> -> <new>
  Tests:    ✓ passing
  Types:    ✓ valid
  Packed:   <N> files, <size>

Then list remaining manual steps:

  1. git add -A && git commit -m "Release vX.Y.Z" (or ask the user if they want you to commit)
  2. git tag vX.Y.Z
  3. git push && git push --tags
  4. npm publish (or npm publish --tag <label> for prereleases)

Do NOT run npm publish or git push automatically — always let the user do it or explicitly confirm.

Step 9: Reinstall Dependencies

After all steps run to refresh package-lock.json:

npm i

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.