Node.js Cookbook
Version: 1.1.0 | Updated: 2026-07-16
Purpose
Operate AI-assisted changes to a HTTP handler, worker, stream pipeline, package, or process lifecycle using Node.js's native contracts, commands, failure evidence, architecture, and rollback mechanisms.
Why
The event loop remains non-blocking; concurrency is bounded; AbortSignal, errors, and shutdown propagate through every I/O boundary. Generic software advice cannot verify that invariant because the decisive evidence lives in runtime and package-manager pin plus lockfile integrity; module mode, export map, TypeScript target, and startup command; event-loop delay, heap, CPU profile, active handles, and request trace.
How
- Supply the evidence below to the matching XML prompt.
- Execute the skill's native workflow rather than accepting prose-only output.
- Use the error workflow to classify observed failure before changing state.
- Preserve architecture boundaries in
architecture/patterns.md. - Block review or release on any unchecked technology gate.
Required evidence
- runtime and package-manager pin plus lockfile integrity
- module mode, export map, TypeScript target, and startup command
- event-loop delay, heap, CPU profile, active handles, and request trace
- timeout, retry, pool, body-size, and graceful-shutdown configuration
Native verification
node --versionand the package manager's immutable install commandnode --testor the repository's exact test scriptnode --trace-warnings <entrypoint>for warning provenancenode --prof <entrypoint>followed bynode --prof-process isolate-*.lognpm audit --omit=devwith lockfile and exploitability review
Version-aware caution
Read engines.node, .nvmrc/toolchain files, the lockfile, and the runtime image. APIs and default module, permission, test-runner, and fetch behavior depend on the deployed Node release; validate against that release's API docs.
Tradeoffs
This cookbook requires deeper Node.js evidence and specialist review than a generic template. The additional work buys reproducible diagnostics and a rollback that respects HTTP handler, worker, stream pipeline, package, or process lifecycle state.
Anti-patterns
- Unbounded
Promise.allover user-controlled input converts one request into connection-pool and memory exhaustion. - Do not remove a native warning, validator, policy, or safety limit merely to make generated output pass.
- Do not claim a successful result without preserving the command, target, artifact/revision, and observed output.
Enterprise considerations
Node service governance pins runtime and package-manager lines, reviews install scripts and native addons, retains SBOMs, and tests shutdown against the orchestrator grace period.
Official sources
Checklist
- Installed/deployed version and target environment are recorded.
- Native commands are selected from repository and platform evidence.
- Failure classes and rollback boundary are explicit.
- Official sources are checked for the recorded version.
- No prompt variable remains unresolved.
Changelog
- 1.1.0 (2026-07-16): Replaced cloned guidance with technology-native evidence, commands, architecture, and rollback.
- 1.0.0 (2026-07-16): Added initial cookbook.