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.
What this skill does
# 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
- [Flutter Hot Reload Documentation](https://docs.flutter.dev/tools/hot-reload)
- [flutter_hot_reload Package](https://pub.dev/packages/flutter_hot_reload)
- [Flutter Auto-Reload for Terminal Workflows](https://paddo.dev/blog/flutter-auto-reload-cli-tools/)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.