Agent skill

Flutter Auto Hot Reload

This skill should be used when the user asks to "set up auto hot reload", "enable automatic reload", "hot reload on save", "watch for file changes", "auto reload flutter", or mentions wanting Flutter to automatically reload when files change. Provides configuration for terminal-based workflows, VS Code, Android Studio, and multi-device setups.

Stars 2
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/jclfocused/claude-agents/tree/main/skills/flutter-auto-reload

SKILL.md

Flutter Auto Hot Reload

This skill provides guidance for setting up automatic hot reload in Flutter projects, enabling instant UI updates when code changes without manual intervention.

Overview

Flutter's hot reload injects updated source code into the running Dart VM, preserving app state while showing changes instantly. By default, terminal-based workflows require manually pressing 'r' after each change. This skill enables automatic hot reload across different development environments.

Terminal-Based Workflows (Claude Code, vim, etc.)

Method 1: PID File + File Watcher (Recommended)

Start Flutter with the --pid-file flag to enable signal-based hot reload:

bash
# Start Flutter with PID tracking
flutter run -d chrome --pid-file=/tmp/flutter.pid
flutter run -d iPhone --pid-file=/tmp/flutter.pid
flutter run -d emulator-5554 --pid-file=/tmp/flutter.pid

Then use a file watcher to trigger reload on changes:

Using fswatch (macOS):

bash
# Install if needed
brew install fswatch

# Watch lib/ and trigger hot reload on changes
fswatch -o lib/ | xargs -n1 -I{} kill -USR1 $(cat /tmp/flutter.pid)

Using entr (cross-platform):

bash
# Install if needed
brew install entr  # macOS
apt install entr   # Linux

# Watch and reload
find lib -name '*.dart' | entr -p kill -USR1 $(cat /tmp/flutter.pid)

Using inotifywait (Linux):

bash
while inotifywait -r -e modify lib/; do
  kill -USR1 $(cat /tmp/flutter.pid)
done

Signal Reference

Signal Action Use Case
SIGUSR1 Hot Reload Dart file changes
SIGUSR2 Hot Restart pubspec.yaml, asset changes

Method 2: flutter_hot_reload Package

Install the CLI wrapper that handles file watching automatically:

bash
dart pub global activate flutter_hot_reload

Run instead of flutter run:

bash
flutter_hot_reload -d chrome
flutter_hot_reload -d iPhone

Features:

  • Watches .dart files automatically
  • Hot restarts on pubspec.yaml changes
  • Works with any editor or terminal
  • No IDE plugin required

Method 3: Web Experimental Hot Reload (Flutter 3.32+)

For web development specifically:

bash
flutter run -d chrome --web-experimental-hot-reload

This enables automatic hot reload for web without additional setup.

Chrome DevTools MCP Integration

When using Chrome DevTools MCP to interact with Flutter web apps, use web-server mode instead of -d chrome to avoid conflicts.

The Problem

Running flutter run -d chrome opens its own Chrome instance. If you also have Chrome DevTools MCP connected to a separate Chrome viewing the same app, you'll get GlobalKey conflicts:

A GlobalKey was used multiple times inside one widget's child list.
The offending GlobalKey was: [LabeledGlobalKey<NavigatorState>]

This happens because both Chrome instances are running the same Flutter app simultaneously.

The Solution: Web Server Mode

Start Flutter as a web server without opening a browser:

bash
# Start Flutter web server only (no browser opens)
flutter run -d web-server --web-port=61060 --pid-file=/tmp/flutter.pid

Then navigate your MCP Chrome to the app:

  • URL: http://localhost:61060

Hot Reload with Web Server Mode

Hot reload signals still work with web-server mode:

bash
# Hot reload
kill -USR1 $(cat /tmp/flutter.pid)

# Hot restart
kill -USR2 $(cat /tmp/flutter.pid)

After sending the signal, refresh the MCP Chrome page to see the changes (the web server recompiles, but the browser needs to reload).

Quick Setup for MCP

bash
# Terminal 1: Start Flutter web server
flutter run -d web-server --web-port=61060 --pid-file=/tmp/flutter.pid

# Then use Chrome DevTools MCP to navigate to http://localhost:61060
# Hot reload with: kill -USR1 $(cat /tmp/flutter.pid)

Note: Unlike -d chrome mode where hot reload updates instantly, with web-server + MCP you may need to refresh the browser after triggering reload.

Multi-Device Auto Reload

Run multiple devices simultaneously with auto-reload for all:

bash
# Terminal 1: iOS Simulator
flutter run -d iPhone --pid-file=/tmp/flutter-ios.pid

# Terminal 2: Android Emulator
flutter run -d emulator-5554 --pid-file=/tmp/flutter-android.pid

# Terminal 3: Chrome
flutter run -d chrome --pid-file=/tmp/flutter-web.pid

