Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generates protocol-based error/crash monitoring with swappable providers (Sentry, Crashlytics). Use when user wants to add crash reporting, error tracking, or production monitoring.
.claude/skills/rshankras-error-monitoring/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-13 | ✗→✓ | ▲ Improved | 80% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 49% | 0% |
Generates a production-ready error monitoring infrastructure with protocol-based architecture for easy provider swapping.
Before generating, ALWAYS check:
bash# Check for existing crash reporting rg -l "Sentry|Crashlytics|CrashReporter" --type swift # Check Package.swift for existing SDKs cat Package.swift | grep -i "sentry\|firebase\|crashlytics" # Check for existing error handling patterns rg "captureError|recordError|logError" --type swift | head -5
If existing crash reporting found:
Ask user via AskUserQuestion:
Always generate:
Sources/ErrorMonitoring/
├── ErrorMonitoringService.swift # Protocol
├── ErrorContext.swift # Breadcrumbs, user info
└── NoOpErrorMonitoring.swift # Testing/privacyBased on provider selection:
Sources/ErrorMonitoring/Providers/
├── SentryErrorMonitoring.swift # If Sentry selected
└── CrashlyticsErrorMonitoring.swift # If Crashlytics selectedRead templates from this skill:
templates/ErrorMonitoringService.swifttemplates/ErrorContext.swifttemplates/NoOpErrorMonitoring.swifttemplates/SentryErrorMonitoring.swift (if selected)templates/CrashlyticsErrorMonitoring.swift (if selected)Adapt templates to match:
In App.swift:
swiftimport SwiftUI @main struct MyApp: App { init() { // Configure error monitoring ErrorMonitoring.shared.configure() } var body: some Scene { WindowGroup { ContentView() .environment(\.errorMonitoring, ErrorMonitoring.shared.service) } } }
Capturing errors:
swiftdo { try await riskyOperation() } catch { ErrorMonitoring.shared.service.captureError(error) }
Adding breadcrumbs:
swiftErrorMonitoring.shared.service.addBreadcrumb( Breadcrumb(category: "navigation", message: "Opened settings") )
swift.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.0.0")
swiftprotocol ErrorMonitoringService: Sendable { func configure() func captureError(_ error: Error, context: ErrorContext?) func captureMessage(_ message: String, level: ErrorLevel) func addBreadcrumb(_ breadcrumb: Breadcrumb) func setUser(_ user: MonitoringUser?) func reset() }
swift// In ErrorMonitoring.swift final class ErrorMonitoring { static let shared = ErrorMonitoring() // Change this ONE line to swap providers: let service: ErrorMonitoringService = SentryErrorMonitoring() // let service: ErrorMonitoringService = CrashlyticsErrorMonitoring() // let service: ErrorMonitoringService = NoOpErrorMonitoring() }
swift// Automatic navigation breadcrumbs struct ContentView: View { @Environment(\.errorMonitoring) var errorMonitoring var body: some View { Button("Open Details") { errorMonitoring.addBreadcrumb( Breadcrumb(category: "ui", message: "Tapped details button") ) showDetails = true } } }
After generation, verify:
NoOpErrorMonitoring for EU users who opt outAdd to PrivacyInfo.xcprivacy if using Sentry/Crashlytics:
xml<key>NSPrivacyCollectedDataTypes</key> <array> <dict> <key>NSPrivacyCollectedDataType</key> <string>NSPrivacyCollectedDataTypeCrashData</string> <key>NSPrivacyCollectedDataTypeLinked</key> <false/> <key>NSPrivacyCollectedDataTypeTracking</key> <false/> <key>NSPrivacyCollectedDataTypePurposes</key> <array> <string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string> </array> </dict> </array>
swiftenum AppError: Error { case networkFailure(URLError) case decodingFailure(DecodingError) case authenticationRequired var context: ErrorContext { ErrorContext( tags: ["error_type": String(describing: self)], extra: ["recoverable": isRecoverable] ) } } // Capture with context errorMonitoring.captureError(error, context: error.context)
swift// Sentry supports performance monitoring let transaction = SentrySDK.startTransaction(name: "Load Data", operation: "http") defer { transaction.finish() } let data = try await fetchData()
swift// Include version info SentrySDK.start { options in options.dsn = "YOUR_DSN" options.releaseName = "\(Bundle.main.appVersion)-\(Bundle.main.buildNumber)" }
analytics-setup - Often combined with error monitoringlogging-setup - Use Logger for debug, error monitoring for productionOther measured skills in the registry, with their headline benchmark lift.