npm-publish
Skill1 starsChanged 5 months agoMITView on GitHub
Publish an NPM package to the registry, handling authentication via browser-based login with 2FA/security key support.
- Sends data out
6 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- metarhia/metaskillstheir own version, first seen Nov 1, 2026
- htekdev/vidpipetheir own version, first seen Oct 8, 2026
- Kanevry/session-orchestratortheir own version, first seen Oct 2, 2026
- kvdm-co-pilot/create-cmptheir own version, first seen Sep 30, 2026
- Fei2-Labs/skill-genieedited, first seen Sep 24, 2026
- jasoncrawford/claude-skillstheir own version, first seen Apr 25, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- Fei2-Labs/skill-genie★ 1265% same
Wrote their own version · 5
- htekdev/vidpipe★ 229same name
- metarhia/metaskills★ 61same name
- Kanevry/session-orchestrator★ 53same name
- jasoncrawford/claude-skills★ 1same name
- kvdm-co-pilot/create-cmp★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- aegis-protocolSkill
- ai-csuiteSkill
- browser-driverSkill
- chinese-humanizerSkill
- close-loopSkill
- de-ai-englishSkill
- dev-inboxSkill
- foxcode-openclawSkill
- git-cryptSkill
- handoff-receiverSkill
- image-prompt-engineerSkill
- init-rulesSkill
- linuxdo-applicationSkill
- omnidebug-autopilotSkill
- psychology-masterSkill
- refactor-agents-mdSkill
- research-to-wechatSkill
- rtk-token-saverSkill
- session-handoffSkill
- shared-memorySkill
- stalwart-dokploy-resend-relaySkill
- web-compliance-builderSkill
- wechat-compliance-checkSkill
- wordpress-vps-installSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 5 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
If this returns a username → already authenticated, skip to Step 5.
- Very specific: line 37
If this returns E401 → need to authenticate, continue to Step 3.
- Distinctive: line 41
If the user has a password manager CLI, retrieve credentials:
- Distinctive: line 84
If the user is NOT already logged into npmjs.com in their browser, use Playwright with the user's Chrome profile to fill credentials:
- Very specific: line 170
After login, create an NPM automation token and write it to ~/.npmrc
- Distinctive: line 178
Must return the correct username before proceeding.
- Very specific: line 189
Check if the package version already exists: npm view <package>@<version>
- Very specific: line 191
Check scope permissions: npm access list packages
- Very specific: line 195
Verify: npm org ls <scope-name> or check on npmjs.com
- Distinctive: line 218
Use password manager CLI to retrieve credentials at runtime
- Very specific: line 220
Add npm-login.mjs to .gitignore
“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.
Files
NPM Publish Skill
Publish an NPM package to the registry. Handles authentication including 2FA and security key (WebAuthn) flows.
Prerequisites
- Node.js 22+ and npm installed
- Package.json with correct name, version, and
prepublishOnlyscript - Password manager CLI (optional, for retrieving credentials)
Process
Step 1: Verify Package Readiness
npm run build:hooks # or whatever build step exists
npm test # ensure tests pass- Build succeeds
- Tests pass
Step 2: Check NPM Authentication
npm whoami- If this returns a username → already authenticated, skip to Step 5.
- If this returns
E401→ need to authenticate, continue to Step 3.
Step 3: Retrieve Credentials (Optional)
If the user has a password manager CLI, retrieve credentials:
rbw (Bitwarden):
rbw get npmjs.com # returns password
rbw get --full npmjs.com # returns username + password + URIsOther password managers — ask the user how to retrieve their NPM credentials:
pass:pass show npmjs.com1password:op item get "npmjs.com" --fields label=username,label=passwordgopass:gopass show npmjs.com- Custom: ask user for their CLI command
Extract:
- Username from the full output
- Password from the first line of output
Step 4: Browser-Based Login (REQUIRED for 2FA/Security Key)
NPM requires browser-based authentication when 2FA or security keys are enabled. Use the user's default browser, not a test/headless browser.
4a: Start npm login (opens browser for 2FA)
npm loginThis prints a URL like:
https://www.npmjs.com/login?next=/login/cli/<uuid>4b: Open the login URL in the user's default browser
open "<the-login-url>"On macOS, open uses the user's default browser with all their existing sessions, cookies, and extensions — including security key/WebAuthn support.
4c: Automate credential entry (optional, if no existing browser session)
If the user is NOT already logged into npmjs.com in their browser, use Playwright with the user's Chrome profile to fill credentials:
npx playwright install chromium # first time onlyThen run a script like:
import { chromium } from 'playwright';
import { writeFileSync } from 'fs';
import { homedir } from 'os';
import { join } from 'path';
import { execSync } from 'child_process';
// Get credentials from password manager or user
const NPM_USER = '<username from password manager>';
const NPM_PASS = '<password from password manager>';
// Use user's Chrome — NOT headless, NOT test browser
// channel: 'chrome' uses the system Chrome installation
const browser = await chromium.launch({ headless: false, channel: 'chrome' });
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://www.npmjs.com/login');
await page.waitForLoadState('networkidle');
// Fill username
const usernameInput = page.locator('input#username, input[name="username"], input[type="text"]').first();
await usernameInput.waitFor({ timeout: 10000 });
await usernameInput.fill(NPM_USER);
// Fill password
const passwordInput = page.locator('input#password, input[name="password"], input[type="password"]').first();
await passwordInput.waitFor({ timeout: 5000 });
await passwordInput.fill(NPM_PASS);
// Click sign in
const signInBtn = page.locator('button[type="submit"], button:has-text("Sign In"), button:has-text("Log In")').first();
await signInBtn.click();
// Wait for user to complete 2FA/security key in the browser
console.log('Waiting for 2FA/security key authentication...');
const result = await Promise.race([
page.waitForURL('**/dashboard**', { timeout: 300000 }).then(() => 'dashboard'),
page.waitForURL('**/login/cli/**', { timeout: 300000 }).then(() => 'cli-callback'),
page.waitForURL('**/~**', { timeout: 300000 }).then(() => 'profile'),
]).catch(() => 'timeout');
console.log('Login result:', result, 'URL:', page.url());
// After successful login, create an automation token via the NPM API
if (result !== 'timeout') {
const tokenResult = await page.evaluate(async () => {
const res = await fetch('/-/npm/v1/tokens', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ password: '<NPM_PASS>', readonly: false, cidr_whitelist: [] }),
});
return res.json();
});
if (tokenResult && tokenResult.token) {
const npmrcPath = join(homedir(), '.npmrc');
writeFileSync(npmrcPath, `//registry.npmjs.org/:_authToken=${tokenResult.token}\n`);
console.log('Token written to .npmrc!');
}
}
// Verify authentication
try {
const whoami = execSync('npm whoami 2>&1').toString().trim();
console.log('npm whoami:', whoami);
} catch (e) {
console.log('npm whoami failed — manual intervention needed');
}
await browser.close();Key points:
channel: 'chrome'uses the user's installed Chrome (with security key support)headless: false— MUST be visible for WebAuthn/security key prompts- The user only needs to tap their security key — everything else is automated
- After login, create an NPM automation token and write it to
~/.npmrc
4d: Verify authentication
npm whoamiMust return the correct username before proceeding.
Step 5: Publish
npm publish --access publicFor scoped packages (@scope/name), --access public is required on first publish.
If publish fails with E403:
- Check if the package version already exists:
npm view <package>@<version> - Bump version if needed
- Check scope permissions:
npm access list packages
If publish fails with E404:
- The NPM scope may not exist or user lacks permission
- Verify:
npm org ls <scope-name>or check on npmjs.com
Step 6: Verify
npm view <package-name> versionConfirm the published version matches.
Troubleshooting
| Error | Cause | Fix |
| E401 Unauthorized | Not logged in | Run Step 4 |
| E403 Forbidden | Version already published or no permission | Bump version or check scope access |
| E404 Not Found | Scope doesn't exist or no publish rights | Create scope on npmjs.com or request access |
| WebAuthn not working in Playwright | Headless mode or wrong browser | Use channel: 'chrome' + headless: false |
| Token expired | NPM tokens have limited lifetime | Re-run Step 4 |
Security Notes
- NEVER hardcode credentials in scripts committed to git
- Use password manager CLI to retrieve credentials at runtime
- The
npm-login.mjsscript should be created as a temp file and deleted after use - Add
npm-login.mjsto.gitignore - Automation tokens should be scoped to publish-only when possible
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
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.

