agentleFS
fluttersdkfluttersdk/dusk/CLAUDE.md

dusk

CLAUDE.md3 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

The file

We split this CLAUDE.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
  1. Very specific:

    CHANGELOG always under [Unreleased]: Every behavioral or interface change lands a bullet under ## [Unreleased] in CHANGELOG.md.

    line 30
  2. Very specific:

    No new production dependencies beyond fluttersdk_artisan, image, meta, fluttersdk_wind_diagnostics_contracts, yaml.

    line 79
  3. Very specific:

    Every developer.registerExtension call routes through registerExtensionIdempotent (from fluttersdk_artisan).

    line 85
  4. Very specific:

    No mockito. Stub via contract inheritance or plain fakes inside the test file.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md
<!-- 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

CommandWhen
flutter test --coverage --exclude-tags=integration --timeout=30sDefault 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 getResolve deps.
dart pub publish --dry-runPre-publish validation. Exits 65 on warnings, 0 on a clean archive.
flutter test test/integration --tags=integrationManual opt-in CDP smoke run (requires Chrome on PATH; excluded from default CI).

Golden Rules (apply on every change)

  1. Doc sync. Any behavioral or interface change must update README.md, ARCHITECTURE.md, CHANGELOG.md (under ## [Unreleased]), the matching page under doc/**/*.md, and llms.txt in the same change. See .claude/rules/docs.md for the surface-to-file map.
  2. 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.
  3. CHANGELOG always under [Unreleased]. Every behavioral or interface change lands a bullet under ## [Unreleased] in CHANGELOG.md. Keep-a-Changelog 1.1.0 ordering: Added, Changed, Deprecated, Removed, Fixed, Security. Promote to a dated section on tag push.
  4. Green gate plus TDD. dart format lib/ test/ bin/ zero diff, dart analyze lib/ test/ bin/ zero issues, flutter test --exclude-tags=integration all green. Red-green-refactor for behavioral changes: failing test first that fails for the right reason, then implementation that turns it green.
  5. GitHub Flow. One long-lived branch: master (released, what pub.dev resolves). Cut every task branch from master, push the work, open a PR back into master. Releases ship by bumping pubspec.yaml, promoting ## [Unreleased] in CHANGELOG.md, merging the bump PR, then tagging the commit on master. No develop accumulator. 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 into master. Squash or merge per the PR's commit shape.
  • Release: open a release: X.Y.Z PR from a topic branch that bumps pubspec.yaml version: and promotes ## [Unreleased] to ## [X.Y.Z] - YYYY-MM-DD with the footer link. Merge, then git tag X.Y.Z && git push origin X.Y.Z. The tag triggers .github/workflows/publish.yml to push to pub.dev.
  • External contributors fork the repo and PR against master using the same shape.

Architecture

Single barrel: lib/dusk.dart re-exports the public API. Subsystem layout under lib/src/:

PathPurpose
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/41 ArtisanCommand subclasses (one file each) plus two shared output helpers (json_output.dart, frame_warning_output.dart), 43 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.dartDuskPlugin.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.darte<N> (snapshot-frozen, dedup-by-node.id) + q<N> (re-resolvable predicate handles) dual token system.
dusk_snapshot_enricher.dartFROZEN typedef: String? Function(Element element, RefRegistry refs).
dusk_navigate_adapter.dartFROZEN typedef: Future<bool> Function(String route).
dusk_artisan_provider.dartDuskArtisanProvider extends ArtisanServiceProvider: commands() returns 41 entries, mcpTools() returns 39 const McpToolDescriptors.
bin/fluttersdk_dusk.dartFlutter-free CLI wrapper (no dart:ui import).
lib/cli.dartCodegen barrel exporting FluttersdkDuskArtisanProvider typedef alias for consumer-side _plugins.g.dart auto-discovery.
install.yamlV1 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:

  1. DuskSnapshotEnricher typedef shape (lib/src/dusk_snapshot_enricher.dart:23): String? Function(Element, RefRegistry).
  2. DuskNavigateAdapter typedef shape (lib/src/dusk_navigate_adapter.dart:19): Future<bool> Function(String route).
  3. DuskPlugin.install() and DuskPlugin.registerNavigateAdapter() signatures, plus the DuskPlugin.enrichers live-read list that magic appends to via MagicDuskIntegration (lib/src/dusk_plugin.dart:39,52,59).
  4. RefRegistry public 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.
  5. DuskActionabilityException reason-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.
  6. Actionability-gate evaluation order (lib/src/utils/actionability_gate.dart): (0) defunct preflight, (1) enabled, (2) zero-rect, (3) off-viewport (auto-showOnScreen if a Scrollable ancestor 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 reports confirmed / indeterminate / skipped through ActionabilityReport; the order and the reason substrings are the frozen part, the report is additive.
  7. e<N> and q<N> token spaces are disjoint. Never mint e<N> from ext.dusk.find/observe or q<N> from ext.dusk.snap.
  8. The 6 alpha-1 MCP tool names (dusk_snap, dusk_tap, dusk_screenshot, dusk_hover, dusk_drag, dusk_type) and their backing ext.dusk.* method names. Renames break pinned consumer scripts and agent prompts.
  9. install.yaml at the package root is load-bearing for plugin:install fluttersdk_dusk. Do not delete; it carries the post-install bootstrap message and the executables: mapping anchor.
  10. No new production dependencies beyond fluttersdk_artisan, image, meta, fluttersdk_wind_diagnostics_contracts, yaml. yaml joined for the dusk:perf_run scenario files; it added no package to any consumer graph, because fluttersdk_artisan already depends on it, and its only importer is lib/src/perf/scenario.dart.

Style

  • final class on new concrete record types and command impls. abstract class for handler shared bases when one exists.
  • Element references inside enrichers are never retained across calls; the enricher contract is synchronous and stateless.
  • Every developer.registerExtension call routes through registerExtensionIdempotent (from fluttersdk_artisan); duplicate registration on hot-restart would otherwise throw ArgumentError.
  • 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() in tearDown to prevent ref state leaking between tests.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.