home / skills / jeremylongshore / claude-code-plugins-plus-skills / sentry-sdk-patterns

This skill helps you implement Sentry SDK best practices in TypeScript and Python, improving error handling, tracing, and issue grouping.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill sentry-sdk-patterns

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.6 KB
---
name: sentry-sdk-patterns
description: |
  Execute best practices for using Sentry SDK in TypeScript and Python.
  Use when implementing error handling patterns, structuring Sentry code,
  or optimizing SDK usage.
  Trigger with phrases like "sentry best practices", "sentry patterns",
  "sentry sdk usage", "sentry code structure".
allowed-tools: Read, Write, Edit, Grep
version: 1.0.0
license: MIT
author: Jeremy Longshore <[email protected]>
---

# Sentry Sdk Patterns

## Prerequisites
- Sentry SDK installed and configured
- Understanding of error handling concepts
- Familiarity with async/await patterns

## Instructions

1. Create a centralized error handler module for consistent error capture
2. Implement scoped context for transactions and operations
3. Add structured breadcrumbs for debugging context
4. Configure error boundaries in frameworks (React, Vue, etc.)
5. Use custom fingerprinting for better issue grouping
6. Implement async error handling with proper scope propagation
7. Add performance tracing for critical paths
8. Configure sampling rates based on traffic volume


See `{baseDir}/references/implementation.md` for detailed implementation guide.

## Output
- Clean, maintainable error handling code
- Consistent error context across application
- Efficient Sentry SDK usage

## Error Handling

See `{baseDir}/references/errors.md` for comprehensive error handling.

## Examples

See `{baseDir}/references/examples.md` for detailed examples.

## Resources
- [Sentry SDK Docs](https://docs.sentry.io/platforms/)
- [Sentry Best Practices](https://docs.sentry.io/product/issues/best-practices/)

Overview

This skill provides practical patterns and checklist-style guidance for using the Sentry SDK in TypeScript and Python. It focuses on consistent error capture, context propagation, and efficient SDK configuration to reduce noise and improve debugging velocity. Apply these patterns when implementing error handling, tracing, or structuring SDK usage across services and front-end apps.

How this skill works

I prescribe a small set of repeatable implementations: a centralized error handler module, scoped contexts for transactions, structured breadcrumbs, and custom fingerprinting rules. The skill covers async scope propagation and performance tracing, plus sampling strategies to keep event volume under control. Examples and concrete steps are framed for both TypeScript (Node/React) and Python (web workers, async frameworks).

When to use it

  • When standardizing error capture across multiple services or repositories
  • When implementing Sentry in a new TypeScript or Python project
  • When you need reliable context propagation for async/await code paths
  • When reducing noise with sampling and issue grouping becomes necessary
  • When adding performance tracing to critical API paths or UI flows

Best practices

  • Create a single, centralized error handler module that wraps SDK init and capture helpers
  • Use scoped contexts (setContext/setTag/setUser) for per-request or per-transaction data
  • Add structured breadcrumbs for key state changes and external calls, not every log line
  • Apply custom fingerprinting to group related errors and split unrelated ones
  • Ensure async scope propagation by binding async callbacks or using SDK integrations
  • Set sampling and rate limits based on traffic; trace only critical paths

Example use cases

  • Server API: initialize SDK in app startup, attach request-scoped tags and trace critical handlers
  • Background worker: capture exceptions with context about job id, input payload, and retry count
  • React app: configure an error boundary plus breadcrumbs for navigation and user actions
  • Async Python service: ensure scope propagation in coroutine-based frameworks and capture additional context
  • High-traffic endpoints: reduce events via dynamic sampling while keeping full traces for latency spikes

FAQ

How do I keep context across async calls?

Use the SDK's async integrations or explicitly bind the scope for callbacks; in Node/Python async frameworks, enable built-in integrations that preserve scope across await boundaries.

When should I adjust sampling rates?

Adjust sampling when event volume exceeds budget or when noise masks actionable issues; sample broadly for noncritical flows and keep 100% for high-value endpoints or error conditions.