nestjs-performance
Optimize NestJS throughput with Fastify adapter, singleton scope enforcement, compression, and query projections. Use when switching to Fastify, diagnosing request-scoped bottlenecks, or profiling API overhead.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 3
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 79d17eb766c6b7f8… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Performance Tuning
Priority: P1 (HIGH)
Workflow: Performance Audit
- Switch to Fastify — Replace Express with
FastifyAdapterfor ~2x throughput. - Enable compression — Add Gzip/Brotli middleware.
- Audit provider scopes — Ensure no unintended
REQUESTscope chains. - Add query projections — Use
select: []on all repository queries. - Profile overhead — Benchmark Total Duration, DB Execution, and API Overhead.
Fastify + Compression Setup
- Keep-Alive: Configure
http.Agentkeep-alive settings to reuse TCP connections for upstream services.
Scope & Dependency Injection
- Default Scope: Adhere to
SINGLETONscope (default). - Request Scope: AVOID
REQUESTscope unless absolutely necessary. - Pro Tip: single request-scoped service makes its entire injection chain request-scoped.
- Solution: Use Durable Providers (
durable: true) for multi-tenancy. - Lazy Loading: Use
LazyModuleLoaderfor heavyweight modules (e.g., Admin panels).
Caching Strategy
- Application Cache: Use
@nestjs/cache-managerfor computation results. - Deep Dive: See Caching & Redis for L1/L2 strategies and Invalidation patterns.
- HTTP Cache: Set
Cache-Controlheaders for client-side caching (CDN/Browser). - Distributed: In microservices, use Redis store, not memory store.
Queues & Async Processing
- Offloading: Never block HTTP request for long-running tasks (Emails, Reports, webhooks).
- Tool: Use
@nestjs/bull(BullMQ) or RabbitMQ (@nestjs/microservices). - Pattern: Producer (Controller) -> Queue -> Consumer (Processor).
Serialization
- Warning:
class-transformerCPU expensive. - Optimization: For high-throughput READ endpoints, consider manual mapping or using
fast-json-stringify(built-in fastify serialization) instead of interceptors.
Database Tuning
- Projections: Always use
select: []to fetch only needed columns. - N+1: Prevent N+1 queries by using
relationscarefully orDataLoaderfor Graph/Field resolvers. - Connection Pooling: Configure pool size (e.g.,
pool: { min: 2, max: 10 }) in config to match DB limits.
Profiling & Scaling
- API Overhead vs DB Execution: Use "Execution Bucket" strategy to continuously benchmark
Total Duration,DB Execution Time, andAPI Overhead. - Total Baseline: Excellent (< 50ms), Acceptable (< 200ms), Poor (> 500ms). Exception: Authentication routes (e.g. bcrypt/argon2) should take 300-500ms intentionally.
- DB Execution Baseline: Excellent (< 5ms), Acceptable (< 30ms), Poor (> 100ms - implies missing index or N+1 problem).
- API Overhead Baseline: Excellent (< 20ms), Poor (> 100ms - implies heavy synchronous processing or serialization blocking Node's event loop).
- Offloading: Move CPU-heavy tasks (Image processing, Crypto) to
worker_threads. - Clustering: For non-containerized environments, use
ClusterModuleto utilize all CPU cores. In K8s, prefer ReplicaSets.
Anti-Patterns
- No REQUEST scope without evaluation: One REQUEST-scoped provider makes entire chain request-scoped.
- No CPU tasks in HTTP handler: Offload image/crypto work to
worker_threadsor BullMQ. - No unprojected queries: Always
select: []needed columns to avoid serializing unused data.
Files
3- SKILL.md
468a037e103.8 KB - evals/evals.json
38def4a3732.2 KB - references/example.md
a4b01f239f430 B
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from HoangNguyen0403/agent-skills-standard8
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci
Configure release signing, R8 obfuscation, and App Bundle publishing for Android. Use when setting up signing configs, enabling minification, adding ProGuard keep rules, or preparing for Play Store submission.
Enforce Material Design 3 theming and design token usage in Jetpack Compose. Use when implementing M3 components, color schemes, typography, or design tokens.
Related backend skillsscan passed
PostHog integration for server-side Node.js applications using posthog-node
REST API design patterns including resource naming, status codes, pagination, filtering, error responses, versioning, and rate limiting for production APIs. Use when designing or reviewing REST endpoints, resource names, status codes, pagination, or versioning.
Report browser/API/CLI/job/worker/webhook bugs. (gstack)
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides
Guide for upgrading Stripe API versions, webhook endpoints, server-side SDKs, Stripe.js, and mobile SDKs
Create and compose tRPC middleware with t.procedure.use(), extend context via opts.next({ ctx }), build reusable middleware with .concat() and .unstable_pipe(), define base procedures like publicProcedure and authedProcedure. Access raw input with getRawInput(). Logging, timing, OTEL tracing pattern