Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .agents/skills/sentry-fix-issues/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
name: sentry-fix-issues
description: Find and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sentry. Methodically analyzes stack traces, breadcrumbs, traces, and context to identify root causes.
---

# Fix Sentry Issues

Discover, analyze, and fix production issues using Sentry's full debugging capabilities.

## Invoke This Skill When

- User asks to "fix Sentry issues" or "resolve Sentry errors"
- User wants to "debug production bugs" or "investigate exceptions"
- User mentions issue IDs, error messages, or asks about recent failures
- User wants to triage or work through their Sentry backlog

## Prerequisites

- Sentry MCP server configured and connected
- Access to the Sentry project/organization

## Phase 1: Issue Discovery

Use Sentry MCP to find issues. Confirm with user which issue(s) to fix before proceeding.

| Search Type | MCP Call |
|-------------|----------|
| Recent unresolved | `sentry_search_issues` query: `"is:unresolved"` sort: `"date"` |
| Specific error type | `sentry_search_issues` query: `"is:unresolved error.type:TypeError"` |
| By ID | `sentry_get_issue` issue_id: `"PROJECT-123"` |

## Phase 2: Deep Issue Analysis

Gather ALL available context for each issue:

| Data Source | MCP Call | Extract |
|-------------|----------|---------|
| **Core Error** | `sentry_get_issue` | Exception type/message, full stack trace, file paths, line numbers, function names |
| **Event Details** | `sentry_get_event` | Breadcrumbs, tags, custom context, request data |
| **Trace** (if available) | `sentry_get_trace` | Parent transaction, spans, DB queries, API calls, error location |
| **Replay** (if available) | `sentry_get_replay` | User actions, UI state, network requests |

## Phase 3: Root Cause Hypothesis

Before touching code, document:

1. **Error Summary**: One sentence describing what went wrong
2. **Immediate Cause**: The direct code path that threw
3. **Root Cause Hypothesis**: Why the code reached this state
4. **Supporting Evidence**: Breadcrumbs, traces, or context supporting this
5. **Alternative Hypotheses**: What else could explain this? Why is yours more likely?

Challenge yourself: Is this a symptom of a deeper issue? Check for similar errors elsewhere, related issues, or upstream failures in traces.

## Phase 4: Code Investigation

| Step | Actions |
|------|---------|
| **Locate Code** | Read every file in stack trace from top down |
| **Trace Data Flow** | Find value origins, transformations, assumptions, validations |
| **Error Boundaries** | Check for try/catch - why didn't it handle this case? |
| **Related Code** | Find similar patterns, check tests, review recent commits (`git log`, `git blame`) |

## Phase 5: Implement Fix

Before writing code, confirm your fix will:
- [ ] Handle the specific case that caused the error
- [ ] Not break existing functionality
- [ ] Handle edge cases (null, undefined, empty, malformed)
- [ ] Provide meaningful error messages
- [ ] Be consistent with codebase patterns

**Apply the fix:** Prefer input validation > try/catch, graceful degradation > hard failures, specific > generic handling, root cause > symptom fixes.

**Add tests** reproducing exact Sentry event conditions and verifying edge cases.

## Phase 6: Verification Audit

Complete before declaring fixed:

| Check | Questions |
|-------|-----------|
| **Evidence** | Does fix address exact error message? Handle data state shown? Prevent ALL events? |
| **Regression** | Could fix break existing functionality? Other code paths affected? Backward compatible? |
| **Completeness** | Similar patterns elsewhere? Related Sentry issues? Add monitoring/logging? |
| **Self-Challenge** | Root cause or symptom? Considered all event data? Will handle if occurs again? |

## Phase 7: Report Results

Format:
```
## Fixed: [ISSUE_ID] - [Error Type]
- Error: [message], Frequency: [X events, Y users], First/Last: [dates]
- Root Cause: [one paragraph]
- Evidence: Stack trace [key frames], breadcrumbs [actions], context [data]
- Fix: File(s) [paths], Change [description]
- Verification: [ ] Exact condition [ ] Edge cases [ ] No regressions [ ] Tests [y/n]
- Follow-up: [additional issues, monitoring, related code]
```

## Quick Reference

**MCP Tools:** `sentry_search_issues`, `sentry_get_issue`, `sentry_get_event`, `sentry_get_trace`, `sentry_get_replay`, `sentry_list_projects`, `sentry_get_project`

**Common Patterns:** TypeError (check data flow, API responses, race conditions) • Promise Rejection (trace async, error boundaries) • Network Error (breadcrumbs, CORS, timeouts) • ChunkLoadError (deployment, caching, splitting) • Rate Limit (trace patterns, throttling) • Memory/Performance (trace spans, N+1 queries)
249 changes: 249 additions & 0 deletions .agents/skills/sentry-ios-swift-setup/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
---
name: sentry-ios-swift-setup
description: Setup Sentry in iOS/Swift apps. Use when asked to add Sentry to iOS, install sentry-cocoa SDK, or configure error monitoring for iOS applications using Swift and SwiftUI.
---

