Skip to main content
skill official · GitHub

npm-trusted-publishing — GitHub Copilot skill for OIDC

Moves npm releases in GitHub Actions from stored tokens to trusted publishing with OIDC. Useful for ENEEDAUTH, E404, and E422 failures.

Install into GitHub Copilot · GitHub CLI All methods and platforms ↓
gh skill install github/awesome-copilot npm-trusted-publishing
Open on GitHub

What npm-trusted-publishing does

This skill guides a GitHub Actions release from NPM_TOKEN or NODE_AUTH_TOKEN to npm trusted publishing. It checks the job’s id-token: write permission, the npm version, registry-url, the repository.url value in package.json, and the trusted publisher configured for each package.

It includes a setup checklist, diagnosis for ENEEDAUTH, 404 Not Found - PUT, and E422 ... repository.url, plus a workflow example. The publishing job needs npm 11.5.1 or newer; older Node releases need an npm upgrade before publishing. Tokens must also be removed from environment variables and npm or Yarn config files.

Trusted publishing requires a GitHub-hosted runner. A self-hosted runner will not work for this setup. Adding the npm trusted publisher and removing the old token require an npm login with 2FA.

What it helps with

  • move npm releases to OIDC authentication
  • trace ENEEDAUTH in a GitHub Actions publish job
  • fix E422 caused by repository.url
  • remove publish tokens from workflow configuration
  • verify an npm trusted publisher setup

Example prompts for the agent

  • Check my npm release workflow and migrate it from NPM_TOKEN to OIDC.
  • Diagnose E422 ... repository.url using package.json and the publishing workflow.
  • Find why this release gets ENEEDAUTH and list the checklist items to fix.

How to install npm-trusted-publishing

1GitHub CLI

gh skill install github/awesome-copilot npm-trusted-publishing

2Manually: put the files in place

.github/skills/npm-trusted-publishing/SKILL.md

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about npm-trusted-publishing

How do I install npm-trusted-publishing in GitHub Copilot?

Run gh skill install github/awesome-copilot npm-trusted-publishing, then use .github/skills/npm-trusted-publishing/SKILL.md.

What does npm-trusted-publishing do?

It helps configure npm releases through OIDC, remove publish tokens from GitHub Actions, and diagnose authentication, repository URL, and trusted publisher errors.

Can trusted publishing run on a self-hosted runner?

No. This setup requires a GitHub-hosted runner.

Source text

SKILL.md · MIT
---
name: npm-trusted-publishing
description: Set up or fix npm trusted publishing (OIDC) in GitHub Actions and remove NPM_TOKEN. Use for ENEEDAUTH, E404 on PUT, E422 repository.url, or migrating off 2FA-bypass tokens before January 2027.
---

# npm Trusted Publishing

