MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

WinForms Expert

WinForms Expert是一款code方向的AI技能,核心价值是Support development of ,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Support development of .NET (OOP) WinForms Designer compatible Apps.

Last verified on: 2026-05-30
mkdir -p ./skills/winformsexpert && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/winformsexpert/SKILL.md -o ./skills/winformsexpert/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# WinForms Development Guidelines


These are the coding and design guidelines and instructions for WinForms Expert Agent development.

When customer asks/requests will require the creation of new projects


**New Projects:**

* Prefer .NET 10+. Note: MVVM Binding requires .NET 8+.

* Prefer `Application.SetColorMode(SystemColorMode.System);` in `Program.cs` at application startup for DarkMode support (.NET 9+).

* Make Windows API projection available by default. Assume 10.0.22000.0 as minimum Windows version requirement.

xml
    <TargetFramework>net10.0-windows10.0.22000.0</TargetFramework>

**Critical:**


**📦 NUGET:** New projects or supporting class libraries often need special NuGet packages.

Follow these rules strictly:


* Prefer well-known, stable, and widely adopted NuGet packages - compatible with the project's TFM.

* Define the versions to the latest STABLE major version, e.g.: `[2.*,)`


**⚙️ Configuration and App-wide HighDPI settings:** *app.config* files are discouraged for configuration for .NET.

For setting the HighDpiMode, use e.g. `Application.SetHighDpiMode(HighDpiMode.SystemAware)` at application startup, not *app.config* nor *manifest* files.


Note: `SystemAware` is standard for .NET, use `PerMonitorV2` when explicitly requested.


**VB Specifics:**

- In VB, do NOT create a *Program.vb* - rather use the VB App Framework.

- For the specific settings, make sure the VB code file *ApplicationEvents.vb* is available.

Handle the `ApplyApplicationDefaults` event there and use the passed EventArgs to set the App defaults via its properties.


| Property | Type | Purpose |

|----------|------|---------|

| ColorMode | `SystemColorMode` | DarkMode setting for the application. Prefer `System`. Other options: `Dark`, `Classic`. |

| Font | `Font` | Default Font for the whole Application. |

| HighDpiMode | `HighDpiMode` | `SystemAware` is default. `PerMonitorV2` only when asked for HighDPI Multi-Monitor scenarios. |


---



🎯 Critical Generic WinForms Issue: Dealing with Two Code Contexts


| Context | Files/Location | Language Level | Key Rule |

|---------|----------------|----------------|----------|

| **Designer Code** | *.designer.cs*, inside `InitializeComponent` | Serialization-centric (assume C# 2.0 language features) | Simple, predictable, parsable |

| **Regular Code** | *.cs* files, event handlers, business logic | Modern C# 11-14 | Use ALL modern features aggressively |


**Decision:** In *.designer.cs* or `InitializeComponent` → Designer rules. Otherwise → Modern C# rules.


---


🚨 Designer File Rules (TOP PRIORITY)


⚠️ Make sure Diagnostic Errors and build/compile errors are eventually completely addressed!


❌ Prohibited in InitializeComponent


| Category | Prohibited | Why |

|----------|-----------|-----|

| Control Flow | `if`, `for`, `foreach`, `while`, `goto`, `switch`, `try`/`catch`, `lock`, `await`, VB: `On Error`/`Resume` | Designer cannot parse |

| Operators | `? :` (ternary), `??`/`?.`/`?[]` (null coalescing/conditional), `nameof()` | Not in serialization format |

| Functions | Lambdas, local functions, collection expressions (`...=[]` or `...=[1,2,3]`) | Breaks Designer parser |

| Backing fields | Only add variables with class field scope to ControlCollections, never local variables! | Designer cannot parse |


**Allowed method calls:** Designer-supporting interface methods like `SuspendLayout`, `ResumeLayout`, `BeginInit`, `EndInit`


❌ Prohibited in *.designer.cs* File


❌ Method definitions (except `InitializeComponent`, `Dispose`, preserve existing additional constructors)

❌ Properties

❌ Lambda expressions, DO ALSO NOT bind events in `InitializeComponent` to Lambdas!

❌ Complex logic

❌ `??`/`?.`/`?[]` (null coalescing/conditional), `nameof()`

❌ Collection Expressions


✅ Correct Pattern


✅ File-scope namespace definitions (preferred)


📋 Required Structure of InitializeComponent Method


| Order | Step | Example |

|-------|------|---------|

| 1 | Instantiate controls | `button1

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply WinForms Expert to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is WinForms Expert compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for WinForms Expert?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install WinForms Expert?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/winformsexpert/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills