Skip to content
Skills Library
DevOps & cloud · Automation

npm-publishing

/npm-publishing

Make a workspace package publishable on npm — the first (bootstrap) publish of a new `@dxos/*` package and its npm trusted publisher (OIDC) for `publish-all.yml`, via `scripts/publish-package.mjs`. Use when asked to publish a package to npm, make a package public, set up or fix a package's trusted publisher, or when the publish preflight (`check-packages-published`) fails. Also explains where regular releases (`@latest`, `@next`, pkg.pr.new) come from, which are never published by hand.

Author
dxos ↗
Repository
dxos ↗
Licence
Apache-2.0
Last repository change
28.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 28.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Make a workspace package publishable on npm — the first (bootstrap) publish of a new `@dxos/*` package and its npm trusted publisher (OIDC) for `publish-all.yml`, via `scripts/publish-package.mjs`. Use when asked to publish a package to npm, make a package public, set up or fix a package's trusted publisher, or when the publish preflight (`check-packages-published`) fails. Also explains where regular releases (`@latest`, `@next`, pkg.pr.new) come from, which are never published by hand.

Original author description

Make a workspace package publishable on npm — the first (bootstrap) publish of a new `@dxos/*` package and its npm trusted publisher (OIDC) for `publish-all.yml`, via `scripts/publish-package.mjs`. Use when asked to publish a package to npm, make a package public, set up or fix a package's trusted publisher, or when the publish preflight (`check-packages-published`) fails. Also explains where regular releases (`@latest`, `@next`, pkg.pr.new) come from, which are never published by hand.

How it works

  1. Procedure
  2. npm bot account
  3. Many packages
  4. Troubleshooting
  5. Rules
Original SKILL.md headings · 131 lines, 1,074 words
SKILL.md preview
---
name: npm-publishing
description: Make a workspace package publishable on npm — the first (bootstrap) publish of a new `@dxos/*` package and its npm trusted publisher (OIDC) for `publish-all.yml`, via `scripts/publish-package.mjs`. Use when asked to publish a package to npm, make a package public, set up or fix a package's trusted publisher, or when the publish preflight (`check-packages-published`) fails. Also explains where regular releases (`@latest`, `@next`, pkg.pr.new) come from, which are never published by hand.
---

# npm publishing

Regular releases are automatic and never run on a laptop: `publish-all.yml` publishes `@latest` when the
"Version Packages" PR merges, and `@next` on manual dispatch; `pkg-pr-new.yml` publishes previews. The design
is in `.github/RELEASE-SPEC.md`, the runbook in `REPOSITORY_GUIDE.md` §Releasing, changesets in
`agents/instructions/changesets.md`.

The one manual job is **bootstrapping a package**: npm can attach a trusted publisher only to a package that
already exists on the registry, so each new package needs one manual publish and then a trusted-publisher
configuration. `scripts/publish-package.mjs` does both. Re-running it is safe: a package that is already on
npm skips the publish and only configures the trusted publisher.

## Procedure

### 1. Check the package

- `package.json` has no `"private": true` and has `"publishConfig": { "access": "public" }`. New packages are
  private by rule (AGENTS.md); removing the flag is a change the user asked for — say so in the PR.
- Every `@dxos/*` dependency the package needs is published already. `node scripts/publish-unpublished-packages.mjs --list`
  shows the unpublished ones. If there is more than one, use that script instead (see "Many packages").
- The worktree has `node_modules` (`pnpm install`); otherwise `pnpm publish` fails with
  `ERR_PNPM_CANNOT_RESOLVE_WORKSPACE_PROTOCOL`.

### 2. Dry run (agent runs this)

```bash
node scripts/publish-package.mjs @dxos/<name> --dry-run --trust
```

It needs no npm session. Read the output: `Registry: not published` means step 3 publishes `0.0.0` then
restores the version in `package.json`; `already published` means only the trusted publisher is configured.

### 3. Ask the user how to configure the trusted publisher

1. **Automatic (recommended)** — the script runs `npm trust github` (npm ≥ 11.15, fetched with `npx` when the
   local npm is older). The user must authenticate: npm prints a URL and waits for a browser 2FA confirmation.
2. **Guided** — the script publishes (if needed), prints the settings and opens the package's npm access page;
   the user enters them by hand.

### 4. Run it in the user's terminal

The real run is interactive (`npm login` and the 2FA confirmation read from a TTY), so do not run it with the
Bash tool. Run it in the user's Terminal panel with `mcp__terminal__run_in_terminal`, or give the user the
command. npm needs ~40s before it prints the 2FA URL, then waits ~5 minutes: tell the user to press ENTER in
that tab as soon as the URL appears (an expired window ends in `E404 … /-/v1/done`; just re-run):

```bash
node scripts/publish-package.mjs @dxos/<name> --trust
```

For the guided option, drop `--trust`. Then read the terminal (`mcp__terminal__read_terminal`, with
`wait_for_output_ms`) to follow progress, and tell the user when the browser confirmation is pending.