Moves a GitHub Actions release from a stored `NPM_TOKEN` to npm [trusted publishing](https://docs.npmjs.com/trusted-publishers). GitHub signs a short-lived OIDC token for the run, and npm exchanges it for a publish token. It also diagnoses the misleading errors a half-finished migration produces. From January 2027, granular tokens that bypass 2FA can no longer publish directly ([npm docs](https://docs.npmjs.com/about-access-tokens/)).

## When to Use This Skill

- The user wants to remove `NPM_TOKEN` / `NODE_AUTH_TOKEN` from a release workflow or set up OIDC or provenance publishing.
- A CI publish fails with `ENEEDAUTH`, `404 Not Found - PUT https://registry.npmjs.org/...` or `E422 ... repository.url`.
- Release logs show `npm notice npm tokens that bypass 2FA are being restricted`.

## Checklist (all must hold)

Work through every item. Missing any one of them produces the errors above.

1. **OIDC permission:** the publishing job has `permissions: id-token: write`. If the job had no `permissions` block, keep the scopes it needs, such as `contents: write` for tags and releases or `pull-requests: write` for changesets. Adding a block drops every scope you don't list.
2. **npm 11.5.1 or newer** runs the publish. Node 24 ships it. Node 22 ships npm 10, so add `npm install -g npm@^11.5.1` (or a newer pinned major) before publishing. pnpm 10 hands the publish to npm, so the same rule applies. Yarn Berry needs 4.10.3+.
3. **No token reaches the publish step.** Remove `NODE_AUTH_TOKEN`, `NPM_TOKEN` and `YARN_NPM_AUTH_TOKEN` from the step, the job and the workflow `env`, and delete script lines that write `_authToken` or `npmAuthToken`. npm tries OIDC first but falls back to a configured token, so a leftover token keeps the old credential in use. Keep a **read-only** token only on install steps that need private packages.
4. **`actions/setup-node` has `registry-url: https://registry.npmjs.org`.**
5. **`package.json` `repository.url` names the same GitHub repo**, for example `git+https://github.com/OWNER/REPO.git`, plus `directory` for workspace packages. A mismatch gives E422.
6. **A trusted publisher exists on npm for each package** (npmjs.com → package → Settings → Trusted publishing), or with npm 11.15+:
   `npm trust github <pkg> --repo OWNER/REPO --file release.yml --allow-publish --yes`
   - The workflow **file name** must match exactly; it is case-sensitive and includes `.yml`.
   - For a **reusable workflow**, use the *calling* workflow's file name, and grant `id-token: write` in the caller too.
   - If the job uses `environment:`, set the same environment on the publisher.
   - A package that doesn't exist yet must be published once by hand first.
7. **GitHub-hosted runner.** Self-hosted runners can't use trusted publishing.

## Security Rules

- **Untrusted triggers:** never add `id-token: write` to a job in a workflow triggered by `pull_request_target`, `issue_comment`, `workflow_run` or `discussion`. It would let outsiders exchange an OIDC token and publish. Move publishing to `release`, `push` (tags) or `workflow_dispatch`.
- **Dry runs:** `npm publish --dry-run` and `npm pack` jobs don't publish, so they need no `id-token` and no trusted publisher.
- **The old token:** delete the secret (`gh secret delete NPM_TOKEN`) and revoke it on npmjs.com only after the first tokenless release succeeds.

## Error Guide

| Error | Usual cause |
|---|---|
| `ENEEDAUTH` | No `id-token: write`, npm older than 11.5.1, or a workflow file name that doesn't match the trusted publisher |
| `404 Not Found - PUT https://registry.npmjs.org/<pkg>` | Same as above, a mismatched `environment`, no trusted publisher yet, or an expired token still being used |
| `E422 ... repository.url` | `repository` is missing in `package.json` or names another repo |
| Publish still uses the token | A token remains in env, `.npmrc` or `.yarnrc.yml` (checklist item 3) |

## Example

```yaml
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
      - run: npm ci
      - run: npm publish --access public   # no NODE_AUTH_TOKEN
```

## Automating It

[go-tokenless](https://github.com/Continuous-Actions/go-tokenless) (MIT) applies this checklist to an existing repository. Use it when the user wants the edits made for them.
- `npx go-tokenless` prints a read-only diff of the workflow and `package.json` changes, plus the `npm trust` commands.
- `npx go-tokenless apply` writes the changes.
- It refuses the unsafe cases above instead of guessing.

## Limitations

- The npm side (adding the trusted publisher, deleting the old token) needs the user's npm login with 2FA. Hand those steps to the user.
- Trusted publishing covers GitHub Actions, GitLab.com and CircleCI cloud only.

© github · MIT · github/awesome-copilot

Similar skills

All skills for DevOps and infrastructure →

From the same set928

The whole set →
java-testcontainers Helps write Java integration tests using Testcontainers 2.x and JUnit Jupiter with Docker dependencies. Useful when adding container tests or migrating from version 1.x. 1installs java-debugging A skill that walks the agent through finding a Java bug: reproduce, narrow down, test one hypothesis, attach a debugger. Useful once logs stop explaining anything. 1installs quarkus-native-and-container Walks the agent through building a Quarkus native executable, fixing reflection failures, and producing container images with Kubernetes manifests. ★ 40,451repo stars quarkus-application-development This skill guides GitHub Copilot through changes in an existing Quarkus project, covering REST, persistence, messaging, security, and operations. ★ 40,451repo stars cypress-flake-fixer A skill that audits an existing Cypress suite for the patterns behind intermittent failures and fixes them. Useful before a jump to Cypress 15 or 16. ★ 40,451repo stars winui3 This rule guides GitHub Copilot on WinUI 3 and Windows App SDK patterns, from XAML bindings to window management. Use it when working on a Windows desktop app. ★ 40,451repo stars vue A Copilot instruction file that sets Vue 3 conventions: Composition API, <script setup>, reactivity, Pinia and Vue Router. Useful when the agent writes components your way. ★ 40,451repo stars vsixtoolkit Instructs GitHub Copilot to write Visual Studio extensions using Community.VisualStudio.Toolkit. Enforces .NET Framework 4.8 constraints and thread-safe UI rules. ★ 40,451repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor