/desktop-apps-macos-linux:desktop-cross-platform-and-architecturefrom desktop-apps-macos-linux
Guides choosing cross-platform desktop frameworks (Electron, Tauri, Flutter, Qt, etc.), structuring app architecture (state management, IPC, threading), and implementing native-feeling features (windows, menus, drag-and-drop, dark mode, accessibility).
Ships in desktop-apps-macos-linux. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 3 of 5 of the Desktop Application Programming — macOS & Linux reference (plugin
desktop-apps-macos-linux), covering §7–§9. Sibling skills:desktop-macos-platform(§0–§3),desktop-linux-platform(§4–§6),desktop-packaging-security-and-testing(§10–§13),desktop-reference(§14–§20). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: Verified August 2026. See §18 →
desktop-referencefor the currency snapshot and what goes stale first.
How to read this. Reference, not tutorial. Sections are independent. Three markers:
- [UNIVERSAL] — true of desktop software regardless of platform or toolkit.
- [PLATFORM] — specific to macOS or a particular Linux stack. Verify against current docs.
- [CONTESTED] — competent engineers disagree. Both cases given; don't adjudicate for the reader.
⚠️ GOTCHA boxes mark the failure modes that actually cost people days.
The single most important framing in this document: macOS is one platform with one vendor, one HIG, and one blessed path. Linux is not a platform — it is a family of overlapping conventions (freedesktop specs), two dominant toolkits, two display protocols, three packaging formats, and a dozen desktop environments. Advice that treats them symmetrically is wrong. Almost every difficulty in cross-platform desktop work traces back to this asymmetry.
| Framework | Language | Rendering | Bundle (typical) | Idle RAM (typical) | Native feel | Maturity |
|---|---|---|---|---|---|---|
| Electron | JS/TS + Node | Bundled Chromium | 80–200 MB | 150–300 MB | Low (unless heavily worked) | Very high (13 yrs) |
| Tauri 2 | JS/TS + Rust | OS WebView | 2–10 MB | 30–50 MB | Medium | High, younger |
| Wails 3 | JS/TS + Go | OS WebView | small | low | Medium | Medium |
| Neutralino | JS/TS + thin C++ | OS WebView | 1–5 MB | very low | Low | Low |
| Qt 6 | C++ / Python / QML | Own (raster/RHI) | 20–60 MB | 40–80 MB | High (Widgets) | Very high (31 yrs) |
| Flutter | Dart | Own (Impeller/Skia) | 20–50 MB | 60–120 MB | Low (identical everywhere by design) | High on mobile, medium on desktop |
| Avalonia | C#/XAML | Own (Skia → Impeller in progress) | ~40 MB + runtime | medium | Medium (drawn, WPF-like) | High for desktop |
| .NET MAUI | C#/XAML | Native controls per platform | — | — | Medium | Mobile-first; no first-party Linux |
| Compose Multiplatform | Kotlin | Own (Skia) | JVM-sized | higher | Low-Medium | Growing fast |
| Slint | Rust/C++/JS + DSL | Own | small | low | Medium | Medium; embedded-focused |
| egui / iced / Xilem / GPUI | Rust | Own | small | low | Low | Varies; see §7.4 |
(Figures are representative ranges from published 2026 comparisons, not measurements of your app. Benchmark your own workload — this is the one place vendor numbers are least trustworthy.)
[CONTESTED], and the numbers are real but not the whole story.
Case for Electron:
electron-builder, electron-updater, code-signing
recipes, crash reporting, native modules, Stack Overflow answers for every failure mode.Case for Tauri 2:
Case against Tauri (the honest knocks):
Migration reality: porting a mid-size Electron app is commonly reported at ~2–3 months — you must reimplement every Node native integration in Rust, rework IPC, and chase WebView rendering differences. Do it when bundle size or memory is causing actual user pain, not on principle.
Also in this space: Wails 3 (Go backend, clean DX, performance claims still mostly
vendor-reported), and deno desktop (shipped in Deno 2.9, June 2026) — best ergonomics
for porting an existing web app, but explicitly experimental, and Deno's own docs concede
Tauri produces far smaller apps.
// main.js — the settings that separate a safe Electron app from a browser
// with filesystem access. These are non-negotiable.
const win = new BrowserWindow({
webPreferences: {
contextIsolation: true, // MUST be true (default since Electron 12)
nodeIntegration: false, // MUST be false
sandbox: true, // renderer in an OS sandbox
webSecurity: true, // never disable to "fix" CORS
preload: path.join(__dirname, 'preload.js'),
}
});
// preload.js — expose a MINIMAL, typed, validated surface. Never expose ipcRenderer.
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
// Good: one narrow, named operation
readConfig: () => ipcRenderer.invoke('config:read'),
// BAD (do not do this): send: (ch, ...a) => ipcRenderer.send(ch, ...a)
});
// main process — validate EVERY argument. The renderer is untrusted.
ipcMain.handle('config:read', async (event) => {
if (!isTrustedSender(event.senderFrame)) throw new Error('untrusted');
return await loadConfigFromKnownPath(); // never a caller-supplied path
});
Plus: a strict Content-Security-Policy; block will-navigate and
setWindowOpenHandler to external origins; never shell.openExternal() a URL that came
from remote content; keep Electron current (you inherit every Chromium CVE, and old
Electron versions are a standing supply-chain liability).
Tauri's equivalent discipline: keep the capability/permission JSON tight, validate command
arguments in Rust, and don't enable withGlobalTauri in production.
The ecosystem is real but fragmented, and every option is a compromise.
| Library | Model | Best for | Weakness |
|---|---|---|---|
| egui (eframe) | Immediate mode | Tools, debug UIs, fastest zero→window | Non-native look; no retained accessibility model; re-renders continuously |
| iced | Elm/functional | Structured apps; more native feel than egui | Documentation gaps; ecosystem thinner |
| Slint | Declarative DSL | Polished product UI, embedded + desktop; commercial licensing available | DSL is another language; smaller community |
| Dioxus | React-like | Web devs; can render via WebView or natively | WebView path inherits WebView trade-offs |
| Xilem | Data-first, from the Druid team | Aligned with Rust's architecture; the "future" bet | Still maturing |
| GPUI | GPU-first, from Zed | Extreme performance, custom rendering | Effectively Zed's framework; limited outside it |
| gtk4-rs / cxx-qt | Bindings | You want a real mature toolkit with Rust | You're using GTK/Qt, with binding friction |
| wxDragon / fltk-rs | Bindings to native | Genuinely native controls → free screen-reader accessibility | Older toolkits, dated aesthetics |
[CONTESTED] Is Rust GUI production-ready? Advocates point to shipping apps and rapid improvement. Skeptics point to a widely-circulated 2026 write-up in which a developer benchmarked egui, iced, Slint, and GTK for a data-heavy table application (search, filter, sort, inline edit), hit walls in each, and shipped Electron for the UI with Rust for the core. Both accounts are honest. The reliable synthesis: Rust GUI is ready for tools, utilities, and apps where you control the design; it is not yet a low-risk choice for dense, data-grid-heavy business applications, and accessibility is the weakest link across every self-drawn Rust toolkit.
┌───────────────────────────────────────────────────────┐
│ Platform UI SwiftUI/AppKit │ GTK4/Qt6 │ ← thin, idiomatic, per-platform
├──────────────────────────────────┴──────────────────── ┤
│ Presentation view models / stores / commands │ ← testable, platform-free
├───────────────────────────────────────────────────────┤
│ Domain entities, rules, use cases │ ← pure. no I/O, no UI, no clock
├───────────────────────────────────────────────────────┤
│ Ports (traits/protocols) FileStore, Clock, Net, Prefs │ ← the seam
├───────────────────────────────────────────────────────┤
│ Adapters real FS, real network, real keychain │ ← platform-specific, thin
└───────────────────────────────────────────────────────┘
[UNIVERSAL] The domain layer must not import a UI framework, a clock, or a filesystem. Everything it needs comes in through a port you can substitute in tests. This is the single highest-leverage architectural decision in a desktop app, for the same reason it is in firmware: it converts a 30-second click-through into a 30-millisecond test.
| Pattern | Where it's idiomatic | Notes |
|---|---|---|
| MVVM | SwiftUI (@Observable view models), Qt/QML, Avalonia, WPF-lineage | The desktop default. Keep view models free of framework types. |
| MVC | AppKit, GTK (loosely) | Classic; degrades into massive controllers without discipline |
| Unidirectional / Redux-ish | Elm-inspired (iced), TCA on Apple platforms, Electron+Redux | Excellent for undo/replay/time-travel; verbose |
| MVP / MVVM-C | Large enterprise apps | Explicit navigation ownership |
[UNIVERSAL] Single source of truth. Desktop apps have multiple windows, inspectors, sidebars, and a menu bar all reflecting the same state. The moment two of them own overlapping state, you get the classic desktop bug: change something in the inspector, and the sidebar shows the old value. One store; views derive.
Desktop apps that edit user data have obligations that web apps don't:
UndoManager — register undo closures at the model layer, not the view layer.NSDocument autosave-in-place and Versions
browsing largely for free; SwiftUI's DocumentGroup inherits it. On Linux you implement
it: write to a temp file in the same directory, fsync, then rename() (atomic on the
same filesystem). Never truncate-and-write the user's file in place — a crash
mid-write destroys their data.// Undo done at the model layer, with coalescing — the shape that works
final class TextModel {
private(set) var text: String = ""
weak var undoManager: UndoManager?
private var coalescingToken: Int = 0
func replace(with new: String, actionName: String, coalesce: Bool = false) {
let old = text
if coalesce && undoManager?.isUndoing == false {
// group rapid edits into one undoable action
undoManager?.groupsByEvent = false
}
undoManager?.registerUndo(withTarget: self) { target in
target.replace(with: old, actionName: actionName) // inverse re-registers redo
}
undoManager?.setActionName(actionName) // "Undo Typing" in the Edit menu
text = new
}
}
[UNIVERSAL] The main thread budget is ~8 ms per frame at 120 Hz, ~16 ms at 60 Hz. Everything else goes off it.
| Work | Where |
|---|---|
| Any file I/O (yes, even "small" reads) | Background |
| Network | Background |
| Parsing, decoding, compression | Background |
| Database queries | Background (or a dedicated actor/queue) |
| Layout, drawing, widget mutation | Main only |
| Sorting/filtering a 10k-row list | Background, deliver a prepared snapshot |
Platform mechanics: macOS → Swift Concurrency (@MainActor + actor + Task) or GCD.
GTK → do work on a thread, marshal back with glib::idle_add_local /
g_main_context_invoke. Qt → QThread/QtConcurrent + queued signal-slot connections
(cross-thread signals are queued automatically, which is the point).
⚠️ GOTCHA — the progress indicator that isn't. A spinner rendered on the same thread that's blocked doesn't spin. If your "loading" UI freezes, the work is on the main thread. This is diagnostic, not cosmetic.
Cancellation is a first-class requirement on desktop. Users close windows, switch documents, and retype search queries. Every long operation needs a cancellation token checked at intervals, and a UI affordance to trigger it.
Reasons to split processes: crash isolation, privilege separation, plugin sandboxing, using a different language/runtime for part of the app.
| Platform | Mechanism |
|---|---|
| macOS | XPC (lifecycle-managed, typed, launchd-integrated) |
| Linux | D-Bus (discoverable, desktop-standard) or plain Unix sockets |
| Cross-platform | Unix domain sockets + a length-prefixed framed protocol; or gRPC; or stdin/stdout with JSON-RPC (what LSP does, and it works fine) |
[UNIVERSAL] Design the protocol to be versioned and forward-compatible from message one. In a desktop app the two processes can end up at different versions during an update; ignoring unknown fields and negotiating a version at handshake avoids a whole class of upgrade bugs.
Desktop users expect: clicking the launcher when the app is running raises the existing window; opening a file when the app is running opens it in the running instance.
NSApplication handles reopen and application(_:open:).GtkApplication/GApplication with G_APPLICATION_HANDLES_OPEN gives you
D-Bus-based single-instance and Open/Activate for free. Qt requires
QtSingleApplication-style code or your own lock file + D-Bus name./tmp is not a correct single-instance mechanism — it
survives crashes, breaks across users, and fails under Flatpak. Own a D-Bus name.This section is the difference between "a program with a window" and "a Mac app" / "a GNOME app." It is mostly unglamorous and almost entirely what users notice.
NSWindow.setFrameAutosaveName /
@SceneStorage; Linux: persist to $XDG_STATE_HOME yourself (Wayland will not let
you set absolute position — restore size and let the compositor place it).[PLATFORM] The macOS menu bar is a contract. Users expect: an App menu with About/Settings(⌘,)/Services/Hide/Quit(⌘Q); File with New(⌘N)/Open(⌘O)/Close(⌘W)/Save(⌘S); Edit with Undo(⌘Z)/Redo(⇧⌘Z)/Cut/Copy/Paste/Select All; a Window menu with Minimize(⌘M)/Zoom and the window list; a Help menu with searchable help. Every command in your app should be in a menu, even if it's also a toolbar button — that's how Help search and accessibility find it, and how power users discover shortcuts.
[PLATFORM] On Linux, menu conventions are contested. GNOME's HIG moved away from menu bars toward header bars with a hamburger menu; KDE retains traditional menu bars. If you use libadwaita you follow GNOME; if you use Qt/KDE you follow the traditional model. Either is defensible; inconsistency within your own app is not.
Keyboard, everywhere [UNIVERSAL]:
NSOpenPanel/fileImporter. On Linux, the
FileChooser portal — even if you're not sandboxed, because it gives the user their
desktop's real dialog, with their bookmarks and recent files. A custom file browser is
almost always a mistake.NSDocumentController handles it; Linux uses
GtkRecentManager / the recently-used.xbel spec.NSColor.labelColor, Color.primary,
GTK's @theme_fg_color, Qt's palette roles), never hardcoded hex. React to live
changes (macOS: NSApp.effectiveAppearance KVO / SwiftUI @Environment(\.colorScheme);
Linux: the Settings portal's color-scheme key, which works for sandboxed apps too).gtk-enable-animations and the
high-contrast theme.String(localized:) + String Catalogs (.xcstrings). Linux: gettext
(_("...")), .po/.mo, or Qt's tr() + Linguist. Rust: fluent.if n == 1., vs . —
a classic parsing bug), sort order, first day of the week, paper size (A4 vs Letter),
and address/name formats.[UNIVERSAL] Non-negotiable, increasingly a legal requirement (ADA/Section 508 in the US; the European Accessibility Act obligations that landed in 2025 for many consumer products in the EU). The floor:
NSAccessibility.post(element:notification:);
ARIA-live equivalents in web shells).Testing: macOS → VoiceOver (⌘F5) and Accessibility Inspector (bundled with Xcode). Linux → Orca plus Accerciser to inspect the AT-SPI tree. Web shells → the browser's accessibility tree devtools. Custom-drawn UI has zero accessibility unless you build it — this is the strongest practical argument for native widget toolkits.
| Metric | Target | Why |
|---|---|---|
| Cold launch to interactive | < 1 s (macOS), < 2 s | Beyond this it "feels slow" |
| Frame time | < 16 ms (60 Hz), < 8 ms (120 Hz ProMotion) | Dropped frames read as jank |
| Input → visible response | < 100 ms | Perceived as instantaneous |
| Any operation > 1 s | Must show progress | Otherwise "it froze" |
| Any operation > 10 s | Must be cancellable + backgroundable | |
| Idle CPU | ~0% | A desktop app that burns CPU idle drains laptops and gets uninstalled |
| Idle RAM | As low as the framework allows | The most common complaint about Electron apps |
The idle-CPU point deserves emphasis. Timers that fire every 100 ms "just in case",
animations that never stop, polling loops, and immediate-mode GUIs that re-render
continuously all produce measurable battery drain. Use event-driven updates and pause work
when the window isn't visible (macOS: occlusionState; Wayland: frame callbacks stop
for hidden surfaces — respect them rather than rendering blind).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
desktop-apps, cross-platform, electron, tauri, flutter, qt, native-feel, architecture
5 skills in this plugin
/desktop-linux-platformUse when building or debugging a Linux desktop app. Covers why 'Linux' is not one platform (the stack, XDG base directories, .desktop files and app IDs), D-Bus as the desktop's nervous system, PipeWire, the honest accessibility picture, GTK4 + libadwaita, Qt 6, the other toolkits, and the Wayland transition — what Wayland takes away from X11 (global hotkeys, window positioning, screen capture) and what replaces it (portals, layer-shell)./desktop-macos-platformUse when building, porting, or debugging a native macOS app. Covers the framework decision and the four architectures of a desktop app (the router for the whole desktop-apps-macos-linux reference), the Darwin stack, bundles, the run loop/GCD/main thread, XPC privilege separation, Apple silicon, Rosetta, and universal binaries, the 2026 SwiftUI-vs-AppKit state of play and the interop seam, Liquid Glass (macOS 26 Tahoe), Mac Catalyst, Swift 6 strict concurrency migration, and persistence on macOS (SwiftData, Core Data, GRDB)./desktop-packaging-security-and-testingUse when shipping a desktop app: macOS code signing, the Hardened Runtime, notarization and stapling, the four macOS distribution channels including the Mac App Store; the Linux packaging matrix (Flatpak, Snap, AppImage, distro packages); auto-update (Sparkle, Squirrel, Flatpak); sandboxing and privacy (TCC, entitlements, the App Sandbox, Keychain and secrets, XDG portals, supply-chain and dependency risk); and the desktop testing pyramid, tools, and CI.npx claudepluginhub the-vibey-project/vibey --plugin desktop-apps-macos-linuxOther plugins' skills for the same job