Migrates a Flutter app's Maestro UI flows (.yaml) to Patrol end-to-end tests. Translates commands, replaces selectors with widget keys, moves JS scripts to Dart, and verifies each test passes before proceeding to the next.
Ships in flutter-patrol. 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.
Read when SKILL.md points to them.
A migration is done when every Maestro flow has a Patrol test that proves the same behavior and passes on a device. Maestro drives an installed app from outside, through the accessibility tree; Patrol runs inside the app and finds Flutter widgets. Selectors, animation waits and platform workarounds written for Maestro mostly disappear.
Companion skills — load them if installed, they own their topics:
patrol-setup — first-time Patrol setup, when the project has none.patrol-write-test — Patrol API, assertion, native-dialog and test-key rules. They
apply here, except for the points listed in Rules that change for a migration.patrol-test-architecture — add-on to patrol-write-test for the modular layout
(Modules, System, ApiClients).The command-by-command mapping is in references/command-mapping.md. Read it before translating the first flow.
key: to an existing widget, plus the keys files. No new widgets, no refactors, no
new Semantics, no deleting Semantics or labels that Maestro needed. Build
configuration Patrol needs is allowed: the pubspec, the native test runner wiring,
and the Kotlin / Android Gradle plugin / Gradle versions Patrol requires. A key that
is not const forces dropping const from the widget that takes it — that edit is
part of adding the key.lib/ rewrites
files you never touched when the project uses an older formatter style.assert* becomes an
assertion. A step with no Patrol equivalent gets a // TODO(maestro: <command>)
marker and goes in the final report. A flow that ends without an assertion gets one
that proves its effect, listed in the report as added.try/catch
around a failing step, no skip. If it fails, find out why (see Debugging).The Maestro flow is the specification, so where patrol-write-test or
patrol-test-architecture say otherwise, these win:
onFlowComplete, and restoring device state the test changed (airplane mode, mock
location), become a patrolTearDown, even though those skills say not to write
teardowns on your own. The teardown is registered in main(), outside testApp, so
it builds its own clients (BackendClient(), and
System(config: PlatformAutomatorConfig.defaultConfig()) in the modular layout or
PlatformAutomator(config: ...) without it), and the test file imports
package:patrol.assertVisible stays in the middle of the test, where the flow has it.assertNotVisible and assertTrue need expect and its matchers, which
package:patrol does not export: import them from package:flutter_test with a
show list (show expect, isFalse, findsNothing).showDatePicker and showTimePicker, and the items of an open dropdown menu.
Scope them when the text is ambiguous: $(DatePickerDialog).$('OK') (the widget
types come from package:flutter/material.dart).Read everything before writing code:
config.yaml in the Maestro directory, including nested
directories and subflows referenced by runFlow: file:.runScript / evalScript JS file — these are backend setup and teardown.--include-tags,
--exclude-tags, -e env vars and per-platform install scripts — they decide
which flows run on which platform.lib/main.dart — everything main() does before runApp (Firebase init, DI,
env loading) is what the Patrol test must do before pumping the app.integration_test code, and any existing keys files. If a test
structure already exists, follow it.Write a migration table and show it to the user before step 2. When nobody is there to answer, put it in the report and continue.
| Maestro flow | Patrol test | Platforms | Setup / teardown | Native interactions | Keys to add |
|---|
The Platforms column comes from the tags together with how CI runs the flows. Comments in flows explain platform limits and selector workarounds — keep them in mind when translating.
If the project has no Patrol setup, run the patrol-setup skill first. The example/
directory of the patrol package in the pub cache has a working native setup for the
installed version. Take the patrol: block values from the flows: appId is the
Android package_name and the iOS bundle_id (check applicationId and the bundle id
in the native projects — a flow's appId can be a flavor's id).
When the Android build fails on a toolchain version, raise only the version the Gradle
error names — a missing compilerOptions() method means the Kotlin Gradle plugin
(org.jetbrains.kotlin.android in android/settings.gradle(.kts)) is too old. Each fix
can reveal the next error. List every version change in the report. Run the first
build in the background.
Values the flows read from env: blocks or -e, and credentials or account names
written into the flows, go to .patrol.env and are read with String.fromEnvironment.
Gitignore .patrol.env and the generated patrol_test/test_bundle.dart.
Write one helper that starts the app the way main() does: the same initialization,
then await $.pumpWidgetAndSettle(const MyApp()). Every test calls it first. This is
the Patrol launchApp. Initialization that may run only once per process needs a
guard that skips it when it already ran: tests share one process on Android without
the test orchestrator, and across hot restarts under patrol develop.
Setup that runs before the app starts can need the same initialization (a backend call
through one of the app's repositories). Split the helper: one guarded init that setup
and teardown can call, and one that runs it and pumps the app.
With no existing Patrol code and patrol-test-architecture installed, use its layout:
create Modules, System and ApiClients from that skill's examples before the first
test, and this base class and wrapper next to the start helper:
abstract class Module {
const Module(this.$);
final PatrolIntegrationTester $;
}
void testApp(
String description,
Future<void> Function(
PatrolIntegrationTester $,
Modules modules,
System system,
ApiClients apiClients,
) callback, {
dynamic tags,
}) {
patrolTest(description, tags: tags, ($) async {
final system = System(config: PlatformAutomatorConfig.defaultConfig());
await callback($, Modules($), system, ApiClients());
});
}
Each test sets up its own state, so a flow that relied on state left by an earlier
flow needs that state created in its own setup. Clean state between tests differs by
platform: on Android, clearPackageData wipes app data before every test; on iOS a
plain patrol test keeps app data, --clear-permissions resets permissions before
each test, and only --full-isolation (Simulator, experimental) reinstalls the app
between tests. For each flow that needs a clean start
on iOS, pick a reset — --full-isolation, or resetting the state in setup — and name
it in the report.
patrol-write-test /
patrol-test-architecture). Text taps, id:, index:, rightOf:, below:,
childOf: and point: on in-app UI all become keys. A widget whose label changes
with state gets one key per state, chosen by the same condition.tapOn an empty field followed by inputText is one enterText.if (patrolTargetPlatform == PatrolTargetPlatform.android) { testApp(...); }.
With build-time test discovery main() also runs on the host, where Platform
describes the computer and would drop the test from the manifest. Inside a test
body Platform is fine.onFlowStart setup into the test body, before the app starts, and
onFlowComplete into a patrolTearDown registered in main(). A runScript in
the middle of a flow stays at its position, as a Dart call; values it passes on
(output.x) become local variables. Write the JS HTTP calls in Dart, reusing the
app's own repositories or API clients when they already do the call. Cleanup must
succeed when there is nothing to delete, and must wait for data the app wrote
through its own SDK: the test can see it in the app before the backend has it.
patrolTearDown has no $: native calls there go through an automator built with
a config, PlatformAutomator(config: PlatformAutomatorConfig.defaultConfig()). With
no config every call throws UnimplementedError.assertVisible becomes a
waitUntilVisible() at the end.runFlow: when: platform:
blocks with different selectors for Android and iOS collapse into one key. Keep a Platform.isIOS branch only
for behavior that really differs.waitForAnimationToEnd and hideKeyboard before a tap are not needed:
Patrol waits for the widget before acting. An extendedWaitUntil keeps its
condition and timeout: when the next step taps the element it waits for, pass the
timeout as tap(visibleTimeout: ...); otherwise it becomes
waitUntilVisible(timeout: ...). Patrol's default wait is 10 seconds.optional: true. Decide whether the element appears in the test environment:
if it does, the step is mandatory; if it never does, drop the step and list it in the
report. An optional permission dialog becomes
if (await $.platform.mobile.isPermissionDialogVisible(timeout: ...)) { ... }, with a
timeout as long as the dialog can take to appear — the default is one second. Any
other optional step that depends on device state is the user's call; when nobody is
there to answer, make it mandatory and say so in the report.Patrol finders see only Flutter widgets. These go through $.platform, using the
Patrol MCP native-tree tool to read the native UI and pick selectors:
grantPermissionWhenInUse(), grantPermissionOnlyThisTime(),
denyPermission(). Maestro's launchApp grants all permissions by default and
Patrol does not, so a dialog can appear in Patrol where the flow had no step for it.
These calls throw when no dialog is shown.$.platform.mobile.tap(MobileSelector(...)), $.platform.mobile.waitUntilVisible(...).
On iOS, native queries search the app under test unless given another app's bundle
id: $.platform.tap(selector, appId: 'com.apple.mobilesafari').A tap that opens a native dialog, a WebView, a map, a camera preview or anything that
keeps animating needs tap(settlePolicy: SettlePolicy.noSettle), otherwise the tap
waits for a frame that never settles.
run if it is configured, otherwise
patrol test -t <file>. With more than one device attached, pass device (the MCP
devices tool lists them).run is patrol develop. It hot-restarts the app: app data and
granted permissions stay from the previous run, and patrolTearDown may not run.
quit before running a different file — while a session is open, run with a new
file returns the previous file's result with a warning. Before rerunning a test that needs a fresh install state
(a permission dialog, a first-launch screen), quit and, on Android,
adb shell pm clear <package>.patrol test run: it builds and installs the app,
and on Android clears its data before every test (on iOS see the clean-state note
in step 3). Finish with the full suite, twice.When all flows are done, give the user:
point: taps that
became a native API call, travel timing, optional steps made mandatory,
assertions added.TODO(maestro: …) left, every app file changed, every build version raised.run shows no output for minutes. The build is likely failing.
Build the test bundle directly to see the error:
flutter build apk --debug --target patrol_test/test_bundle.dart.screenshot). If the
element is off-screen, add .scrollTo(). If it is native UI, use $.platform.DropdownButton builds its
items both in the button and in the open menu, and a key on DropdownMenuItem can
match the copy that is not hit-testable. Tap the item by its text and remove the
unused key.Semantics labels and tooltips.
Find the widget and key it.SettlePolicy.noSettle on that tap.What SKILL.md sets; muted values are Claude Code's defaults
/flutter-patrol:patrol-migrate-from-maestrofrom flutter-patrol
flutter-patrol@leancode-ai-plugins is listed by leancodepl/ai-plugins — review the source before installing
npx claudepluginhub leancodepl/ai-plugins --plugin flutter-patrol4 skills in this plugin
/patrol-setupSet up Patrol end-to-end (E2E) testing in a Flutter project for the first time — configure the pubspec `patrol` block, wire native Android, and get a first minimal test passing on an Android emulator. Covers Android only (iOS and other platforms follow the same install doc). Use when adding Patrol to a project that does not have it yet./patrol-test-architectureAdd-on to patrol-write-test for Patrol test suites built on LeanCode's recommended architecture — Modules, System, and ApiClients — with per-feature keys.dart files. Use together with patrol-write-test when the project's Patrol tests already follow this architecture (e.g. a `patrol_test/modules/` directory and a `testApp` wrapper), or when the user asks to introduce it or to organize test code into modules./patrol-write-testWrite Patrol end-to-end (E2E) tests for a Flutter app — order of actions, Patrol API and assertion rules, native dialog handling, and test-key conventions. Use when adding or editing Patrol/integration tests, assigning widget keys for testing, or debugging a failing Patrol test.Other plugins' skills for the same job