.agents/skills/check-xaml/SKILL.md
Validates XAML files for syntax errors, resource references, namespace declarations, and optionally binding paths against ViewModels. Designed for WPF/XAML projects in .NET development.
npx skillsauth add sekiya-sato/obsolete-cvnet10 check-xamlInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
このスキルは、WPF/XAMLファイルの品質チェックを実行し、以下のエラーを検出します:
以下の状況でこのスキルを使用してください:
Cvnet10 では、WPF作業の共通規約は wpf-project-guide、画面単位の追加・改修手順は wpf-view-workflow が担当します。本スキルはその後段の検証専用スキルです。
XAMLファイル [ファイルパス] をチェックしてください
または
check-xaml [ファイルパス]
ユーザーが「バインディングチェックは不要」「バインディング検証を無視して」と指示した場合、 バインディングパス検証をスキップしてください。
XAMLファイル [ファイルパス] をチェックしてください(バインディング検証は不要)
以下の構文エラーを検出します:
開始タグと閉じタグの不一致
<!-- ❌ 悪い例 -->
<Button Content="OK" />
</Button>
<!-- ✅ 良い例 -->
<Button Content="OK" />
属性値のクォーテーション不備
<!-- ❌ 悪い例 -->
<Button Content=OK />
<!-- ✅ 良い例 -->
<Button Content="OK" />
不正なXML文字(エスケープ未処理)
<!-- ❌ 悪い例 -->
<TextBlock Text="A & B" />
<!-- ✅ 良い例 -->
<TextBlock Text="A & B" />
使用されているプレフィックスに対して、名前空間宣言が存在するかを確認します。
<!-- ❌ 悪い例: md名前空間が宣言されていない -->
<Window x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<md:Card />
</Window>
<!-- ✅ 良い例 -->
<Window x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes">
<md:Card />
</Window>
StaticResourceやDynamicResourceで参照されているリソースキーが、以下の場所に定義されているかを確認します:
<Window.Resources>や<UserControl.Resources>App.xamlの<Application.Resources>App.xamlでマージされているResourceDictionaryファイル<!-- ❌ 悪い例: PrimaryBrushが定義されていない -->
<Button Background="{StaticResource PrimaryBrush}" />
<!-- ✅ 良い例 -->
<Window.Resources>
<SolidColorBrush x:Key="PrimaryBrush" Color="Blue" />
</Window.Resources>
<Button Background="{StaticResource PrimaryBrush}" />
Converterプロパティで参照されているコンバーターがリソースとして定義されているかを確認します。
<!-- ❌ 悪い例: BoolToVisibilityConverterが定義されていない -->
<TextBlock Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibilityConverter}}" />
<!-- ✅ 良い例 -->
<Window.Resources>
<local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</Window.Resources>
<TextBlock Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibilityConverter}}" />
デフォルトで有効ですが、ユーザーが無効化を指示した場合はスキップします。
BindingのPathプロパティが、対応するViewModelクラスに存在するかを確認します。
x:Class属性から、対応するViewを特定Views/SomeView.xaml → ViewModels/SomeViewModel.csMyView.xaml → MyViewModel.cs<!-- ✅ ViewModelにIsEnabledプロパティが存在する -->
<Button IsEnabled="{Binding IsEnabled}" />
<!-- ❌ ViewModelにNonExistentPropertyが存在しない -->
<Button Content="{Binding NonExistentProperty}" />
<!-- ✅ ItemsSourceバインディング先のコレクション内のプロパティ -->
<DataGrid ItemsSource="{Binding DetailItems}">
<DataGrid.Columns>
<!-- DetailItemsのアイテム型のNoプロパティをチェック -->
<DataGridTextColumn Header="No" Binding="{Binding No}" />
</DataGrid.Columns>
</DataGrid>
以下の場合、バインディングパス検証をスキップします:
指定されたXAMLファイルを読み込み、構文エラーをチェックします。
# Readツールでファイルを取得
XAMLルート要素の名前空間宣言を抽出し、使用されているプレフィックスとマッチングします。
プロジェクト内のApp.xamlを読み込み、定義されているリソースキーとMergedDictionariesをリストアップします。
# App.xamlの場所を特定
find . -name "App.xaml" -type f
StaticResource/DynamicResourceで参照されているキーが、ステップ3で取得したリソースに存在するかを確認します。
正規表現例:
\{(?:StaticResource|DynamicResource)\s+([a-zA-Z0-9_]+)\}
Converter={StaticResource ...}パターンを検出し、リソースに定義されているかを確認します。
ユーザーが無効化を指示していない場合のみ実行
BindingのPathプロパティと照合正規表現例:
\{Binding\s+([a-zA-Z0-9_.]+)
ViewModelプロパティ抽出(C#):
public\s+\w+(?:<[^>]+>)?\s+([a-zA-Z0-9_]+)\s*\{
検出されたエラーと警告を、以下の形式で報告します:
エラー・警告: 詳細に報告(すべて列挙)
正常項目: サマリーと主要項目のみ
## XAML検証結果: [ファイルパス]
### ✅ 合格項目
- 構文エラー: なし
- 名前空間宣言: OK (helpers, vm, materialDesign など)
- バインディングパス: すべて検証OK (50個以上のバインディングを確認)
### ⚠️ 警告
- リソース参照: 未定義のリソースキー「PrimaryBrush」が使用されています(行123)
→ App.xaml または Resources/UIColors.xaml に定義を追加してください
### ❌ エラー
- 構文エラー: 閉じタグ不一致 </Button> (行456)
→ 開始タグが自己完結型 <Button .../> のため、閉じタグは不要です
- コンバーター参照: 未定義のコンバーター「BoolToVisConverter」(行789)
→ App.xaml の Application.Resources に以下を追加してください:
<helpers:BoolToVisibilityConverter x:Key="BoolToVisConverter" />
### 📋 チェック詳細
- 合計行数: 415行
- リソース参照数: 11個 (うち2個が未定義)
- バインディング数: 50個 (すべて検証OK)
- コンバーター使用: なし
### 🎯 推奨事項
1. [修正が必要な項目の優先順位付きリスト]
2. [将来的な改善提案]
このプロジェクト(Cvnet10)では、以下の命名規則とディレクトリ構造を前提とします:
Cvnet10Wpfclient/
├── Views/
│ └── 04Juchu/
│ └── JuchuInputView.xaml
├── ViewModels/
│ └── 04Juchu/
│ └── JuchuInputViewModel.cs
├── App.xaml
└── Resources/
├── UIColors.xaml
├── UICommon.xaml
└── UIMainWindow.xaml
*View.xaml*ViewModel.csViews/04Juchu/ → ViewModels/04Juchu/)App.xamlでマージされているResourceDictionaryファイル:
Resources/UIColors.xamlResources/UICommon.xamlResources/UIMainWindow.xamlこれらのファイルもリソース参照チェック時に確認対象とします。
エージェントは以下のような手順でチェックを実行します:
// 疑似コード
async function checkXaml(filePath, skipBindingCheck = false) {
// 1. XAMLファイルを読み込み
const xamlContent = await readFile(filePath);
// 2. 構文チェック
const syntaxErrors = checkSyntax(xamlContent);
// 3. 名前空間チェック
const namespaceErrors = checkNamespaces(xamlContent);
// 4. App.xamlとリソースファイルを読み込み
const appXaml = await readFile("App.xaml");
const resourceFiles = extractMergedDictionaries(appXaml);
const allResources = await loadAllResources(resourceFiles);
// 5. リソース参照チェック
const resourceErrors = checkResourceReferences(xamlContent, allResources);
// 6. コンバーター参照チェック
const converterErrors = checkConverterReferences(xamlContent, allResources);
// 7. バインディングパス検証(オプション)
let bindingErrors = [];
if (!skipBindingCheck) {
const viewModelPath = inferViewModelPath(filePath);
const viewModelContent = await readFile(viewModelPath);
const properties = extractProperties(viewModelContent);
bindingErrors = checkBindingPaths(xamlContent, properties);
}
// 8. 結果を報告
return reportResults({
syntaxErrors,
namespaceErrors,
resourceErrors,
converterErrors,
bindingErrors,
skippedBinding: skipBindingCheck
});
}
A: 正常な項目はサマリーのみ表示されます。詳細リストが表示されるのはエラーや警告がある場合のみです。これにより、問題がある箇所に集中でき、レビュー効率が向上します。
A: ユーザーが以下のいずれかの表現で指示した場合、バインディングパス検証をスキップします:
A: 警告として報告し、バインディングパス検証をスキップします。他のチェックは継続します。
A: カスタムコントロールの定義ファイルが読み込めない場合は、そのプロパティに対する検証をスキップします。
A: 現在のバージョンでは{Binding ...}のみサポートしています。{x:Bind ...}は将来のバージョンで対応予定です。
x:Bind構文はサポート対象外tools
Defines the standard workflow for creating or updating individual WPF Views and ViewModels in Cvnet10Wpfclient, including menu wiring and validation steps.
tools
Provides the shared Cvnet10Wpfclient project conventions, resource usage, BaseWindow rules, validation flow, and build checks required before any WPF-related work.
tools
Guides the agent through unifying the material-design inspired layout across master maintenance windows in Cvnet10Wpfclient.
tools
Guides opencode to save Windows clipboard images into WSL with `clipimg` and pass the resulting file path into prompts.