Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
SwiftUI Refactor
Use this reference for SwiftUI View structure, dependency injection, Observation usage, MV patterns, and ViewModel boundaries.
Core Guidelines
View Ordering
Prefer this order inside a SwiftUI view:
- Environment values.
- Stored
letvalues. @Stateand other stored properties.- Non-view computed properties.
init.body.- Computed view builders and view helpers.
- Helper / async functions.
Prefer Model-View
- Default to SwiftUI-native Model-View patterns.
- Views are lightweight state expressions; models/services own business logic.
- Favor
@State,@Environment,@Query,task, andonChangefor orchestration. - Inject services and shared models via
@Environmentwhen that matches the app architecture. - Split large views into subviews before adding a ViewModel.
For deeper rationale, read references/mv-patterns.md.
Split Large Bodies
- If
bodyspans multiple logical sections, split it. - Keep simple computed view helpers in the same file when that improves local readability.
- Extract standalone
Viewtypes when there is state, complex branching, reuse, or a clear component boundary. - Prefer passing small inputs, bindings, and callbacks over passing the entire parent state.
ViewModel Handling
- Do not introduce a ViewModel unless the request or existing code clearly calls for one.
- If a ViewModel exists, make it non-optional when possible.
- For
@Observablereference types owned by a root view, store them as@State. - Initialize
@Stateview models ininitwhen dependencies are provided by the view. - Avoid
bootstrapIfNeededpatterns when a clear initializer can establish state.
Example:
@State private var viewModel: SomeViewModel
init(dependency: Dependency) {
_viewModel = State(initialValue: SomeViewModel(dependency: dependency))
}
Refactor Workflow
- Reorder the view to match the ordering rules.
- Identify which state actually drives each section.
- Split large body sections into smaller views or helpers.
- Move business logic out of views only when it is genuinely business logic or expensive work.
- Preserve behavior unless the user asks for behavior changes.
- Check Observation usage and dependency boundaries.
- Provide a before/after summary and verification plan.
Output
- Structural issues found.
- Refactor plan with behavior-preserving steps.
- Code changes if the user asked for implementation.
- Risks: data flow changes, animation changes, identity changes, preview coverage.
- Verification: build, previews, relevant unit/UI tests, and manual scenario.