npm publish is rejected, but the token still retains selected package write permissions (GitHub’s official changelog). That leads to a clear 2026 decision: an npm Stage-only Token can stop an AI Agent from directly publishing a new public version, but it is not a complete security boundary for the Agent.Your safest default is a three-part workflow: the Agent prepares and stages the package, a maintainer reviews the version and tarball, and a separate human identity completes 2FA approval. If your CI platform supports npm Trusted Publishing, evaluate OIDC before creating another long-lived write token.
This guide is for:
- Open-source maintainers allowing an AI Coding Agent to edit code, build packages, and prepare npm releases.
- Platform engineers choosing between long-lived tokens, npm staged publishing, Trusted Publishing, and GitHub Actions.
- Security teams testing residual npm permissions, credential exposure, and audit evidence.
- Teams using a remote Mac to build native dependencies or cross-platform packages without placing final approval credentials on the build host.
Last updated: September 19, 2026. Facts were checked against the npm access token documentation, npm staged publishing documentation, npm Trusted Publishing documentation, and the September 18 GitHub Changelog entry.
1The acceptance timeline
Treat npm Stage-only Token AI Agent access as a release-control change, not as a simple token replacement.
| Release milestone | Agent responsibility | Human responsibility | Evidence to retain |
|---|---|---|---|
| Code preparation | Modify source files and run approved checks | Review the change scope and repository state | Commit, task record, test output |
| Package construction | Generate the tarball and inspect package contents | Confirm the artifact matches the intended source commit | Tarball manifest, build log, checksum |
| Staged submission | Submit the candidate package for review | Confirm that the package entered the expected staged state | npm staging record, package version, submission log |
| Final approval | No final approval action | Review version, files, provenance, and change range; complete 2FA | Reviewer identity, approval event, release record |
| Post-release control | No account administration | Monitor tags, deprecations, rollback, and token status | Audit trail, revocation record, incident notes |
The key separation is between staging and publishing. A successful staging command does not prove that the package is safe, correct, or ready for public consumption. It proves only that the automated identity submitted a candidate to the staged workflow.
The npm documentation describes staged publishing as a workflow in which a package is uploaded for review before final release. The exact permissions and CLI behavior must be checked against the current npm documentation before rollout, because npm can change token scopes, supported clients, or migration dates.
What Stage-only Token blocks
The direct npm publish test is the first gate. The current confirmed behavior is that a Stage-only Token is rejected when used for direct publishing of a new version (npm’s staged publishing documentation).
That answers the first operational question: yes, the token can block an AI Agent from directly executing the final publication path.
It does not answer the broader security question. The token is still a package write credential. According to the official change record, it retains permissions for selected package operations, including moving distribution tags and deprecating versions. Those actions can change what users install or how npm presents a package, even when the Agent cannot publish a new version directly.
Therefore, your policy should say:
- The Agent may create or update code within the assigned repository.
- The Agent may build and stage a package.
- The Agent may not hold the maintainer identity used for final 2FA approval.
- The Agent may not receive unrestricted npm account administration.
- The Agent must not be assumed harmless merely because direct
npm publishfails.
A token that cannot upload a new version can still affect an existing package’s release surface. That is why the acceptance test must include more than one failed publish attempt.
2Maintainer controls: staged package versus approved release
For package maintainers, the main risk is approval drift. An Agent can prepare a valid-looking package while changing the version range, generated files, dependency metadata, lifecycle scripts, or included build output. A staging boundary gives you time to inspect those changes, but it does not perform the inspection for you.
The four review objects
Before final approval, review four separate objects:
- Version identity: confirm the version number, prerelease label, package name, and intended release channel.
- Artifact contents: inspect the actual tarball rather than trusting the repository diff. Check
files, ignore rules, generated output, package metadata, and lifecycle scripts. - Source relationship: connect the tarball to a specific repository commit, build command, dependency lockfile, and test result.
- Change scope: verify that the Agent did not modify unrelated packages, release configuration, distribution tags, or deprecation state.
A staged package should remain a candidate until those four objects agree. “The Agent reported success” is not an approval record.
Does an AI Coding Agent still need human 2FA?
Yes, if your release policy requires a maintainer to approve the final public release. Stage-only access does not turn the Agent into an authorized approver, and 2FA is not replaced by the Agent’s test report.
Keep the approval identity outside the Agent’s execution context. Do not place the maintainer’s one-time password seed, recovery codes, browser session, or final publish token in the same workspace used for code generation and package construction.
The maintainer should approve only after checking:
- The staged version is the intended version.
- The tarball can be reproduced or explained from the recorded build.
- The package contains no unexpected files.
- The Agent’s commit and task record cover the complete change.
- The intended distribution tag has not moved unexpectedly.
- The package has passed the required tests on the target operating systems.
The final approval event should identify a person, not only a machine account. That distinction matters during an incident because it shows who reviewed the artifact, what evidence was available, and whether the approval was based on the actual staged package.
3AI Coding team boundaries
An AI Coding Agent should have a narrow action contract. “Prepare a release” is too broad if the same tool can edit source, invoke Shell commands, access npm credentials, alter tags, and request final publication.
The Agent action contract
Define separate permissions for:
- Source modification.
- Test execution.
- Package generation.
- Tarball inspection.
- Staged submission.
- Read-only release metadata.
- No final approval.
- No arbitrary tag movement.
- No package deprecation.
- No token creation, deletion, or account administration.
This division prevents a vague prompt from becoming an account-level instruction. It also gives your security team a specific test plan instead of a general promise that the Agent is “restricted.”
The repository and workspace should be unique to the task. Preserve the commit identifier, package manager lockfile, build command, environment declaration, tarball name, and staging result together. If the Agent uses sub-agents or external tools, record which tool received the token and whether the token could appear in their context.
Residual permission testing
A Stage-only Token must be tested for actions it still allows. Run these checks against a disposable package or a controlled package namespace:
- Attempt direct
npm publishand preserve the rejection. - Attempt an unauthorized distribution-tag move and record the response.
- Attempt package deprecation and record whether the operation is permitted.
- Attempt access to a package outside the intended scope.
- Search command output, logs, caches, workspace snapshots, and Agent transcripts for the token value.
- Revoke the token and confirm that the previous automation path stops working.
Do not infer a permission boundary from the token label. The name “stage only” describes the intended publishing path, not every operation available to the credential. The current npm access token guidance should be checked when creating, viewing, rotating, or revoking tokens.
4Platform choice: Stage-only Token versus Trusted Publishing
The choice between a token and Trusted Publishing depends on your CI identity, runner model, package authorization, and approval design. Neither option removes the need for artifact review or execution isolation.
| Decision factor | Stage-only Token | Trusted Publishing with OIDC |
|---|---|---|
| Credential model | A scoped npm token is provided to automation | CI obtains short-lived authorization through an OIDC identity |
| Best fit | Automation that cannot yet use a supported Trusted Publishing route | Supported CI/CD workflows with a reliable workload identity |
| Long-lived secret exposure | Still possible if the token is stored or injected poorly | Reduced because the workflow does not rely on a persistent npm token |
| Final release control | Staging can be separated from maintainer approval | OIDC authenticates the workflow; it does not automatically approve every release |
| Main failure mode | Residual package write permissions and secret leakage | Incorrect workflow identity, package authorization, or overbroad automation |
| Migration requirement | Define token storage, rotation, scope, and revocation | Verify provider support, repository or workflow binding, and package-level setup |
The npm Trusted Publishing documentation explains the supported identity model and setup requirements. GitHub has also documented support for multiple Trusted Publishing configurations for npm, so teams should not assume that one old workflow configuration represents the current limit (GitHub’s Trusted Publishing update).
Use Stage-only Token first when your CI system or runner cannot satisfy the supported OIDC conditions, but keep the token in a dedicated staging job with narrow network and workspace access. Prefer Trusted Publishing when the workflow identity is supported, package authorization is explicit, and your team can prove that the job cannot silently change its own release conditions.
A dual-track migration is reasonable when:
- Existing automation must remain available during migration.
- A separate workflow can test OIDC without inheriting the production release secret.
- The package owner can compare staged artifacts from both paths.
- The rollback path preserves manual approval.
Do not describe OIDC as “no approval required.” OIDC changes how the workflow authenticates. It does not decide whether the package contents, version, or release scope deserve approval.
5Security acceptance checklist
Use this checklist before enabling an AI Agent to stage npm packages:
- [ ] Direct
npm publishwith the Stage-only Token is rejected, and the response is saved. - [ ] The token cannot access packages outside the intended package or organization scope.
- [ ] Distribution-tag operations are tested separately from direct publishing.
- [ ] Package deprecation behavior is tested separately from direct publishing.
- [ ] The Agent has no maintainer 2FA seed, recovery code, browser session, or final approval credential.
- [ ] The staged tarball is inspected independently of the Agent’s own report.
- [ ] The tarball is linked to a repository commit, lockfile, build command, and test record.
- [ ] The workflow records the package version, staging result, reviewer, and approval event.
- [ ] Logs, caches, workspace snapshots, and sub-agent contexts are checked for token leakage.
- [ ] Token revocation is tested and the failure is visible to the automation owner.
- [ ] The build workspace is isolated from unrelated repositories and release identities.
- [ ] A failed staging or approval attempt leaves a documented recovery path.
- [ ] The team has decided whether the next phase is limited rollout, OIDC migration, or manual publishing.
If any item involving credential isolation, artifact provenance, or revocation fails, do not expand access. Keep the workflow in manual publishing until the missing evidence exists.
6Remote Mac delivery boundary
Remote Mac builds need a stricter separation when the package contains native dependencies, Apple-specific tooling, platform binaries, or signing-related output. The Mac should be treated as a build and verification host, not as the place where final npm approval happens.
Keep the following on separate trust boundaries:
- The remote Mac: source checkout, dependency installation, native build, tests, tarball generation, and staging submission.
- The approval workstation or controlled approval job: staged tarball review, maintainer identity, 2FA, and final release decision.
- The audit store: commit, build output, test results, package manifest, staging record, and approval evidence.
If your team needs a temporary macOS environment for native npm builds, review the vpstix remote Mac environment guide before deciding how the build host will receive source files, expose terminal access, and handle cleanup. The remote Mac should receive only the credentials required for staging, not the maintainer’s final approval identity.
Keep the following delivery records together:
- Source commit and dependency lockfile.
- Mac build command and environment declaration.
- Test output for each required target.
- Tarball manifest and checksum.
- Staging identity and submission result.
- Approval identity and final decision.
- Cleanup result showing that temporary credentials and workspace data were removed.
For teams comparing build hosts, the vpstix remote Mac build resources can help you evaluate the operational steps around temporary access, environment use, and teardown. That operational layer does not replace npm authorization testing; it helps you define where the testing should occur.
For remote Mac builds, the npm Stage-only Token should be injected only for the staging operation, not written into a persistent shell profile or shared machine image. Clear environment variables, command history, temporary files, package-manager caches containing credentials, and workspace snapshots after the task. Also check whether the remote execution layer records terminal output or captures the workspace for later restoration.
A usable evidence package should answer these questions:
- Which source commit produced the tarball?
- Which Mac environment and build command were used?
- Which tests ran, and where are their results?
- Which files entered the tarball?
- Which identity submitted the staged package?
- Which person approved or rejected it?
- Could the build host still use the credential after task cleanup?
Do not treat an isolated Mac as an absolute security control. Isolation limits the blast radius of the build host, but it does not correct an over-permissioned token, an unsafe Agent tool, a leaked log, or an unreviewed tarball.
7Release owner decision
Use the following release grouping:
- Limited rollout: suitable for low-impact packages when the Agent can stage only, a maintainer performs 2FA approval, residual write permissions are tested, and the build environment is isolated.
- Dual-track migration: suitable when your supported CI/CD platform can test Trusted Publishing while the existing Stage-only workflow remains available for controlled fallback.
- Manual publishing: required when the team cannot separate the build host from the approval identity, cannot inspect staged artifacts, cannot preserve provenance, or cannot prove token revocation.
The official GitHub changelog identifies January 2027 as npm’s target period for removing the ability of bypass-2FA tokens to publish directly. That is an official plan, not an immutable guarantee, so treat it as a migration deadline for testing rather than as proof that every token behavior will remain unchanged. Recheck the npm documentation if npm changes Stage-only permissions, expands OIDC support, modifies self-hosted runner support, or changes the planned bypass-2FA retirement.
For now, the practical conclusion is narrow: let the Agent generate, test, package, and stage; keep final approval with a separate maintainer; and prefer Trusted Publishing when your CI identity and package authorization support it. If your team cannot prove those boundaries, do not hand the Agent broader npm access just because direct publishing is blocked.
A long-lived token still carries operational risk, and a remote Mac still adds workspace, logging, and cleanup concerns. For temporary builds or cross-platform validation, renting an isolated Mac through vpstix can be preferable to placing native toolchains and npm credentials on a shared developer machine, but you should still keep the approval identity outside that environment. Before expanding the rollout, use this acceptance path to decide whether your current build host, Agent workflow, and npm authorization can produce evidence that a reviewer can actually verify.
8Further Reading
vpstix M4 Remote Node
Give Your AI Agent a Controlled Remote Mac
Run package builds and release checks on a dedicated remote Mac with vpstix.