View refactor

From fanfan-de/anybox · View interactive version

View refactor is an AI agent skill from the GitHub repository fanfan-de/anybox. Refactor macOS SwiftUI views and scenes into stable structure. Use when splitting large views, tightening scene state, or narrowing AppKit escapes.

How to use this skill

Skill file

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

2) Keep a predictable file shape

2b) Split files by responsibility

3) Prefer dedicated subview types over many computed `some View` fragments

4) Keep selection and layout stable

5) Extract commands, toolbars, and actions out of `body`

6) Use scene and app storage intentionally

7) Keep AppKit escape hatches narrow

8) Observation usage

Workflow

  1. Identify the current scene boundary and whether the file is trying to do too much.
  2. Reorder the file into a predictable top-to-bottom structure.
  3. Extract desktop-specific sections into dedicated subview types.
  4. Stabilize the root layout around selection, scenes, and commands rather than top-level branching.
  5. Move action logic, command routing, and toolbar behavior into named helpers or separate types.
  6. Tighten any AppKit bridge so the imperative edge is small and explicit.
  7. Keep behavior intact unless the request explicitly asks for structural and behavioral changes together.

Refactor Checklist

Common Smells

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.