← ClaudeAtlas

node-patternslisted

Node.js runtime patterns — ESM, package manager discipline, async/await, streams, error handling, environment config.
jjackkun/claude-harness-hermes · ★ 1 · AI & Automation · score 74
Install: claude install-skill jjackkun/claude-harness-hermes
# Node.js Patterns Modern Node.js (≥20) runtime patterns. Runtime-level concerns; framework patterns live in their own skills (svelte-patterns, fastapi-patterns, etc.). ## When to Activate - Editing Node.js scripts, CLIs, or server entrypoints - Configuring `package.json`, `tsconfig.json`, build/run scripts - Working with the filesystem, streams, child processes - Designing async flows, error propagation - Deciding ESM vs CJS, dependency choices ## Package Management **Always follow the existing lockfile** — don't switch managers casually. | Lockfile | Manager | |---|---| | `pnpm-lock.yaml` | pnpm | | `yarn.lock` | yarn | | `package-lock.json` | npm | | `bun.lockb` | bun | - `engines` field in `package.json` pinning Node version - `packageManager` field locks the manager version - Prefer `npm ci` / `pnpm install --frozen-lockfile` in CI - Never commit `node_modules/` ## ESM First ```json // package.json { "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } } } ``` ```ts // use .js extensions in imports even for .ts source (TS ESM convention) import { foo } from './foo.js'; import { readFile } from 'node:fs/promises'; // always 'node:' prefix for built-ins ``` - Use `node:` prefix for all built-in modules — makes intent explicit, avoids user-package shadowing. - CJS only when forced by a legacy dependency. Document why. - Top-level `await` is available in ESM — use it for bootstrap code. ## As