skills/nestjs-wide-events/SKILL.md
Implement structured, wide-event logging in NestJS applications following the canonical log line / wide event pattern. Use this skill whenever the user asks about logging, observability, debugging, or tracing in a NestJS app. Also trigger when the user mentions log lines, structured logging, canonical log lines, wide events, request context, observability, or asks how to improve their NestJS logging setup. Use this even if the user just says "add logging" to a NestJS project, since the wide event pattern should be the default, not scattered console.log calls.
npx skillsauth add cmglezpdev/custom-skills nestjs-wide-eventsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Emit ONE context-rich structured JSON event per request per service, instead of scattering dozens of log lines across the codebase.
user_id, request_id, order_id with millions of unique values make debugging possible.WideEventInterceptor (global): Creates context at request start, emits the single event at request end.WideEventService (request-scoped): Holds the mutable event context. Any service/guard/pipe injects it to enrich the event.WideEventModule: Wires everything together. Import at root level.TailSampler: Decides whether to persist the event (always keeps errors, slow requests, VIP users).WideEventExceptionFilter (global): Enriches the event with error details before the interceptor emits.WideEventMiddleware: Resolves the request-scoped service and attaches it to the request object for the singleton interceptor.Request arrives
-> Middleware resolves request-scoped WideEventService, attaches to req
-> Interceptor seeds event with HTTP metadata, starts timer
-> Guards/pipes inject WideEventService, add user context
-> Controller/services inject WideEventService, add business context
-> Response or exception
-> ExceptionFilter catches errors, enriches event
-> Interceptor finalizes: duration, status, outcome
-> TailSampler decides: persist or drop
-> Single JSON event emitted
timestamp, request_id, trace_id, method, path, status_code, duration_ms, ip, user_agent, service, versionuser.id, user.subscription, user.role, user.org_idcart.*, payment.*error.type, error.code, error.message, error.retriabledb.query_count, db.total_ms, cache.hit, external_calls[]feature_flags.* as flat booleansoutcome (success|error|client_error), level (info|warn|error)REQUEST scope for WideEventService -- each request gets its own instance.logger.info(event). Services only enrich.AsyncLocalStorage when request-scoped DI is unavailable (queues, event handlers).user.id not userId, payment.latency_ms not paymentLatencyMs._ms suffix, always integers.console.log() / this.logger.log() through services.Read these only when you need implementation details for a specific area:
core-setup.md -- Full code for WideEventService, WideEventInterceptor, WideEventExceptionFilter, TailSampler, WideEventMiddleware, WideEventModule, and app bootstrap. Read this when setting up wide events from scratch.usage-examples.md -- How to enrich events from controllers, services, and auth guards. Read this when adding wide event enrichment to existing code.advanced-patterns.md -- AsyncLocalStorage bridge, queue/cron job pattern, and Pino integration. Read this for non-HTTP contexts or production logger setup.testing.md -- Unit tests for WideEventService and TailSampler. Read this when writing tests.core-setup.md for full component code.WideEventModule with all components, register at app root.WideEventService and call event.enrich({...}).TailSampler sampling rules.development
Add application-level Prometheus metrics to a NestJS app using the OpenTelemetry SDK and an OTel Collector. Covers HTTP RED metrics, Node.js runtime metrics, business metrics, and advanced observability patterns. Use this skill whenever the user wants to add metrics, dashboards, or monitoring to a NestJS application, mentions Prometheus, Grafana metrics, OpenTelemetry metrics, OTel Collector, or asks about SLIs/SLOs, or application-level monitoring in a NestJS context. Also trigger when the user wants custom counters, histograms, gauges, or summaries in NestJS. This skill focuses exclusively on metrics the APPLICATION must emit. It does not cover logging, tracing, infra-level metrics from cAdvisor, node-exporter, postgres-exporter, or redis-exporter.
development
How to create, update, and manage documentation for any software project. Use this skill whenever asked to add documentation, update docs, create a runbook, write an ADR, document a feature, add a product spec, write onboarding guides, or any documentation-related task. Also trigger when making behavior-changing code changes (features, fixes, refactors, integrations, infra changes) that require accompanying documentation updates — even if the user doesn't explicitly mention "docs".
development
Perform a comprehensive security and code quality audit on web-based projects (React, Next.js, NestJS). Uses the OWASP Top 10:2025 standard as the primary security framework. Generates a detailed Markdown report with findings categorized by severity (CRITICAL, HIGH, MEDIUM, LOW). Use this skill whenever the user asks to audit, review, scan, or analyze their codebase for vulnerabilities, security issues, code quality problems, bad patterns, or potential bugs. Also trigger when the user mentions "OWASP", "security review", "vulnerability scan", "code audit", "pentest review", "security assessment", "code health check", or asks "is my code secure?" or "find bugs in my project". Trigger even if the user just says "audit this" or "check my code" pointing at a web project. This skill supports React, Next.js, and NestJS projects, including monorepos containing multiple project types.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.