From 77e2dea8000ac7f91a96b3b3c4532175574adcf3 Mon Sep 17 00:00:00 2001 From: Jaime Wren Date: Mon, 17 Aug 2026 13:38:19 -0700 Subject: [PATCH] feat(rules): add flutter-app-runtime rule for proactive hot reload https://github.com/dart-lang/ai/issues/498 Add proactive Flutter hot reload rules (flutter-app-runtime.md and flutter-app-runtime.mdc) to automate the hot reload and runtime error verification loop when editing Dart and Flutter files. Problem: The sub-second Stateful Hot Reload cycle is the cornerstone of the Flutter development experience. However, during AI-driven workflows: - Out-of-Sync Execution: Agents modify source code on disk but fail to update the active session, leaving the simulator/device screen stale. - Friction in Context Switching: Users must exit the chat interface to manually initiate a reload via the CLI ('r') or IDE tooling. - Latent Feedback on Regressions: Build failures and layout issues (e.g., RenderFlex overflows) are only revealed after manual intervention, leading to fragmented multi-turn debugging sessions. --- rules/flutter-app-runtime.md | 24 ++++++++++++++++++++++++ rules/flutter-app-runtime.mdc | 25 +++++++++++++++++++++++++ rules/hot_reload.md | 10 ---------- rules/hot_reload.mdc | 9 --------- 4 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 rules/flutter-app-runtime.md create mode 100644 rules/flutter-app-runtime.mdc delete mode 100644 rules/hot_reload.md delete mode 100644 rules/hot_reload.mdc diff --git a/rules/flutter-app-runtime.md b/rules/flutter-app-runtime.md new file mode 100644 index 0000000..527bdba --- /dev/null +++ b/rules/flutter-app-runtime.md @@ -0,0 +1,24 @@ +--- +description: Proactively connect to running Dart/Flutter apps and trigger hot reload using the flutter-app-runtime skill workflows upon editing .dart files. +globs: "**/*.dart" +--- + +# Proactive Flutter Hot Reload Rule + +Whenever you edit or modify any `.dart` file in this project, adhere to the runtime management procedures in the `flutter-app-runtime` skill: + +1. **Refer to Skill**: + - Activate and follow the `flutter-app-runtime` skill workflows for Dart Tooling Daemon (`dtd`), hot reloading, hot restarting, and runtime error inspection. + +2. **Discover & Connect**: + - Discover active running application instances using the `dtd` tool (or `list_running_apps` / `vm_service`). + +3. **Trigger Hot Reload / Hot Restart**: + - Execute `hot_reload` immediately after making changes to UI widgets or simple methods. + - Execute `hot_restart` if fundamental logic, state initialization, or `main()` was modified. + +4. **Verify Runtime Stability**: + - Run `get_runtime_errors` via `dart-mcp-server` to confirm that the hot reload/restart did not introduce new exceptions. + +5. **Fallback Handling**: + - If no running app instance is connected via DTD, briefly inform the user, but do not let it stop you from completing the code edits. diff --git a/rules/flutter-app-runtime.mdc b/rules/flutter-app-runtime.mdc new file mode 100644 index 0000000..bd0aa59 --- /dev/null +++ b/rules/flutter-app-runtime.mdc @@ -0,0 +1,25 @@ +--- +description: Proactively connect to running Dart/Flutter apps and trigger hot reload using the flutter-app-runtime skill workflows upon editing .dart files. +globs: "**/*.dart" +alwaysApply: false +--- + +# Proactive Flutter Hot Reload Rule + +Whenever you edit or modify any `.dart` file in this project, adhere to the runtime management procedures in the `flutter-app-runtime` skill: + +1. **Refer to Skill**: + - Activate and follow the `flutter-app-runtime` skill workflows for Dart Tooling Daemon (`dtd`), hot reloading, hot restarting, and runtime error inspection. + +2. **Discover & Connect**: + - Discover active running application instances using the `dtd` tool (or `list_running_apps` / `vm_service`). + +3. **Trigger Hot Reload / Hot Restart**: + - Execute `hot_reload` immediately after making changes to UI widgets or simple methods. + - Execute `hot_restart` if fundamental logic, state initialization, or `main()` was modified. + +4. **Verify Runtime Stability**: + - Run `get_runtime_errors` via `dart-mcp-server` to confirm that the hot reload/restart did not introduce new exceptions. + +5. **Fallback Handling**: + - If no running app instance is connected via DTD, briefly inform the user, but do not let it stop you from completing the code edits. diff --git a/rules/hot_reload.md b/rules/hot_reload.md deleted file mode 100644 index 68bc31b..0000000 --- a/rules/hot_reload.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -trigger: glob -globs: *.dart -description: Proactively connect to apps and hot reload ---- - -Whenever you make edits to any Dart or Flutter files in this project: -1. Proactively connect to the running application using the `dtd` tool and its subcommands. Make sure to read the schema for this tool. -2. Trigger a hot reload using the `hot_reload` tool to push the changes immediately. -3. If no app is running, inform the user but do not let it stop you from completing the code edits. diff --git a/rules/hot_reload.mdc b/rules/hot_reload.mdc deleted file mode 100644 index e97ded5..0000000 --- a/rules/hot_reload.mdc +++ /dev/null @@ -1,9 +0,0 @@ ---- -globs: *.dart -alwaysApply: false ---- - -Whenever you make edits to any Dart or Flutter files in this project: -1. Proactively connect to the running application using the `dtd` tool and its subcommands. Make sure to read the schema for this tool. -2. Trigger a hot reload using the `hot_reload` tool to push the changes immediately. -3. If no app is running, inform the user but do not let it stop you from completing the code edits.