Skip to main content

claude_pilot 0.1.1 copy "claude_pilot: ^0.1.1" to clipboard
claude_pilot: ^0.1.1 copied to clipboard

AI-powered Flutter app testing and interaction via Claude. Exposes app internals through VM service extensions for MCP tools.

claude_pilot #

Lightweight Dart package that exposes your Flutter app to AI tools via VM service extensions. Add two lines to main.dart and your app becomes controllable by any tool that speaks the Dart VM service protocol.

Installation #

Add claude_pilot as a dev dependency in your pubspec.yaml:

dev_dependencies:
  claude_pilot: ^0.1.1

Then run:

flutter pub get

Usage #

Add two lines to your main.dart:

import 'package:claude_pilot/claude_pilot.dart';

void main() {
  FlutterPilot.ensureInitialized(); // <-- add this line
  runApp(const MyApp());
}

That is it. Your app now exposes service extensions that AI tools (or any VM service client) can call to inspect and interact with your running UI.

How It Works #

FlutterPilot.ensureInitialized() registers a set of Dart VM service extensions after the first frame is rendered. These extensions allow external tools to:

  • Find widgets by text, key, type, or semantics label
  • Tap, long-press, scroll, and enter text
  • Read the semantics/accessibility tree
  • List all interactive widgets on screen

The extensions are registered via dart:developer.registerExtension(), which is only available in debug and profile modes. In release builds, ensureInitialized() is a complete no-op -- the kReleaseMode guard returns immediately before any code runs.

Registered Extensions #

Extension Params Purpose
ext.claude_pilot.tap x, y or findBy, value Tap a widget by coordinates or by finder
ext.claude_pilot.enterText text Enter text into the currently focused text field
ext.claude_pilot.scroll x, y, dx, dy Scroll at a position by a given delta
ext.claude_pilot.longPress x, y or findBy, value Long-press a widget by coordinates or by finder
ext.claude_pilot.findWidget by, value Find a widget and return its bounds (centerX, centerY, left, top, width, height, type)
ext.claude_pilot.getInteractiveWidgets (none) List all interactive widgets with their positions and labels
ext.claude_pilot.getSemanticsTree maxDepth (optional, default 20) Export the semantics tree as compact AI-friendly JSON
ext.claude_pilot.getNavigation (none) Get navigator state: current route, route stack, canPop

Widget Finder #

The findWidget extension (and the findBy/value params on tap and longPress) support four finder strategies:

findBy What it matches Example value
text Text and RichText widgets whose content contains the value "Increment"
key Widgets whose Key matches (supports ValueKey and string-contains matching) "submit_button"
type Widgets whose runtimeType.toString() equals the value exactly "FloatingActionButton"
semantics Semantics widgets whose label contains the value "Add item"

When a match is found, the response includes the widget's bounding box:

{
  "found": true,
  "centerX": 195.0,
  "centerY": 680.0,
  "left": 170.0,
  "top": 655.0,
  "width": 50.0,
  "height": 50.0,
  "type": "FloatingActionButton"
}

Semantics Tree #

The getSemanticsTree extension exports the full accessibility tree as compact JSON. Each node includes only non-empty fields to keep the payload small:

{
  "tree": {
    "id": 1,
    "rect": { "x": 0, "y": 0, "w": 393, "h": 852 },
    "children": [
      {
        "id": 3,
        "label": "Increment",
        "actions": ["tap"],
        "flags": ["button", "enabled"],
        "rect": { "x": 170, "y": 655, "w": 50, "h": 50 }
      }
    ]
  }
}

Supported fields per node: id, label, value, hint, actions, flags, rect, children.

Actions: tap, longPress, scrollUp, scrollDown, scrollLeft, scrollRight, increase, decrease, setText.

Flags: button, textField, checked, selected, enabled, focused, header, image, link, slider, toggled.

Security #

  • FlutterPilot.ensureInitialized() checks kReleaseMode as its very first operation. In release builds, the method returns immediately and no extensions are registered.
  • The extensions use dart:developer.registerExtension(), which is stripped from release binaries by the Dart compiler.
  • The VM service itself is only available when an app is launched in debug or profile mode (e.g., flutter run). It is not accessible in release builds.

There is no network server, no open port, and no additional attack surface. The extensions are only reachable through the Dart VM service WebSocket, which requires knowing the randomly generated authentication token included in the URI.

Requirements #

Dependency Minimum Version
Flutter >= 3.10
Dart SDK >= 3.0

Used By #

  • @flutterpilot/mcp-server (npm) -- MCP server that connects Claude, and other AI assistants that support the Model Context Protocol, directly to your Flutter app.
  • @flutterpilot/core (npm) -- TypeScript client library for programmatic access to Flutter debug apps.

License #

MIT

0
likes
120
points
72
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

AI-powered Flutter app testing and interaction via Claude. Exposes app internals through VM service extensions for MCP tools.

Topics

#ai #mcp #debug #automation #testing

License

MIT (license)

Dependencies

flutter

More

Packages that depend on claude_pilot