home / skills / sickn33 / antigravity-awesome-skills / avalonia-zafiro-development

avalonia-zafiro-development skill

/skills/avalonia-zafiro-development

This skill enforces Avalonia Zafiro development conventions for maintainable, reactive MVVM with safety, cross-platform ViewModels, and reusable patterns.

This is most likely a fork of the avalonia-zafiro-development skill from xfstudio
npx playbooks add skill sickn33/antigravity-awesome-skills --skill avalonia-zafiro-development

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
1.7 KB
---
name: avalonia-zafiro-development
description: Mandatory skills, conventions, and behavioral rules for Avalonia UI development using the Zafiro toolkit.
---

# Avalonia Zafiro Development

This skill defines the mandatory conventions and behavioral rules for developing cross-platform applications with Avalonia UI and the Zafiro toolkit. These rules prioritize maintainability, correctness, and a functional-reactive approach.

## Core Pillars

1.  **Functional-Reactive MVVM**: Pure MVVM logic using DynamicData and ReactiveUI.
2.  **Safety & Predictability**: Explicit error handling with `Result` types and avoidance of exceptions for flow control.
3.  **Cross-Platform Excellence**: Strictly Avalonia-independent ViewModels and composition-over-inheritance.
4.  **Zafiro First**: Leverage existing Zafiro abstractions and helpers to avoid redundancy.

## Guides

- [Core Technical Skills & Architecture](core-technical-skills.md): Fundamental skills and architectural principles.
- [Naming & Coding Standards](naming-standards.md): Rules for naming, fields, and error handling.
- [Avalonia, Zafiro & Reactive Rules](avalonia-reactive-rules.md): Specific guidelines for UI, Zafiro integration, and DynamicData pipelines.
- [Zafiro Shortcuts](zafiro-shortcuts.md): Concise mappings for common Rx/Zafiro operations.
- [Common Patterns](patterns.md): Advanced patterns like `RefreshableCollection` and Validation.

## Procedure Before Writing Code

1.  **Search First**: Search the codebase for similar implementations or existing Zafiro helpers.
2.  **Reusable Extensions**: If a helper is missing, propose a new reusable extension method instead of inlining complex logic.
3.  **Reactive Pipelines**: Ensure DynamicData operators are used instead of plain Rx where applicable.

Overview

This skill defines mandatory conventions and behavioral rules for building cross-platform Avalonia UI applications using the Zafiro toolkit. It mandates a functional-reactive MVVM approach, predictable error handling, and reuse of Zafiro abstractions to ensure maintainability and correctness. The goal is consistent, testable UI code that scales across desktop and mobile targets.

How this skill works

The skill enforces pure MVVM where ViewModels remain Avalonia-independent and use ReactiveUI with DynamicData for collection pipelines. It requires explicit Result-style error handling instead of exceptions for flow control and prioritizes composition over inheritance by preferring Zafiro helpers. Before adding code, developers must search for existing helpers and propose reusable extensions when needed.

When to use it

  • Starting new Avalonia UI features that must be cross-platform and testable
  • Refactoring UI code to remove platform dependencies from ViewModels
  • Implementing reactive collection transformations or validation pipelines
  • Adding common utilities—prefer creating reusable Zafiro extensions
  • Auditing an app for predictable error handling and exception avoidance

Best practices

  • Keep ViewModels free of Avalonia types; expose plain models, commands, and observables
  • Use DynamicData for collection operations and ReactiveUI for bindings and commands
  • Return Result-like types for operations and handle errors explicitly at boundaries
  • Search the codebase for existing Zafiro helpers before writing new logic
  • Favor composable extension methods in Zafiro style instead of inlining complex behavior

Example use cases

  • Create a paged, filterable list using DynamicData pipelines and a RefreshableCollection pattern
  • Introduce a reusable Zafiro extension for debounce+distinct operator used across multiple ViewModels
  • Refactor a ViewModel to return Result<T> from async commands and display errors via a centralized UI handler
  • Implement validation flows using ReactiveUI combined with Zafiro validation helpers
  • Replace inheritance-based controls with composition and Zafiro-provided helpers for cross-platform styling

FAQ

What if a legacy ViewModel references Avalonia types?

Refactor by extracting UI-specific code into a thin adapter or service and keep the core ViewModel logic Avalonia-free. Use tests to verify behavior before and after the change.

When should I add a new Zafiro helper?

Add a helper when the logic is reusable across multiple components or reduces duplication; prefer extension methods that compose with existing Zafiro primitives.