Awesome-omni-skill dotnet-maui
.NET MAUI component and application patterns Triggers on: **/*.xaml, **/*.cs
install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/dotnet-maui" ~/.claude/skills/diegosouzapw-awesome-omni-skill-dotnet-maui && rm -rf "$T"
manifest:
skills/development/dotnet-maui/SKILL.mdsource content
.NET MAUI
.NET MAUI Code Style and Structure
- Write idiomatic and efficient .NET MAUI and C# code.
- Follow .NET and .NET MAUI conventions.
- Keep UI (Views) focused on layout and bindings; keep logic in ViewModels and services.
- Use async/await for I/O and long-running work to keep the UI responsive.
Naming Conventions
- Follow PascalCase for component names, method names, and public members.
- Use camelCase for private fields and local variables.
- Prefix interface names with "I" (e.g., IUserService).
.NET MAUI and .NET Specific Guidelines
- Utilize .NET MAUI's built-in features for component lifecycle (e.g. OnAppearing, OnDisappearing).
- Use data binding effectively with
and MVVM patterns.{Binding} - Structure .NET MAUI components and services following Separation of Concerns.
- Use the language version supported by the repo's target .NET SDK and settings; avoid requiring preview language features unless the project is already configured for them.
Critical Rules (Consistency)
- NEVER use ListView (deprecated). Use CollectionView.
- NEVER use TableView (deprecated). Prefer CollectionView or layouts such as Grid/VerticalStackLayout.
- NEVER use Frame (deprecated). Use Border instead.
- NEVER use
layout options (deprecated). Use Grid and explicit sizing instead.*AndExpand - NEVER place ScrollView or CollectionView inside StackLayout/VerticalStackLayout/HorizontalStackLayout (can break scrolling and virtualization). Use Grid as the parent layout.
- NEVER reference images as
at runtime. Use PNG/JPG resources..svg - NEVER mix Shell navigation with NavigationPage/TabbedPage/FlyoutPage.
- NEVER use renderers. Use handlers.
- NEVER set
; useBackgroundColor
(supports gradients/brushes and is the preferred modern API).Background
Layout and Control Selection
- Prefer
/VerticalStackLayout
overHorizontalStackLayout
(more performant).StackLayout Orientation="..." - Use
for small, non-scrollable lists (≤20 items). UseBindableLayout
for larger or scrollable lists.CollectionView - Prefer
for complex layouts and when you need to subdivide space.Grid - Prefer
overBorder
for containers with borders/backgrounds.Frame
Shell Navigation
- Use Shell as the primary navigation host.
- Register routes with
and navigate withRouting.RegisterRoute(...)
.Shell.Current.GoToAsync(...) - Set
once at startup; avoid changing it frequently.MainPage - Don't nest tabs inside Shell.
Error Handling and Validation
- Implement proper error handling for .NET MAUI pages and API calls.
- Use logging for app-level errors; log and surface user-friendly messages for recoverable failures.
- Implement validation using FluentValidation or DataAnnotations in forms.
MAUI API and Performance Optimization
- Prefer compiled bindings for performance and correctness.
- In XAML, set
on pages/views/templates.x:DataType - Prefer expression-based bindings in C# where possible.
- Consider enabling stricter XAML compilation in project settings (for example
), especially in CI.MauiStrictXamlCompilation=true
- In XAML, set
- Avoid deep layout nesting (especially nested StackLayouts). Prefer Grid for complex layouts.
- Keep bindings intentional:
- Use
when values don't change.OneTime - Use
only for editable values.TwoWay - Avoid binding static constants; set them directly.
- Use
- Update UI from background work using
orDispatcher.Dispatch()
:Dispatcher.DispatchAsync()- Prefer
when you have a reference to a Page, View, or other BindableObject.BindableObject.Dispatcher - Inject
via DI when working in services or ViewModels without direct BindableObject access.IDispatcher - Use
as a fallback only when no Dispatcher is available.MainThread.BeginInvokeOnMainThread(...) - Avoid obsolete
patterns.Device.BeginInvokeOnMainThread
- Prefer
Resources and Assets
- Place images in
, fonts inResources/Images/
, and raw assets inResources/Fonts/
.Resources/Raw/ - Reference images as PNG/JPG (e.g.,
), not<Image Source="logo.png" />
..svg - Use appropriately sized images to avoid memory bloat.
State Management
- Prefer DI-managed services for shared state and cross-cutting concerns; keep ViewModels scoped to navigation/page lifetimes.
API Design and Integration
- Use HttpClient or other appropriate services to communicate with external APIs or your own backend.
- Implement error handling for API calls using try-catch and provide proper user feedback in the UI.
Storage and Secrets
- Use
for secrets (tokens, refresh tokens), and handle exceptions (unsupported device, key changes, corruption) by clearing/resetting and re-authenticating.SecureStorage - Avoid storing secrets in Preferences.
Testing and Debugging
- Test components and services using xUnit, NUnit, or MSTest.
- Use Moq or NSubstitute for mocking dependencies during tests.
Security and Authentication
- Implement Authentication and Authorization in the MAUI app where necessary using OAuth or JWT tokens for API authentication.
- Use HTTPS for all web communication and ensure proper CORS policies are implemented.
Common Pitfalls
- Changing
frequently can cause navigation issues.MainPage - Gesture recognizers on both parent and child views can conflict; use
where needed.InputTransparent = true - Memory leaks from unsubscribed events; always unsubscribe and dispose resources.
- Deeply nested layouts hurt performance; flatten the visual hierarchy.
- Testing only on emulators misses real-device edge cases; test on physical devices.