npm-packages

Enforce npm package conventions for JavaScript ES module projects.

11|Updated Apr 4, 2025
One-click install
npx skills add https://github.com/sanand0/scripts --skill npm-packages
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: npm-packages
Source: https://github.com/sanand0/scripts/tree/main/agents/npm-packages
Command: npx skills add https://github.com/sanand0/scripts --skill npm-packages

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide for structuring, coding, and publishing npm packages, ensuring consistency, maintainability, and ease of use across projects. It streamlines the package development lifecycle from creation to deployment.

Core Features & Use Cases

  • package.json Conventions: Defines mandatory and recommended fields for package.json, including scripts for linting, building, and testing (prepublishOnly).
  • README.md Structure: Outlines a standardized README.md format with essential sections like shields, installation, usage, and development, improving discoverability and user adoption.
  • Coding & Testing Styles: Recommends JavaScript coding practices (ESM, named exports) and testing methodologies (Vitest, Playwright) for high-quality code.
  • Use Case: Automatically generate a package.json and README.md for a new JavaScript utility, pre-filling all standard fields and build scripts according to best practices, saving hours of setup time.

Quick Start

Create a package.json and README.md for a new npm package named 'my-utility', including build and test scripts.

Frequently Asked Questions about npm-packages

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a package.json for publishing an npm package?

A package.json for npm publishing requires mandatory fields: name, version, description, homepage, repository, license, type (set to 'module' for ESM), files, and exports. Include scripts for build, lint, test, and prepublishOnly to automate quality checks before publishing.

What should I include in a README for an npm package?

A professional README includes shields for badges, installation instructions, usage examples, development setup, and contribution guidelines. This structure improves discoverability, helps users understand your package quickly, and establishes trust through clear documentation.

Can I enforce coding standards across JavaScript npm packages?

Yes, enforce standards by defining scripts for linting and testing in package.json, using ESM with named exports, avoiding TypeScript in core files while providing type definitions, and standardizing build workflows. This ensures consistency across projects and simplifies maintenance.

What coding practices should I follow when publishing JavaScript packages?

Use ES modules (ESM) with named exports, provide type definitions alongside JavaScript code, standardize test frameworks like Vitest and Playwright, and follow consistent naming conventions. These practices improve compatibility, developer experience, and code quality for consumers.

Do I need to automate testing and linting before publishing npm packages?

Yes, configuring prepublishOnly, test, and lint scripts in package.json ensures code quality gates run automatically before publishing. This prevents defects from reaching consumers and establishes a reliable release process.

What files should I include when publishing an npm package?

Define the files field in package.json to explicitly list distributable assets: built output, type definitions, and README. Use exports to map entry points for different module consumers. This reduces package size and clarifies which files are public API.