Agent skill
frontend__feature_scaffold
Adds a new feature to the Web Frontend (Blazor) with Reactive State, Optimistic Updates, and Cache Invalidation. Use this when implementing user-facing features that need real-time updates.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/frontend-feature-scaffold
SKILL.md
Follow this guide to implement a responsive frontend feature in src/Web/BookStore.Web.
-
Prerequisites
- Ensure the API Client exists:
src/Client/BookStore.Client/I{Resource}Client.cs. - Ensure the Shared/Response DTOs exist in
BookStore.Shared. - if NOT, run
/marten__guide(for queries) or/wolverine__guide(for mutations) first.
- Ensure the API Client exists:
-
Create the Component
- Create/Update
src/Web/BookStore.Web/Components/Pages/{Feature}.razor. - Template:
templates/Page.razor - Lifecycle: Use
OnInitializedAsyncto start listening:EventsService.StartListening();.
- Create/Update
-
Implement Data Fetching
- Pattern: Use
ReactiveQuery<T>. - Setup (Template):
templates/ReactiveQueryInit.cs
- Pattern: Use
-
Implement Optimistic Updates (Properties)
- Use Case: Toggling a boolean, changing a number (e.g., Favorites).
- Pattern:
Mutate -> Call -> Rollback.csharpquery.MutateData(s => s with { IsFavorite = true }); // 1. Instant UI update try { await Client.UpdateAsync(); // 2. API Call } catch { query.MutateData(s => s with { IsFavorite = false }); // 3. Revert on error }
-
Implement Optimistic Updates (Lists)
- Use Case: Adding a new item to a list instantly.
- Pattern:
csharp
OptimisticService.AddOptimisticBook(id, title); // 1. Add to separate list await Client.CreateAsync(); // 2. API Call (Event will confirm/remove it) - UI: Merge
query.DatawithOptimisticService.GetOptimisticBooks()when rendering lists.
-
Configure Invalidation
- Open
src/Web/BookStore.Web/Services/QueryInvalidationService.cs. - Add cases to
GetInvalidationKeys(IDomainEventNotification notification). - Rule: Map the Domain Event (e.g.,
BookCreated) to the Query Keys you defined in Step 2 (e.g.,"Books").
- Open
-
Verify
- Run the app and verify:
- Data loads.
- Mutations update UI instantly.
- SSE events (from other tabs/users) trigger auto-refetch.
- Run
/test__verify_featurefor complete verification.
- Run the app and verify:
Related Skills
Prerequisites:
- Backend endpoints must exist first:
/wolverine__guide- For mutation endpoints/marten__guide- For query endpoints
- Client SDK must be configured (usually done by the backend scaffolding skills)
Next Steps:
/test__integration_scaffold- Create integration tests for the feature/test__verify_feature- Complete verification
Debugging:
/frontend__debug_sse- If real-time updates don't work/cache__debug_cache- If query data is stale
See Also:
- real-time-notifications - SSE architecture
- wolverine__guide - Backend mutations
- marten__guide - Backend queries
- Web AGENTS.md - ReactiveQuery patterns and SSE integration
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?