/azure-dotnet-webapp:scaffold-blazor [--mode server|wasm|auto] [--feature <name>]from azure-dotnet-webapp
Scaffolds a complete Blazor feature — page component, service interface, models, auth guard, and NavMenu entry. Supports InteractiveServer, InteractiveWebAssembly, and InteractiveAuto render modes.
Ships in azure-dotnet-webapp. Installing the plugin adds it to Claude Code.
Scaffold a complete Blazor feature: page component, service interface, models, auth guard, and NavMenu entry. Supports InteractiveServer, InteractiveWebAssembly, and InteractiveAuto render modes.
Search for .csproj files and look for Microsoft.NET.Sdk.Web and AddRazorComponents in
Program.cs. If found, determine:
.Client project exists (for WASM/Auto modes)Components/Pages pathAsk if not provided via --mode:
Note: WASM and Auto pages must be placed in the
.Clientproject (if present). Server pages go in the main project'sComponents/Pages/.
Ask for the feature name (PascalCase):
FileInventory, DuplicatesDashboard, UserProfile, Reports/feature-name), component name, service interfaceGenerate Components/Pages/{FeatureName}.razor:
@page "/{feature-route}"
@attribute [Authorize]
@rendermode InteractiveServer
@inject I{FeatureName}Service {FeatureName}Service
@inject NavigationManager Nav
<PageTitle>{Feature Display Name}</PageTitle>
<h1>{Feature Display Name}</h1>
<AuthorizeView>
<Authorized>
@if (isLoading)
{
<p>Loading...</p>
}
else if (errorMessage is not null)
{
<div class="alert alert-danger">@errorMessage</div>
}
else if (items is null || items.Count == 0)
{
<p>No items found.</p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in items)
{
<tr>
<td>@item.Name</td>
<td>@item.CreatedAt.ToString("yyyy-MM-dd")</td>
<td>
<button class="btn btn-sm btn-danger"
@onclick="() => DeleteItem(item.Id)">
Delete
</button>
</td>
</tr>
}
</tbody>
</table>
}
</Authorized>
<NotAuthorized>
<p>Please <a href="MicrosoftIdentity/Account/SignIn">sign in</a> to view this page.</p>
</NotAuthorized>
</AuthorizeView>
@code {
private List<{FeatureName}Dto>? items;
private bool isLoading = true;
private string? errorMessage;
protected override async Task OnInitializedAsync()
{
try
{
items = await {FeatureName}Service.GetAllAsync();
}
catch (Exception ex)
{
errorMessage = $"Failed to load data: {ex.Message}";
}
finally
{
isLoading = false;
}
}
private async Task DeleteItem(string id)
{
await {FeatureName}Service.DeleteAsync(id);
items?.RemoveAll(i => i.Id == id);
}
}
Generate {ProjectName}.Client/Components/Pages/{FeatureName}.razor:
@page "/{feature-route}"
@attribute [Authorize]
@rendermode InteractiveWebAssembly
@inject HttpClient Http
<PageTitle>{Feature Display Name}</PageTitle>
<h1>{Feature Display Name}</h1>
@if (isLoading)
{
<p>Loading...</p>
}
else if (items is null)
{
<p>Failed to load data.</p>
}
else
{
<ul>
@foreach (var item in items)
{
<li>@item.Name — @item.CreatedAt.ToString("yyyy-MM-dd")</li>
}
</ul>
}
@code {
private List<{FeatureName}Dto>? items;
private bool isLoading = true;
protected override async Task OnInitializedAsync()
{
try
{
items = await Http.GetFromJsonAsync<List<{FeatureName}Dto>>("api/{feature-route}");
}
finally
{
isLoading = false;
}
}
public record {FeatureName}Dto(string Id, string Name, DateTimeOffset CreatedAt);
}
Generate Services/I{FeatureName}Service.cs:
namespace {Namespace}.Services;
public interface I{FeatureName}Service
{
Task<List<{FeatureName}Dto>> GetAllAsync(CancellationToken ct = default);
Task<{FeatureName}Dto?> GetByIdAsync(string id, CancellationToken ct = default);
Task DeleteAsync(string id, CancellationToken ct = default);
}
Generate Services/{FeatureName}Service.cs:
namespace {Namespace}.Services;
public class {FeatureName}Service : I{FeatureName}Service
{
private readonly List<{FeatureName}Dto> _store =
[
new("1", "Sample Item A", DateTimeOffset.UtcNow.AddDays(-5)),
new("2", "Sample Item B", DateTimeOffset.UtcNow.AddDays(-2))
];
public Task<List<{FeatureName}Dto>> GetAllAsync(CancellationToken ct = default) =>
Task.FromResult(_store.ToList());
public Task<{FeatureName}Dto?> GetByIdAsync(string id, CancellationToken ct = default) =>
Task.FromResult(_store.FirstOrDefault(x => x.Id == id));
public Task DeleteAsync(string id, CancellationToken ct = default)
{
_store.RemoveAll(x => x.Id == id);
return Task.CompletedTask;
}
}
public record {FeatureName}Dto(string Id, string Name, DateTimeOffset CreatedAt);
Add service registration:
builder.Services.AddScoped<I{FeatureName}Service, {FeatureName}Service>();
Use the Edit tool to insert after the existing AddScoped lines or after
builder.Services.AddRazorComponents().
Read Components/Layout/NavMenu.razor and add a navigation entry:
<NavLink href="/{feature-route}" Match="NavLinkMatch.Prefix">
{Feature Display Name}
</NavLink>
Insert after the last existing <NavLink> element using the Edit tool.
dotnet build
Report errors. Fix missing @using directives in _Imports.razor if needed.
## Scaffold Complete — {FeatureName}
Files created:
- Components/Pages/{FeatureName}.razor (@rendermode {mode})
- Services/I{FeatureName}Service.cs
- Services/{FeatureName}Service.cs
Updated:
- Program.cs — service registration added
- Components/Layout/NavMenu.razor — navigation entry added
Route: /{feature-route}
Auth: [Authorize] attribute applied
Next steps:
- Replace stub service with real data access (EF Core / Graph API)
- Run: /azure-dotnet-webapp:add-webapi-operation to add Graph data sources
--mode server: Use InteractiveServer render mode--mode wasm: Use InteractiveWebAssembly (places page in .Client project)--mode auto: Use InteractiveAuto render mode--feature <name>: Feature name (e.g., FileInventory) — skips the questionFiles this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
5 commands in this plugin
/add-webapi-operationazure-dotnet-webapp:add-webapi-operationAdd an ASP.NET Core endpoint or Blazor service call that wraps a Microsoft Graph operation — preset patterns for file inventory, duplicate detection, and metadata, or a custom operation. Wires GraphServiceClient and ResiliencePipeline DI if not already present./deploy-webappazure-dotnet-webapp:deploy-webappProvision Azure App Service (Plan + Web App + App Insights + Key Vault) with Bicep, deploy the ASP.NET Core app, configure Managed Identity and Key Vault access, set up staging slots, and generate a GitHub Actions or Azure DevOps CI/CD pipeline./scaffold-apiazure-dotnet-webapp:scaffold-apiScaffold a Minimal API endpoint group or MVC controller with CRUD operations, service interface, DTOs, and OpenAPI metadata — wires the service into Program.cs automatically./webapp-setupazure-dotnet-webapp:webapp-setupInteractive setup wizard for ASP.NET Core Web API or Blazor projects on Azure — selects project type, auth, database, and Graph integration; scaffolds the full project structure with compilable stubs; and verifies the build.npx claudepluginhub thelobbi/claude-m --plugin azure-dotnet-webappOther plugins' commands for the same job