using-sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
Best use case
using-sentry is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
Teams using using-sentry should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/using-sentry/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How using-sentry Compares
| Feature / Agent | using-sentry | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Working with Sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
## Implement Working with Sentry
Capture exceptions, add context, create performance spans, and use structured logging with Sentry.
**See:**
- Resource: `using-sentry` in Fullstack Recipes
- URL: https://fullstackrecipes.com/recipes/using-sentry
---
### Capturing Exceptions
Manually capture errors that are handled but should be tracked:
```typescript
import * as Sentry from "@sentry/nextjs";
try {
await riskyOperation();
} catch (err) {
Sentry.captureException(err);
// Handle the error gracefully...
}
```
### Adding Context
Attach user and custom context to errors:
```typescript
import * as Sentry from "@sentry/nextjs";
// Set user context (persists for session)
Sentry.setUser({
id: session.user.id,
email: session.user.email,
});
// Add custom context to exceptions
Sentry.captureException(err, {
tags: {
feature: "checkout",
plan: "pro",
},
extra: {
orderId: "order_123",
items: cart.items,
},
});
```
### Performance Tracing
Create spans for meaningful operations:
```typescript
import * as Sentry from "@sentry/nextjs";
// Wrap async operations
const result = await Sentry.startSpan(
{
op: "http.client",
name: "GET /api/users",
},
async () => {
const response = await fetch("/api/users");
return response.json();
},
);
// Wrap sync operations
Sentry.startSpan(
{
op: "ui.click",
name: "Submit Button Click",
},
(span) => {
span.setAttribute("form", "checkout");
processSubmit();
},
);
```
### Using the Sentry Logger
Sentry provides structured logging that appears in the Logs tab:
```typescript
import * as Sentry from "@sentry/nextjs";
const { logger } = Sentry;
logger.info("Payment processed", { orderId: "123", amount: 99.99 });
logger.warn("Rate limit approaching", { current: 90, max: 100 });
logger.error("Payment failed", { orderId: "123", reason: "declined" });
```
### Breadcrumbs
Add breadcrumbs to provide context for errors:
```typescript
import * as Sentry from "@sentry/nextjs";
// Automatically captured: console logs, fetch requests, UI clicks
// Manual breadcrumbs for custom events:
Sentry.addBreadcrumb({
category: "auth",
message: "User signed in",
level: "info",
});
```
### Clearing User Context
Clear user data on sign out:
```typescript
import * as Sentry from "@sentry/nextjs";
async function signOut() {
Sentry.setUser(null);
await authClient.signOut();
}
```
---
## References
- [Sentry Next.js SDK](https://docs.sentry.io/platforms/javascript/guides/nextjs/)
- [Custom Instrumentation](https://docs.sentry.io/platforms/javascript/guides/nextjs/tracing/instrumentation/custom-instrumentation/)Related Skills
using-workflows
Create and run durable workflows with steps, streaming, and agent execution. Covers starting, resuming, and persisting workflow results.
using-user-stories
Document and track feature implementation with user stories. Workflow for authoring stories, building features, and marking acceptance criteria as passing.
using-tests
Testing strategy and workflow. Tests run in parallel with isolated data per suite. Prioritize Playwright for UI, integration tests for APIs, unit tests for logic.
using-nuqs
Manage React state in URL query parameters with nuqs. Covers Suspense boundaries, parsers, clearing state, and deep-linkable dialogs.
using-logging
Use structured logging with Pino throughout your application. Covers log levels, context, and workflow-safe logging patterns.
using-drizzle-queries
Write type-safe database queries with Drizzle ORM. Covers select, insert, update, delete, relational queries, and adding new tables.
using-authentication
Use Better Auth for client and server-side authentication. Covers session access, protected routes, sign in/out, and fetching user data.
using-analytics
Track custom events and conversions with Vercel Web Analytics. Covers common events, form tracking, and development testing.
sentry-setup
Configure Sentry for error tracking, performance monitoring, and log aggregation. Integrates with Pino to forward logs to Sentry automatically.
url-state-management
Sync React state to URL query parameters for shareable filters, search, and deep-linkable dialogs with nuqs.
testing
Complete testing setup with Neon database branching, Playwright browser tests, integration tests, and unit tests. Isolated branches with automatic TTL cleanup.
stripe-subscriptions
Complete subscription billing system with Stripe integration, feature flags for plan gating, webhook handling, and billing portal.