Official agent skill

Mvvm Toolkit Di

by github in github/awesome-copilot

Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection.

OfficialMITAuto-check passedMobile

Install Mvvm Toolkit Di

skills CLI
$ npx skills add github/awesome-copilot --skill mvvm-toolkit-di -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install github/awesome-copilot mvvm-toolkit-di --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/github/awesome-copilot.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/mvvm-toolkit-di .claude/skills/mvvm-toolkit-di && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mvvm-toolkit-di
GitHub stars
40k
Used in
1 other repo
Token cost
~2.3k tokens
SKILL.md length
620 words
Files
2 (incl. references)
Skills in repo
417
Repo updated
First seen
Licence
MIT

At a glance

Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection.

  • Works in 6 steps: Ioc.Default.GetService() inside a VM… → Everything Singleton. A "per-document"… → Multiple BuildServiceProvider() calls.… → …
  • Mobile work in your project
  • SKILL.md covers When to use this skill, Recommended composition root…, Constructor injection and Lifetimes, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Mvvm Toolkit Di is an agent skill from github/awesome-copilot, published by the product's own GitHub organization. Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection. Covers the .NET Generic Host composition root, constructor injection, service lifetimes (Singleton / Transient / Scoped), IMessenger registration, resolving ViewModels in Views, keyed services, testing seams, and the legacy Ioc.Default escape hatch. Use across WPF, WinUI 3, .NET MAUI, Uno, and Avalonia.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/dependency-injection.md`).

It sits in Mobile. It works with .NET, Avalonia and Windows. The repository describes itself as: Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot. The licence is MIT.

When your agent uses it

  • Mobile work in your project

Example prompts

  • “/mvvm-toolkit-di”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Ioc.Default.GetService() inside a VM constructor. Hides the
  2. Everything Singleton. A "per-document" VM registered as singleton
  3. Multiple BuildServiceProvider() calls. Each call is a fresh
  4. Capturing IServiceProvider in long-lived objects. Indicates a
  5. No scope validation in development. Use Host.CreateDefaultBuilder()
  6. Resolving scoped services from the root provider. They're

What it can do on your machine

Read from SKILL.md and the folder at commit 727ff2e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mvvm Toolkit Di loads about 2.3k tokens when it runs, and up to ~4.4k if it reads all its reference files. Until then it costs about 101 tokens; SKILL.md has 620 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~101
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from github/awesome-copilot at commit 727ff2e, republished under its MIT licence (© github). 620 words, ~2,339 tokens.

Download SKILL.mdSave it as .claude/skills/mvvm-toolkit-di/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
mvvm-toolkit-di
description
Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection. Covers the .NET Generic Host composition root, constructor injection, service lifetimes (Singleton / Transient / Scoped), IMessenger registration, resolving ViewModels in Views, keyed services, testing seams, and the legacy Ioc.Default escape hatch. Use across WPF, WinUI 3, .NET MAUI, Uno, and Avalonia.

CommunityToolkit.Mvvm + Microsoft.Extensions.DependencyInjection

The MVVM Toolkit deliberately ships no DI container — it composes with Microsoft.Extensions.DependencyInjection, the same container ASP.NET Core, Worker services, and the .NET Generic Host use.

TL;DR. Build the service provider once at startup (prefer Host.CreateDefaultBuilder()). Register services and ViewModels. Inject through constructors. Avoid Ioc.Default.GetService<T>() in user code.


When to use this skill

  • Standing up the composition root for a new XAML app (WPF, WinUI 3, MAUI, Uno, Avalonia)
  • Choosing service/VM lifetimes
  • Wiring IMessenger once and injecting it into ObservableRecipient ViewModels
  • Resolving a page's ViewModel without coupling to a service locator
  • Diagnosing "Unable to resolve service for type X while attempting to activate Y"

For source generators and ViewModel patterns see the mvvm-toolkit skill. For Messenger pub/sub see mvvm-toolkit-messenger.


csharp
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using CommunityToolkit.Mvvm.Messaging;

public partial class App : Application
{
    public IHost Host { get; }

    public App()
    {
        Host = Microsoft.Extensions.Hosting.Host
            .CreateDefaultBuilder()
            .ConfigureServices((_, services) =>
            {
                services.AddSingleton<IFilesService, FilesService>();
                services.AddSingleton<ISettingsService, SettingsService>();
                services.AddSingleton<IMessenger>(WeakReferenceMessenger.Default);

                services.AddSingleton<ShellViewModel>();
                services.AddTransient<ContactViewModel>();
                services.AddTransient<EditorViewModel>();
            })
            .Build();
    }

