What the agent does
The agent clones the repository into its own cloud sandbox and reads how the package is built and released today. In a library like sindresorhus/ky, package.json is type: module at version 2.2.0 with exports pointing types at ./distribution/index.d.ts and default at ./distribution/index.js, a files list of just distribution, engines.node >=22, and sideEffects: false. The scripts tell the story: build runs del-cli distribution && tsc --project tsconfig.dist.json, prepare runs the build so a fresh npm install compiles the sources, test chains xo, the build, a type check with tsconfig.test.json and ava, and release is np, which means a maintainer publishes from their own machine with a long-lived token in their npm login. .npmrc says package-lock=false and .gitignore lists both lockfiles, so there is no lockfile to npm ci against. The only workflow, .github/workflows/main.yml, runs the AVA suite on macOS for Node latest, 24 and 22 and a second job for the Playwright browser tests, and never publishes.
It writes .github/workflows/release.yml that runs when a GitHub release is published. The job has permissions of id-token: write and contents: read, checks out the tag, and sets up Node 24 with actions/setup-node, registry-url set to https://registry.npmjs.org and package-manager-cache: false. Because trusted publishing needs npm 11.5.1 or newer and Node 22.14.0 or newer, the agent checks the npm version bundled with the Node it picked by running it in the sandbox and adds an npm install -g npm@latest step only if that version is too old. It then runs npm install, npm test (which builds, lints and type-checks before AVA) and a guard step that compares the release tag with the version field and fails the job when they differ, so a release tagged v2.3.0 cannot publish 2.2.0. The last step is npm publish --access public, with no NODE_AUTH_TOKEN: npm exchanges the job's OIDC token for a short-lived credential and attaches provenance on its own for a public package from a public repository.
The browser job in main.yml installs Playwright with --with-deps, which is slow on a release runner and not a publish gate the maintainer currently has, so the agent leaves the browser tests to the CI workflow and says so in the pull request. It changes the release script's comment and the contributing notes rather than deleting np, since np still does the version bump, the changelog and the tag; the publish step is what moves. It also checks that repository in package.json reads sindresorhus/ky, which npm resolves to the GitHub repository it must match exactly, and expands it to the full URL form if the registry's check needs it.
In the sandbox it runs npm install, npm test on Node 22 and 24, and npm pack --dry-run to list what the distribution folder ships, then npm publish --dry-run to show the registry call the workflow would make. It lints the new workflow with actionlint. Nothing is published: the workflow runs only on a published release and the sandbox has no OIDC token. The README gets a short Releasing section with the one-time step on npmjs.com, under the package's settings, where a maintainer adds a trusted publisher of type GitHub Actions with the owner, the repository name and the workflow file name release.yml, and no environment unless the workflow uses one.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Set up npm trusted publishing for this TypeScript library. Read package.json, the build and test scripts, the existing workflows and the release tooling first. Add a release workflow that runs on a published GitHub release, uses id-token: write, sets up Node with the npm registry URL, checks the bundled npm meets the trusted publishing minimum, installs, runs the full test script, fails if the tag and package version differ, and publishes with provenance and no token. Keep the existing release script for version bumps and tagging, document the one-time trusted publisher setup on npmjs.com, prove the package contents with npm pack --dry-run and npm publish --dry-run in the sandbox, lint the workflow, and open a pull request. Publish nothing.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch that adds .github/workflows/release.yml, adds a Releasing section to readme.md and, where needed, expands the repository field in package.json. The description quotes the npm pack --dry-run file list, the npm publish --dry-run output, the npm test results on the Node versions the workflow and CI use, the actionlint result and the exact trusted publisher fields to enter on npmjs.com.
The run's record keeps every command with its output, including the npm --version check that decided whether the workflow needs an npm upgrade step, so a reviewer can see the reasoning rather than a bare workflow file.
Before merging, a reviewer decides whether publishing should wait on a protected GitHub environment with required reviewers, whether the browser tests belong in the release gate, and who adds the trusted publisher on npmjs.com. The first real publish happens on the next release a maintainer cuts with np, and its provenance then shows on the package page.
Run it on every release cut from a laptop
A maintainer of several packages sends one POST /o/{org}/sessions per repository with this prompt and the repository in resources. GET /o/{org}/github lists every repository the Rush GitHub App installation can reach, so a script starts a run for each package whose package.json is not private and whose workflows never publish. Each run reads that package's own scripts, files list and lockfile situation, so a package with a lockfile and a separate build gets npm ci and its build step, and each opens its own pull request.
Set a webhook URL on the API key and Rush posts run.completed or run.failed when a run's turn finishes, with session_url so your server can read the pull request link. Send a fresh UUID as request_id with each request so a retry returns the run already started.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A trusted publishing setup fails at publish time, not at configuration time: npm does not validate the publisher when you save it, an npm older than 11.5.1 silently falls back to asking for a token, and a repository field that does not match the GitHub repository is refused. The agent checks each of those in its sandbox before the workflow exists, runs the dry-run publish and puts the evidence in the pull request, so the first real release is the second time the path has been exercised.
The sandbox is its own computer with the Node versions the package supports, and every command stays in the run's record. Several libraries can be converted at once in separate sandboxes, each with its own workflow written against its own scripts and its own pull request.
Frequently asked questions
Do I still need an npm token anywhere?
Not for publishing a public package. The workflow has no NODE_AUTH_TOKEN; npm exchanges the GitHub Actions OIDC token for a short-lived credential during npm publish. A read-only granular token is only needed if the package installs private dependencies, which this library does not.
Why run on a published release instead of a tag push?
Because np already creates the tag and the GitHub release together, and a release is an explicit act a maintainer takes, while a tag can be pushed by accident or by a script. The guard step still compares the tag and package.json so the two cannot drift.
Is provenance attached automatically?
Yes, for a public package published from a public repository through trusted publishing; no --provenance flag is needed. The pull request notes that provenance=false in .npmrc or publishConfig would turn it off, and that a private repository gets no provenance.
What about the missing lockfile?
The repository sets package-lock=false and ignores lockfiles on purpose, so the workflow uses npm install like CI does and the agent does not add one. The prepare script builds distribution during that install, which is why npm pack --dry-run lists compiled files from a clean checkout.