/bawa:csharp-winuifrom bawa
Provides C# 14 and WinUI 3 coding rules for Windows apps: threading, x:Bind, observable models, SQLite, Win32 interop, and fixes for common build/launch errors.
Ships in bawa. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The code is right when it builds with zero warnings, launches without a
CRASH line, and the app does what the story says. For how it should
look, call the Skill tool with windows-design. For copyable XAML, read
../../design/windows-design/patterns.md.
WinUI has one UI thread per window. Every control and every object bound to a control lives on it.
| Work | Put it in |
|---|---|
Pages, view models, ObservableCollections bound to lists | The UI thread (the default in event handlers and OnLaunched) |
| CPU-heavy pure work (parsing, image work, diffing) | await Task.Run(() => ...), then set results back on the UI thread |
| File and database work | async methods; small SQLite calls on the UI thread are fine, anything over a few ms goes to Task.Run |
| A Win32 callback (hotkey, hook, timer from another thread) | Hop back with DispatcherQueue.TryEnqueue(() => ...) |
await in an event handler returns to the UI thread on its own. Inside
Task.Run you are on a pool thread: never touch a control there.async void only for event handlers. Everything else returns Task.DispatcherQueue of the window (window.DispatcherQueue) for
code that runs outside a page.CRASH line from
UnhandledException. Catch and log in every Task.Run body you start
and forget, and run every background path once after changing it.partial class X : ObservableObject with
[ObservableProperty] public partial string Title { get; set; }
(CommunityToolkit.Mvvm 8.4 and C# 14). Initialize partial properties in
the constructor: they cannot have initializers.[NotifyPropertyChangedFor(nameof(DisplayTitle))] for computed
properties.ObservableCollection<T>. Rebuild it in place
(Clear, Add), never assign a new collection to a bound property.x:Bind is compiled and checked, so prefer it over {Binding}. Its
default mode is OneTime: write Mode=OneWay for anything that
changes and Mode=TwoWay for inputs, and
UpdateSourceTrigger=PropertyChanged on a TextBox that saves as you
type.Model.Selection), call
Bindings.Update() if the binding path starts above the changed object.AppJson
([JsonSerializable(typeof(T))]) and pass AppJson.Default.T. Reflection
JSON breaks under NativeAOT and trimming (IL2026, IL3050).Prefs (JSON next to the database). Unpackaged
apps have no ApplicationData.Current.LocalSettings: it throws. Secrets
go in the Windows Credential Locker (PasswordVault) or DPAPI
(ProtectedData), never in the JSON.OnXChanged.SqliteConnection per app, opened once, WAL mode, in <App>.Core.ItemStore.Migrations, keyed by
PRAGMA user_version. Never edit a step that shipped. A new column has
a DEFAULT, so old files keep loading.Guid id. Never use the row number or list index as an
identity.APP_STORE overrides the path, and the app refuses test modes unless it
points into %TEMP%. Tests never touch
%LOCALAPPDATA%\<App>\<App>.db.agent-cli), so the file keeps one writer.KeyboardAccelerator.
The accelerator works wherever focus is in the window.ScopeOwner="{x:Bind List}", and set
args.Handled = true in Invoked.DataContext. Pass the row with Tag="{x:Bind}".Window, Page, Frame, Layout, Path, Rectangle, Grid, Color,
Colors, Thickness, Point, Size, and Application all exist in WinUI
namespaces. Do not name your own types after them. Path collides with
System.IO.Path as soon as a file imports Microsoft.UI.Xaml.Shapes:
write System.IO.Path. Task collides with System.Threading.Tasks.Task:
name a to-do Todo or TaskItem.
Namespaces collide too, and worse. C# looks for a name in the
enclosing namespaces before the using lines. A namespace
MyApp.Features.Windows makes Windows.Foundation mean
MyApp.Features.Windows.Foundation in every sibling namespace
(CS0234); MyApp.Features.Clipboard hides the WinRT Clipboard class;
Colors and Launcher do the same. Each feature compiles alone, and the
break shows only when two are merged. Never name a namespace segment
Windows, Microsoft, System, or after a type you call
(Clipboard, Colors, Launcher): use Snapping, ClipboardHistory,
Palette, AppLauncher.
WinUI covers windows, pages, and controls. Win32 is still the answer for:
WinRT.Interop.WindowNative.GetWindowHandle(window).FileOpenPicker, FolderPicker):
WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd), or they
throw.GetDpiForWindow. AppWindow sizes are physical pixels; XAML is in
epx. The template's WindowBehavior scales between them.os-integrations.Declare calls with [LibraryImport] in one Win32.cs, with
AllowUnsafeBlocks on. Keep every P/Invoke in that file. Callbacks
(window procedures, hooks, EnumDisplayMonitors) are
[UnmanagedCallersOnly] static methods passed as &Method; catch every
exception inside them, because one that escapes ends the process.
Keep unsafe to the block that takes the address: a class marked
unsafe cannot await anywhere (CS4004).
Building controls in C# is fine, with three traps:
Application.Current.Resources["TextFillColorSecondaryBrush"]
returns the brush for the app's theme, not the theme of the element it
lands in. A panel or page set to dark (RequestedTheme, Settings'
theme choice, snapshot mode) then shows light text on dark or dark on
dark. Give code-built elements a Style from XAML whose setters use
{ThemeResource ...}, or build the part as a XAML UserControl.Measure on code-built content
before it is in a shown window gets heights wrong (templates are not
applied yet). Size a panel to its content after the first layout: in
SizeChanged, or one DispatcherQueue turn after showing it.new TextBox { Text = s, AcceptsReturn = true }
keeps only the first line of s: Text is set while AcceptsReturn is
still false. Set AcceptsReturn (and TextWrapping) first.Events fire when code sets a value, not only when a person does:
ToggleSwitch.Toggled runs when you set IsOn to show the current state,
and TextBox.TextChanged runs later, after Text is set. Guard handlers
with a _loading flag while a page fills itself, and in a self-test call
the search or filter function directly instead of waiting for
TextChanged.
Segoe Fluent Icons glyphs are private-use characters that show as nothing
in an editor or a diff. Write them as code points:
char.ConvertFromUtf32(0xE734) in C#,  in XAML. Never paste the
character itself.
| Error | Fix |
|---|---|
XamlParseException: Failed to assign to property 'ColumnDefinition.Width' ... 'Double' cannot be assigned to 'GridLength' | The resource is the wrong type: a GridLength resource for widths of rows and columns, x:Double for Width and Spacing |
0xC000027B exit and a CRASH ... XamlParseException | Read the property and type in the message; the line number is often 0 |
0xC000027B and no CRASH line at all | An exception in the App constructor, before the handler exists. Keep the constructor to InitializeComponent(); do setup in OnLaunched |
COMException 0x8000FFFF from Application.Current.Resources | Called in the App constructor. Move it to OnLaunched |
CS0104 'Path' is an ambiguous reference | System.IO.Path |
CS0104 'Layout' is an ambiguous reference | Your type shares a WinUI name: rename it (SnapLayout) |
CS4004 Cannot await in an unsafe context | Remove unsafe from the class; wrap only the pointer line in unsafe { } |
CS0234 'Foundation' does not exist in the namespace 'MyApp.Features.Windows' | A namespace segment shadows a framework name (see "Names that collide"): rename the namespace |
A crash at load with no build error after Padding="{StaticResource SpaceSm}" | Spacing tokens are x:Double; Padding, Margin, and BorderThickness need a Thickness. Use a Thickness token (CardPadding) |
0xC000027B with no CRASH line, from a DispatcherQueue.TryEnqueue callback | An exception in an enqueued callback ends the process before UnhandledException. Wrap the body in try and log with AgentLog.Line |
App dies at once after dotnet publish | Publish without EnableMsixTooling=true drops <App>.pri. Use tools/publish.ps1 |
A multi-line TextBox shows only the first line | Text was set before AcceptsReturn. Set AcceptsReturn first |
| Dark text on dark, or light cards, in one panel only | A brush looked up in code; see "UI built in code" |
ContentDialog.ShowAsync throws | Set XamlRoot = this.XamlRoot first |
The property 'X' was not found in type 'Y' in x:Bind | Add x:DataType to the DataTemplate, and make the property public |
| A binding that never updates | x:Bind is OneTime by default: add Mode=OneWay |
ApplicationData.Current throws InvalidOperationException | The app is unpackaged. Use Prefs or a file in AppPaths.Folder |
Warning CS8618 non-nullable field | Initialize it in the constructor, or make it nullable. Fix every warning |
Fix the first error first. Later errors often come from it.
Done when the app builds with zero warnings, the self-test passes, and the story's acceptance checks pass.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub daveebbelaar/bawa --plugin bawa22 skills in this plugin
/agent-cliOptional command line and MCP server for a Windows app, so Claude Code, Codex, and scripts can drive it (list, add, change, search, act) through the running app. Use when the user wants agents to work with their app or its data, asks for a CLI, an MCP server, or automation for the app, or says "Claude should be able to use my app"./app-briefOne-page brief (docs/BRIEF.md) for a new Windows app, written before any code. Use when the user has an app idea, wants to replace an app they pay for, or the research and clone skills are done./app-iconWindows app icon drawn as an SVG (Icon/AppIcon.svg), rendered by tools/make-icon.ps1 into a multi-size AppIcon.ico and AppIcon.png, and reviewed on light and dark taskbar and Start backgrounds, with hand-tuned small sizes. Use when the user wants an app icon, a better icon, or a taskbar or Start icon./bawaBuild any Windows app. Start here to pick the next skill for a native Windows app./build-and-verifyBuild a WinUI 3 app from the command line, install it, and check light and dark window snapshots of every page before calling a change done. Use after any UI code change, when a build fails, or when the user asks to run, screenshot, or check the app./cloneWalk through any existing app (native Windows app with computer use, web app with a browser), screenshot every screen, menu, and dialog, write a screen index, and turn it into user stories. Use when the user wants to clone, rebuild, replace, or copy the design of an app, or says "screenshot every screen".Other plugins' skills for the same job