Nodejs Backend Patterns
ever-works/ever-works
Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices.
Full Sentry SDK setup for NestJS. An agent skill from getsentry/sentry-for-ai.
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdk --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .claude/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .claude/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdkType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdk --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .agents/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .agents/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdk --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .cursor/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .cursor/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/getsentry/sentry-for-ai.git --path skills-legacy/sentry-nestjs-sdk--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdk --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .gemini/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .gemini/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdkInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .github/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .github/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install getsentry/sentry-for-ai sentry-nestjs-sdk --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/getsentry/sentry-for-ai.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills-legacy/sentry-nestjs-sdk .opencode/skills/sentry-nestjs-sdk && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "sentry-nestjs-sdk" agent skill from https://github.com/getsentry/sentry-for-ai/tree/main/skills-legacy/sentry-nestjs-sdk into .opencode/skills/sentry-nestjs-sdk/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sentry-nestjs-sdk", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
sentry-nestjs-sdkFull Sentry SDK setup for NestJS. An agent skill from getsentry/sentry-for-ai.
Sentry Nestjs SDK is an agent skill from getsentry/sentry-for-ai, published by the product's own GitHub organization. Full Sentry SDK setup for NestJS. Use when asked to "add Sentry to NestJS", "install @sentry/nestjs", "setup Sentry in NestJS", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for NestJS applications. Supports Express and Fastify adapters, GraphQL, microservices, WebSockets, and background jobs.
Its SKILL.md is about 8.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files (for example `references/ai-monitoring.md`, `references/crons.md` and `references/error-monitoring.md`).
It sits in Backend & APIs, covering Microservices, Background jobs and Scheduled and recurring tasks. It works with Sentry, NestJS, Fastify and GraphQL. The repository describes itself as: Teach your AI coding assistant how to use Sentry - setup, debugging, alerts, and more. The licence is Apache-2.0.
4 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit d8fd106. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmnodenpxFrom the folder's file list and the shell code blocks in SKILL.md.
Hosts in commands or code, which the agent is likely to contact:
docs.sentry.ioAlso links to:
github.comFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
SENTRY_PROXY_TOKENSENTRY_AUTH_TOKENFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Sentry Nestjs SDK loads about 8.7k tokens when it runs, and up to ~32k if it reads all its reference files. Until then it costs about 90 tokens; SKILL.md has 1,823 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from getsentry/sentry-for-ai at commit d8fd106, republished under its Apache-2.0 licence (© getsentry). 1,823 words, ~8,744 tokens.
.claude/skills/sentry-nestjs-sdk/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.All Skills > SDK Setup > NestJS SDK
Opinionated wizard that scans your NestJS project and guides you through complete Sentry setup.
@sentry/nestjs or Sentry + NestJSNote: SDK versions and APIs below reflect
@sentry/nestjs10.x (NestJS 8–11 supported). Always verify against docs.sentry.io/platforms/node/guides/nestjs/ before implementing.
Run these commands to understand the project before making recommendations:
# Confirm NestJS project
grep -E '"@nestjs/core"' package.json 2>/dev/null
# Check NestJS version
node -e "console.log(require('./node_modules/@nestjs/core/package.json').version)" 2>/dev/null
# Check existing Sentry
grep -i sentry package.json 2>/dev/null
ls src/instrument.ts 2>/dev/null
grep -r "Sentry.init\|@sentry" src/main.ts src/instrument.ts 2>/dev/null
# Check for existing Sentry DI wrapper (common in enterprise NestJS)
grep -rE "SENTRY.*TOKEN|SentryProxy|SentryService" src/ libs/ 2>/dev/null
# Check for config-class-based init (vs env-var-based)
grep -rE "class SentryConfig|SentryConfig" src/ libs/ 2>/dev/null
# Check if SentryModule.forRoot() is already registered in a shared module
grep -rE "SentryModule\.forRoot|SentryProxyModule" src/ libs/ 2>/dev/null
# Detect HTTP adapter (default is Express)
grep -E "FastifyAdapter|@nestjs/platform-fastify" package.json src/main.ts 2>/dev/null
# Detect GraphQL
grep -E '"@nestjs/graphql"|"apollo-server"' package.json 2>/dev/null
# Detect microservices
grep '"@nestjs/microservices"' package.json 2>/dev/null
# Detect WebSockets
grep -E '"@nestjs/websockets"|"socket.io"' package.json 2>/dev/null
# Detect task queues / scheduled jobs
grep -E '"@nestjs/bull"|"@nestjs/bullmq"|"@nestjs/schedule"|"bullmq"|"bull"' package.json 2>/dev/null
# Detect databases
grep -E '"@prisma/client"|"typeorm"|"mongoose"|"pg"|"mysql2"' package.json 2>/dev/null
# Detect AI libraries
grep -E '"openai"|"@anthropic-ai"|"langchain"|"@langchain"|"@google/generative-ai"|"ai"' package.json 2>/dev/null
# Check for companion frontend
ls -d ../frontend ../web ../client ../ui 2>/dev/nullWhat to note:
@sentry/nestjs already installed? If yes, check if instrument.ts exists and Sentry.init() is called — may just need feature config.SENTRY_PROXY_TOKEN) for testability. Use the injected proxy for all runtime Sentry calls (startSpan, captureException, withIsolationScope) instead of importing @sentry/nestjs directly in controllers, services, and processors. Only instrument.ts should import @sentry/nestjs directly.Sentry.init() options (e.g. loaded from YAML or @nestjs/config). Any new SDK options must be added to the config type — do not hardcode values that should be configurable per environment.SentryModule.forRoot() already registered? → If it's in a shared module (e.g. a Sentry proxy module), do not add it again in AppModule — this causes duplicate interceptor registration.SentryGlobalFilter handles it natively.@nestjs/schedule? → Recommend crons.prismaIntegration().Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation:
Always recommended (core coverage):
Recommend when detected:
@sentry/profiling-node)@nestjs/schedule, Bull, or BullMQ detectedRecommendation matrix:
| Feature | Recommend when... | Reference |
|---|---|---|
| Error Monitoring | Always — non-negotiable baseline | ${SKILL_ROOT}/references/error-monitoring.md |
| Tracing | Always — NestJS lifecycle is auto-instrumented | ${SKILL_ROOT}/references/tracing.md |
| Profiling | Production + CPU-sensitive workloads | ${SKILL_ROOT}/references/profiling.md |
| Logging | Always; enhanced for structured log aggregation | ${SKILL_ROOT}/references/logging.md |
| Metrics | Custom business KPIs or SLO tracking | ${SKILL_ROOT}/references/metrics.md |
| Crons | @nestjs/schedule, Bull, or BullMQ detected | ${SKILL_ROOT}/references/crons.md |
| AI Monitoring | OpenAI/Anthropic/LangChain/etc. detected | ${SKILL_ROOT}/references/ai-monitoring.md |
Propose: "I recommend Error Monitoring + Tracing + Logging. Want Profiling, Crons, or AI Monitoring too?"
# Core SDK (always required — includes @sentry/node)
npm install @sentry/nestjs
# With profiling support (optional)
npm install @sentry/nestjs @sentry/profiling-node⚠️ Do NOT install
@sentry/nodealongside@sentry/nestjs—@sentry/nestjsre-exports everything from@sentry/node. Installing both causes duplicate registration.
NestJS requires a specific three-file initialization pattern because the Sentry SDK must patch Node.js modules (via OpenTelemetry) before NestJS loads them.
Before creating new files, check Phase 1 results:
- If
instrument.tsalready exists → modify it, don't create a new one.- If a config class drives
Sentry.init()→ read options from the config instead of hardcoding env vars.- If a Sentry DI wrapper exists → use it for runtime calls instead of importing
@sentry/nestjsdirectly in services/controllers.
src/instrument.tsimport * as Sentry from "@sentry/nestjs";
// Optional: add profiling
// import { nodeProfilingIntegration } from "@sentry/profiling-node";
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENVIRONMENT ?? "production",
release: process.env.SENTRY_RELEASE,
// Data collection (SDK ≥ 10.57.0 — replaces deprecated sendDefaultPii)
dataCollection: {
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
// https://docs.sentry.io/platforms/javascript/guides/nestjs/configuration/options/#dataCollection
// userInfo: false,
// httpBodies: [],
},
// Tracing — lower to 0.1–0.2 in high-traffic production
tracesSampleRate: 1.0,
// Profiling (requires @sentry/profiling-node)
// integrations: [nodeProfilingIntegration()],
// profileSessionSampleRate: 1.0,
// profileLifecycle: "trace",
// Structured logs (SDK ≥ 9.41.0)
enableLogs: true,
});Config-driven Sentry.init(): If Phase 1 found a typed config class (e.g. SentryConfig), read options from it instead of using raw process.env. This is common in NestJS apps that use @nestjs/config or custom config loaders:
import * as Sentry from "@sentry/nestjs";
import { loadConfiguration } from "./config";
const config = loadConfiguration();
Sentry.init({
dsn: config.sentry.dsn,
environment: config.sentry.environment ?? "production",
release: config.sentry.release,
dataCollection: config.sentry.dataCollection ?? {
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
// https://docs.sentry.io/platforms/javascript/guides/nestjs/configuration/options/#dataCollection
// userInfo: false,
// httpBodies: [],
},
tracesSampleRate: config.sentry.tracesSampleRate ?? 1.0,
profileSessionSampleRate: config.sentry.profilesSampleRate ?? 1.0,
profileLifecycle: "trace",
enableLogs: true,
});When adding new SDK options (e.g. dataCollection, profileSessionSampleRate), add them to the config type so they can be configured per environment.
instrument.ts FIRST in src/main.ts// instrument.ts MUST be the very first import — before NestJS or any other module
import "./instrument";
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Enable graceful shutdown — flushes Sentry events on SIGTERM/SIGINT
app.enableShutdownHooks();
await app.listen(3000);
}
bootstrap();Why first? OpenTelemetry must monkey-patch
http,express, database drivers, and other modules before they load. Any module that loads beforeinstrument.tswill not be auto-instrumented.
SentryModule and SentryGlobalFilter in src/app.module.tsimport { Module } from "@nestjs/common";
import { APP_FILTER } from "@nestjs/core";
import { SentryModule, SentryGlobalFilter } from "@sentry/nestjs/setup";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
@Module({
imports: [
SentryModule.forRoot(), // Registers SentryTracingInterceptor globally
],
controllers: [AppController],
providers: [
AppService,
{
provide: APP_FILTER,
useClass: SentryGlobalFilter, // Captures all unhandled exceptions
},
],
})
export class AppModule {}What each piece does:
SentryModule.forRoot() — registers SentryTracingInterceptor as a global APP_INTERCEPTOR, enabling HTTP transaction namingSentryGlobalFilter — extends BaseExceptionFilter; captures exceptions across HTTP, GraphQL (rethrows HttpException without reporting), and RPC contexts⚠️ Do NOT register
SentryModule.forRoot()twice. If Phase 1 found it already imported in a shared library module (e.g. aSentryProxyModuleorAnalyticsModule), do not add it again inAppModule. Duplicate registration causes every span to be intercepted twice, bloating trace data.
⚠️ Two entrypoints, different imports:
@sentry/nestjs→ SDK init, capture APIs, decorators (SentryTraced,SentryCron,SentryExceptionCaptured)@sentry/nestjs/setup→ NestJS DI constructs (SentryModule,SentryGlobalFilter)Never import
SentryModulefrom@sentry/nestjs(main entrypoint) — it loads@nestjs/commonbefore OpenTelemetry patches it, breaking auto-instrumentation.
For ESM applications, use --import instead of a file import:
// instrument.mjs
import * as Sentry from "@sentry/nestjs";
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
});// package.json
{
"scripts": {
"start": "node --import ./instrument.mjs -r ts-node/register src/main.ts"
}
}Or via environment:
NODE_OPTIONS="--import ./instrument.mjs" npm run startChoose the approach that fits your existing architecture:
SentryGlobalFilter (recommended)Already covered in Step 3 above. This is the simplest option.
@SentryExceptionCaptured() decoratorimport { Catch, ExceptionFilter, ArgumentsHost } from "@nestjs/common";
import { SentryExceptionCaptured } from "@sentry/nestjs";
@Catch()
export class YourExistingFilter implements ExceptionFilter {
@SentryExceptionCaptured() // Wraps catch() to auto-report exceptions
catch(exception: unknown, host: ArgumentsHost): void {
// Your existing error handling continues unchanged
}
}import { ArgumentsHost, Catch } from "@nestjs/common";
import { BaseExceptionFilter } from "@nestjs/core";
import * as Sentry from "@sentry/nestjs";
@Catch(ExampleException)
export class ExampleExceptionFilter extends BaseExceptionFilter {
catch(exception: ExampleException, host: ArgumentsHost) {
Sentry.captureException(exception);
super.catch(exception, host);
}
}import { Catch, RpcExceptionFilter, ArgumentsHost } from "@nestjs/common";
import { Observable, throwError } from "rxjs";
import { RpcException } from "@nestjs/microservices";
import * as Sentry from "@sentry/nestjs";
@Catch(RpcException)
export class SentryRpcFilter implements RpcExceptionFilter<RpcException> {
catch(exception: RpcException, host: ArgumentsHost): Observable<any> {
Sentry.captureException(exception);
return throwError(() => exception.getError());
}
}@SentryTraced(op?) — Instrument any methodimport { Injectable } from "@nestjs/common";
import { SentryTraced } from "@sentry/nestjs";
@Injectable()
export class OrderService {
@SentryTraced("order.process")
async processOrder(orderId: string): Promise<void> {
// Automatically wrapped in a Sentry span
}
@SentryTraced() // Defaults to op: "function"
async fetchInventory() { ... }
}@SentryCron(slug, config?) — Monitor scheduled jobsimport { Injectable } from "@nestjs/common";
import { Cron } from "@nestjs/schedule";
import { SentryCron } from "@sentry/nestjs";
@Injectable()
export class ReportService {
@Cron("0 * * * *")
@SentryCron("hourly-report", {
// @SentryCron must come AFTER @Cron
schedule: { type: "crontab", value: "0 * * * *" },
checkinMargin: 2, // Minutes before marking missed
maxRuntime: 10, // Max runtime in minutes
timezone: "UTC",
})
async generateReport() {
// Check-in sent automatically on start/success/failure
}
}Background jobs share the default isolation scope — wrap with Sentry.withIsolationScope() to prevent cross-contamination:
import * as Sentry from "@sentry/nestjs";
import { Injectable } from "@nestjs/common";
import { Cron, CronExpression } from "@nestjs/schedule";
@Injectable()
export class JobService {
@Cron(CronExpression.EVERY_HOUR)
handleCron() {
Sentry.withIsolationScope(() => {
Sentry.setTag("job", "hourly-sync");
this.doWork();
});
}
}Apply withIsolationScope to: @Cron(), @Interval(), @OnEvent(), @Processor(), and any code outside the request lifecycle.
Some NestJS projects wrap Sentry behind a dependency injection token (e.g. SENTRY_PROXY_TOKEN) for testability and decoupling. If Phase 1 detected this pattern, use the injected service for all runtime Sentry calls — do not import @sentry/nestjs directly in controllers, services, or processors.
import { Controller, Inject } from "@nestjs/common";
import { SENTRY_PROXY_TOKEN, type SentryProxyService } from "./sentry-proxy";
@Controller("orders")
export class OrderController {
constructor(
@Inject(SENTRY_PROXY_TOKEN) private readonly sentry: SentryProxyService,
private readonly orderService: OrderService,
) {}
@Post()
async createOrder(@Body() dto: CreateOrderDto) {
return this.sentry.startSpan(
{ name: "createOrder", op: "http" },
async () => this.orderService.create(dto),
);
}
}Where direct @sentry/nestjs import is still correct:
instrument.ts — always uses import * as Sentry from "@sentry/nestjs" for Sentry.init()Add a test endpoint to confirm events reach Sentry:
import { Controller, Get } from "@nestjs/common";
import * as Sentry from "@sentry/nestjs";
@Controller()
export class DebugController {
@Get("/debug-sentry")
triggerError() {
throw new Error("My first Sentry error from NestJS!");
}
@Get("/debug-sentry-span")
triggerSpan() {
return Sentry.startSpan({ op: "test", name: "NestJS Test Span" }, () => {
return { status: "span created" };
});
}
}Hit GET /debug-sentry and check the Sentry Issues dashboard within seconds.
Walk through features one at a time. Load the reference, follow its steps, verify before moving on:
| Feature | Reference file | Load when... |
|---|---|---|
| Error Monitoring | ${SKILL_ROOT}/references/error-monitoring.md | Always (baseline) |
| Tracing | ${SKILL_ROOT}/references/tracing.md | Always (NestJS routes are auto-traced) |
| Profiling | ${SKILL_ROOT}/references/profiling.md | CPU-intensive production apps |
| Logging | ${SKILL_ROOT}/references/logging.md | Structured log aggregation needed |
| Metrics | ${SKILL_ROOT}/references/metrics.md | Custom KPIs / SLO tracking |
| Crons | ${SKILL_ROOT}/references/crons.md | Scheduled jobs or task queues |
| AI Monitoring | ${SKILL_ROOT}/references/ai-monitoring.md | OpenAI/Anthropic/LangChain detected |
For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.
Sentry.init() Options| Option | Type | Default | Purpose |
|---|---|---|---|
dsn | string | — | SDK disabled if empty; env: SENTRY_DSN |
environment | string | "production" | e.g., "staging"; env: SENTRY_ENVIRONMENT |
release | string | — | e.g., "myapp@1.0.0"; env: SENTRY_RELEASE |
dataCollection | object | See below | Controls what data the SDK collects (SDK ≥ 10.57.0) |
dataCollection.userInfo | boolean | true | Include IP addresses and user context |
dataCollection.httpHeaders | object | See below | Capture HTTP headers for requests/responses |
dataCollection.cookies | boolean|object | true | Capture cookies; use {allow: [...]} or {deny: [...]} for filtering |
dataCollection.queryParams | boolean|object | true | Capture URL query parameters; use {allow: [...]} or {deny: [...]} for filtering |
dataCollection.genAI | object | See below | Control AI input/output recording |
sendDefaultPii | boolean | false | Deprecated — use dataCollection.userInfo instead |
tracesSampleRate | number | — | Transaction sample rate; undefined disables tracing |
tracesSampler | function | — | Custom per-transaction sampling (overrides rate) |
tracePropagationTargets | Array<string|RegExp> | — | URLs to propagate sentry-trace/baggage headers to |
profileSessionSampleRate | number | — | Continuous profiling session rate (SDK ≥ 10.27.0) |
profileLifecycle | "trace"|"manual" | "trace" | "trace" = auto-start profiler with spans; "manual" = call startProfiler()/stopProfiler() |
enableLogs | boolean | false | Send structured logs to Sentry (SDK ≥ 9.41.0) |
ignoreErrors | Array<string|RegExp> | [] | Error message patterns to suppress |
ignoreTransactions | Array<string|RegExp> | [] | Transaction name patterns to suppress |
beforeSend | function | — | Hook to mutate or drop error events |
beforeSendTransaction | function | — | Hook to mutate or drop transaction events |
beforeSendLog | function | — | Hook to mutate or drop log events |
debug | boolean | false | Verbose SDK debug output |
maxBreadcrumbs | number | 100 | Max breadcrumbs per event |
dataCollection defaults:
httpHeaders: { request: true, response: true }httpBodies: ["incomingRequest", "outgoingRequest", "incomingResponse", "outgoingResponse"]userInfo: truegenAI: { inputs: true, outputs: true }| Variable | Maps to | Notes |
|---|---|---|
SENTRY_DSN | dsn | Used if dsn not passed to init() |
SENTRY_RELEASE | release | Also auto-detected from git SHA, Heroku, CircleCI |
SENTRY_ENVIRONMENT | environment | Falls back to "production" |
SENTRY_AUTH_TOKEN | CLI/source maps | For npx @sentry/wizard@latest -i sourcemaps |
SENTRY_ORG | CLI/source maps | Organization slug |
SENTRY_PROJECT | CLI/source maps | Project slug |
These integrations activate automatically when their packages are detected — no integrations: [...] needed:
| Auto-enabled | Notes |
|---|---|
httpIntegration | Outgoing HTTP calls via http/https/fetch |
expressIntegration | Express adapter (default NestJS) |
nestIntegration | NestJS lifecycle (middleware, guards, pipes, interceptors, handlers) |
onUncaughtExceptionIntegration | Uncaught exceptions |
onUnhandledRejectionIntegration | Unhandled promise rejections |
openAIIntegration | OpenAI SDK (when installed) |
anthropicAIIntegration | Anthropic SDK (when installed) |
langchainIntegration | LangChain (when installed) |
graphqlIntegration | GraphQL (when graphql package present) |
postgresIntegration | pg driver |
mysqlIntegration | mysql / mysql2 |
mongoIntegration | MongoDB / Mongoose |
redisIntegration | ioredis / redis |
| Integration | When to add | Code |
|---|---|---|
nodeProfilingIntegration | Profiling desired | import { nodeProfilingIntegration } from "@sentry/profiling-node" |
prismaIntegration | Prisma ORM used | integrations: [Sentry.prismaIntegration()] |
consoleLoggingIntegration | Capture console output | integrations: [Sentry.consoleLoggingIntegration()] |
localVariablesIntegration | Capture local var values in errors | integrations: [Sentry.localVariablesIntegration()] |
Test that Sentry is receiving events:
// Add a test endpoint (remove before production)
@Get("/debug-sentry")
getError() {
throw new Error("My first Sentry error!");
}Or send a test message without crashing:
import * as Sentry from "@sentry/nestjs";
Sentry.captureMessage("NestJS Sentry SDK test");If nothing appears:
debug: true in Sentry.init() — prints SDK internals to stdoutSENTRY_DSN env var is set in the running processimport "./instrument" is the first line in main.tsSentryModule.forRoot() is imported in AppModulehttps://<key>@o<org>.ingest.sentry.io/<project>After completing NestJS setup, check for a companion frontend missing Sentry:
ls -d ../frontend ../web ../client ../ui 2>/dev/null
cat ../frontend/package.json ../web/package.json 2>/dev/null \
| grep -E '"react"|"svelte"|"vue"|"next"|"nuxt"'If a frontend exists without Sentry, suggest the matching skill:
| Frontend detected | Suggest skill |
|---|---|
| Next.js | sentry-nextjs-sdk |
| React | sentry-react-sdk |
| Svelte / SvelteKit | sentry-svelte-sdk |
| Vue / Nuxt | Use @sentry/vue — see docs.sentry.io/platforms/javascript/guides/vue/ |
| React Native / Expo | sentry-react-native-sdk |
| Issue | Solution |
|---|---|
| Events not appearing | Set debug: true, verify SENTRY_DSN, check instrument.ts is imported first |
| Malformed DSN error | Format: https://<key>@o<org>.ingest.sentry.io/<project> |
| Exceptions not captured | Ensure SentryGlobalFilter is registered via APP_FILTER in AppModule |
| Auto-instrumentation not working | instrument.ts must be the first import in main.ts — before all NestJS imports |
| Profiling not starting | Requires tracesSampleRate > 0 + profileSessionSampleRate > 0 + @sentry/profiling-node installed |
enableLogs not working | Requires SDK ≥ 9.41.0 |
| No traces appearing | Verify tracesSampleRate is set (not undefined) |
| Too many transactions | Lower tracesSampleRate or use tracesSampler to drop health checks |
| Fastify + GraphQL issues | Known edge cases — see GitHub #13388; prefer Express for GraphQL |
| Background job events mixed | Wrap job body in Sentry.withIsolationScope(() => { ... }) |
| Prisma spans missing | Add integrations: [Sentry.prismaIntegration()] to Sentry.init() |
| ESM syntax errors | Set registerEsmLoaderHooks: false (disables ESM hooks; also disables auto-instrumentation for ESM modules) |
SentryModule breaks instrumentation | Must import from @sentry/nestjs/setup, never from @sentry/nestjs |
| RPC exceptions not captured | Add dedicated SentryRpcExceptionFilter (see Option D in exception filter section) |
| WebSocket exceptions not captured | Use @SentryExceptionCaptured() on gateway handleConnection/handleDisconnect |
@SentryCron not triggering | Decorator order matters — @SentryCron MUST come after @Cron |
| TypeScript path alias issues | Ensure tsconfig.json paths are configured so instrument resolves from main.ts location |
import * as Sentry ESLint error | Many projects ban namespace imports. Use named imports (import { startSpan, captureException } from "@sentry/nestjs") or use the project's DI proxy instead |
profilesSampleRate vs profileSessionSampleRate | profilesSampleRate is deprecated in SDK 10.x. Use profileSessionSampleRate + profileLifecycle: "trace" instead |
| Duplicate spans on every request | SentryModule.forRoot() registered in multiple modules. Ensure it's only called once — check shared/library modules |
Config property not recognized in instrument.ts | When using a typed config class, new SDK options must be added to the config type definition and the project rebuilt before TypeScript recognizes them |
| Feature | Minimum SDK Version |
|---|---|
@sentry/nestjs package | 8.0.0 |
@SentryTraced decorator | 8.15.0 |
@SentryCron decorator | 8.16.0 |
| Event Emitter auto-instrumentation | 8.39.0 |
SentryGlobalFilter (unified) | 8.40.0 |
Sentry.logger API (enableLogs) | 9.41.0 |
profileSessionSampleRate | 10.27.0 |
| Node.js requirement | ≥ 18 |
Node.js for ESM --import | ≥ 18.19.0 |
| NestJS compatibility | 8.x – 11.x |
© getsentry, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 7 other files (references) in skills-legacy/sentry-nestjs-sdk of getsentry/sentry-for-ai.
Open the folder on GitHubat commit d8fd106
Sentry Nestjs SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Sentry Nestjs SDK this skillgetsentry/sentry-for-ai | 268 | — | ~8.7k | Automated safety check: Pass | Apache-2.0 | |
| Nodejs Backend Patternsever-works/ever-works | 158 | 17 repos | ~4k | Automated safety check: Pass | AGPL-3.0 | |
| Senior Backendalirezarezvani/claude-skills | 28k | 1 repos | ~3.8k | Automated safety check: Pass | MIT | |
| Nestjsgiuseppe-trisciuoglio/developer-kit | 355 | — | ~1.4k | Automated safety check: Notes | MIT | |
| Nestjs Features Performanceaiskillstore/marketplace | 430 | — | ~3.8k | Automated safety check: Pass | MIT | |
| GraphQL ArchitectJeffallan/claude-skills | 12k | 1 repos | ~1.3k | Automated safety check: Pass | MIT |
ever-works/ever-works
Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices.
alirezarezvani/claude-skills
Designs and implements backend systems including REST APIs, microservices, database architectures, authentication flows, and security hardening.
giuseppe-trisciuoglio/developer-kit
Provides comprehensive NestJS framework patterns with Drizzle ORM integration for building scalable server-side applications.
aiskillstore/marketplace
Selects and implements NestJS runtime features, error and API contracts, security, testing, DevOps, performance, and safe scale.
Jeffallan/claude-skills
Designs GraphQL schemas and Apollo Federation graphs, with DataLoader resolvers, subscriptions, query complexity limits and caching.
twentyhq/twenty
Registers a new syncable entity in three NestJS modules and adds its service and GraphQL resolver layers when contributing to the Twenty server.
getsentry/sentry-for-ai
Full Sentry SDK setup for Elixir. An agent skill from getsentry/sentry-for-ai.
getsentry/sentry-for-ai
Full Sentry SDK setup for Go. An agent skill from getsentry/sentry-for-ai.
getsentry/sentry-for-ai
Full Sentry SDK setup for Next.js. An agent skill from getsentry/sentry-for-ai.
getsentry/sentry-for-ai
Full Sentry SDK setup for PHP. An agent skill from getsentry/sentry-for-ai.
getsentry/sentry-for-ai
Full Sentry SDK setup for Python. An agent skill from getsentry/sentry-for-ai.
getsentry/sentry-for-ai
Full Sentry SDK setup for React Router Framework mode. An agent skill from getsentry/sentry-for-ai.
Categories
Full Sentry SDK setup for NestJS. An agent skill from getsentry/sentry-for-ai. Sentry Nestjs SDK is an agent skill from getsentry/sentry-for-ai, published by the product's own GitHub organization. Full Sentry SDK setup for NestJS.
Sentry Nestjs SDK fits situations like: asked to add Sentry to NestJS; install @sentry/nestjs; setup Sentry in NestJS; configure error monitoring.
Run `npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a claude-code`. Or copy the skill folder (skills-legacy/sentry-nestjs-sdk in getsentry/sentry-for-ai) into .claude/skills/sentry-nestjs-sdk in your project. Claude Code loads it when a task matches its description.
Run `npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a codex`. Or copy the skill folder (skills-legacy/sentry-nestjs-sdk in getsentry/sentry-for-ai) into .agents/skills/sentry-nestjs-sdk in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add getsentry/sentry-for-ai --skill sentry-nestjs-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sentry-nestjs-sdk, .gemini/skills/sentry-nestjs-sdk, .github/skills/sentry-nestjs-sdk and .opencode/skills/sentry-nestjs-sdk in your project.
Going by SKILL.md and its folder, Sentry Nestjs SDK needs the command-line tools its instructions call (npm, node and npx) and credentials named SENTRY_PROXY_TOKEN and SENTRY_AUTH_TOKEN. Our summary lists: Node.js; A credential in SENTRY_PROXY_TOKEN.
SKILL.md names 2 domains. In commands or code: docs.sentry.io; the agent is likely to contact it when it follows the instructions. As links in the text: github.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Sentry Nestjs SDK is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 8.7k tokens (SKILL.md is roughly 35k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 23k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Sentry Nestjs SDK: Nodejs Backend Patterns (ever-works/ever-works, 158 stars), Senior Backend (alirezarezvani/claude-skills, 28k stars), Nestjs (giuseppe-trisciuoglio/developer-kit, 355 stars) and Nestjs Features Performance (aiskillstore/marketplace, 430 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
getsentry (a GitHub organization, an official publisher) maintains it in getsentry/sentry-for-ai, which has 268 GitHub stars. The repository holds 32 skills in this directory. The repository was last updated on October 7, 2026.
Source: getsentry/sentry-for-ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.