mvvm-toolkit
できること
このツールは、アプリケーションのコードを効率よく書くためのものです。ユーザーインターフェースやコマンドを作る際の反復的な部分を自動化し、開発を速く、ミスを減らしやすくします。
使う場面
- ✓アプリケーションの表示ロジック(ViewModel)を作成または見直すとき。
- ✓ユーザーが実行できるボタンや操作を定義する必要があるとき。
- ✓フォームにユーザーが入力した情報を検証するとき。
スキルのリンク
https://github.com/github/awesome-copilot/blob/main/skills/mvvm-toolkit/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“名前欄が空でない場合にだけ動作する、ユーザーのデータを保存するボタンはどう作ればよいですか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは「コードジェネレーター」を使い、プログラマーが追加した簡単な属性(アノテーション)をもとに、必要なコードを自動で生成します。これにより、繰り返しの多いコードを手で書く必要がなくなります。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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-messengerforIMessengerpub/sub patterns. Loadmvvm-toolkit-diforMicrosoft.Extensions.DependencyInjectionintegration.
Quick recap.
[ObservableProperty]on private fields inpartialclasses;[RelayCommand]on instance methods; inherit fromObservableObject(orObservableValidatorfor input forms,ObservableRecipientwhen usingIMessenger).
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 declaredpartial. Without it, the generators emitMVVMTK0008/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);
}
}
…
よくある質問
追加でインストールする必要はありますか?
いいえ。メインのツールは`CommunityToolkit.Mvvm`パッケージをインストールすると一緒に使えるようになります。
「コードジェネレーター」とは何ですか?
指示をもとに、コードを自動で書いてくれるツールのことです。繰り返しの多いコードを書く手間を省くのに役立ちます。
ObservableObjectではなくObservableValidatorを使うのはいつですか?
アプリがフォームにユーザーが入力した情報を検証する必要があるとき、たとえば必須項目が入力されているかを確認したいときに、ObservableValidatorを使います。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 40k
- ランキング
- #7304
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
acquire-codebase-knowledge
40kエージェントが、既存のコードプロジェクトを理解してドキュメント化できるよう支援します。新しく参加するメンバーのオンボーディングや、アーキテクチャの全体像の把握に役立ちます。
acreadiness-assess
40kエージェントが、プロジェクトのAI対応状況を評価してレポートを生成できるよう支援します。プロジェクトがAIツールをどの程度活用できる状態にあるかを把握するのに役立ちます。
acreadiness-generate-instructions
40kエージェントが、評価結果をもとにAIツール向けの指示文を作成できるよう支援します。AIがコードとどのようにやり取りするかを改善し、特定された不足点を解消するのに役立ちます。
acreadiness-policy
40kエージェントが、AIプロジェクトの評価ポリシーの策定や適用を支援できるようにします。プロジェクトの評価方法を標準化し、コンプライアンスを確保するのに役立ちます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。