/bug-handler:migrate-dev6-to-dev7from Bug Handler
Use when upgrading bug_handler from 1.0.0-dev.6 to 1.0.0-dev.7. Covers file-based reporters, browser context injection and sharing tests, and Equatable 3 comparisons in exception metadata and custom props.
Ships in Bug Handler. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use Flutter 3.38.1 or newer. Keep existing imports from
package:bug_handler/bug_handler.dart; it exports the attachment and readers.
Use the whole generated report ID as a string key. Apps that previously
decoded the clock from id should read event.timestamp instead. The ID
now includes a suffix to distinguish captures across isolates or tabs.
Check what consumes the file. For an upload, change the transport to accept
the filename, MIME type and bytes. This reporter works on native and web.
Use import 'dart:typed_data'; for Uint8List.
class UploadReporter extends Reporter {
const UploadReporter(this.upload);
final Future<bool> Function(String name, String mime, Uint8List bytes) upload;
@override
Future<bool> send(ReportEvent event) async {
try {
final attachment = ReportAttachment.fromEvent(event);
return await upload(attachment.name, attachment.mimeType, attachment.bytes);
} catch (_) {
return false;
}
}
}
Pass fileName: to preserve a custom upload name. Native ShareReporter
adds a unique suffix to the default file name for each handoff. An explicit
fileNameBuilder controls the shared name. A defaultFileName override that
supplies a distinct name is also preserved. ReportAttachment.fromEvent
keeps its deterministic name across targets.
A native reporter that persists reports for another program can keep its
dev.6 implementation. This subclass writes to a caller-selected directory.
In an app that also targets a browser, select the library that imports
dart:io and calls generateFile with a conditional import or export. A
runtime kIsWeb check still compiles both branches.
class ArchiveReporter extends Reporter {
const ArchiveReporter(this.directory);
final Directory directory;
@override
Future<bool> send(ReportEvent event) async {
try {
await generateFile(event, directory: directory, fileName: 'latest.json');
return true;
} on FileSystemException {
return false;
}
}
}
The protected defaultFileName(event) hook keeps its spelling and remains
overridable on both platforms. For a hook used by your upload, supply its
result as fileName: defaultFileName(event). Replacing generateFile with
an attachment also removes a filesystem write and changes the result from
Future<File> to in-memory bytes, so there is no general dart fix rewrite.
Keep the zero-argument providers in production wherever their platform defaults work. Native constructors still accept the dev.6 plugin objects. For a test or integration shared with the browser, supply only the reads you want to replace. For example, replace an injected connectivity plugin and network-info fake that returned Wi-Fi details with these readers.
final network = NetworkContextProvider.withReaders(
readInterfaces: () => ['wifi'],
readWifi: () => (ssid: 'Guest', bssid: null, ipv4: '192.0.2.1', ipv6: null),
);
A readWifi result is a nullable WifiContextData record. The reader runs
only when the interfaces contain wifi. Browsers have no built-in access
to SSID, BSSID or IP addresses. For device data, use
DeviceContextProvider.withReader(() => {'platform': 'test'}). Replace an
injected PackageInfo with an AppPackageData reader. Battery and interface
callbacks work independently of the package reader.
final app = AppContextProvider.withReaders(
readPackage: () => (
appName: 'Shop',
packageName: 'com.example.shop',
version: '1.0.0',
buildNumber: '7',
buildSignature: '',
installerStore: null,
),
readInterfaces: () => ['wifi'],
readBatteryLevel: () => 75,
);
Adapt a dynamic fake by calling it inside each callback so the provider collects the current readings after its cache expires. A plugin-to-reader rename cannot preserve these reads, their timing and their result types.
Keep native SharePlatform.instance overrides in native tests. The browser
uses navigator.share for supported file shares, and downloads JSON when
that capability is missing. Test the share from a user gesture and inspect
the file passed to the browser or the downloaded bytes. A rejected share
(including dismissal) ends the attempt and returns false.
The dev.6 provider implicitly used any PackageInfo object already cached
by PackageInfo.fromPlatform(baseUrl: …) or PackageInfo.setMockInitialValues.
The dev.7 web default calls the registered platform's getAll() with its
default manifest location. If your app's version.json lives on a custom CDN,
supply a reader that requests it. Add package_info_plus_platform_interface
as a direct dependency and import
package:package_info_plus_platform_interface/package_info_platform_interface.dart.
AppContextProvider appFromManifest(String baseUrl) =>
AppContextProvider.withReaders(readPackage: () async {
final info = await PackageInfoPlatform.instance.getAll(baseUrl: baseUrl);
return (
appName: info.appName,
packageName: info.packageName,
version: info.version,
buildNumber: info.buildNumber,
buildSignature: info.buildSignature,
installerStore: info.installerStore,
);
});
Pass the manifest's directory URL with a trailing slash, for example
https://cdn.example.com/shop/. If the app already owns an initialized
PackageInfo, return the same six fields from that object in the reader.
This also preserves test metadata seeded in the app's plugin cache.
Tests can instead return a fixed AppPackageData record, as above.
The browser connectivity plugin maps its online flag to wifi and offline
to none. Treat this as an online/offline signal. The web battery plugin
returns 0 when the browser battery API is unavailable. A battery reader
that throws gives the provider's fallback of -1.
Run flutter pub get and check the resolved equatable version in
pubspec.lock. With Equatable 3, two exceptions of the same type can compare
equal when their metadata or custom props contain values of different
runtime types whose operator == considers them equal. Equatable 2 treated
ordinary values of those different types as distinct. A cached order reference
and a network order reference might compare by order ID alone. This also
applies to SDK objects. On Dart 3.10 and 3.14, Uri.parse('https://example.com/orders')
and Uri.https('example.com', '/orders') produce equal URIs with different runtime types.
Inspect exception comparisons in the app, including state equality, sets and map keys. If the source of a reference matters, use one of these approaches.
equatable: ^2.0.8 under the app's
dependencies, run flutter pub get, and confirm the lockfile selects 2.x.{'kind': 'cached', 'id': orderId}
or {'kind': 'network', 'id': orderId} in metadata. If the distinction belongs
only to a custom exception's equality, add the kind alongside ...super.props
in its props getter.Exercise both references with the same order ID in the app's equality test.
If they represent the same value to the app, the Equatable 3 result already
expresses that choice. The comparison compiles under both major versions, so
this migration requires app judgment and produces no diagnostic for dart fix.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub omar-hanafy/bug_handler --plugin bug-handler8 skills in this plugin
/audit-error-handlingUse when reviewing code in an app that depends on bug_handler - PR review, "check our error handling", pre-release audits, or "are we using bug_handler correctly". Finds violations of the guard contract: string errors in state, unreported catches, raw exceptions crossing repository boundaries, missing source labels, misused isReportable./diagnose-reportingUse when bug_handler reports are missing, duplicated, delayed, or unexpected - "nothing arrives in Sentry", "capture doesn't send", "errors only show sometimes", outbox files piling up in bug_report_outbox, StateError about initialization, or events arriving that should have been suppressed./Other plugins' skills for the same job