dusk
Copilot instructions3 starsChanged 2 months agoMITView on GitHub
Guidance for Claude Code working inside the fluttersdk_dusk repo. Path-scoped rules under .claude/rules/{tests,extensions,commands,docs}.md cover their subsystems; this file is the root spec. Flutter SDK package (Dart 3.4+, Flutter 3.22+). Plugin of fluttersdk_artisan ^0.0.17: contributes DuskArtisanProvider with 41 CLI commands and 39 MCP tool descriptors over 38 ext.dusk.* VM Service extensions: 33 MCP tools call an extension directly and 6 route through the artisan:dusk:* substrate. The other five extensions have no MCP tool of their own: perf_trace and semantics_hold are driven…
- Commits and pushes
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- fluttersdk-duskSkill
The file
We split this copilot-instructions.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
CHANGELOG always under
[Unreleased]: Every behavioral or interface change lands a bullet under ## [Unreleased] in CHANGELOG.md. - Very specific: line 79
No new production dependencies beyond fluttersdk_artisan, image, meta, fluttersdk_wind_diagnostics_contracts, yaml.
- Very specific: line 85
Every developer.registerExtension call routes through registerExtensionIdempotent (from fluttersdk_artisan).
- Very specific: line 88
No mockito. Stub via contract inheritance or plain fakes inside the test file.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
<!-- Generated by ac:init-project 2026-05-22. Source-grounded against 0.0.2. -->CLAUDE.md
Guidance for Claude Code working inside the fluttersdk_dusk repo. Path-scoped rules under .claude/rules/{tests,extensions,commands,docs}.md cover their subsystems; this file is the root spec.
Stack
Flutter SDK package (Dart 3.4+, Flutter 3.22+). Plugin of fluttersdk_artisan ^0.0.17: contributes DuskArtisanProvider with 41 CLI commands and 39 MCP tool descriptors over 38 ext.dusk.* VM Service extensions: 33 MCP tools call an extension directly and 6 route through the artisan:dusk:* substrate. The other five extensions have no MCP tool of their own: perf_trace and semantics_hold are driven by the substrate tools, and find_by_text, find_by_label and boot_id are internal helpers.
Production deps (hosted only): fluttersdk_artisan ^0.0.17, image ^4.0.0, meta ^1.16.0, fluttersdk_wind_diagnostics_contracts ^1.2.0, yaml ^3.1.0. Dev deps: flutter_test, flutter_lints >=5.0.0 <7.0.0. Kept out of release at the consumer call site: the consumer wraps DuskPlugin.install() in if (!kReleaseMode), so debug and profile builds carry it (a profile build is what dusk:perf_run measures) and release builds tree-shake the subsystem on dart2js (web) and dart2native (mobile/desktop AOT).
Two CLI surfaces. bin/fluttersdk_dusk.dart is the Flutter-free wrapper (dart run fluttersdk_dusk <cmd>); lib/cli.dart exports FluttersdkDuskArtisanProvider (typedef alias of DuskArtisanProvider) for consumer-side lib/app/_plugins.g.dart auto-discovery. install.yaml at the package root drives plugin:install fluttersdk_dusk via the artisan PluginInstaller. After install the consumer's ./bin/fsa (~110ms warm AOT) is the recommended entry point.
Commands
| Command | When |
flutter test --coverage --exclude-tags=integration --timeout=30s | Default runner (CI gate). Emits coverage/lcov.info; 80% line floor enforced. |
dart format lib/ test/ bin/ | Must produce zero diff (CI runs --output=none --set-exit-if-changed). |
dart analyze lib/ test/ bin/ | Zero issues across all three roots. |
flutter pub get | Resolve deps. |
dart pub publish --dry-run | Pre-publish validation. Exits 65 on warnings, 0 on a clean archive. |
flutter test test/integration --tags=integration | Manual opt-in CDP smoke run (requires Chrome on PATH; excluded from default CI). |
Golden Rules (apply on every change)
- Doc sync. Any behavioral or interface change must update
README.md,ARCHITECTURE.md,CHANGELOG.md(under## [Unreleased]), the matching page underdoc/**/*.md, andllms.txtin the same change. See.claude/rules/docs.mdfor the surface-to-file map. - Coverage at or above 80%. CI enforces via lcov parse in
.github/workflows/ci.yml:42-44. Verify locally after behavioral changes:awk -F: '/^LF:/{lf+=$2} /^LH:/{lh+=$2} END{ if (lf==0) exit 1; printf "%.2f%%\n", (lh/lf)*100 }' coverage/lcov.info. Drops below 80% block the change. - CHANGELOG always under
[Unreleased]. Every behavioral or interface change lands a bullet under## [Unreleased]inCHANGELOG.md. Keep-a-Changelog 1.1.0 ordering: Added, Changed, Deprecated, Removed, Fixed, Security. Promote to a dated section on tag push. - Green gate plus TDD.
dart format lib/ test/ bin/zero diff,dart analyze lib/ test/ bin/zero issues,flutter test --exclude-tags=integrationall green. Red-green-refactor for behavioral changes: failing test first that fails for the right reason, then implementation that turns it green. - GitHub Flow. One long-lived branch:
master(released, what pub.dev resolves). Cut every task branch frommaster, push the work, open a PR back intomaster. Releases ship by bumpingpubspec.yaml, promoting## [Unreleased]inCHANGELOG.md, merging the bump PR, then tagging the commit onmaster. Nodevelopaccumulator. See the Branching section below for the full flow.
Branching
- One long-lived branch:
master. Direct pushes blocked; everything lands via PR. Matches the flutter, dart-lang/sdk, dart-lang/pub, and Anthropic-ecosystem convention. - Task branches: cut from
master, short kebab-case names (feat/snap-ref-dedup,fix/race-on-restart,docs/skills-section-7). One topic per branch, PR back intomaster. Squash or merge per the PR's commit shape. - Release: open a
release: X.Y.ZPR from a topic branch that bumpspubspec.yamlversion:and promotes## [Unreleased]to## [X.Y.Z] - YYYY-MM-DDwith the footer link. Merge, thengit tag X.Y.Z && git push origin X.Y.Z. The tag triggers.github/workflows/publish.ymlto push to pub.dev. - External contributors fork the repo and PR against
masterusing the same shape.
Architecture
Single barrel: lib/dusk.dart re-exports the public API. Subsystem layout under lib/src/:
| Path | Purpose |
extensions/ | 22 files: ext_snapshot, ext_pointer, ext_text_input, ext_screenshot, ext_scroll, ext_wait_find, ext_modal_router, ext_navigation, ext_evaluate, ext_close_app, ext_find, ext_fill, ext_console, ext_exceptions, ext_checkbox, ext_observe, ext_focus, ext_perf, ext_perf_trace, ext_semantics_hold, ext_boot, plus register_dusk_extensions aggregator. See .claude/rules/extensions.md. |
commands/ | 40 ArtisanCommand subclasses (one file each) plus two shared output helpers (json_output.dart, frame_warning_output.dart), 42 files in all. See .claude/rules/commands.md. |
cdp/ | cdp_client.dart (JSON-RPC over /json + WebSocket, 30s timeout), chrome_finder.dart, device_presets.dart (8 named presets). |
utils/ | actionability_gate.dart (6-check gate), dusk_exceptions.dart, error_envelope.dart, chrome_reaper.dart, frame_summary.dart (pure frame-metric summarizer), perf_readers.dart (the seven settable cross-package perf pointers). |
dusk_plugin.dart | DuskPlugin.install() entry, enricher list, navigate adapter hook. Idempotent. Wraps the app root in a RepaintBoundary (no GlobalKey) so ext.dusk.screenshot finds it via render-tree walk. |
ref_registry.dart | e<N> (snapshot-frozen, dedup-by-node.id) + q<N> (re-resolvable predicate handles) dual token system. |
dusk_snapshot_enricher.dart | FROZEN typedef: String? Function(Element element, RefRegistry refs). |
dusk_navigate_adapter.dart | FROZEN typedef: Future<bool> Function(String route). |
dusk_artisan_provider.dart | DuskArtisanProvider extends ArtisanServiceProvider: commands() returns 40 entries, mcpTools() returns 39 const McpToolDescriptors. |
bin/fluttersdk_dusk.dart | Flutter-free CLI wrapper (no dart:ui import). |
lib/cli.dart | Codegen barrel exporting FluttersdkDuskArtisanProvider typedef alias for consumer-side _plugins.g.dart auto-discovery. |
install.yaml | V1 plugin manifest (zero stubs, post-install bootstrap message, executables: anchor). |
VM Service surface
38 ext.dusk.* extensions registered via registerExtensionIdempotent (from fluttersdk_artisan) for hot-restart safety, the 35 listed here plus the three internal helpers named after them: snap, tap, hover, drag, dblclick, right_click, triple_click, type, fill, clear, press_key, focus, blur, scroll, select_option, set_checkbox, screenshot, wait_for, wait_for_network_idle, find, observe, dismiss_modals, reset_overlays, navigate, navigate_back, get_routes, evaluate, close_app, console, exceptions, perf_begin, perf_end, perf_insight, perf_trace, semantics_hold. Two internal helpers (find_by_text, find_by_label) back the dusk:wait polling loop and are not MCP-surfaced; a third, boot_id, answers the id DuskPlugin.install() mints per run of main(), registered last, which dusk:perf_run waits on across a hot restart. Handler signature: Future<ServiceExtensionResponse> Function(String method, Map<String, String> params). Parse integers via int.tryParse(params['key'] ?? ''). Return .result(jsonEncode(payload)) or .error(ServiceExtensionResponse.extensionError, msg) with JSON-encoded errorDetail (Flutter framework convention).
Six MCP tools route through the artisan:dusk:* substrate prefix instead of a direct VM extension call: dusk_hot_reload_and_snap (in-isolate self-reload would deadlock), dusk_resize_viewport and dusk_device_profile (drive Chrome DevTools Protocol from a non-Flutter Dart context), dusk_perf_run (drives ext.dusk.perf_begin/perf_end itself in a loop, host-side), dusk_perf_compare (diffs two run files on disk, no VM Service involved), and dusk_perf_trace (calls ext.dusk.perf_trace then writes the trace to a host file, so the MCP dispatch itself goes through the CLI substrate).
Off-limits (FROZEN contracts, alpha-2 cycle)
These cannot change without a coordinated bump across fluttersdk_dusk + magic + wind:
DuskSnapshotEnrichertypedef shape (lib/src/dusk_snapshot_enricher.dart:23):String? Function(Element, RefRegistry).DuskNavigateAdaptertypedef shape (lib/src/dusk_navigate_adapter.dart:19):Future<bool> Function(String route).DuskPlugin.install()andDuskPlugin.registerNavigateAdapter()signatures, plus theDuskPlugin.enricherslive-read list that magic appends to viaMagicDuskIntegration(lib/src/dusk_plugin.dart:39,52,59).RefRegistrypublic method signatures:register,lookup,registerQuery,lookupQuery,disposeAll,resetForTesting(lib/src/ref_registry.dart:190,251,264,274,316,363). Magic-side enrichers call these directly.DuskActionabilityExceptionreason-substring vocabulary (lib/src/utils/dusk_exceptions.dart:51):"defunct (element no longer mounted)","not enabled","zero rect","off-viewport (rect=..., viewport=...)","not stable (rect changed by Xpx)","obscured by other widget (top=...)". Agents branch on these substrings.- Actionability-gate evaluation order (
lib/src/utils/actionability_gate.dart): (0) defunct preflight, (1) enabled, (2) zero-rect, (3) off-viewport (auto-showOnScreenif aScrollableancestor exists), (4) not-stable (2-frame rect drift > 0.5px; opt-out--no-checkStable), (5) receives-events (hit-test path includes target or descendant; opt-out--no-checkReceivesEvents). New checks append; do not reorder. Step 5 reportsconfirmed/indeterminate/skippedthroughActionabilityReport; the order and the reason substrings are the frozen part, the report is additive. e<N>andq<N>token spaces are disjoint. Never minte<N>fromext.dusk.find/observeorq<N>fromext.dusk.snap.- The 6 alpha-1 MCP tool names (
dusk_snap,dusk_tap,dusk_screenshot,dusk_hover,dusk_drag,dusk_type) and their backingext.dusk.*method names. Renames break pinned consumer scripts and agent prompts. install.yamlat the package root is load-bearing forplugin:install fluttersdk_dusk. Do not delete; it carries the post-install bootstrap message and theexecutables:mapping anchor.- No new production dependencies beyond
fluttersdk_artisan,image,meta,fluttersdk_wind_diagnostics_contracts,yaml.yamljoined for thedusk:perf_runscenario files; it added no package to any consumer graph, becausefluttersdk_artisanalready depends on it, and its only importer islib/src/perf/scenario.dart.
Style
final classon new concrete record types and command impls.abstract classfor handler shared bases when one exists.Elementreferences inside enrichers are never retained across calls; the enricher contract is synchronous and stateless.- Every
developer.registerExtensioncall routes throughregisterExtensionIdempotent(fromfluttersdk_artisan); duplicate registration on hot-restart would otherwise throwArgumentError. - Numbered step comments (
// 1.,// 2.) inside handler bodies that have three or more distinct phases (parse params, actionability check, synthesise event, return payload). - Docblocks (
///) on public classes and the public contracts only; skip decorative docstrings on trivial getters. - No mockito. Stub via contract inheritance or plain fakes inside the test file.
RefRegistry.resetForTesting()intearDownto prevent ref state leaking between tests.
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.

