agentleFS
mag1artmag1art/skills/blazor/SKILL.md

blazor

Skill1 starsChanged 3 months agoApache-2.0View on GitHub

Use for Blazor Web Apps and Blazor components, including static SSR, interactive Server/WebAssembly/Auto render modes, forms, state, and JavaScript interop.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

21 rules. 0 are common, 21 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 21

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use for Blazor Web Apps, Razor components, render modes, component lifecycle, forms, validation, routing, authentication, state management, …

    line 26
  2. Distinctive:

    Do not use for MVC/Razor Views-only work, a standalone JavaScript SPA, or backend API changes with no component boundary.

    line 30
  3. Distinctive:

    Every component render mode determines where it renders and whether it is interactive.

    line 36
  4. Distinctive:

    Keep server-only services and secrets out of WebAssembly components.

    line 43
  5. Distinctive:

    Add component, integration, accessibility, and end-to-end tests where warranted.

    line 45
  6. Distinctive:

    Verify prerendering, hydration, refresh, navigation, authorization, and production publishing.

    line 46
  7. Distinctive:

    Keep components focused and use parameters/events for local composition.

    line 58
  8. Distinctive:

    Use cascading values deliberately and avoid hidden global mutable state.

    line 59
  9. Distinctive:

    Treat scoped services differently in Server and WebAssembly hosting models.

    line 60
  10. Distinctive:

    Do not assume a scoped service has the same lifetime or process location across render modes.

    line 61
  11. Distinctive:

    Use clearly owned state transitions for complex screens.

    line 63
  12. Distinctive:

    Use EditForm and explicit server-side validation.

    line 67
  13. Distinctive:

    Do not trust client-side validation, hidden fields, or component parameters for authorization.

    line 68
  14. Distinctive:

    Never ship secrets, database credentials, or privileged connection strings to WebAssembly.

    line 71
  15. Distinctive:

    Keep JS interop at a narrow boundary and provide a C# abstraction for reusable behavior.

    line 75
  16. Distinctive:

    Do not call browser-only APIs during prerendering unless guarded.

    line 76
  17. Distinctive:

    Avoid synchronous JS interop in Server scenarios.

    line 78
  18. Distinctive:

    Treat data crossing the JS boundary as untrusted and validate it.

    line 79
  19. Distinctive:

    Avoid making every page globally interactive without a reason.

    line 83
  20. Distinctive:

    Use streaming or incremental rendering where supported and beneficial.

    line 87
  21. Distinctive:

    Verify render mode, prerender/hydration behavior, state lifetime, authorization, antiforgery, reconnect behavior, JS disposal, …

    line 91

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Blazor

When to Use

Use for Blazor Web Apps, Razor components, render modes, component lifecycle, forms, validation, routing, authentication, state management, JavaScript interop, and performance.

When Not to Use

Do not use for MVC/Razor Views-only work, a standalone JavaScript SPA, or backend API changes with no component boundary.

Identify the Hosting Model

For .NET 8 and later, inspect whether the project is a Blazor Web App and which components use Static, Interactive Server, Interactive WebAssembly, or Interactive Auto rendering. For older projects, distinguish Blazor Server and standalone Blazor WebAssembly before changing hosting or state assumptions.

Every component render mode determines where it renders and whether it is interactive. Prerendering can run before the interactive runtime starts, so initialization code must tolerate two phases.

Workflow

  1. Inspect TargetFramework, project template, render modes, authentication, persistence, JavaScript dependencies, and deployment model.
  2. Identify the component boundary and decide whether behavior belongs in a component, service, API, or database.
  3. Choose the smallest render mode that satisfies the interaction.
  4. Keep server-only services and secrets out of WebAssembly components.
  5. Implement loading, error, empty, and disconnected states.
  6. Add component, integration, accessibility, and end-to-end tests where warranted.
  7. Verify prerendering, hydration, refresh, navigation, authorization, and production publishing.

Render Modes

  • Static SSR: server renders HTML without an interactive circuit.
  • Interactive Server: events execute on the server over a circuit; manage connection loss and circuit state.
  • Interactive WebAssembly: component code runs in the browser; protect API boundaries and account for download size.
  • Interactive Auto: use only when the project is configured for it and the client/server transition is understood.
  • Apply a render mode at the smallest practical component boundary; global interactivity increases resource use and coupling.

Components and State

  • Keep components focused and use parameters/events for local composition.
  • Use cascading values deliberately and avoid hidden global mutable state.
  • Treat scoped services differently in Server and WebAssembly hosting models.
  • Do not assume a scoped service has the same lifetime or process location across render modes.
  • Persist state explicitly when it must survive prerendering, refresh, reconnect, or navigation.
  • Use clearly owned state transitions for complex screens.

Forms and Security

  • Use EditForm and explicit server-side validation.
  • Do not trust client-side validation, hidden fields, or component parameters for authorization.
  • Enforce resource authorization on the server/API.
  • Protect antiforgery and cookie-authenticated actions according to the hosting model.
  • Never ship secrets, database credentials, or privileged connection strings to WebAssembly.

JavaScript Interop

  • Keep JS interop at a narrow boundary and provide a C# abstraction for reusable behavior.
  • Do not call browser-only APIs during prerendering unless guarded.
  • Dispose JS object references and event subscriptions.
  • Avoid synchronous JS interop in Server scenarios.
  • Treat data crossing the JS boundary as untrusted and validate it.

Performance

  • Avoid making every page globally interactive without a reason.
  • Virtualize large lists, paginate server data, and cancel stale requests.
  • Minimize component rerenders and expensive lifecycle work.
  • Measure WebAssembly download size, startup time, circuit count, memory, and API latency.
  • Use streaming or incremental rendering where supported and beneficial.

Quality Gate

Verify render mode, prerender/hydration behavior, state lifetime, authorization, antiforgery, reconnect behavior, JS disposal, accessibility, download size, tests, and deployment configuration.

Official references:

Example: Interactive Component and Form

@page "/orders/{Id:guid}"
@rendermode InteractiveServer

<EditForm Model="_model" OnValidSubmit="SaveAsync">
    <DataAnnotationsValidator />
    <InputText @bind-Value="_model.Comment" />
    <ValidationSummary />
    <button type="submit" disabled="@_saving">Save</button>
</EditForm>

@code {
    [Parameter] public Guid Id { get; set; }
    private readonly OrderModel _model = new();
    private bool _saving;

    private async Task SaveAsync()
    {
        _saving = true;
        try { await Orders.UpdateCommentAsync(Id, _model.Comment); }
        finally { _saving = false; }
    }
}

Choose the render mode deliberately. InteractiveServer keeps execution on the server; InteractiveWebAssembly requires client-downloaded code and a suitable API boundary. Treat component state as scoped to the selected hosting model and never put secrets in WebAssembly code.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.