author-component
强调参数流动与事件回流等最佳实践,利于构建可维护组件库。
编写或审查 Blazor .razor 组件的结构、参数与生命周期模式规范。
帮你设计或审查 .razor 组件的结构、参数和生命周期用法,覆盖 [Parameter]、EventCallback、RenderFragment、OnInitializedAsync、OnParametersSet、IAsyncDisposable、CancellationToken 等常见模式。适用于纯 Blazor 组件开发(不含 JS 互操作或浏览器 API)的代码编写或规范校验。强调数据下行、事件上行、不在参数上直接变更,以及异步生命周期与 CSS 隔离等最佳实践,降低组件出错概率。
▸ 展开 SKILL.md 英文原文
Create or review Blazor components (.razor files) with correct architecture. USE FOR: writing new Blazor components that do NOT involve JavaScript interop, implementing parameters and EventCallback, RenderFragment slots, component lifecycle (OnInitializedAsync, OnParametersSet), async patterns, IAsyncDisposable, CancellationToken, CSS isolation, code-behind. DO NOT USE FOR: creating new projects (use create-blazor-project), JavaScript interop or calling browser APIs from Blazor (use use-js-interop), forms and validation (use collect-user-input), prerendering issues (use support-prerendering), HTTP data fetching patterns (use fetch-and-send-data), coordinating state between unrelated components (use coordinate-components).
帮我安装这个 skill:https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-blazor/skills/author-component/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-blazor/skills/author-component/SKILL.md"# Author Blazor Component
## Core Rules
- Data flows **down** via `[Parameter]`. Events flow **up** via `EventCallback<T>` (never `Action`/`Func`).
- Never mutate `[Parameter]` properties. Copy to a private field in `OnParametersSet`.
- Use `[Parameter] public T Prop { get; set; }` — never `required` or `init` (causes BL0007).
- Use `[EditorRequired]` for required parameters.
- Handle all states: loading, empty, loaded, error — each with `@if`/`@else`.
- Use `@key` on repeated elements in loops for efficient diffing.
- Use `IReadOnlyList<T>` (not `IEnumerable<T>`) for collection parameters.
## RenderFragment & Generics
```csharp
[Parameter] public RenderFragment? ChildContent { get; set;