iamantoniodinuzzo/claude-flutter/sentry-init
Claude Code and agent skill by iamantoniodinuzzo/claude-flutter
- community
Checking that the SKILL.md file is still in the repository.
Bootstrap sentry_flutter in a Flutter+Riverpod+GoRouter project — installs deps, wires SentryFlutter.init (Approach 3), GoRouter observer, Riverpod error capture (LoggerService decorator if present, else a scaffolded ErrorLogger sink), web BetterFeedback gated by CanvasKit renderer, beforeSend/sampling policy, and a release upload checklist (source maps + dSYM). Use when the user says \"add Sentry to this app\", \"set up error monitoring\", \"bootstrap sentry-init\", \"integrate crash reporting\", or asks to wire up Sentry for a Flutter/Riverpod/GoRouter project.
Install
npx vskill@latest install iamantoniodinuzzo/claude-flutter/sentry-initSKILL.md
The same SKILL.md was published earlier as iamantoniodinuzzo/claude-flutter/sentry-init.
sentry-init
Runtime and resources
Use the current agent's native file, search, shell, and question tools; plain-text questions and direct sequential scans are valid fallbacks. Subagents are optional and require host permission. Bundled paths below are relative to this installed skill directory; application paths are relative to the target Flutter project. Resolve sibling skills through the installed skill registry (or sibling directories), never by assuming a skills/ folder in the application. If a required dependency is absent, name it and report the affected step as unavailable; never invent its rules or claim complete coverage.
Bootstraps the Sentry Flutter SDK in an existing Flutter project that uses Riverpod and GoRouter. Run all phases in order; each phase is idempotent — if the target already has partial Sentry setup, report deltas only, do not duplicate.
Before coding anything, load the bundled references in parallel:
references/initialization-flow.mdreferences/error-capture-architecture.mdreferences/event-filtering-and-sampling.mdreferences/gorouter-and-dio-wiring.mdreferences/web-feedback-canvaskit.mdreferences/release-uploads.md
Also fetch the latest sentry_flutter SDK docs via context7 (getsentry/sentry-dart) before pinning any version numbers — the reference files cite minimum-tested baselines, not pinned versions.
Phase 0 — Intake & prerequisite gate
Goal: gather all project shape facts before touching any file. Never assume — detect.
Prerequisite: a Sentry account and project must already exist (sentry.io → Create Project → platform Flutter). This skill wires the SDK into the app; it does not create or configure anything on Sentry's side.
0.1 Melos workspace detection
Grep root pubspec.yaml for workspace: (pub workspaces) or melos: block.
- Monorepo detected: ask the user which package(s) to target. All subsequent phases apply to the selected package root. Use
melos exec --scope=<pkg> -- <cmd>for pub operations. - Single-app: target root is the project root.
0.2 GoRouter prerequisite (hard gate)
In the target pubspec.yaml, grep for go_router.
- Not found: abort immediately with this message:
`` ✗ sentry-init requires go_router for NavigatorObserver wiring. Run the flutter-go-router skill first, then re-run sentry-init. ``
- Found: proceed.
0.3 Error sink detection (soft)
Grep project lib/ for:
class LoggerServiceorabstract.*LoggerServiceloggerServiceProvider
Record result as HAS_LOGGER_SERVICE=true/false and derive the sink identity Phase 4 wires everything through — LoggerService decorator and a scaffolded ErrorLogger are both sinks (something a caller hands an error to); ProviderObserver is a channel (where errors arrive from), not a competing sink:
HAS_LOGGER_SERVICE | SINK_PROVIDER | SINK_CAPTURE call shape | |
|---|---|---|---|
true | loggerServiceProvider | sink.e(msg, error, stackTrace) — takes a message | |
false | errorLoggerProvider | sink.logException(error, stackTrace) — no message |
The two shapes are not interchangeable — Branch A's .e(...) always takes a leading message string, Branch B's .logException(...) never does. Use the row matching the detected branch verbatim; don't average the two signatures.
0.4 Optional dependency detection
| Probe | Grep target | Variable | |
|---|---|---|---|
| Dio | import 'package:dio/dio.dart' or dio: in pubspec | HAS_DIO | |
| logging package | logging: in pubspec | HAS_LOGGING | |
| Existing Sentry | sentry_flutter in pubspec | ALREADY_HAS_SENTRY |
If ALREADY_HAS_SENTRY=true, proceed but operate in delta mode: report what already exists vs what needs changing.
0.5 DSN source
Ask the user how the DSN is provided. Present this priority order as default:
dart_defines.json/dart_defines.json.example(keySENTRY_DSN) — recommended, compile-time, never committed--dart-define=SENTRY_DSN=...in.vscode/launch.jsonorMakefile.envfile read at runtime
dart_defines.json is the default because it's validated prior art (see this repo's docs/adr/0001-sentry-init-dsn-source-convention.md), not a guess — a single shared file beats one .env per flavor for a toolkit that has no other skill scaffolding .env files. If the target project already uses .env-per-flavor, detect and adapt to it instead of migrating it.
Confirm the exact key name (default SENTRY_DSN). In Phase 2, the skill always emits an empty-string gate so local dev without the define simply skips Sentry init.
Determine how the value is accessed in Dart (e.g. const String.fromEnvironment('SENTRY_DSN') or via an AppEnv/Env class). Record as DSN_DART_EXPR.
0.6 Flavor detection
Grep for lib/main_*.dart or a Flavor / AppFlavor enum. List discovered flavors.
Performance monitoring is opt-in, default off. sentry-init bootstraps error monitoring; tracesSampleRate/profilesSampleRate open two additional Sentry quota buckets (spans, profiling) the course itself doesn't enable by default (see references/event-filtering-and-sampling.md). Ask the user whether to enable it. If yes, map flavors to this table — profilesSampleRate is relative to tracesSampleRate, not independent, so the values below are chosen for the stated effective rate, not copied 1:1:
| Flavor | tracesSampleRate | profilesSampleRate (relative) | effective profiling | |
|---|---|---|---|---|
| prod / release | 0.2 | 1.0 | 0.2 | |
| dev / debug / staging | 1.0 | 1.0 | 1.0 |
profilesSampleRate only does anything on iOS/macOS — Sentry doesn't support profiling on Android or Web yet. tracesSampleRate still applies everywhere. If the target is Android-only or web-only, mention this before asking — the profiling half of the table is a no-op there.
Ask the user to confirm or adjust. If declined, record PERF_MONITORING=false and omit both options entirely in Phase 2 — leaving them unset consumes zero span/profile quota (both default to null in the SDK).
0.7 Package name
Grep pubspec.yaml for name:. Record as APP_PACKAGE_NAME — used for addInAppInclude.
Phase 0 summary
Before proceeding, print a one-line summary of what was detected:
Ask the user to confirm before proceeding.
Phase 1 — Install dependencies
1.1 Core
For monorepo: prefix with melos exec --scope=<pkg> -- .
Minimum-tested baseline versions (verify current latest via context7 before pinning):
sentry_flutter: ^9.20.0sentry_dart_plugin: 3.2.0
1.2 Conditional additions
| Condition | Command | |
|---|---|---|
HAS_DIO=true | flutter pub add sentry_dio | |
HAS_LOGGING=true | flutter pub add sentry_logging | |
| Always (for web BetterFeedback) | flutter pub add feedback feedback_sentry |
Minimum-tested baselines: feedback: ^3.2.0, feedback_sentry: ^3.2.0.
Phase 2 — Patch main.dart (Approach 3 — no appRunner)
See references/initialization-flow.md for full rationale and comparison of all three approaches.
2.1 Locate entrypoints
Find all flavor entrypoints: lib/main.dart, lib/main_dev.dart, lib/main_prod.dart, etc. (from Phase 0.6). Apply this phase to each.
2.2 Required initialization order
Critical ordering rule: Sentry must init _before_ first provider read. Do not reorder SentryFlutter.init below ProviderContainer creation. See references/initialization-flow.md.
beforeSend carries no DioException filter — the expected-offline-error filter lives at the call site (Phase 4.3), not here. See references/event-filtering-and-sampling.md for why, and SENTRY_DEBUG_REPORTING for how to run the Phase 7 smoke test without touching this file.
2.3 Idempotency
If SentryFlutter.init( already exists in the file:
- Check the existing options block against the template above.
- Report any missing options as a diff.
- Do not add a second
SentryFlutter.initcall.
2.4 Global error hooks
Also wire in main() (idempotent — check if already present):
If the project already has these hooks routing to a LoggerService, do not duplicate — the decorator in Phase 4 will handle Sentry capture automatically.
Phase 3 — Wire GoRouter observer
See references/gorouter-and-dio-wiring.md for full context.
3.1 Locate GoRouter constructors
Typical paths: lib/router/app_router.dart, lib/src/router/, lib/router.dart. Grep for GoRouter(.
3.2 Inject observer
For each GoRouter( call found, add observers: [SentryNavigatorObserver()]. If observers: already present, append to the list:
For Riverpod-wrapped variant:
Do NOT add to MaterialApp.router — it has no navigatorObservers argument.
3.3 Named routes warning
Inspect routes for name: fields. If no named routes found, emit this advisory:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sentry-init/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/iamantoniodinuzzo/claude-flutter/sentry-init)