/odin-typescript:nodejs-service-foundationsfrom ODIN TypeScript
Sets up Node.js service foundations: env validation, structured logging with redaction, typed error taxonomy, and type stripping. Use when scaffolding or hardening a new or existing Node.js service.
Ships in ODIN TypeScript. 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.
| Field | Bound contract |
|---|---|
| Trigger | Setting up or hardening Node.js service foundations: env or secrets configuration, structured logging with redaction, typed error taxonomy, module system, native TypeScript type stripping. |
| Authority | Reversible local: writes only named local artifacts (env schema, logger, error classes, tsconfig, package scripts) and may install the dependencies they need; rollback is version control. No remote mutation. |
| Side effect | Writes service scaffolding files and installs declared dependencies. |
| Done | The service validates startup env (invalid config fails fast), emits structured logs with secret redaction, throws typed coded errors with working instanceof checks and HTTP status mapping, and runs under type stripping or tsc with no errors. |
package.json.{ code, message, httpStatus } tuples for the service's domain errors.Validate environment at startup. Create an env schema module (e.g., src/env.ts) that reads process.env at import time. For each declared variable: parse the value against its type (string, number, boolean, URL); if required and missing or malformed, throw a descriptive error and exit with code 1 before any server binding. Export the frozen validated config object. Do not allow the service to start with invalid or missing configuration. Done when: the env schema module validates all declared variables and fails fast on invalid config.
Configure structured logging with redaction. Create a logger module (e.g., src/logger.ts) using the stated logger dependency. Configure the log level from env, ISO-8601 timestamps, and a request-id correlation field. Implement a redaction serializer that replaces values of every secret field name with [REDACTED] at every log level. Export a singleton logger instance. Done when: the logger module emits structured JSON with secret redaction at every log level.
Define a typed-error catalogue with instanceof and HTTP mapping. Create an error module (e.g., src/errors.ts) exporting a base ServiceError class with fields code: string, message: string, httpStatus: number, and cause?: Error. For each entry in the error catalogue, export a named subclass or factory. Ensure instanceof ServiceError works for error-handling middleware to map codes to HTTP responses. Done when: the error module exports ServiceError base and all catalogue entries, instanceof ServiceError returns true for every subclass instance, and every catalogue code maps to its declared HTTP status.
Wire AbortController signal, drain, and exit. In the service entry point, create an AbortController. Listen for SIGTERM and SIGINT: call controller.abort(), pass the signal to in-flight operations, drain active requests, then exit with code 0 on clean drain or non-zero on timeout. This wires the shutdown spine without implementing the full shutdown handler (that is the job of nodejs-graceful-shutdown when a dedicated implementation is needed). Done when: the entry point creates an AbortController, wires both signals to controller.abort(), and exits after drain.
Verify startup logs, one invalid-env case, and tsc. Run the service with valid env and confirm: server binds, startup log emits as structured JSON with secrets redacted. Run with a missing required env var and confirm: process exits with code 1 and a descriptive error before any server binding. Run tsc --noEmit and confirm: zero type errors. Verify the typed-error catalogue: instantiate one subclass, confirm instanceof ServiceError returns true, and confirm its httpStatus matches the catalogue entry. Verify redaction: log a record containing a secret field name and confirm the output shows [REDACTED]. Done when: valid-env startup emits structured redacted JSON, invalid-env exits code 1 before binding, tsc --noEmit reports zero errors, the instanceof check passes, the HTTP mapping is correct, and the redaction test passes.
| Failure class | Detection | Recovery |
|---|---|---|
| Missing dependency | The stated logger or a required package is not installed | Install it using the project's package manager. If installation fails, stop and report the missing dependency. |
| Invalid or missing env var | Env schema validation throws at import time | Process exits code 1 with descriptive message listing the missing or invalid vars. Do not start the server. |
| Unredacted log | Secret value appears unredacted in log output | Halt: the redaction serializer is misconfigured. Fix the field-name list before proceeding. |
| Unmapped error | A catalogue entry has no matching subclass or HTTP status | Add the missing subclass or factory. Every catalogue entry must have a working instanceof check and HTTP mapping. |
| Type error on tsc --noEmit | Compiler emits diagnostics | Fix the type errors. Do not suppress with @ts-ignore or any. |
| Partial write on rollback | Some files written, others not | Use the recorded rollback path: git checkout -- <written files> or delete the listed untracked files. |
Local named files: src/env.ts (validated env schema), src/logger.ts (structured JSON logger with redaction), src/errors.ts (typed ServiceError base and subclasses with instanceof and HTTP mapping), tsconfig.json (strict type-stripping config), package.json (ESM, engines, scripts). All reversible via the stated rollback path. The Done proof covers startup logs, invalid-env failure, tsc, instanceof, HTTP mapping, and redaction.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
15 skills in this plugin
/eslint-to-biome-migrationUse when migrating a JavaScript or TypeScript project from ESLint, Prettier, Standard, or mixed legacy lint configuration to Biome 2.5./fastify-inject-testingUse when asked to test Fastify applications without network sockets. Not for building the app: use fastify-schema-first-service./fastify-production-hardeningUse when asked to prepare a Fastify service for production load and exposure. Not for building the app: use fastify-schema-first-service.npx claudepluginhub outlinedriven/odin-claude-plugin --plugin odin-typescriptOther plugins' skills for the same job