# Terminal 4: Watcher (reloads ALL devices)
fswatch -o lib/ | xargs -n1 -I{} sh -c 'kill -USR1 $(cat /tmp/flutter-ios.pid) $(cat /tmp/flutter-android.pid) $(cat /tmp/flutter-web.pid) 2>/dev/null'

VS Code Setup

VS Code with the Flutter extension supports auto hot reload natively:

  1. Open Settings (Cmd+,)
  2. Search "Flutter Hot Reload On Save"
  3. Set to one of:
    • manual - Only on manual save (Cmd+S)
    • all - On manual save and autosave
    • allDirty - When file has unsaved changes
    • manualDirty - Manual save only if changes exist

Recommended setting for autosave users:

json
{
  "dart.flutterHotReloadOnSave": "all"
}

Android Studio / IntelliJ Setup

  1. Open Settings > Tools > Actions on Save
  2. Enable "Save files if IDE is idle for X seconds" (recommend 2 seconds)
  3. Open Settings > Languages & Frameworks > Flutter
  4. Check "Perform hot reload on save"

Convenience Script

Use the bundled script for easy setup:

bash
# From skill directory
~/.claude/skills/flutter-auto-reload/scripts/flutter-watch.sh -d chrome
~/.claude/skills/flutter-auto-reload/scripts/flutter-watch.sh -d iPhone

Troubleshooting

Hot Reload Not Triggering

  1. Verify PID file exists: cat /tmp/flutter.pid
  2. Verify process is running: ps -p $(cat /tmp/flutter.pid)
  3. Check file watcher is running and watching correct directory
  4. Ensure changes are in lib/ directory (not test/ or other)

Hot Reload vs Hot Restart

Some changes require hot restart (SIGUSR2) instead of reload:

  • Changes to main() function
  • Changes to global/static variables initialization
  • Changes to native code
  • Asset changes
  • pubspec.yaml changes

State Not Preserved

Hot reload preserves state, but if state is lost:

  • Check for errors in console
  • Ensure no syntax errors in changed files
  • Try hot restart if reload fails silently

Quick Reference

Environment Command
Terminal + fswatch fswatch -o lib/ | xargs -n1 -I{} kill -USR1 $(cat /tmp/flutter.pid)
Terminal + entr find lib -name '*.dart' | entr -p kill -USR1 $(cat /tmp/flutter.pid)
flutter_hot_reload flutter_hot_reload -d <device>
Web experimental flutter run -d chrome --web-experimental-hot-reload
VS Code Set dart.flutterHotReloadOnSave to all
Android Studio Enable in Settings > Flutter > Hot reload on save

Resources

Expand your agent's capabilities with these related and highly-rated skills.

jclfocused/claude-agents

graphite-workflow

Use this skill when working with Graphite (gt) for stacked PRs, using execute-issue-graphite agent, or when the user mentions Graphite, stacking, or gt commands. Ensures proper use of gt commands instead of raw git for stack-aware operations.

2 0
Explore
jclfocused/claude-agents

vertical-slice-planning

Use this skill when discussing feature breakdown, PR structure, implementation ordering, or how to decompose work. Guides thinking about vertical slices (end-to-end functionality) rather than horizontal layers (all of one layer first). Triggers on "how should we break this down?", "what order should we implement?", "how many PRs?", or decomposition discussions.

2 0
Explore
jclfocused/claude-agents

issue-writing

Use this skill when writing, reviewing, or discussing issue descriptions, acceptance criteria, or task breakdowns. Ensures consistent, high-quality issue structure that any developer or AI can pick up and execute. Triggers when drafting issues, defining requirements, or when users ask "how should I write this issue?" or "what should the acceptance criteria be?"

2 0
Explore
jclfocused/claude-agents

mvp-scoping

Use this skill when discussing features, planning work, or when users describe what they want to build. Guides MVP thinking - focusing on "what's the minimum to make this work?" rather than comprehensive solutions. Triggers on phrases like "help me think through this feature", "what should we build first?", "how should we scope this?", or any feature planning discussion.

2 0
Explore
jclfocused/claude-agents

atomic-design-planning

Use this skill when discussing UI components, design systems, frontend implementation, or component architecture. Guides thinking about Atomic Design methodology - atoms, molecules, organisms - and promotes component reuse over creation. Triggers on UI/frontend discussions, "what components do we need?", "should I create a new component?", or design system questions.

2 0
Explore
jclfocused/claude-agents

linear-discipline

Use this skill when discussing code changes, implementation work, feature status, or when starting/completing development tasks. Reminds about Linear issue tracking discipline - always having an issue in progress before writing code, marking work as done, and creating issues for unexpected scope. Triggers when users mention implementing features, writing code, or checking on work status.

2 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results