# Sentry iOS Swift Setup

Install and configure Sentry in iOS projects using Swift and SwiftUI.

## Invoke This Skill When

- User asks to "add Sentry to iOS" or "install Sentry" in a Swift app
- User wants error monitoring, tracing, or session replay in iOS
- User mentions "sentry-cocoa" or iOS crash reporting

## Requirements

- iOS 13.0+
- Xcode 15.0+
- Swift 5.0+

## Install

### Swift Package Manager (Recommended)

1. File > Add Package Dependencies
2. Enter: `https://github.com/getsentry/sentry-cocoa`
3. Select version rule: "Up to Next Major" from `9.0.0`

### CocoaPods

```ruby
# Podfile
pod 'Sentry', '~> 9.0'
```

Then run `pod install`.

## Configure

### SwiftUI App

```swift
import SwiftUI
import Sentry

@main
struct YourApp: App {
init() {
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = true

// Tracing
options.tracesSampleRate = 1.0

// Profiling
options.configureProfiling = {
$0.sessionSampleRate = 1.0
$0.lifecycle = .trace
}

// Session Replay
options.sessionReplay.sessionSampleRate = 1.0
options.sessionReplay.onErrorSampleRate = 1.0

// Logs
options.enableLogs = true

// Error context
options.attachScreenshot = true
options.attachViewHierarchy = true
}
}

var body: some Scene {
WindowGroup { ContentView() }
}
}
```

### UIKit App

```swift
import UIKit
import Sentry

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = true
options.tracesSampleRate = 1.0
options.enableLogs = true
}
return true
}
}
```

## Configuration Options

| Option | Description | Default |
|--------|-------------|---------|
| `dsn` | Sentry DSN | Required |
| `tracesSampleRate` | % of transactions traced | `0` |
| `sessionReplay.sessionSampleRate` | % of sessions replayed | `0` |
| `sessionReplay.onErrorSampleRate` | % of error sessions replayed | `0` |
| `enableLogs` | Send logs to Sentry | `false` |
| `attachScreenshot` | Attach screenshot on error | `false` |
| `attachViewHierarchy` | Attach view hierarchy on error | `false` |

## Auto-Instrumented Features

| Feature | What's Captured |
|---------|-----------------|
| App Launches | Cold/warm start times |
| Network | URLSession requests |
| UI | Screen loads, transitions |
| File I/O | Read/write operations |
| Core Data | Fetch/save operations |
| App Hangs | Main thread blocking |

## Logging

```swift
let logger = SentrySDK.logger

logger.info("User action", attributes: [
"userId": "123",
"action": "checkout"
])

// Log levels: trace, debug, info, warn, error, fatal
```

## Session Replay Masking

```swift
// SwiftUI modifiers
Text("Safe content").sentryReplayUnmask()
Text(user.email).sentryReplayMask()

// Debug masking in development
#if DEBUG
SentrySDK.replay.showMaskPreview()
#endif
```

## User Context

```swift
let user = User()
user.userId = "user_123"
user.email = "user@example.com"
SentrySDK.setUser(user)

// Clear on logout
SentrySDK.setUser(nil)
```

## Verification

```swift
// Test error capture
SentrySDK.capture(message: "Test from iOS")

// Test crash (dev only)
SentrySDK.crash()
```

## Production Settings

```swift
SentrySDK.start { options in
options.dsn = "YOUR_SENTRY_DSN"
options.debug = false
options.tracesSampleRate = 0.2 // 20%
options.sessionReplay.sessionSampleRate = 0.1 // 10%
options.sessionReplay.onErrorSampleRate = 1.0 // 100% on error
options.enableLogs = true
}
```

## Size Analysis (Fastlane)

Track app bundle size with Sentry using the Fastlane plugin.

### Install Plugin

```ruby
# fastlane/Pluginfile
gem 'fastlane-plugin-sentry'
```

Then run `bundle install`.

### Configure Authentication

```bash
# Environment variable (recommended for CI)
export SENTRY_AUTH_TOKEN=your_token_here
```

Or create `.sentryclirc` (add to `.gitignore`):

```ini
[auth]
token=YOUR_SENTRY_AUTH_TOKEN
```

### Fastfile Lane

```ruby
lane :sentry_size do
build_app(
scheme: "YourApp",
configuration: "Release",
export_method: "app-store"
)

sentry_upload_build(
org_slug: "your-org",
project_slug: "your-project",
build_configuration: "Release"
)
end
```

### Run Size Analysis

```bash
bundle exec fastlane sentry_size
```

View results in Sentry: **Settings > Size Analysis**

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Events not appearing | Check DSN, enable `debug = true` |
| No traces | Set `tracesSampleRate` > 0 |
| No replays | Set `sessionSampleRate` > 0, check SDK 8.0+ |
| No logs | Set `enableLogs = true`, check SDK 8.55+ |
| CocoaPods fails | Run `pod repo update`, check iOS 13+ target |
| Size upload fails | Check `SENTRY_AUTH_TOKEN`, verify org/project slugs |
Loading