SwiftUIアプリをヴァイブコーディングするのはとても楽しい
本文の状態
日本語全文を表示中
詳細モードで約6分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Simon Willison Blog
筆者が新しいM5 MacBook ProでローカルLLMを実行し、Activity Monitorに不満を持ち、パフォーマンス監視ツールをヴァイブコーディングで開発した。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
新しいノートパソコンを手に入れました——128GBのM5 MacBook Proで、初期の印象では優れたローカルLLMを実行するのに非常に能力があるようです。アクティビティモニターに不満を感じ、パフォーマンス監視のための代替ツールをバイブコーディングで作成することに決め、結果にとても満足しています。
これはmacOSアプリのバイブコーディングでの2回目の実験です——最初は数週間前に作ったこのプレゼンテーションアプリでした。
Claude Opus 4.6とGPT-5.4の両方がSwiftUIに非常に熟練していることがわかりました——そして完全なSwiftUIアプリは単一のテキストファイルに収まるため、Xcodeを開かずに何かを立ち上げるためにこれらを使用できます。
これまでに2つのアプリを構築しました: Bandwidtherはどのアプリがネットワーク帯域幅を使用しているかを表示し、GpuerはGPUで何が起こっているかを表示します。Claudeの提案により、これらは両方とも情報でいっぱいのパネルを開くメニューバーアイコンになりました。
Bandwidther
最初にこのアプリを構築しました。Dropboxが何をしているかを見たかったからです。このように見えます:
最初バージョンのアプリを構築するために使用した完全なトランスクリプトを共有しました。私のプロンプトはかなり最小限でした:
このマシンからインターネットへのネットワーク帯域幅がどれだけ使用されているかを、ローカルLANとの対比で表示してください
(私の最初の好奇心は、Dropboxが古いコンピューターからLAN経由でファイルを転送しているのか、インターネットからダウンロードしているのかを見ることでした。)
/tmp/bandwidtherディレクトリを作成し、これらの詳細を継続的にライブ表示するネイティブSwiftUIアプリをそこに記述してください
これで最初のバージョンができ、これがさらに追求する価値があることを証明しました。
git initして、これまでに作成したものをgit commitしてください
新しい機能を追加し始めようとしていたからです。
次に、そのアプリに追加できる機能を提案してください。目標は、異なるアプリによる使用を含むネットワーク使用に関するできるだけ詳細な情報を提供することです
Claudeに機能を提案させることの良い点は、私よりも何が可能かについてはるかに良いアイデアを持っていることです。
いくつかのバグを修正するために少しやり取りをし、その後、上記の2列レイアウトに到達するためにさらにいくつかのプロンプトを送信しました:
プロセスごとの帯域幅を追加し、完了したらアプリを再起動してください
次に逆DNS機能を追加しますが、元のIPアドレスも小さな書体で表示されるようにしてください
アプリを再設計して幅を広げ、2列にします——左側にプロセスごとの列、右側に残りを配置します
OK、タスクバーアイコンにしてください。アイコンをクリックするとアプリが表示されるようにし、アイコン自体はきちんとした最小限の小さなものにしてください
ソースコードとビルド手順はsimonw/bandwidtherで入手できます。
Gpuer
Bandwidtherを構築しているセッション中に、GPUが何をしているかを見るための同様のツールを構築する別のセッションを実行していました。これが最終的にできたものです:
これがトランスクリプトです。進行中のBandwidtherを例として使用できたため、これはさらに少ないプロンプトで済みました:
このコンピューターがどれだけのRAMとGPUを使用しているかを知りたいのですが、GPUとRAM上のものはアクティビティモニターに表示されないようで難しいです
これはsystem_profilerとmemory_pressureを使用して情報を収集し、回答をくれました——さらに重要なことに、これが可能であることを示してくれたので、私は言いました:
/tmp/bandwidtherを見てから、上記の情報を継続的に表示する、あるいはより良い方法で表示する同様のアプリを/tmp/gpuerに作成してください
Bandwidtherアプリにさらにいくつかの変更を加えた後、追いつくように指示しました:
次に、/tmp/bandwidtherの最近の変更を見てください——そのアプリはシステムトレイアイコンを使用するようになりました。それを模倣してください
これは、コーディングエージェントを使用する際の私のお気に入りのトリックの1つです: 他のプロジェクトから要素を再結合させることです。
GpuerのコードはGitHubのsimonw/gpuerで見つけることができます。
これらのアプリを信頼すべきではありません
これら2つのアプリは典型的なバイブコーディングです: 私はSwiftを知らず、彼らが書いているコードをほとんど見ませんでした。
さらに重要なことに、これらのツールが測定している値などのmacOS内部についての経験がほとんどありません。これらのツールが吐き出す数字やチャートが信頼できるか正確かを評価する資格は全くありません!
その効果について両方のGitHubリポジトリに警告を追加しました。
今朝、Gpuerが明らかにそうではなかった(アクティビティモニターによると)のに、たった5GBのメモリしか残っていないと報告しているのを見つけました。スクリーンショットをClaude Codeに貼り付け、計算を調整し、新しい数字は正しく見えますが、それでも正しく報告しているかどうか確信が持てません。
これらをGitHubで共有したのは、ClaudeがSwiftUIで何ができるかの例として興味深いと思ったからです。
アプリ自体への自信のなさにもかかわらず、これらのプロジェクトからいくつかの有用なことを学びました:
- SwiftUIアプリは単一のコードファイルで多くのことを達成できます——これがGpuerApp.swift(880行)とBandwidtherApp.swift(1063行)です。
- 様々なターミナルコマンドをSwiftで整ったUIにラップすることは簡単に達成できます。
- ClaudeはSwiftUIアプリケーションに関して驚くほど良いデザインセンスを持っています。
- アプリをメニューバーアプリにすることも、わずか数行の追加コードで済みます。
- この種のアプリケーションをビルドするためにXcodeを開く必要はありません!
これら2つのアプリは非常に短時間で構築され、SwiftUIでmacOSアプリを構築することが将来のプロジェクトで考慮すべき新しい能力であると確信させてくれました。
タグ: macos, ai, generative-ai, llms, vibe-coding, coding-agents, swift, claude-code
原文を表示
I have a new laptop - a 128GB M5 MacBook Pro, which early impressions show to be *very* capable for running good local LLMs. I got frustrated with Activity Monitor and decided to vibe code up some alternative tools for monitoring performance and I'm very happy with the results.
This is my second experiment with vibe coding macOS apps - the first was this presentation app a few weeks ago.
It turns out Claude Opus 4.6 and GPT-5.4 are both very competent at SwiftUI - and a full SwiftUI app can fit in a single text file, which means I can use them to spin something up without even opening Xcode.
I’ve built two apps so far: Bandwidther shows me what apps are using network bandwidth and Gpuer to show me what’s going on with the GPU. At Claude’s suggestion both of these are now menu bar icons that open a panel full of information.
Bandwidther
I built this app first, because I wanted to see what Dropbox was doing. It looks like this:
I’ve shared the full transcript I used to build the first version of the app. My prompts were pretty minimal:
Show me how much network bandwidth is in use from this machine to the internet as opposed to local LAN
(My initial curiosity was to see if Dropbox was transferring files via the LAN from my old computer or was downloading from the internet.)
mkdir /tmp/bandwidther and write a native Swift UI app in there that shows me these details on a live ongoing basis
This got me the first version, which proved to me this was worth pursuing further.
git init and git commit what you have so far
Since I was about to start adding new features.
Now suggest features we could add to that app, the goal is to provide as much detail as possible concerning network usage including by different apps
The nice thing about having Claude suggest features is that it has a much better idea for what’s possible than I do.
We had a bit of back and forth fixing some bugs, then I sent a few more prompts to get to the two column layout shown above:
add Per-Process Bandwidth, relaunch the app once that is done
now add the reverse DNS feature but make sure original IP addresses are still visible too, albeit in smaller typeface
redesign the app so that it is wider, I want two columns - the per-process one on the left and the rest on the right
OK make it a task bar icon thing, when I click the icon I want the app to appear, the icon itself should be a neat minimal little thing
The source code and build instructions are available in simonw/bandwidther.
Gpuer
While I was building Bandwidther in one session I had another session running to build a similar tool for seeing what the GPU was doing. Here’s what I ended up with:
Here's the transcript. This one took even less prompting because I could use the in-progress Bandwidther as an example:
I want to know how much RAM and GPU this computer is using, which is hard because stuff on the GPU and RAM does not seem to show up in Activity Monitor
This collected information using system_profiler and memory_pressure and gave me an answer - more importantly it showed me this was possible, so I said:
Look at /tmp/bandwidther and then create a similar app in /tmp/gpuer which shows the information from above on an ongoing basis, or maybe does it better
After a few more changes to the Bandwidther app I told it to catch up:
Now take a look at recent changes in /tmp/bandwidther - that app now uses a sys tray icon, imitate that
This remains one of my favorite tricks for using coding agents: having them recombine elements from other projects.
The code for Gpuer can be found in simonw/gpuer on GitHub.
You shouldn't trust these apps
These two apps are classic vibe coding: I don't know Swift and I hardly glanced at the code they were writing.
More importantly though, I have very little experience with macOS internals such as the values these tools are measuring. I am completely unqualified to evaluate if the numbers and charts being spat out by these tools are credible or accurate!
I've added warnings to both GitHub repositories to that effect.
This morning I caught Gpuer reporting that I had just 5GB of memory left when that clearly wasn't the case (according to Activity Monitor). I pasted a screenshot into Claude Code and it adjusted the calculations and the new numbers *look* right, but I'm still not confident that it's reporting things correctly.
I only shared them on GitHub because I think they're interesting as an example of what Claude can do with SwiftUI.
Despite my lack of confidence in the apps themselves, I did learn some useful things from these projects:
- A SwiftUI app can get a whole lot done with a single file of code - here's GpuerApp.swift (880 lines) and BandwidtherApp.swift (1063 lines).
- Wrapping various terminal commands in a neat UI with Swift is easily achieved.
- Claude has surprisingly good design taste when it comes to SwiftUI applications.
- Turning an app into a menu bar app is just a few lines of extra code as well.
- You don't need to open Xcode to build this kind of application!
These two apps took very little time to build and have convinced me that building macOS apps in SwiftUI is a new capability I should consider for future projects.
Tags: macos, ai, generative-ai, llms, vibe-coding, coding-agents, swift, claude-code
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み