    public static T GetService<T>() where T : class =>
        ((App)Current).Host.Services.GetRequiredService<T>();
}

Generic Host benefits:

  • appsettings.json binding via Microsoft.Extensions.Configuration
  • Logging via Microsoft.Extensions.Logging
  • Hosted services (IHostedService) for background work
  • Scope validation in development builds

WPF and Windows Forms must integrate the host lifetime with the app lifetime — see Use the .NET Generic Host in a WPF app.

Without Generic Host

When you only need a service container and want zero extra dependencies:

csharp
var services = new ServiceCollection();
services.AddSingleton<IFilesService, FilesService>();
services.AddTransient<ContactViewModel>();
ServiceProvider provider = services.BuildServiceProvider();

Constructor injection

Inject services and child ViewModels through the constructor:

csharp
public sealed partial class ContactViewModel(
    IFilesService files,
    IMessenger messenger,
    ILogger<ContactViewModel> logger)
    : ObservableRecipient(messenger)
{
    [ObservableProperty]
    private string? name;

    [RelayCommand]
    private async Task SaveAsync()
    {
        logger.LogInformation("Saving {Name}", Name);
        await files.SaveAsync(Name!);
    }
}

Why constructor injection beats a service locator:

  • Dependencies are explicit and visible at the call site
  • Unit tests inject fakes/mocks directly
  • The DI container validates the dependency graph at startup
  • Missing registrations throw immediately, not at first use

Lifetimes

LifetimeMethodTypical use in XAML apps
SingletonAddSingleton<T>Shell/main-window VM, settings, file/HTTP services, the shared IMessenger, app-wide caches
TransientAddTransient<T>Per-page or per-document ViewModels (a fresh instance every resolve)
ScopedAddScoped<T>Rarely needed in client apps; useful with explicit IServiceScope (e.g., per-window scopes)
csharp
services.AddSingleton<ShellViewModel>();   // 1 instance for app lifetime
services.AddTransient<NoteViewModel>();    // new instance per resolve
services.AddScoped<DialogService>();       // 1 per scope (rare)

Resolving in a View

Resolve the page's root ViewModel in code-behind, then let it pull its own dependencies:

csharp
public sealed partial class ContactPage : Page
{
    public ContactViewModel ViewModel { get; }

    public ContactPage()
    {
        ViewModel = App.GetService<ContactViewModel>();
        InitializeComponent();
    }
}

Bind in XAML with {x:Bind ViewModel.Xxx} (compiled bindings) or {Binding Xxx} against DataContext.

For navigation frameworks (WinUI 3 Frame.Navigate, MAUI Shell, Prism, MVVMCross), let the framework resolve the page and the page resolves its ViewModel from DI. Don't new ViewModels manually.


IMessenger registration

Register the messenger you want once, inject IMessenger everywhere:

csharp
services.AddSingleton<IMessenger>(WeakReferenceMessenger.Default);
// or
services.AddSingleton<IMessenger>(StrongReferenceMessenger.Default);

Then:

csharp
public sealed partial class MyViewModel(IMessenger messenger)
    : ObservableRecipient(messenger) { }

For per-window messengers, register with keyed services or as scoped instances and inject into per-window ViewModels.

See the mvvm-toolkit-messenger skill for the messenger surface area.


Show full SKILL.md (247 more words)Show less

Keyed services (.NET 8+)

Resolve different implementations of the same interface by key:

csharp
services.AddKeyedSingleton<IExporter, CsvExporter>("csv");
services.AddKeyedSingleton<IExporter, JsonExporter>("json");

public sealed partial class ExportViewModel(
    [FromKeyedServices("csv")] IExporter csvExporter,
    [FromKeyedServices("json")] IExporter jsonExporter)
    : ObservableObject { /* ... */ }

Testing seams

Constructor-injected dependencies are trivial to swap in tests. With Moq:

csharp
[Fact]
public async Task Save_calls_files_service()
{
    var files = new Mock<IFilesService>();
    var messenger = new WeakReferenceMessenger();
    var logger = NullLogger<ContactViewModel>.Instance;

    var vm = new ContactViewModel(files.Object, messenger, logger)
    {
        Name = "Ada"
    };

    await vm.SaveCommand.ExecuteAsync(null);

    files.Verify(f => f.SaveAsync("Ada"), Times.Once);
}

