/aimi-engineering:typescript-node-conventionsfrom aimi-engineering
Sets strict TypeScript conventions for Node.js/Bun: strict mode, ESM/CJS interop, typed error handling, async hygiene, and runtime adapter patterns.
Ships in aimi-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Condensed, actionable TypeScript-on-Node/Bun conventions distilled from the
official TypeScript Handbook and Node.js documentation. Full-depth material
lives under references/; this file carries everything needed to write or
review TypeScript/Node/Bun code without reading further.
Attribution: The rules below adapt and paraphrase guidance from the official TypeScript Handbook (microsoft/TypeScript-Website, CC-BY 4.0 for prose) and the official Node.js documentation (nodejs/nodejs.org, MIT). Nothing here is reproduced verbatim — conventions are restated in original wording as agent-facing rules. Cross-checked against current TypeScript and Node.js documentation via Context7. See
NOTICE.mdfor full attribution and license text.
tsconfig.json, module boundaries,
package.json exports, error handling, or async code.implementation.approach must justify a typing, module, or
error-handling decision on a TS/Node/Bun stack.strict: true is the non-negotiable baseline. It is TypeScript's single
highest-leverage setting — tsc --init has generated it by default since
TypeScript 2.3, and TypeScript 5.9's default tsc --init output layers
additional stricter options (noUncheckedIndexedAccess,
exactOptionalPropertyTypes) on top of it as the current recommended
starting point. Disabling strict (or leaving it off in a migrated project)
forfeits most of what makes TypeScript worth using. Every rule below assumes
it is on.
strict: true; do not selectively disable its sub-flags
(strictNullChecks, noImplicitAny, strictFunctionTypes, ...) to make a
migration easier — fix the underlying types instead.any to silence the compiler. For genuinely dynamic data
(API responses, JSON.parse results, third-party payloads), type it
unknown and narrow with typeof, instanceof, a user-defined type
predicate, or a runtime schema check before use. unknown accepts any
value but permits no operations until narrowed — that gap is the safety
any throws away.unknown under strict (useUnknownInCatchVariables,
on since TS 4.4) — narrow with if (err instanceof Error) before reading
.message/.stack; don't reflexively re-type a caught value as any.interface for object shapes callers might extend or implement;
prefer type for unions, intersections, and mapped/conditional types. Not
a compiler rule, but the near-universal community and linter default
(@typescript-eslint/consistent-type-definitions) — pick one rationale and
apply it consistently rather than mixing arbitrarily.as SomeType cast on
unchecked external data is a false sense of safety — types vanish at
runtime; only a runtime check catches a shape mismatch.import/export) is the default for new code. Reach for
CommonJS interop deliberately, not as an ad hoc per-file habit — mixing
require() and import in the same module graph without a chosen
boundary produces __dirname/import.meta.url confusion and dual-package
hazards."module": "nodenext" with "moduleResolution": "nodenext" (implied)
and "verbatimModuleSyntax": true when targeting Node — this elides
type-only imports correctly and keeps the ESM/CJS boundary unambiguous
instead of TypeScript silently rewriting import syntax. For bundler-driven
targets, pair "module": "preserve" with "moduleResolution": "bundler"
instead (implies esModuleInterop), which models how bundlers and
Bun-style runtimes actually resolve modules. For a library meant to run
unbundled on Node, prefer node16/nodenext resolution over bundler —
bundler resolution can produce output that works under a bundler but
fails under plain Node due to missing extensions.require() a synchronous ESM graph directly
— process.features.require_module reports whether it's active. This
narrows, but does not eliminate, the case for ad hoc interop: still choose
the boundary deliberately (native require(esm) vs. createRequire vs.
dynamic import()) and document it, since older supported Node/Bun
versions may not have it.references/module-boundaries.md for the full moduleResolution
decision table, the exports-map deep dive, and worked interop examples.Error, never throw
strings or plain objects (throw "failed", throw { code: 500 }) — doing
so breaks stack traces and downstream instanceof Error checks. Add
discriminating fields (code, isOperational) so a catch can branch
reliably.try/catch,
.catch) and return/report a meaningful result. Programmer errors are
bugs — a null dereference, a failed invariant, corrupted in-memory state.
Let them crash the process and restart via a supervisor (container
orchestrator, systemd, process manager) rather than catching and
continuing in a state you no longer understand.catch {}, or a catch that
only logs without rethrowing or otherwise surfacing the failure, hides
operational failures from callers and monitoring.unhandledRejection/uncaughtException process handlers as a
last-resort safety net for logging/telemetry before exit, never as the
primary way an operational error gets handled.awaited
inside a try/catch, chained with .catch(), or explicitly discarded
with a void and a one-line comment explaining why it's fire-and-forget.
An unhandled rejection is, by default, a process-crashing event on modern
Node — don't rely on that default as your error-handling strategy.async/await over chained .then(), and
don't mix callback-style APIs with promise-style APIs inside the same
function — pick one, wrap the other at the boundary.references/async-hygiene.md for floating-promise patterns, the
fire-and-forget escape hatch worked example, and the full operational-vs-
programmer error taxonomy with examples.exports map in
package.json rather than letting consumers deep-import into internal
files (pkg/dist/internal/helper.js). exports is what makes internal
refactors safe and what makes ESM/CJS dual-publishing possible at all —
anything not listed simply isn't importable.require() and import consumers during a
transition, use conditional exports ("import", "require", and — for
packages opting into modern Node's synchronous ESM require
— "module-sync") pointing at the same or equivalent ESM output, rather
than hand-maintaining two divergent builds. Drop the transitional
conditions once you no longer need to support Node versions that lack
require(esm).Bun.serve,
bun:sqlite, Bun.file, or Node's worker_threads/node:sqlite go
behind a small module boundary (e.g. runtime/server.ts,
runtime/db.ts) with one implementation per runtime, selected at the
composition root. Core business logic imports the adapter's interface,
never the runtime-specific module directly.typeof Bun !== "undefined" runtime checks through
business logic — that's the adapter boundary leaking. Push the branch to
the edge, once, at the adapter.any, @ts-ignore, or as unknown as X
instead of fixing the underlying mismatch or narrowing properly.Error values (throw "failed", throw { code }).catch {}, or catch-and-log without
rethrowing/handling.require() and import ad hoc within the same module graph with
no deliberate interop boundary.exports map entry points.Bun.serve, bun:sqlite,
worker_threads) directly from shared business logic instead of through
an adapter.Before accepting TypeScript/Node/Bun code as convention-compliant, confirm:
strict: true is on and no sub-flag is selectively disabled.unknown + narrowed or schema-validated at the
boundary, never cast with any or a bare as.moduleResolution/module match the actual runtime target, and
verbatimModuleSyntax is set when targeting nodenext.Error subclasses; operational failures are handled
locally, programmer errors are allowed to crash and restart..catch()-ed, or deliberately voided with a
documented reason — none are left floating.exports in
package.json, not implied by file layout.For full-depth material behind these condensed rules — moduleResolution decision tables, exports-map worked examples, dual-package-hazard detail, floating-promise patterns, and the Bun/Node adapter pattern in full — read on demand (not auto-loaded):
references/module-boundaries.md — ESM/CJS interop boundary, the full
moduleResolution/module decision table, package.json exports map
patterns (including module-sync and dual-package-hazard avoidance), and
worked CJS/ESM interop examples.references/async-hygiene.md — floating-promise patterns and fixes, the
fire-and-forget escape hatch worked example, the full operational-vs-
programmer error taxonomy with code examples, and the Bun/Node adapter
pattern worked end-to-end.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aimi-so/aimi-engineering-plugin --plugin aimi-engineering19 skills in this plugin
/agent-browserBrowser automation using Vercel's agent-browser CLI. Use when you need to interact with web pages, fill forms, take screenshots, or scrape data. Alternative to Playwright MCP - uses Bash commands with ref-based element selection. Triggers on "browse website", "fill form", "click button", "take screenshot", "scrape page", "web automation"./agent-native-architectureBuild applications where agents are first-class citizens. Use this skill when designing autonomous agents, creating MCP tools, implementing self-modifying systems, or building apps where features are outcomes achieved by agents operating in a loop./Other plugins' skills for the same job