一键导入
node-modern
Use this skill when writing, reviewing, or refactoring Node.js >= 22 TypeScript code in WrongStack. Triggers: ESM imports, fetch usage, AbortSignal, node: protocol, Web Streams, or any async patterns.
菜单
Use this skill when writing, reviewing, or refactoring Node.js >= 22 TypeScript code in WrongStack. Triggers: ESM imports, fetch usage, AbortSignal, node: protocol, Web Streams, or any async patterns.
Use this skill when choosing, installing, or recommending packages, libraries, frameworks, or tooling — any decision that involves a version number or a technology name. This skill enforces latest-version verification, blocks dead/obsolete choices, and intervenes when the LLM hallucinates version numbers or suggests 5+ year-old technology. Triggers: user says "install", "package", "dependency", "upgrade", "latest version", "add package", "npm install", "pnpm add", "what version", "which library", "tech stack", "choose framework".
Use this skill when a task would benefit from parallel execution across multiple AI agents, or when orchestrating leader/worker patterns in WrongStack. Triggers: user says "fan out", "parallel", "delegate", "subagent", "fleet", "coordinator".
Use this skill when designing, reviewing, or refactoring REST APIs in WrongStack. Triggers: user says "API", "endpoint", "REST", "request", "response", "JSON", "HTTP", "status code", "pagination", "query params", "request body".
Use this skill when analyzing WrongStack session logs, event streams, or system traces to surface patterns, anomalies, or operational insights. Triggers: user says "audit", "session analysis", "log analysis", "usage patterns".
Use this skill when scanning source code for bugs, anti-patterns, code smells, or quality issues in a WrongStack project. Triggers: user says "bug", "bug hunt", "scan for issues", "find problems", "anti-pattern", "code smell", "static analysis".
Use this skill when building, containerizing, or deploying WrongStack with Docker. Triggers: user says "docker", "container", "dockerfile", "image", "docker-compose", "deploy", "containerize", "registry", "multi-stage", "distroless".
| name | node-modern |
| description | Use this skill when writing, reviewing, or refactoring Node.js >= 22 TypeScript code in WrongStack. Triggers: ESM imports, fetch usage, AbortSignal, node: protocol, Web Streams, or any async patterns. |
| version | 1.1.0 |
Node.js >= 22 patterns: ESM-only imports, native fetch with AbortSignal, Web Streams, and async patterns. WrongStack uses ESM throughout — no CommonJS in new code.
import with .js extension) — never require().node: protocol for built-in modules.AbortSignal.timeout() for long-running operations (fetch, spawn, setTimeout).ENOENT on file reads — use try/catch or access first.Promise.allSettled when partial failure is acceptable.// ✅ ESM with .js extension and node: protocol
import * as fs from 'node:fs/promises';
import { createServer } from 'node:http';
import { helper } from './helper.js';
// ✅ Native fetch with AbortSignal
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
// ✅ Atomic write
const tmp = `${target}.${randomBytes(4).toString('hex')}.tmp`;
await writeFile(tmp, data);
await rename(tmp, target);
// ✅ Parallel with allSettled
const results = await Promise.allSettled(tasks.map(t => t.run()));
// ❌ CommonJS
const fs = require('fs/promises');
// ❌ No AbortSignal — hangs forever on timeout
await fetch(url);
// ❌ axios in new code
const res = await axios.get(url);
// ❌ Swallowing AbortError silently
try {
await fetch(url);
} catch (e) {
// AbortError means timeout — log it or handle explicitly
}
// ✅ Always — node: protocol for built-ins
import * as fs from 'node:fs/promises';
import { createServer } from 'node:http';
import { join, resolve } from 'node:path';
// ✅ ESM with .js extension in relative imports
import { helper } from './helper.js';
import { types } from '../types/index.js';
// ❌ Never — CommonJS
const fs = require('fs/promises');
// ✅ Native fetch (Node 18+)
const res = await fetch('https://api.example.com/data', {
signal: AbortSignal.timeout(5000),
});
// ❌ Never — axios, node-fetch, got
const res = await axios.get('https://api.example.com/data');
// ✅ Timeout on fetch
await fetch(url, { signal: AbortSignal.timeout(5000) });
// ✅ Timeout on child_process
const child = spawn('pnpm', ['test'], { signal: AbortSignal.timeout(30_000) });
// ✅ Combined signals
const combined = AbortSignal.any([userSignal, timeoutSignal]);
// ✅ setTimeout with signal (Node 22+)
setTimeout(handler, 1000, { signal: userSignal });
// ✅ Atomic write pattern
import { rename, writeFile } from 'node:fs/promises';
const tmp = `${target}.${randomBytes(4).toString('hex')}.tmp`;
await writeFile(tmp, data);
await rename(tmp, target);
// ✅ Sequential with error handling
for (const file of files) {
try {
await processFile(file);
} catch (err) {
console.error(`Failed ${file}: ${err}`);
}
}
// ✅ Parallel with allSettled (when partial failure is ok)
const results = await Promise.allSettled(tasks.map(t => t.run()));
const failures = results.filter(r => r.status === 'rejected');
// ✅ Readable stream from fetch
const response = await fetch('https://api.example.com/stream');
const reader = response.body!.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}
| Anti-pattern | Why bad | Fix |
|---|---|---|
require() in new code | WrongStack uses ESM | Use import with .js extension |
__dirname without fileURLToPath | ESM doesn't have __dirname | path.dirname(fileURLToPath(import.meta.url)) |
Mixing fs.readFile callback with await | Callback API doesn't return a promise | Use fs.promises.readFile |
Swallowing AbortError silently | Means timeout/abort happened | Log it or handle explicitly |
process.cwd() without fallback | May not match user's cwd | Accept cwd as a parameter |
Not handling ENOENT on file reads | File may not exist | Use try/catch or access first |
{
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsup",
"test": "vitest run"
}
}
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
}
}
typescript-strict — strict TypeScript patternsreact-modern — React Server Components with Node.jsbug-hunter — catching async/await bugs, unhandled rejectionssdd — for setting up new Node.js features with a spec first