If you're mocking Ioc.Default or static state, the ViewModel is using a service locator — refactor to constructor injection.


Legacy: Ioc.Default

CommunityToolkit.Mvvm.DependencyInjection.Ioc is an escape hatch for cases where constructor injection is impossible — XAML-instantiated VMs for design-time data, ValueConverters, control templates.

csharp
Ioc.Default.ConfigureServices(
    new ServiceCollection()
        .AddSingleton<IFilesService, FilesService>()
        .AddTransient<ContactViewModel>()
        .BuildServiceProvider());

var files = Ioc.Default.GetRequiredService<IFilesService>();

Treat it as the last resort. Inside ViewModels, services, and any class the DI container can construct, prefer constructor injection.


Common pitfalls

  1. Ioc.Default.GetService<T>() inside a VM constructor. Hides the dependency, breaks unit tests, prevents startup graph validation.
  2. Everything Singleton. A "per-document" VM registered as singleton becomes shared state across all documents — subtle data corruption. Use AddTransient for per-instance VMs.
  3. Multiple BuildServiceProvider() calls. Each call is a fresh container — singletons aren't shared. Build once at startup.
  4. Capturing IServiceProvider in long-lived objects. Indicates a service-locator pattern. Inject the specific dependencies you need.
  5. No scope validation in development. Use Host.CreateDefaultBuilder() (which sets ValidateScopes and ValidateOnBuild in development) so registration mistakes fail at startup, not at first use.
  6. Resolving scoped services from the root provider. They're effectively promoted to singleton lifetime — the warning is silent without scope validation. Either change the lifetime or resolve from an explicit IServiceScope.

References

TopicFile
Full deep dive (Generic Host setup, lifetimes, keyed services, testing patterns, legacy Ioc)references/dependency-injection.md

External:

© github, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in skills/mvvm-toolkit-di of github/awesome-copilot.

  • SKILL.md
  • references/dependency-injection.md

Open the folder on GitHubat commit 727ff2e

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in github/awesome-copilot, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Mvvm Toolkit Di next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mvvm Toolkit Di compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mvvm Toolkit Di this skillgithub/awesome-copilot40k1 repos~2.3kAutomated safety check: PassMIT
Winuimanagedcode/dotnet-skills486—~1.4kAutomated safety check: PassMIT
QA TesterJocysCom/FocusLogger213—~12kAutomated safety check: PassGPL-3.0
Code Reviewsbroenne/mcp-windows105—~1.6kAutomated safety check: PassMIT
Windows Automationsbroenne/mcp-windows105—~1.5kAutomated safety check: PassMIT
Migrate Vstest To Mtprunceel/ReactiveProperty944—~4.3kAutomated safety check: PassMIT

Similar skills

  • Winui

    managedcode/dotnet-skills

    Build or review WinUI 3 applications with the Windows App SDK, including MVVM patterns, packaging decisions, navigation, theming, windowing, and interop boundaries with other .NET stacks.

    486 GitHub stars~1.4k tokensUpdated today
    MobileAuto-check passed
  • QA Tester

    JocysCom/FocusLogger

    Create and maintain automated tests in Microsoft-native/.NET projects with a minimal stack — MSTest runner, System.Windows.Automation for Windows desktop, Playwright for real browser smoke.

    213 GitHub stars~12k tokensUpdated 3 mo ago
    Testing & QAAuto-check passed
  • Code Review

    sbroenne/mcp-windows

    Review pull requests in mcp-windows for concrete bugs in MCP and CLI contracts, Windows UI automation, element identity, snapshots, bounded searches, and service lifetime.

    105 GitHub stars~1.6k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Windows Automation

    sbroenne/mcp-windows

    Guidance for reliable, token-efficient Windows automation through MCP.

    105 GitHub stars~1.5k tokensUpdated yesterday
    Productivity & AutomationAuto-check passed
  • Migrate Vstest To Mtp

    runceel/ReactiveProperty

    Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP).

    944 GitHub stars~4.3k tokensUpdated 1 mo ago
    DevOps & CloudAuto-check passed
  • Windows CLI

    sbroenne/mcp-windows

    Guidance for driving Windows desktop automation from the wincli command-line tool - the token-efficient entry point that mirrors the Windows MCP server.

    105 GitHub stars~1.8k tokensUpdated yesterday
    Productivity & AutomationAuto-check passed

