Node.js Reliable Programming
Paste the following prompt into your AI chat to install this skill:
Please install @user_f12a44b7/self-dev-nodejs according to https://skillhub.cn/install/skillhub.md.
About this skill
The Problem
Crashes and subtle failures in Node.js projects often come from async boundaries, module caching, stream backpressure, environment typing, and dependency structure rather than syntax alone. fs.readFileSync can block the event loop, unhandled rejections may terminate Node 15+ processes, process.env values are always strings, and require() caching plus circular dependencies can make shared object state hard to reason about.
How It Works
The skill organizes quick references by topic: async.md covers callbacks, Promises, async/await, and the event loop; modules.md compares CommonJS and ESM; errors.md addresses uncaught exceptions; streams.md focuses on Readable, Writable, Transform, and backpressure; performance.md covers memory leaks, event loop blocking, and profiling; security.md covers input validation, dependencies, and environment variables; testing.md covers Jest/Mocha, mocking, and integration tests; packages.md covers npm, package.json, lockfiles, and publishing. The core is engineering guardrails around common traps: prefer fs.promises.readFile, wrap JSON.parse in try/catch, use pipeline() instead of .pipe(), and use fileURLToPath(import.meta.url) in ESM.
Boundaries
It is best for triage, review, and refactoring of existing Node.js services or libraries. The skill does not provide business architecture decisions, nor does it replace a full test environment. For ESM/CJS hybrids, multi-process setups, or containerized networking, decisions should be made with project dependencies and runtime versions in mind.
Use Cases
- Review a Node.js endpoint where `fs.readFileSync` blocks the event loop, then replace it with `fs.promises.readFile` and add error handling.
- Debug a Node 15+ service exiting from unhandled rejections by locating Promise chains missing `catch` or `try/catch`.
- Refactor a data pipeline from `.pipe()` to `pipeline()`, handling `Readable` and `Transform` backpressure and cleanup.
- Fix ESM/CJS mixing errors by addressing missing `__dirname`, `require()` caching, and circular dependency issues.
Best For
- Engineers owning Node.js backend services who need to check async, error, and stream pitfalls during code review.
- Developers maintaining data pipelines or gateway middleware who need to handle `Readable` and `Transform` backpressure and cleanup.
- Full-stack engineers taking over ESM/CJS repos who need to trace module loading, `__dirname`, and caching issues.
- Node.js contributors preparing Jest/Mocha tests and npm publishing who need mocking, integration, and packaging details.
Related Skills
A one-shot coding agent built on Claude Code CLI that runs non-interactively, supports a specified workdir, and can be monitored in the foreground or background.
Preview and confirm file sorting by extension, with recursive cleanup, ignore rules, and transactional rollback.
An engineering assistant for static HTML/CSS/JS pages, design-token extraction, IE8-compatible review, and structured delivery.
An engineering workflow for requirement analysis, scenario modeling, risk planning, quality gates, testing, and knowledge capture, with lightweight, standard, and full modes.