magic-devtools
Skill3 starsChanged 17 days agoMITView on GitHub
Wire tapir and crumbs into a Magic app with magic_devtools, and keep the wiring out of release builds.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- anilcancakir/aiword for word, first seen Nov 16, 2026
Other versions1 project uses a version of this.
Word for word · 1
- anilcancakir/ai★ 3100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- crumbsSkill
- dowelSkill
- flutter-reviewSkill
- magic-analyticsSkill
- magic-deeplinkSkill
- magic-deviceSkill
- magic-encryptionSkill
- magic-frameworkSkill
- magic-local-storageSkill
- magic-notificationsSkill
- magic-paymentsSkill
- magic-pickerSkill
- magic-sentrySkill
- magic-social-authSkill
- magic-socketSkill
- magic-starterSkill
- tapirSkill
- wind-uiSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 2 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Use !kReleaseMode, not kDebugMode.
- Very specific: line 33
Every install() is idempotent within an isolate, so a second call registers nothing twice.
- Very specific: line 37
Call MagicDevtools.installPre() before await Magic.init(...) and MagicDevtools.installPost() after it.
- Very specific: line 45
Keep custom enricher keys distinct from the 14 magic* keys.
- Very specific: line 55
Keep secrets out of model attributes in a debug session: a ModelRecord copies every attribute unmasked.
- Very specific: line 56
Read EventRecord.payload as always empty: MagicEventWatcher records which event fired and when, not its fields.
- Very specific: line 65
Run an attribution session (the tapir:perf_begin default) for counters and insights, a timing one for comparable milliseconds.
- Very specific: line 70
Call MagicPreview.register(previewEntries()) and then MagicPreview.registerRoutes() from a provider's boot().
- Distinctive: line 72
Keep entries in a function, never a top-level const list, so a release build can drop them.
- Distinctive: line 178
Every integration keeps static state.
≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
magic_devtools
magic_devtools is the seam between a Magic app and two dev tools: tapir, the E2E driver an agent uses to snapshot and drive the app, and crumbs, the runtime inspector that records HTTP, logs, exceptions and app activity. It adds Magic-aware enrichers to tapir's snapshots, feeds Magic's HTTP, model, cache, event, gate, query and log activity into crumbs, assembles the data path behind tapir's perf sessions, and hosts a dev-only component catalog at /preview. magic itself depends on neither tool; this package is where they meet.
This skill covers wiring and testing magic_devtools only. Driving the app (tapir:snap, tapir:tap, perf sessions) is the tapir skill, reading records is the crumbs skill, Magic's container, router, forms and providers are the magic-framework skill, and styling a preview with Wind classes is the wind-ui skill.
Install
flutter pub add magic_devtools tapir crumbsRequires Dart >=3.13, Flutter >=3.47 and magic ^1.0.0. All three packages go under dependencies, because lib/main.dart imports them and a dev_dependencies entry trips the depend_on_referenced_packages lint. There is no service provider, config file or plugin:install step. dart run magic:dowel magic:install --with-devtools writes the wiring as per-tool blocks while it installs Magic; by hand it is the two calls below.
| Barrel | Exports |
package:magic_devtools/magic_devtools.dart | MagicDevtools, MagicPerfIntegration, PerfInsightRules, PerfRuleInputs |
package:magic_devtools/tapir.dart | MagicTapirIntegration and its 14 enricher functions |
package:magic_devtools/crumbs.dart | MagicCrumbsIntegration, MagicHttpFacadeAdapter and the six watchers |
package:magic_devtools/preview.dart | MagicPreview, PreviewEntry, MagicPreviewCatalog, kPreviewEnabled |
Rules for every install call
- Guard each call with
if (!kReleaseMode)at the call site, in the app'smain.dart. Nothing in this package checks the build mode, andkReleaseModeis a compile-time constant, so the guard is what drops tapir, crumbs and this package from a release build. Never move the guard into a helper that is itself called unguarded. - Use
!kReleaseMode, notkDebugMode. Debug and profile builds both carry the tools, and a performance measurement belongs on a profile build, wherekDebugModeis false. - Every
install()is idempotent within an isolate, so a second call registers nothing twice. That does not make a late call safe: see the perf rules.
MagicDevtools rules
- Call
MagicDevtools.installPre()beforeawait Magic.init(...)andMagicDevtools.installPost()after it. The pre half installsTapirPlugin,CrumbsPlugin, oneExceptionWatcher, oneDumpWatcherandMagicPerfIntegration, so boot errors land in crumbs; the post half installsMagicCrumbsIntegrationthenMagicTapirIntegration, which resolve Magic's container. - Pick one style per app: the umbrella, or the per-tool blocks.
installPre()keeps the watcher pair it registered, but it cannot see a pair the app registered by hand, and twoExceptionWatchers record every exception twice. - Register an extra crumbs watcher with
CrumbsPlugin.registerWatcher(...)afterinstallPre(), not instead of it.
MagicTapirIntegration rules
- Install it after
Magic.init(). Its Echo subscription is made only when thebroadcastingbinding exists atinstall(); installed earlier,magicEchoConnectioncan answer onlyconnectedordisconnected. - Expect the
magic*lines only fromtapir:snap --includeEnrichers: enrichers are off by default. - Keep custom enricher keys distinct from the 14
magic*keys. tapir prints every line every enricher returns and removes no duplicates. - An enricher has tapir's signature
String? Function(Element, RefRegistry), runs synchronously, and never keeps theElementbetween calls. tapir:navigate --routetakes a URL path: the adapter callsMagicRouter.instance.to(route), nottoNamed. On aStateErrorit answersfalseand tapir falls back to its own navigation.magicAuthUserreads only theidanddisplay_nameattributes; a user model withoutdisplay_nameprints the id alone. AMagicMiddlewareobject prints through itstoString().- Expect no
magicAuthUserline in an app withoutAuthServiceProvider: the enricher checksMagic.bound('auth')first, as the Echo enricher does forbroadcasting, and the other enrichers keep their lines.
MagicCrumbsIntegration rules
- Install it after
Magic.init(). Before it, the HTTP adapter finds nonetworkbinding and attaches nothing, and the install guard stops a later call from retrying. - Bodies are masked by key before they are stringified and cut at 8192 characters, and the header named by
auth.token.header(defaultAuthorization) is hidden. Add your own names withCrumbsRedaction.hideRequestHeaders,hideRequestParametersandhideResponseParameters; they merge with crumbs' defaults. - Keep secrets out of model attributes in a debug session: a
ModelRecordcopies every attribute unmasked. - Read
EventRecord.payloadas always empty:MagicEventWatcherrecords which event fired and when, not its fields. Http.fake()installs no interceptors, so faked requests never reach crumbs. Assert on the fake.- The event watchers'
uninstall()removes nothing, because magic'sEventDispatcherhas no per-listener removal; tests clear the dispatcher themselves. MagicLogWatcherwraps the container'slogmanager, soLog.*calls land incrumbs:tailandtapir:console; a call made duringMagic.init(), before the post half, is not recorded.Log.fake()still works: called before the install it is wrapped and keeps its entries, called after it replaces the wrapper.Log.unfake()drops the wrapper too, so callMagicLogWatcher().install()after it to bridge again. AMaporListcontext is masked by key before it is stored; the message text is not.
MagicPerfIntegration rules
- Install it before
Magic.init(), whichinstallPre()does.Magic.init()builds the router after the providers boot, andMagicRouter.addObserverthrows aStateErrorfrom then on. The throw is deliberate: a missing observer would leave the report without route transitions and nothing to say why. tapir:installandcrumbs:installnever writeMagicPerfIntegrationorMagicDevtools. An app wired only by them gets a structurally complete perf report with every counter at zero, because tapir's unassigned pointers fail silently.- Run an
attributionsession (thetapir:perf_begindefault) for counters and insights, atimingone for comparable milliseconds; a timing session counts nothing and evaluates no insight. routeTransitionsholds named pushes only, at most 200. A dialog or bottom sheet pushes an unnamed route and is skipped.
MagicPreview rules
- Call
MagicPreview.register(previewEntries())and thenMagicPreview.registerRoutes()from a provider'sboot().boot()runs insideMagic.init()before the router is built; a laterregisterRoutes()throws the router'sStateError, andregister()afterregisterRoutes()leaves the catalog empty because the routes captured the entries when they were added. - Generate the index with
dart run magic:dowel previews:refresh(scans--path, defaultlib, and writes<path>/_previews.g.dart). Each*.preview.dartfile holds exactly one public class whose name ends inPreview, with aconstconstructor; the generated builder is(_) => const XxxPreview(). - Keep entries in a function, never a top-level const list, so a release build can drop them.
registerRoutes()returns at once in release, and whenkPreviewEnabled(PREVIEW_ENABLED, defaultkDebugMode) is false. A profile build needs--dart-define=PREVIEW_ENABLED=trueand a call site guarded by!kReleaseMode, since akDebugModecheck is false there.
Recipes
Wire both tools with the umbrella:
import 'package:flutter/foundation.dart' show kReleaseMode;
import 'package:flutter/widgets.dart';
import 'package:magic/magic.dart';
import 'package:magic_devtools/magic_devtools.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
if (!kReleaseMode) MagicDevtools.installPre();
await Magic.init(); // the app's configFactories and providers go here
if (!kReleaseMode) MagicDevtools.installPost();
runApp(MagicApplication());
}Wire tapir with the perf path and no crumbs:
import 'package:flutter/foundation.dart' show kReleaseMode;
import 'package:flutter/widgets.dart';
import 'package:magic/magic.dart';
import 'package:magic_devtools/magic_devtools.dart';
import 'package:magic_devtools/tapir.dart';
import 'package:tapir/tapir.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
if (!kReleaseMode) {
TapirPlugin.install();
MagicPerfIntegration.install();
}
await Magic.init();
if (!kReleaseMode) MagicTapirIntegration.install();
runApp(MagicApplication());
}Mask an app-specific header and request body key next to the auth header the integration hides, inside the same guard:
import 'package:crumbs/crumbs.dart';
import 'package:flutter/foundation.dart' show kReleaseMode;
import 'package:flutter/widgets.dart';
import 'package:magic/magic.dart';
import 'package:magic_devtools/magic_devtools.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
if (!kReleaseMode) MagicDevtools.installPre();
await Magic.init();
if (!kReleaseMode) {
MagicDevtools.installPost();
CrumbsRedaction.hideRequestHeaders(<String>['X-Device-Secret']);
CrumbsRedaction.hideRequestParameters(<String>['pin']);
}
runApp(MagicApplication());
}Register the preview catalog from the route provider. _previews.g.dart is the file previews:refresh writes:
import 'package:flutter/foundation.dart' show kReleaseMode;
import 'package:magic/magic.dart';
import 'package:magic_devtools/preview.dart';
import '_previews.g.dart';
class RouteServiceProvider extends ServiceProvider {
RouteServiceProvider(super.app);
@override
void register() {}
@override
Future<void> boot() async {
// The app's own routes are registered here first.
if (!kReleaseMode) {
MagicPreview.register(previewEntries());
MagicPreview.registerRoutes();
}
}
}Testing
Every integration keeps static state. Reset each one you installed, and the packages underneath, so a test cannot leak enrichers, watchers or tapir pointers into the next:
import 'package:crumbs/crumbs.dart';
// flutter_test exports its own EventDispatcher; Magic's is the one to clear.
import 'package:flutter_test/flutter_test.dart' hide EventDispatcher;
import 'package:magic/magic.dart';
import 'package:magic_devtools/crumbs.dart';
import 'package:magic_devtools/tapir.dart';
import 'package:tapir/tapir.dart';
void main() {
setUpAll(TestWidgetsFlutterBinding.ensureInitialized);
setUp(() {
MagicApp.reset();
Magic.flush();
MagicRouter.reset();
CrumbsStore.resetForTesting();
EventDispatcher.instance.clear();
});
tearDown(() {
MagicTapirIntegration.resetForTesting();
MagicCrumbsIntegration.resetForTesting();
});
test('installs the Magic enrichers once', () {
MagicTapirIntegration.install();
MagicTapirIntegration.install();
expect(TapirPlugin.enrichers, hasLength(14));
});
}| Reset | Clears |
MagicDevtools.resetForTesting() | The ExceptionWatcher and DumpWatcher installPre() registered, restoring FlutterError.onError, the platform error callback and debugPrint |
MagicTapirIntegration.resetForTesting() | The 14 enrichers, the navigate adapter, the Echo subscription, the install guard |
MagicCrumbsIntegration.resetForTesting() | The install guard, the log manager wrapper and tapir's three crumbs readers; not the adapter or the watchers' listeners, so also call EventDispatcher.instance.clear() |
MagicPerfIntegration.resetForTesting() | The guard, the session counters, the sink, the insight contributor, the frame watcher, every tapir perf pointer; not the navigator observer, so also call MagicRouter.reset() |
MagicPreview.resetForTesting() | The registered entries; MagicRouter.reset() drops the routes |
Inside testWidgets, call MagicDevtools.resetForTesting() at the end of the test body rather than in tearDown: flutter_test checks debugPrint right after the body, before tearDown runs. A host test cannot open a real tapir interaction (PerfInteraction has a private constructor), so replace MagicPerfIntegration.zoneInteraction, interactionIdAt or activeInteractionId instead; MagicPerfIntegration.resetForTesting() puts them back.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

