Skip to content
Back to skills

Coding

ASecurity

Speed up Node.js services: profile first, then worker threads, streams with backpressure, ESM, structured logging and tracing. Use when a Node.js service is slow, blocks the event loop or uses too much memory.

  • 24 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 14, 2026
ai-agentsrustgonodenodejsapidatabasesecurityperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-coding-b166af44/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-coding-b166af44)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: performant-nodejs
description: "Speed up Node.js services: profile first, then worker threads, streams with backpressure, ESM, structured logging and tracing. Use when a Node.js service is slow, blocks the event loop or uses too much memory."
triggers: [nodejs, performance, scalability, worker threads, clustering, esm, observability, hexagonal architecture]
tags: [coding, nodejs, architecture]
context_cost: medium
---
# Performant Node.js Skill

## Goal
Build and maintain high-throughput, low-latency, and horizontally scalable Node.js systems using modern primitives and architectural patterns.

## Capabilities

### 1. Concurrency & Parallelism
- **Clustering**: Scale vertically by spawning a process per CPU core using the `cluster` module.
- **Worker Threads**: Offload CPU-intensive tasks (encryption, compression, heavy logic) to separate threads using `worker_threads` to avoid blocking the Event Loop.
- **Event Loop Management**: Prevent starvation by avoiding long-running synchronous operations and heavy JSON parsing on the main thread (for Node.js internals and Fastify see `nodejs-expert.skill`).

### 2. Modern Standards & Async
- **ES Modules (ESM)**: Favor ESM for new projects for better tree-shaking, top-level await, and future-proofing.
- **AsyncLocalStorage**: Use for context propagation (trace IDs, user sessions) across asynchronous boundaries without manual passing.
- **Concurrency Control**: Use libraries like `p-limit` or custom semaphores to prevent resource exhaustion when calling external APIs or databases.

### 3. High-Performance Streams
- **Backpressure Handling**: Efficiently stream large files or data sets using `stream.pipeline` to manage memory usage (see `file-processing.skill` for uploads and large files).
- **HTTP Streaming**: Implement streaming responses for real-time data processing and low TTFB (Time To First Byte).

### 4. Observability & Monitoring
- **Structured Logging**: Use `pino` for low-overhead, JSON-based logging.
- **GC Insight**: Monitor Garbage Collection pauses and memory leaks using `v8` and `inspector` modules.
- **Distributed Tracing**: Implement OpenTelemetry for cross-service visibility.

### 5. Architectural Patterns
- **Hexagonal Architecture (Ports & Adapters)**: Decouple business logic from external dependencies (DB, APIs) for better testability and evolution.
- **CQRS (Command Query Responsibility Segregation)**: Separate read and write models for performance optimization.
- **Outbox/Saga Patterns**: Ensure eventual consistency in distributed systems without distributed transactions.

### 6. Security & Hardening
- **Helmet**: Use for setting secure HTTP headers (CSP, HSTS, etc.).
- **Input Validation**: Mandatory use of `zod` or `ajv` for schema-first validation.
- **Graceful Shutdown**: Properly handle `SIGTERM` and `SIGINT` to close DB connections and finish in-flight requests.

## Steps
1. **Profile First**: Use `node --inspect` or `0x` to generate flamegraphs before any optimization.
2. **Standardize**: Ensure ESM is used and dependencies are audited using `npm audit`.
3. **Analyze Concurrency**: Determine if the bottleneck is CPU-bound (needs Workers) or I/O-bound (needs better async flow/caching).
4. **Implement Observability**: Add structured logs and basic metrics as the first step of any performance task.

## Output Format
- `BENCHMARK_REPORT_TEMPLATE.md`: Flamegraph analysis and latency baseline.
- `SCALABILITY_ANALYSIS_TEMPLATE.md`: Strategy for clustering, sharding, or worker usage.
- `ARCHITECTURE_REVIEW_TEMPLATE.md`: Standardized logging, tracing configuration, and architecture review.

## Constraints
- Profile first (`node --inspect` or `0x`); do not optimise code that is not shown to be a bottleneck.
- Never trust raw JSON; validate against a strict schema.

## Limits and safety
- Do not pass secrets or raw database connections to worker threads that run untrusted code.
- Validate input against a schema (`zod` or `ajv`) before piping it into the file system or any external sink.
- Rate-limit at the gateway or app level when scaling out.
- `cluster` processes and worker threads do not share memory: move in-process state (caches, sessions, rate-limit counters) to a shared store first.

Files in this skill

  • agent-trajectory-eval.skill.md5.7 KB
  • artisan-commands.skill.md3.7 KB
  • browser-tdd.skill.md7 KB
  • chaos-fault-injection.skill.md8.1 KB
  • ci-autofix.skill.md4.2 KB
  • clean-coder.skill.md4.5 KB
  • code-review.skill.md6.1 KB
  • debug.skill.md6.5 KB
  • documentation.skill.md7.3 KB
  • eval-driven-development.skill.md6.9 KB
  • evals/code-review.eval.yaml1 KB
  • excalidraw.skill.md3.7 KB
  • file-processing.skill.md4.3 KB
  • git-workflow.skill.md7.2 KB
  • metamorphic-testing.skill.md7.8 KB
  • mobile-dev.skill.md4.2 KB
  • nodejs-expert.skill.md1.6 KB
  • output-validation.skill.md5.4 KB
  • pbt-strategy.skill.md8 KB
  • performant-ai.skill.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.