Skip to content
reason-machines avatar

Npm Security Best Practices

Hardened npm and pnpm configuration guidance that blocks lifecycle scripts, git dependencies, and freshly published packages.

CCM score
46 of 100
skills.sh installs
770
GitHub stars
13
last updated
Jul 14, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers secure-by-default .npmrc, pnpm-workspace.yaml, and Bun trustedDependencies settings for supply chain attack prevention
  • Includes secure install commands, @lavamoat/allow-scripts allowlisting, hardened npx usage, and scoped registries against dependency confusion
  • Enforces a 30-day minimum release age, ignore-scripts, and allow-git=none as the baseline configuration
  • Designed for Node.js teams that want to audit npm, pnpm, and Bun dependency installs alongside tools like npq and Socket

Install

$ npx -y skills add reason-machines/security-skills --skill npm-security-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

npm Security Best Practices

Skill by ara.so — Security Skills collection.

This skill provides expert guidance on securing npm package installations, preventing supply chain attacks, and implementing security best practices for Node.js development. Based on the comprehensive npm-security-best-practices repository by Lirantal.

Overview

The npm ecosystem is a frequent target for supply chain attacks including:

  • Shai-Hulud attacks - Worm-like propagation through compromised packages
  • Nx incident - Malicious code in postinstall scripts
  • event-stream attack - Long-running exfiltration via lifecycle scripts
  • Dependency confusion - Attackers publishing malicious packages with internal names

This skill covers configuration, tooling, and practices to mitigate these risks across npm, pnpm, and Bun.

Secure-by-Default Configuration

npm (.npmrc)

Create or update .npmrc in your project root or global config (~/.npmrc):

# Disable all lifecycle scripts (postinstall, preinstall, etc.)
ignore-scripts=true

# Block git-based dependencies (git+ssh://, git+https://, etc.)
allow-git=none

Details

Repository
github.com/reason-machines/security-skills
Categories
Security, DevOps & Cloud
First seen
Jul 14, 2026

Questions

What does the npm-security-best-practices skill do?

It gives expert guidance on securing npm packages, preventing supply chain attacks, and hardening npm, pnpm and Bun configurations. It covers settings such as ignore-scripts, allow-git and minimum release age, plus tools like npq and Socket Firewall.

How do I install the npm-security-best-practices skill?

Run npx -y skills add reason-machines/security-skills --skill npm-security-best-practices -y inside your project. Once installed, the agent can apply npm security settings and install hardening steps to your Node.js project.

Where does npm-security-best-practices stand in the Security category?

It sits in the Security category on Claude Marketplaces, alongside skills such as security-audit and cloudflare-one. It focuses specifically on npm dependency risk, covering postinstall scripts, git-based dependencies and dependency confusion.

Which npm attacks does this skill help protect against?

It addresses supply chain attacks like the Shai-Hulud worm, the Nx incident, the event-stream attack and dependency confusion. It shows how to block malicious lifecycle scripts and reduce exposure to newly published packages.

More from reason-machines/security-skills

All 58

Similar to Npm Security Best Practices

More Security