Add Sentry v8 error tracking and performance monitoring to your project services. Use this skill when adding error handling, creating new controllers, instrumenting cron jobs, or tracking database performance. ALL ERRORS MUST BE CAPTURED TO SENTRY - no exceptions.
Enforces comprehensive Sentry v8 error tracking and performance monitoring across all services. Use when adding error handling, creating controllers, instrumenting cron jobs, or tracking database performance.
/plugin marketplace add moonklabs/aiwf/plugin install moonklabs-aiwf@moonklabs/aiwfThis skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill enforces comprehensive Sentry error tracking and performance monitoring across all your project services following Sentry v8 patterns.
ALL ERRORS MUST BE CAPTURED TO SENTRY - No exceptions. Never use console.error alone.
// ā
CORRECT - Use BaseController
import { BaseController } from '../controllers/BaseController';
export class MyController extends BaseController {
async myMethod() {
try {
// ... your code
} catch (error) {
this.handleError(error, 'myMethod'); // Automatically sends to Sentry
}
}
}
import * as Sentry from '@sentry/node';
router.get('/route', async (req, res) => {
try {
// ... your code
} catch (error) {
Sentry.captureException(error, {
tags: { route: '/route', method: 'GET' },
extra: { userId: req.user?.id }
});
res.status(500).json({ error: 'Internal server error' });
}
});
import { WorkflowSentryHelper } from '../workflow/utils/sentryHelper';
// ā
CORRECT - Use WorkflowSentryHelper
WorkflowSentryHelper.captureWorkflowError(error, {
workflowCode: 'DHS_CLOSEOUT',
instanceId: 123,
stepId: 456,
userId: 'user-123',
operation: 'stepCompletion',
metadata: { additionalInfo: 'value' }
});
#!/usr/bin/env node
// FIRST LINE after shebang - CRITICAL!
import '../instrument';
import * as Sentry from '@sentry/node';
async function main() {
return await Sentry.startSpan({
name: 'cron.job-name',
op: 'cron',
attributes: {
'cron.job': 'job-name',
'cron.startTime': new Date().toISOString(),
}
}, async () => {
try {
// Your cron job logic
} catch (error) {
Sentry.captureException(error, {
tags: {
'cron.job': 'job-name',
'error.type': 'execution_error'
}
});
console.error('[Job] Error:', error);
process.exit(1);
}
});
}
main()
.then(() => {
console.log('[Job] Completed successfully');
process.exit(0);
})
.catch((error) => {
console.error('[Job] Fatal error:', error);
process.exit(1);
});
import { DatabasePerformanceMonitor } from '../utils/databasePerformance';
// ā
CORRECT - Wrap database operations
const result = await DatabasePerformanceMonitor.withPerformanceTracking(
'findMany',
'UserProfile',
async () => {
return await PrismaService.main.userProfile.findMany({
take: 5,
});
}
);
import * as Sentry from '@sentry/node';
const result = await Sentry.startSpan({
name: 'operation.name',
op: 'operation.type',
attributes: {
'custom.attribute': 'value'
}
}, async () => {
// Your async operation
return await someAsyncOperation();
});
Use appropriate severity levels:
import * as Sentry from '@sentry/node';
Sentry.withScope((scope) => {
// ALWAYS include these if available
scope.setUser({ id: userId });
scope.setTag('service', 'form'); // or 'email', 'users', etc.
scope.setTag('environment', process.env.NODE_ENV);
// Add operation-specific context
scope.setContext('operation', {
type: 'workflow.start',
workflowCode: 'DHS_CLOSEOUT',
entityId: 123
});
Sentry.captureException(error);
});
Location: ./blog-api/src/instrument.ts
import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV || 'development',
integrations: [
nodeProfilingIntegration(),
],
tracesSampleRate: 0.1,
profilesSampleRate: 0.1,
});
Key Helpers:
WorkflowSentryHelper - Workflow-specific errorsDatabasePerformanceMonitor - DB query trackingBaseController - Controller error handlingLocation: ./notifications/src/instrument.ts
import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV || 'development',
integrations: [
nodeProfilingIntegration(),
],
tracesSampleRate: 0.1,
profilesSampleRate: 0.1,
});
Key Helpers:
EmailSentryHelper - Email-specific errorsBaseController - Controller error handling[sentry]
dsn = your-sentry-dsn
environment = development
tracesSampleRate = 0.1
profilesSampleRate = 0.1
[databaseMonitoring]
enableDbTracing = true
slowQueryThreshold = 100
logDbQueries = false
dbErrorCapture = true
enableN1Detection = true
# Test basic error capture
curl http://localhost:3002/blog-api/api/sentry/test-error
# Test workflow error
curl http://localhost:3002/blog-api/api/sentry/test-workflow-error
# Test database performance
curl http://localhost:3002/blog-api/api/sentry/test-database-performance
# Test error boundary
curl http://localhost:3002/blog-api/api/sentry/test-error-boundary
# Test basic error capture
curl http://localhost:3003/notifications/api/sentry/test-error
# Test email-specific error
curl http://localhost:3003/notifications/api/sentry/test-email-error
# Test performance tracking
curl http://localhost:3003/notifications/api/sentry/test-performance
import * as Sentry from '@sentry/node';
// Automatic transaction tracking for Express routes
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
// Manual transaction for custom operations
const transaction = Sentry.startTransaction({
op: 'operation.type',
name: 'Operation Name',
});
try {
// Your operation
} finally {
transaction.finish();
}
ā NEVER use console.error without Sentry ā NEVER swallow errors silently ā NEVER expose sensitive data in error context ā NEVER use generic error messages without context ā NEVER skip error handling in async operations ā NEVER forget to import instrument.ts as first line in cron jobs
When adding Sentry to new code:
/blog-api/src/instrument.ts - Sentry initialization/blog-api/src/workflow/utils/sentryHelper.ts - Workflow errors/blog-api/src/utils/databasePerformance.ts - DB monitoring/blog-api/src/controllers/BaseController.ts - Controller base/notifications/src/instrument.ts - Sentry initialization/notifications/src/utils/EmailSentryHelper.ts - Email errors/notifications/src/controllers/BaseController.ts - Controller base/blog-api/config.ini - Form service config/notifications/config.ini - Email service config/sentry.ini - Shared Sentry config/dev/active/email-sentry-integration//blog-api/docs/sentry-integration.md/notifications/docs/sentry-integration.mdThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.