plugins/smedjen/skills/nodejs-patterns/SKILL.md
Node.js streams, worker threads, event loop, error handling, and clustering patterns. Covers when to use streams vs buffers, CPU-bound offloading decisions, async error propagation, and graceful shutdown.
npx skillsauth add hjemmesidekongen/ai nodejs-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Beyond standard event loop and streams — Node 22+ features, structured cancellation, diagnostic channels, and ESM migration.
Built-in test runner (node:test): describe, it, mock — no framework. node --test **/*.test.js + --experimental-test-coverage.
--env-file: node --env-file=.env server.js — no dotenv. Multiple files supported (last wins).
Watch mode: node --watch server.js replaces nodemon. Scope: --watch-path=./src.
Native fetch: Stable in 21+, undici-backed. Supports AbortSignal natively.
require(esm) (22.12+): require() of ES modules without flags. CJS consumers, ESM libraries.
Propagate signals through async chains — fetch, setTimeout (node:timers/promises), and pipeline all accept { signal }. AbortSignal.timeout(5000) auto-aborts. AbortSignal.any([userSignal, timeoutSignal]) for composite cancellation.
node:diagnostics_channel — zero-overhead instrumentation, no APM coupling. dc.channel('app:db-query').publish({ query, duration }). Subscribers attach externally — app code never imports the observer. Undici publishes on undici:request:create for HTTP telemetry without middleware.
pipeline() + Transform with automatic backpressure:
const jsonLines = new Transform({
objectMode: true,
transform(chunk, enc, cb) { cb(null, JSON.stringify(chunk) + '\n'); }
});
await pipelinePromise(dataSource, jsonLines, response);
Stay CJS: consumers use require(), tooling assumes CJS, migration cost > benefit.
Go ESM: shipping a library, top-level await, Node 20+.
Dual publish: "type": "module" + "exports" with "import"/"require" conditions. Build CJS from ESM.
See references/process.md for worker thread pools, cluster, child processes, memory management, and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.