Where `op` can read the `CI` vault (the cloud sandbox, with `OP_SERVICE_ACCOUNT_TOKEN` set), add `--op`:
`--trust --op` runs unattended as the [npm bot account](#npm-bot-account) — it logs in from 1Password,
answers each 2FA prompt with a fresh TOTP code, and revokes the session token on exit — so the Bash tool
can run it.

Manual settings, for the guided option or to check the automatic one on
`https://www.npmjs.com/package/@dxos/<name>/access` → Trusted Publisher → GitHub Actions:

| Field           | Value                                        |
| --------------- | -------------------------------------------- |
| Repository      | `dxos/dxos`                                  |
| Workflow file   | `publish-all.yml`                            |
| Environment     | blank                                        |
| Allowed actions | `npm publish` only — not `npm stage publish` |

### 5. Verify

```bash
npm view @dxos/<name> versions --json
```

```bash
pnpm check-packages-published
```

The trusted publisher has no unauthenticated read API; `npm trust list @dxos/<name>` needs a 2FA confirmation
too, so ask the user to check the access page only if the `--trust` run did not print
`Trusted publisher configured`.

### 6. Commit

The script restores `package.json` after the publish, so the only change to commit is the removal of
`"private": true` (plus any `publishConfig` fix). Add a changeset only if the PR also changes the package
(`agents/instructions/changesets.md`).

## npm bot account

The `npm-bot` npm account's credentials live in 1Password (`CI` vault, item `NPM bot`). Use the references, never
the values (`1password` skill):

| Field             | Reference                           |
| ----------------- | ----------------------------------- |
| Username          | `op://CI/NPM bot/username`          |
| Password          | `op://CI/NPM bot/password`          |
| One-time password | `op://CI/NPM bot/one-time password` |

A TOTP code lasts 30 seconds, so read it fresh for each npm command that asks for one (`--otp "$(op read -n
'op://CI/NPM bot/one-time password?attribute=otp')"`), never once for a loop.

## Many packages

`node scripts/publish-unpublished-packages.mjs` bootstrap-publishes every package that fails the gate, in
dependency order, at `0.0.0`. It does not configure trusted publishers: afterwards run
`node scripts/publish-package.mjs <name> --trust` for each package (each asks for its own 2FA confirmation),
or use the [npm-trusted-publisher](https://github.com/wittjosiah/npm-trusted-publisher) Chrome extension for
10+ packages.

## Troubleshooting

| Symptom                                                   | Cause / fix                                                                                                                                                                                                     |
| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `EOTP` / "requires a one-time password"                   | Expected on `trust` and some publishes; complete the browser confirmation at the printed URL.                                                                                                                   |
| `trust` reports `permissions: publish, stage publish`     | npm adds stage publish even when only `--allow-publish` is passed (seen with npm 11.15.0). Harmless for `publish-all.yml`; to match the guide, untick it on the package's access page.                          |
| `Unknown command: "trust"`                                | npm < 11.15 called directly; the script uses `npx npm@11.15.0` — run it through the script.                                                                                                                     |
| `ERR_PNPM_CANNOT_RESOLVE_WORKSPACE_PROTOCOL`              | Missing `node_modules`; run `pnpm install`.                                                                                                                                                                     |
| `publish-all.yml` fails with 404/ENEEDAUTH for a package  | No trusted publisher for it yet; run the script with `--trust`. The `preflight` job (`scripts/check-packages-published.ts`) now catches this before the build, for every package at once.                       |
| `E401 … token is invalid` on one package mid-publish      | Transient: preflight's OIDC exchange had passed for the same package. Re-run the failed job; `changeset publish` skips versions already on npm, so a re-run resumes the release.                                |
| `E409 … Cannot publish over previously staged version`    | npm is holding that version in **Validating** (automated review, shown on the package's Versions tab); nobody staged it and nothing needs approving. Wait until it shows Published, then re-run the failed job. |
| Release stops partway (`Some packages failed to publish`) | `changeset publish` stops at the first failure, so `latest` is left mixed across versions. Fix the named package, then re-run; tags and the CLI publish run only once every package succeeds.                   |

## Rules

- Never publish a real version by hand, and never run `changeset publish` locally — releases come from
  `publish-all.yml` only.
- Never ask the user for an npm token or password; npm's own browser flow handles auth.
- Never rename `publish-all.yml`: every trusted publisher is bound to that filename.
Files in this package (2)
  • README.md 1 KB
  • SKILL.md 9 KB

Versions

RepositoryScoreLicence
This page · dxos/dxos100Apache-2.0
avsm/ocaml-claude-marketplace100ISC
Amey-Thakur/AI-SKILLS90MIT

Database snapshot: 13.11.2026 · package version 9b84b4f60bb3 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100publish-npm-package
    Use if publishing to npm via GitHub Actions — trusted publishing, provenance, semantic-release.
  • 100npm-publish
    配置 npm 包通过 GitHub Actions 自动发布到 npmjs.com。使用 OIDC Trusted Publishing(无需 npm token)。 当用户提到"发布 npm"、"npm publish"、"配置 npm 自动发布"、"npm 包发布"、"设置 npm CI/CD"、 "把包发到 npm"、"npm trusted publishing"、"OIDC 发布"时使用此技能。 也适用于用户已有项目想添加 npm 自动发布流程的场景,或者 npm publish 失败需要排查的场景。
  • 100npm-trusted-publishing
    Use when setting up npm publishing with GitHub Actions - provides trusted publishing with OIDC, provenance attestations, and monorepo configuration
  • 100npm-trusted-publishing
    Publish npm packages via GitHub Actions with OIDC trusted publishing and provenance. Use when setting up automated npm publishes, debugging ENEEDAUTH/E404 errors, configuring provenance attestations, or setting up a new package for publication.
  • 100secure-npm-package
    Set up a secure release process for an npm package to protect it from supply chain attacks. Use for any request to create and publish a new npm package, secure npm publishing or releasing, set up npm Trusted Publishing, provenance, or Staged Publishing, harden a release workflow.
  • 100secure-npm-package
    Use when creating or hardening an npm release with Trusted or Staged Publishing, including E404 packages sequenced after first publish. Not for remote changes or publishing.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.