More from github/awesome-copilot

All 417 skills in this repo
  • Acquire Codebase Knowledge

    github/awesome-copilot

    Official

    Maps an unfamiliar codebase into seven evidence-backed documents in docs/codebase/, using a scan script and templates, for onboarding or architecture write-ups.

    40k GitHub starsUsed in 1 repo~2.3k tokens
    Auto-check passed
  • Azure Architecture Autopilot

    github/awesome-copilot

    Official

    Designs Azure infrastructure from a natural-language description, or diagrams an existing resource group, then refines the design through conversation and deploys it with Bicep.

    40k GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • Draw.io Diagram Generator

    github/awesome-copilot

    Official

    Generates, edits and validates draw.io files with correct mxGraph XML, covering flowcharts, architecture, sequence, ER and UML class diagrams.

    40k GitHub starsUsed in 1 repo~4.9k tokens
    Auto-check passed
  • Credit Risk Data Cleaning

    github/awesome-copilot

    Official

    Cleans raw credit data and screens variables before loan modeling, dropping unstable, noisy or redundant features and writing an Excel report of every step.

    40k GitHub starsUsed in 1 repo~1.5k tokens
    Auto-check passed
  • Daily Focus Board

    github/awesome-copilot

    Official

    Builds a warm, browser-based daily focus board the user updates by talking to their agent, with Eisenhower priorities, a brain-dump box and kind not-today carryover.

    40k GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Python Pypi Package Builder

    github/awesome-copilot

    Official

    End-to-end skill for building, testing, linting, versioning, and publishing a production-grade Python library to PyPI.

    40k GitHub starsUsed in 1 repo~4.6k tokens
    Auto-check passed

Categories

Questions about Mvvm Toolkit Di

What does Mvvm Toolkit Di do?

Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection. Mvvm Toolkit Di is an agent skill from github/awesome-copilot, published by the product's own GitHub organization.DependencyInjection.

When should I use Mvvm Toolkit Di?

Mvvm Toolkit Di fits situations like: mobile work in your project.

How do I install Mvvm Toolkit Di in Claude Code?

Run `npx skills add github/awesome-copilot --skill mvvm-toolkit-di -a claude-code`. Or copy the skill folder (skills/mvvm-toolkit-di in github/awesome-copilot) into .claude/skills/mvvm-toolkit-di in your project. Claude Code loads it when a task matches its description.

How do I install Mvvm Toolkit Di in Codex?

Run `npx skills add github/awesome-copilot --skill mvvm-toolkit-di -a codex`. Or copy the skill folder (skills/mvvm-toolkit-di in github/awesome-copilot) into .agents/skills/mvvm-toolkit-di in your project. Codex loads it when a task matches its description.

Can I use Mvvm Toolkit Di in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add github/awesome-copilot --skill mvvm-toolkit-di -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mvvm-toolkit-di, .gemini/skills/mvvm-toolkit-di, .github/skills/mvvm-toolkit-di and .opencode/skills/mvvm-toolkit-di in your project.

What does Mvvm Toolkit Di need to run?

SKILL.md names no scripts, command-line tools or credentials: Mvvm Toolkit Di is instructions for the agent only.

Does Mvvm Toolkit Di access the network?

SKILL.md names 1 domain. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.

Is Mvvm Toolkit Di safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mvvm Toolkit Di use?

Mvvm Toolkit Di is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mvvm Toolkit Di use?

About 2.3k tokens (SKILL.md is roughly 9.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2k tokens, read only when the agent opens those files.

What are the alternatives to Mvvm Toolkit Di?

Skills that share tags, products or a category with Mvvm Toolkit Di: Winui (managedcode/dotnet-skills, 486 stars), QA Tester (JocysCom/FocusLogger, 213 stars), Code Review (sbroenne/mcp-windows, 105 stars) and Windows Automation (sbroenne/mcp-windows, 105 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mvvm Toolkit Di?

github (a GitHub organization, an official publisher) maintains it in github/awesome-copilot, which has 39,748 GitHub stars. The repository holds 417 skills in this directory. The repository was last updated on October 7, 2026.

Source: github/awesome-copilot on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.