view-refactor
Skill4.3k starsChanged 5 months agoMITView on GitHub
Refactor macOS SwiftUI views and scenes with strong defaults for small dedicated subviews, stable sidebar and selection structure, explicit command and toolbar ownership, scene-aware state, and narrow AppKit escape hatches. Use when cleaning up a macOS view file, splitting oversized scene roots, removing iOS-centric patterns, or tightening mixed SwiftUI/AppKit architecture.
3 other projects use a version of this, 1 of them edited.
Trending
More talk lately.about the whole repository
Most recently taken up by
- openai/pluginsedited, first seen May 13, 2026
- LWaetzig/claude-code-skillstheir own version, first seen Apr 10, 2026
- patrickserrano/skillstheir own version, first seen Jan 17, 2026
Who's talking about robinebers/openusage
- A Hacker News story“OpenUsage: Track all your AI usage, in one panel”Hacker News · Apr 30, 2026 · 2 points
- @github-trending-js.bsky.social“📦 robinebers / openusage ⭐ 1,831 (+53) 🗒 JavaScript Burning through your subscriptions too fast? Paying …”Bluesky · Apr 12, 2026 · 1 likes
- @mikestaub2.bsky.social“This is a useful too to track your AI agent usage: github.com/robinebers/o...”Bluesky · Feb 3, 2026 · 1 likes
- XusBadia/altillo“Upstream openusage: cambios en proveedores”GitHub · Oct 5, 2026
- sudosubin/agents.nix“agent-skills.github.robinebers.openusage: 0.7.12 → 0.7.13”GitHub · Oct 3, 2026
The biggest 5 of 26 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 26
Talked about on GitHub, Bluesky and Hacker News (26 times).
On GitHub · 23
- Oct 5, 2026Upstream openusage: cambios en proveedores — XusBadia/altillo0 reactions
- Oct 3, 2026agent-skills.github.robinebers.openusage: 0.7.12 → 0.7.13 — sudosubin/agents.nix0 reactions
- Oct 3, 2026Z.ai GLM Coding Plan detected but usage resources are empty — LuigiElleBalotta/AIUsage.NET0 reactions
- Oct 1, 2026agent-skills.github.robinebers.openusage: init at 0.7.12 — sudosubin/agents.nix0 reactions
- Sep 26, 2026[quota-watch] 2026-09-26 — Claude'un oauth/usage'ı artık User-Agent'a göre dallanıyor (cedar_ember); Codex refresh token'ının tek kullanımlık olduğu doğrulandı — erayendes/mimir0 reactions
18 more on GitHub
- Sep 24, 2026usage API が 429 を返し続けると、入札も回復待ちの判定も効かなくなり、自動の着手が止まり、走っている run も stall として止められうる — maimuzo/continuo0 reactions · 130 comments
- Sep 19, 2026[quota-watch] 2026-09-19 — Claude CLAUDE_CONFIG_DIR hiç okunmuyor; Codex kendi auth.json'a token yazıyor; yeni bir oauth/profile ucu var — erayendes/mimir0 reactions · 4 comments
- Sep 16, 2026feat(cursor): Cursor card — plan usage by session token — Rast53/usage-board0 reactions · 1 comment
- Sep 13, 2026[P2][RELIABILITY][DOCUMENTATION] Complete or retire the expired Prometheus counter migration — Reese-max/lobsterpulse0 reactions · 2 comments
- Sep 9, 2026feat(muse) - Add muse-code from Meta as provider — janekbaraniewski/openusage0 reactions · 5 comments
- Sep 5, 2026[quota-watch] 2026-09-05 — Antigravity grup-kota alan adları iki bağımsız rakipte doğrulandı; Claude web endpoint'i Cloudflare engeline takılabiliyor — erayendes/mimir0 reactions · 1 comment
- Aug 29, 2026[quota-watch] 2026-08-29 — Codex 5 saatlik pencere Plus için canlıya geçti; Antigravity grup-kota alan adlarında olası uyuşmazlık — erayendes/mimir0 reactions · 3 comments
- Aug 28, 2026feat(providers): add grok quota monitoring — medokin/ReservePane0 reactions
- Aug 26, 2026feat(providers): add OpenCode Go quota monitoring — medokin/ReservePane0 reactions
- Aug 13, 2026Document OpenCode Go Rate limits from GET /zen/go/v1/usage — lidge-jun/opencodex0 reactions · 4 comments
- Aug 10, 2026[quota-watch] 2026-08-10 — Antigravity: olası app/bundle adı değişikliği ve RetrieveUserQuotaSummary'de auth race raporu (düşük güven) — erayendes/mimir0 reactions · 3 comments
- Aug 4, 2026feat(ai): add Cursor personal usage reporting — can1357/oh-my-pi0 reactions
- Jul 13, 2026openusage: 0.6.13 -> 0.7.5, add Br1ght0ne to maintainers — NixOS/nixpkgs0 reactions
- Jun 26, 2026Wire SQLite reader into getSummary() to fix usage accuracy drift (#23 root cause) — ltmoerdani/opencode-copilot-chat0 reactions · 1 comment
- Apr 30, 2026[feature]: Opencode Go without workspace ID and auth cookie — slkiser/opencode-quota0 reactions · 4 comments
- Apr 10, 2026Upstream merge — Rana-Faraz/usage-tray-windows0 reactions · 1 comment
- Apr 7, 2026limit what provider models show up (includes PR) — Rana-Faraz/usage-tray-windows0 reactions · 1 comment
- Apr 5, 2026openusage: init at 0.6.13 — NixOS/nixpkgs0 reactions · 2 comments
On Bluesky · 2
- Apr 12, 2026📦 robinebers / openusage ⭐ 1,831 (+53) 🗒 JavaScript Burning through your subscriptions too fast? Paying for stuff you never use? Stop… — @github-trending-js.bsky.social1 likes and repost
- Feb 3, 2026This is a useful too to track your AI agent usage: github.com/robinebers/o... — @mikestaub2.bsky.social1 likes and repost
On Hacker News · 1
- Apr 30, 2026OpenUsage: Track all your AI usage, in one panel2 points
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- openai/plugins★ 7.3k98% same
Wrote their own version · 2
- patrickserrano/skills★ 13same name
- LWaetzig/claude-code-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/openusage-preview-launch.mdcCursor rule
- appkit-interopSkill
- build-and-run-macos-appSkill
- build-run-debugSkill
- fix-codesign-errorSkill
- liquid-glassSkill
- macos-appkit-interopSkill
- macos-build-run-debugSkill
- macos-liquid-glassSkill
- macos-packaging-notarizationSkill
- macos-signing-entitlementsSkill
- macos-swiftpmSkill
- macos-swiftui-patternsSkill
- macos-telemetrySkill
- macos-test-triageSkill
- macos-view-refactorSkill
- macos-window-managementSkill
- packaging-notarizationSkill
- pricing-updateSkill
- release-swiftSkill
- signing-entitlementsSkill
- swiftpm-macosSkill
- swiftui-patternsSkill
- telemetrySkill
- test-macos-appSkill
- test-triageSkill
- window-managementSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. 0 are common, 11 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Do not let one giant root view silently own every desktop surface.
- Distinctive: line 23
Follow this ordering unless the file already has a stronger local convention:
- Very specific: line 37
Use App/<AppName>App.swift for the @main app and AppDelegate only.
- Very specific: line 38
Keep Views/ContentView.swift focused on root layout and composition.
- Distinctive: line 40
Keep files small and named after the primary type they contain.
- Very specific: line 45
Keep computed some View helpers small and rare.
- Distinctive: line 50
Prefer one stable split or window layout with local conditionals inside it.
- Distinctive: line 51
Avoid top-level branch swapping between radically different roots when selection changes.
- Distinctive: line 56
Do not bury non-trivial button logic inline.
- Distinctive: line 57
Do not mix command routing, menu state, and layout in the same block if they can be named clearly.
- Very specific: line 58
Keep body readable as UI, not as a desktop view controller.
- Very specific: line 62
Use @SceneStorage for per-window ephemeral state when it truly helps restore the scene.
- Very specific: line 63
Use @AppStorage for durable preferences, not transient UI toggles that only matter in one window.
- Distinctive: line 64
Keep scene-owned state close to the scene root.
- Very specific: line 68
If a representable or NSWindow bridge exists, isolate it behind a small wrapper or helper.
- Distinctive: line 69
Do not let AppKit references spread through unrelated SwiftUI views.
- Distinctive: line 70
If the bridge starts owning the feature, re-evaluate the architecture.
- Distinctive: line 86
Keep behavior intact unless the request explicitly asks for structural and behavioral changes together.
- Very specific: line 93
Keep AppDelegate and the @main app entrypoint minimal.
- Very specific: line 108
When the problem is fundamentally a missing desktop pattern, use swiftui-patterns.
- Very specific: line 109
When the problem is fundamentally a boundary with AppKit, use appkit-interop.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
View Refactor
Overview
Refactor macOS views toward small, explicit, stable scene and view types. Default to native SwiftUI for layout, selection, commands, and settings. Reach for AppKit only at the narrow edges where desktop behavior truly requires it.
Core Guidelines
1) Model scenes explicitly
- Break the app into meaningful scene roots: main window, settings, utility windows, inspectors, or menu bar extras.
- Do not let one giant root view silently own every desktop surface.
2) Keep a predictable file shape
- Follow this ordering unless the file already has a stronger local convention:
- Environment
private/publiclet@State/ other stored properties- computed
var(non-view) initbody- computed view builders / other view helpers
- helper / async functions
2b) Split files by responsibility
- For non-trivial apps, do not keep the full app, all views, models, stores, networking clients, process clients, and helpers in one Swift file.
- Accept a single Swift file only for tiny throwaway examples or snippets: roughly under 50 lines, one screen, no persistence, no networking/process client, and no reusable models.
- Use
App/<AppName>App.swiftfor the@mainapp andAppDelegateonly. - Keep
Views/ContentView.swiftfocused on root layout and composition; move feature UI into files such asViews/SidebarView.swift,Views/DetailView.swift, andViews/ComposerView.swift. - Move value types and selection enums into
Models/*.swift, stores intoStores/*.swift, app-server/network/process clients intoServices/*.swift, and small formatters/resolvers/extensions intoSupport/*.swift. - Keep files small and named after the primary type they contain.
3) Prefer dedicated subview types over many computed some View fragments
- Extract meaningful desktop sections like sidebar rows, detail panels, inspectors, or toolbar content into focused subviews.
- Keep computed
some Viewhelpers small and rare. - Pass explicit data, bindings, and actions into subviews instead of handing down the whole scene model.
4) Keep selection and layout stable
- Prefer one stable split or window layout with local conditionals inside it.
- Avoid top-level branch swapping between radically different roots when selection changes.
- Let the layout be constant; let state drive the content inside it.
5) Extract commands, toolbars, and actions out of body
- Do not bury non-trivial button logic inline.
- Do not mix command routing, menu state, and layout in the same block if they can be named clearly.
- Keep
bodyreadable as UI, not as a desktop view controller.
6) Use scene and app storage intentionally
- Use
@SceneStoragefor per-window ephemeral state when it truly helps restore the scene. - Use
@AppStoragefor durable preferences, not transient UI toggles that only matter in one window. - Keep scene-owned state close to the scene root.
7) Keep AppKit escape hatches narrow
- If a representable or
NSWindowbridge exists, isolate it behind a small wrapper or helper. - Do not let AppKit references spread through unrelated SwiftUI views.
- If the bridge starts owning the feature, re-evaluate the architecture.
8) Observation usage
- For
@Observablereference types on modern macOS targets, store them as@Statein the owning view. - Pass observables explicitly to children.
- On older deployment targets, fall back to
@StateObjectand@ObservedObjectwhere needed.
Workflow
- Identify the current scene boundary and whether the file is trying to do too much.
- Reorder the file into a predictable top-to-bottom structure.
- Extract desktop-specific sections into dedicated subview types.
- Stabilize the root layout around selection, scenes, and commands rather than top-level branching.
- Move action logic, command routing, and toolbar behavior into named helpers or separate types.
- Tighten any AppKit bridge so the imperative edge is small and explicit.
- Keep behavior intact unless the request explicitly asks for structural and behavioral changes together.
Refactor Checklist
- Split oversized view files before adding more UI.
- Move pure models, identifiers, and selection enums out of view files.
- Move
Process,URLSession, app-server, and platform client code out of SwiftUI views intoServices/. - Keep
AppDelegateand the@mainapp entrypoint minimal. - Build after each major split so compile errors stay local.
Common Smells
- A root view that mixes window scaffolding, settings, toolbar code, command handling, and detail layout.
- A single app file that mixes app entrypoint, root layout, feature views, models, stores, service clients, and support extensions.
- iOS-style push navigation forced into a Mac sidebar-detail problem.
- Several booleans for mutually exclusive inspectors, sheets, or utility windows.
- AppKit objects passed through many SwiftUI layers without a clear ownership reason.
- Large computed view fragments standing in for real subviews.
Notes
- A good macOS refactor should make scene structure, selection flow, and command ownership obvious.
- When the problem is fundamentally a missing desktop pattern, use
swiftui-patterns. - When the problem is fundamentally a boundary with AppKit, use
appkit-interop.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

