MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Mvvm-Toolkit

Mvvm-Toolkit是一款code方向的AI技能,核心价值是CommunityToolkit,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

CommunityToolkit.Mvvm (the MVVM Toolkit) core: source generators ([ObservableProperty], [RelayCommand], [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyDataErrorInfo]), base classes (

Last verified on: 2026-05-30
mkdir -p ./skills/mvvm-toolkit && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/mvvm-toolkit/SKILL.md -o ./skills/mvvm-toolkit/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# CommunityToolkit.Mvvm (core)


Use this skill when authoring or reviewing ViewModels, properties,

commands, or validation in apps that use `CommunityToolkit.Mvvm` 8.x.


> **Companion skills.** Load **`mvvm-toolkit-messenger`** for `IMessenger`

> pub/sub patterns. Load **`mvvm-toolkit-di`** for

> `Microsoft.Extensions.DependencyInjection` integration.


> **Quick recap.** `[ObservableProperty]` on private fields in `partial`

> classes; `[RelayCommand]` on instance methods; inherit from

> `ObservableObject` (or `ObservableValidator` for input forms,

> `ObservableRecipient` when using `IMessenger`).


---


Package & setup


xml
<ItemGroup>
  <PackageReference Include="CommunityToolkit.Mvvm" Version="8.*" />
</ItemGroup>

Targets: `netstandard2.0`, `netstandard2.1`, `net6.0`+. Works on .NET, .NET

Framework, Mono. Source generators ship in the same NuGet — no extra

analyzer reference required.


Namespaces:


csharp
using CommunityToolkit.Mvvm.ComponentModel;   // ObservableObject, [ObservableProperty]
using CommunityToolkit.Mvvm.Input;             // [RelayCommand], RelayCommand, AsyncRelayCommand

> **Universal rule.** Every type that uses `[ObservableProperty]` or

> `[RelayCommand]` — and every enclosing type, if nested — must be

> declared `partial`. Without it, the generators emit

> `MVVMTK0008` / `MVVMTK0042`.


---


Source generators cheat sheet


| Attribute | Applied to | Generates |

|-----------|-----------|-----------|

| `[ObservableProperty]` | private field | Public `INotifyPropertyChanged` property + `OnXxxChanging`/`OnXxxChanged` partial-method hooks |

| `[NotifyPropertyChangedFor(nameof(Other))]` | observable field | Also raises `PropertyChanged` for the listed property |

| `[NotifyCanExecuteChangedFor(nameof(MyCommand))]` | observable field | Calls `MyCommand.NotifyCanExecuteChanged()` on change |

| `[NotifyDataErrorInfo]` | observable field on `ObservableValidator` | Calls `ValidateProperty(value)` from the setter |

| `[NotifyPropertyChangedRecipients]` | observable field on `ObservableRecipient` | `Broadcast(old, new)` after the change |

| `[RelayCommand]` | instance method | Lazy `RelayCommand` / `AsyncRelayCommand` exposed as `IRelayCommand` / `IAsyncRelayCommand` |

| `[RelayCommand(CanExecute = nameof(CanX))]` | instance method | Wires `CanExecute` to a method or property |

| `[RelayCommand(IncludeCancelCommand = true)]` | async method with `CancellationToken` | Also generates `XxxCancelCommand` |

| `[RelayCommand(AllowConcurrentExecutions = true)]` | async method | Allows queued/parallel invocations (default disables while running) |

| `[RelayCommand(FlowExceptionsToTaskScheduler = true)]` | async method | Surfaces exceptions via `ExecutionTask` instead of awaiting and rethrowing |

| `[property: SomeAttr]` | observable field or `[RelayCommand]` method | Forwards `SomeAttr` onto the generated property (e.g., `[JsonIgnore]`) |


**Naming.** Field `name` / `_name` / `m_name` → `Name`. Method `LoadAsync` →

`LoadCommand` (the `Async` suffix is stripped; a leading `On` is also

stripped).


See [`references/source-generators.md`](references/source-generators.md) for

the full attribute reference with generated-code samples.


---


ViewModel patterns


Simple observable property


csharp
public partial class ContactViewModel : ObservableObject
{
    [ObservableProperty]
    private string? name;
}

Hooks: `OnXxxChanging` / `OnXxxChanged`


csharp
[ObservableProperty]
private string? name;

partial void OnNameChanged(string? value) =>
    Logger.LogInformation("Name changed to {Name}", value);

Both single-arg `(value)` and two-arg `(oldValue, newValue)` overloads

are available. Implement only the ones you need; unimplemented hooks are

elided by the compiler (zero runtime cost).


Dependent properties + dependent commands


csharp
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
[NotifyCanExecuteChangedFor(nameof(SaveCommand))]
private string? firstName;

[Observab

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Mvvm-Toolkit to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is Mvvm-Toolkit compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Mvvm-Toolkit?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Mvvm-Toolkit?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/mvvm-toolkit/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills