>100 Views
November 07, 25
スライド概要
git worktree を用いて Flutter 開発する際、各 worktree のディレクトリで flutter run する必要があるのが課題です。そこで、ディレクトリのパスはそのままに、中身の worktree だけ入れ替えることで hot restart のみで任意の worktree の変更を確認できるシェルスクリプトを作成しました。
Flutter×AIぽちぽちLT会 with ale in 梅田
https://potipotinotsudoi.connpass.com/event/372558/
Parallel Claude Code x Flutter ゆにねこ 1
$ whoami ゆにねこ (Twitter) Google Developer Group on Campus Ex-Organizer 大阪大学基礎工学部情報科学科 Flutterエンジニア@Gather, inc. 好きなこと・勉強していること Web (Next.js, React, Hono.js, Google Cloud etc) Flutter Unity, Blender (初心者) 関数型, 圏論, モデル検査 2
Coding Agent 使ってますか? 3
Flutter と Coding Agent 現在地点 (主観) tool overview dart-mcp pub.dev 検索, widget tree, get runtime errors etc flutter-mcp Flutter ドキュメント検索 etc serena コード検索, ファイル検索 etc gemini-search Gemini CLI を呼び出して Web 検索 Sub Agents 役割ごとにシステムプロンプトを変更 git worktree worktree ごとに Agent を並列実行 4
Flutter と Coding Agent 現在地点 (主観) tool overview dart-mcp pub.dev 検索, widget tree, get runtime errors etc flutter-mcp Flutter ドキュメント検索 etc serena コード検索 gemini-search Gemini CLI を呼び出して Web 検索 Sub Agents 役割ごとにシステムプロンプトを変更 git worktree worktree ごとに Agent を並列実行 5
git worktree? 6
異なるディレクトリにブランチを作成する方法 複製先ディレクトリ, 複製先ブランチ名, 複製元ブランチ名を指定して (~/foo-app/main) $ git worktree add ../issue-123 -b issue-123 main 実行すると下記のようなディレクトリ構成になる foo-app ├─ main ├─ issue-123 └─ issue-124 7
Usecase: 異なるタスクを並列して実行する 8
例えば: ディレクトリでは BarPage の UI を更新 issue-124/ ディレクトリでは状態管理の不具合を修正 issue-123/ とか 9
おすすめツール: wtp git worktree より簡潔なコマンドで worktree を作成・削除できる worktree 作成時にフックを設定できる .wtp.yml: hooks: post_create: - type: copy from: .env.example to: .env - type: command command: "npm install" https://zenn.dev/satococoa/articles/f93f34f0e13696 10
Pain 11
flutter run を各 worktree ごとに実行するのが辛い・・・例えば: 1. issue-123 を Claude に作業させる 2. issue-123 で flutter run する (n分の待ちが発生) 3. issue-124 も作業させる 4. issue-124 でも flutter run する (n分の待ちが発生) flutter run のバッテリー消費も大きい 12
Solution 13
git worktree のディレクトリを swap する 1. ステージング + 未追加のファイルを stash に追加 2. 入れ替え対象のブランチを Detached HEAD してメインのディレクトリと交換 3. stash を apply foo-app-workspace ├─ main # ├─ issue-123 # └─ issue-124 ここで flutter run ここと main を入れ替え 14
シェルスクリプトを作った $ git worktree add ../example-1 $ ../swap.sh ~/proj/GG_worktrees/GG example-1 https://gist.github.com/Harineko0/c98 c3663a0e16c7d3932a07c4f20f33b 15
他にいいアイデアあったら教えてください 16
おまけ 17
11/22 Devfest Tokyo で展示します https://gdgtokyo.connpass.com/event/369416/ 12月 京大の GDG と AI Coding 勉 強会します @京都 18