Skip to content
Skillpedia
APIs & servers (backend)40k · #5247

mvvm-toolkit

Helps your agent build .NET apps with MVVM patterns. It generates code for properties, commands, and validation.

What it does

This tool helps programmers write code for applications more efficiently. It automates repetitive parts of creating user interfaces and commands, making development faster and less error-prone.

When to use it

  • ✓When creating or reviewing display logic (ViewModel) in an application.
  • ✓When you need to define buttons or actions that the user can perform.
  • ✓When validating information that the user enters into forms.

Example of what to ask your AI

“How can I create a button that saves user data and only works if the name field is not empty?”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/mvvm-toolkit/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/mvvm-toolkit/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool uses 'code generators' that automatically create extra code based on simple annotations the programmer adds. This avoids the programmer having to write a lot of repetitive code manually.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill mvvm-toolkit

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/mvvm-toolkit/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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

<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:

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 for the full attribute reference with generated-code samples.


ViewModel patterns

Simple observable property

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

Hooks: OnXxxChanging / OnXxxChanged

[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

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

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

public string FullName => $"{FirstName} {LastName}".Trim();

Wrapping a non-observable model

public sealed class ObservableUser(User user) : ObservableObject
{
    public string Name
    {
        get => user.Name;
        set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
    }
}

…

FAQ

Do I need to install anything extra?

No, the main tool comes bundled with the installation of the `CommunityToolkit.Mvvm` package.

What are 'code generators'?

They are tools that automatically write code for you, based on instructions you provide. They help avoid writing repetitive code.

When should I use `ObservableValidator` instead of `ObservableObject`?

Use `ObservableValidator` when your application needs to validate the information the user types into forms, such as checking if a required field has been filled.

Details

Original description by the author

CommunityToolkit.Mvvm (the MVVM Toolkit) core: source generators ([ObservableProperty], [RelayCommand], [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyDataErrorInfo]), base classes (ObservableObject / ObservableValidator / ObservableRecipient), commands (RelayCommand / AsyncRelayCommand), and validation. Companion skills: mvvm-toolkit-messenger for pub/sub, mvvm-toolkit-di for Mi

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5247
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills