skills/cli-scripting/nodejs/22/SKILL.md
Node.js 22 LTS version-specific expertise. require() for ESM (experimental), built-in WebSocket client, built-in glob in node:fs, snapshot testing in node:test, util.parseEnv(), V8 12.4, Promise.withResolvers(). WHEN: "Node 22", "Node.js 22", "require ESM", "built-in WebSocket", "node:fs glob", "snapshot testing", "parseEnv".
npx skillsauth add chrishuffman5/domain-expert cli-nodejs-22Install 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.
Node 22 LTS (codename Jod). Released April 2024, EOL April 2027. Second-latest LTS.
| Feature | Status |
|---|---|
| require() for ES modules | Experimental (no flag needed from 22.12+) |
| WebSocket client built-in | Stable |
| glob / globSync in node:fs | Stable |
| --watch mode improvements | Stable |
| node:test snapshot testing | Added |
| V8 12.4, Promise.withResolvers() | Included |
| util.parseEnv() | Added |
No need to install the ws package for basic WebSocket usage.
// Built-in WebSocket (no import needed, global)
const socket = new WebSocket('wss://echo.websocket.org');
socket.addEventListener('open', () => {
console.log('Connected');
socket.send('Hello from Node 22!');
});
socket.addEventListener('message', (event) => {
console.log('Received:', event.data);
socket.close();
});
socket.addEventListener('close', () => {
console.log('Disconnected');
});
socket.addEventListener('error', (event) => {
console.error('WebSocket error:', event);
});
import { glob, globSync } from 'node:fs/promises';
// Async glob (returns AsyncIterable)
const jsFiles = await Array.fromAsync(glob('**/*.js'));
console.log(jsFiles);
// With options
const tsFiles = await Array.fromAsync(glob('**/*.ts', {
cwd: '/project/src',
exclude: (name) => name.includes('node_modules'),
}));
// For-await iteration (memory efficient for large trees)
for await (const file of glob('**/*.json', { cwd: '/data' })) {
console.log(file);
}
// Sync version (for startup/config loading)
import { globSync as globSyncFs } from 'node:fs';
const configs = globSyncFs('*.config.{js,ts,json}');
CJS code can now require() ES modules that meet certain constraints (no top-level await, synchronous).
// In a CJS file (no flag needed from Node 22.12+):
const { helper } = require('./esm-module.mjs');
// Restrictions:
// - The ESM module must not use top-level await
// - Works for most pure-function ESM libraries
// - Enables gradual ESM migration
import { test } from 'node:test';
test('snapshot test', (t) => {
const result = generateReport();
// First run: creates snapshot. Subsequent runs: compares.
t.assert.snapshot(result);
});
test('named snapshot', (t) => {
t.assert.snapshot(JSON.stringify(data, null, 2), 'report-data');
});
# Update snapshots
node --test --test-update-snapshots
import { parseEnv } from 'node:util';
const envContent = `
DB_HOST=localhost
DB_PORT=5432
# This is a comment
SECRET="my secret value"
`;
const parsed = parseEnv(envContent);
// { DB_HOST: 'localhost', DB_PORT: '5432', SECRET: 'my secret value' }
Promise.withResolvers() -- returns { promise, resolve, reject } in one callObject.groupBy() / Map.groupBy() -- native groupingArrayBuffer.prototype.transfer() stable// Promise.withResolvers
const { promise, resolve, reject } = Promise.withResolvers();
setTimeout(() => resolve('done'), 1000);
const result = await promise;
// Object.groupBy
const people = [{ name: 'Alice', dept: 'eng' }, { name: 'Bob', dept: 'sales' }];
const byDept = Object.groupBy(people, p => p.dept);
// { eng: [{ name: 'Alice', ... }], sales: [{ name: 'Bob', ... }] }
When migrating from Node 20 to Node 22:
glob eliminates need for fast-glob/globby in many casesWebSocket eliminates need for ws package (basic usage)require() ESM support enables gradual migration of CJS codebasesparseEnv() can replace dotenv for simple .env parsingtools
kubectl command-line usage and scripting: kubeconfig and context management, output formats (jsonpath, custom-columns, go-template), all major verbs (get, describe, apply, delete, exec, logs, port-forward, rollout, scale, drain), workload resources, config/storage, networking, RBAC, node management, debugging (CrashLoopBackOff, ImagePullBackOff, OOMKilled), and scripting patterns (dry-run, diff, wait, jq, kustomize). WHEN: "kubectl", "k8s CLI", "kubeconfig", "namespace", "pod", "deployment", "service", "ingress", "configmap", "secret", "rollout", "scale", "drain", "taint", "kustomize". Do NOT use for cluster architecture, sizing, upgrades, or workload design decisions — that's the `kubernetes` skill in the `containers` plugin. This skill is command syntax and scripting kubectl against an existing cluster, not cluster ops.
tools
Bash 5.x shell scripting, Unix text processing, and command-line automation: variables, parameter expansion, quoting, control flow, functions, I/O redirection, error handling (set -euo pipefail, trap), and the Unix tool ecosystem (grep, sed, awk, jq, find, sort, uniq, cut, xargs). Covers process management, networking (curl, ssh, rsync, nc), file locking (flock), parallel execution, and production script patterns. WHEN: "Bash", "bash", "shell", "sh", ".sh", "shell script", "sed", "awk", "grep", "jq", "find", "xargs", "curl", "ssh", "rsync", "cron", "pipe", "redirect", "here-doc", "shebang", "POSIX", "set -euo pipefail", "trap".
tools
Azure CLI (az) command syntax and scripting: authentication (interactive, service principal, managed identity, SSO), output formats and JMESPath queries, resource groups, VMs, storage accounts/blobs, networking (VNets, NSGs, load balancers, DNS), Entra ID, AKS, App Service, Functions, databases (SQL, Cosmos DB, MySQL, PostgreSQL), Key Vault, Monitor/alerting, and infrastructure scripting patterns. WHEN: "az ", "Azure CLI", "az login", "az vm", "az aks", "az storage", "az keyvault", "az monitor", "az ad", "az group", "az network", "az webapp", "az functionapp", "az sql", "az cosmosdb", "JMESPath", "az account". Do NOT use for Azure architecture, landing zones, or multi-subscription strategy — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.
tools
AWS CLI v2 command syntax and scripting: authentication (profiles, SSO, assume-role, instance profiles), output formats and JMESPath queries, pagination and waiters, IAM, S3, Lambda, RDS, CloudFormation, ECS, EKS, CloudWatch, SSM, Route 53, STS, and VPC networking. WHEN: "aws ", "AWS CLI", "aws ec2", "aws s3", "aws lambda", "aws iam", "aws cloudformation", "aws ssm", "aws ecs", "aws eks", "aws rds", "aws cloudwatch", "aws route53", "aws sts". Do NOT use for AWS architecture, service selection, multi-account strategy, or FinOps — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.