nodejs-backend

A guide to designing Node.js backends, the server-side programs that handle requests, data, and business rules. It covers framework choice, TypeScript, project structure, validation, errors, security, and deployment.

In plain words
What is it for?
Use it when building REST APIs, Express or Fastify servers, microservices, or server-side TypeScript, including decisions about architecture, validation, authentication-related middleware, and deployment.
Why use it?
It helps keep HTTP handling, business logic, and database access separate as a backend grows. It also guides framework choices based on the project's needs.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/iliaal/whetstone/nodejs-backend
Any agent
npx skills add iliaal/whetstone --skill nodejs-backend
Clone the repo
git clone --depth 1 https://github.com/iliaal/whetstone

Made for: Claude Code, Codex.

Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,048 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00050 $0.01048
Opus 5 $0.00025 $0.00524
Sonnet 5 $0.00010 $0.00210
Haiku 4.5 $0.00005 $0.00105

Measured 3d ago against content hash 899fb1fec22c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

nodejs-backend scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

distillery/generated-skills/nodejs-backend/SKILL.md · 97 lines

How it starts

The opening of the file, as written. The whole thing — 97 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Node.js Backend

Framework Selection

Context Choose Why
Edge/Serverless Hono Zero-dep, fastest cold starts
Performance API Fastify 2-3x faster than Express, built-in schema validation
Enterprise/team NestJS DI, decorators, structured conventions
Legacy/ecosystem Express Most middleware, widest adoption

Ask user: deployment target, cold start needs, team experience, existing codebase.

Architecture

src/
├── routes/          # HTTP: parse request, call service, format response
├── middleware/       # Auth, validation, rate limiting, logging
├── services/        # Business logic (no HTTP types)
├── repositories/    # Data access only (queries, ORM)
├── config/          # Env, DB pool, constants
└── types/           # Shared TypeScript interfaces
  • Routes never contain business logic
  • Services never import Request/Response
  • Repositories never throw HTTP errors
  • For scripts/prototypes: single file is fine — ask "will this grow?"

TypeScript Rules

  • Use import type { } for type-only imports — eliminates runtime overhead
  • Prefer interface for object shapes (2-5x faster type resolution than intersections)
  • Prefer unknown over any — forces explicit narrowing
  • Use z.infer<typeof Schema> as single source of truth — never duplicate types and schemas
  • Minimize as assertions — use type guards instead
  • Add explicit return types to exported functions (faster declaration emit)
  • Untyped package? declare module 'pkg' { const v: unknown; export default v; } in types/ambient.d.ts

Validation

Zod (TypeScript inference) or TypeBox (Fastify native). Validate at boundaries only: request entry, before DB ops, env vars at startup. Use .extend(), .pick(), .omit(), .partial(), .merge() for DRY schemas.

Error Handling

Custom error hierarchy: AppError(message, statusCode, isOperational)ValidationError(400), NotFoundError(404), UnauthorizedError(401), ForbiddenError(403), ConflictError(409)

Read the full file on GitHub · 97 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 97 lines · 50 tokens per session scan A 899fb1fec22c

Subscribe to this mod's changes

nodejs-backend is a skill published in the GitHub repository iliaal/whetstone (32 stars, last pushed 4d ago), licensed MIT. It adds 50 tokens to every session and 1,048 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.