author-component
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),
npx skills add dotnet/skills --skill author-component --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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; } [Parameter] public RenderFragment<TItem>? RowTemplate { get; set; } // generic template ``` Use `@typeparam TItem` for generic components. ## File Patterns - **Single-file:** `.razor` with `@code` block when logic < ~50 lines. - **Code-behind:** `.razor` + `.razor.cs` with `partial class` when logic > ~50 lines. ## Disposal Implement `IAsyncDisposable` (not `IDisposable`) when the component owns subscriptions, timers, or CTS. In `DisposeAsync`: unsubscribe (`-=`), cancel CTS, dispose resources. N
- Core Rules
- RenderFragment & Generics
- File Patterns
- Disposal
- Async Patterns
- Don'ts
What does the author-component skill do?
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),
How do I install it?
Run `npx skills add dotnet/skills --skill author-component --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
