Swift Binding Fixer

VerifiedSafe

Fixes SwiftUI binding errors ($var issues) by adding @Bindable to @Observable ViewModels in the Leavn app.

Sby Skills Guide Bot
DevelopmentIntermediate
306/2/2026
Claude Code
#swiftui#bindable#observable#binding-errors

Recommended for

Our review

Fixes SwiftUI 'cannot find $viewModel' errors by adding @Bindable to @Observable ViewModels.

Strengths

  • Automates a repetitive fix
  • Uses concrete patterns from the Leavn app
  • Combines grep and editing for precise correction

Limitations

  • Only works with @Observable ViewModels
  • May need manual tweaking for unlisted cases
  • Depends on build_output.txt for error detection
When to use it

When the SwiftUI compiler reports a $viewModel binding error in a view using an @Observable ViewModel.

When not to use it

For binding errors not related to @Observable or in projects without SwiftUI ViewModels.

Security analysis

Safe
Quality score85/100

The skill uses only safe tools (Read, Edit, Grep) to modify Swift source code. It fixes a specific SwiftUI binding issue without any destructive, obfuscated, or exfiltrating actions.

No concerns found

Examples

Fix HomeViewModel binding
Fix 'cannot find $viewModel' error in HomeView. The viewModel is @Observable HomeViewModel and uses $viewModel in sheet bindings.
Fix CommunityViewModel sheet
Fix binding error: Cannot find '$viewModel' in CommunityView. The viewModel is @Observable CommunityViewModel and uses $viewModel for showCreateSheet bindings.

name: swift-binding-fixer description: Fix SwiftUI binding errors ($var issues) by adding @Bindable to @Observable ViewModels in Leavn app allowed-tools: Read, Edit, Grep disable-model-invocation: false context: fork user-invocable: true argument-hint: "[context]"

Swift Binding Fixer

Instructions

Fix "cannot find '$viewModel'" errors:

  1. Find the error:

    grep "cannot find '\$viewModel'" build_output.txt
    
  2. Read the view file:

    • Check if viewModel is @Observable type
    • Look for @State var viewModel or var viewModel
    • Find all $viewModel.property usages
  3. Apply fix:

    // BEFORE
    @State var viewModel: MyViewModel
    // OR
    var viewModel: MyViewModel
    
    // AFTER (if using $viewModel)
    @Bindable var viewModel: MyViewModel
    
  4. Common Leavn patterns:

    • HomeViewModel: Use @Bindable for sheet bindings
    • CommunityViewModel: Use @Bindable for showCreate* bindings
    • SettingsViewModel: Use @Bindable for alert bindings
    • SermonAIView: Use @Bindable for showing* bindings

Use this skill when: $viewModel errors, @Observable binding issues, sheet presentation errors

Related skills