Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET.
gRPC for .NET
Build or review gRPC services and clients in .NET. USE FOR: ASP.NET Core gRPC, protobuf contracts, unary or streaming RPC, gRPC client factory, interceptors, deadlines, cancellation, channel reuse, backend service integration. DO NOT USE FOR: broad browser-facing APIs without gRPC-Web tradeoff review, SignalR realtime hubs, plain REST APIs. INVOKES: dotnet build/test and focused service or client smoke checks when code changes.
Trigger On
- building backend-to-backend RPC services or clients
- adding protobuf contracts, streaming calls, or interceptors
- deciding between gRPC, HTTP APIs, and SignalR
- optimizing gRPC performance, deadlines, cancellation, or connection reuse
- integrating service-to-service communication in microservices
Workflow
- Validate the architecture fit before touching code.
- prefer gRPC for backend RPC, strong contracts, low-latency calls, or streaming - prefer REST or minimal APIs for broad browser compatibility and loosely coupled public APIs - prefer SignalR for browser/client realtime fan-out and UI collaboration
- Treat
.protofiles as the source of truth.
- keep package names, csharp_namespace, service names, and versioning deliberate - reserve removed field numbers and avoid reusing tags - use wrapper types or explicit messages when optionality matters
- Choose the RPC shape from the interaction model.
- unary for request/response - server streaming for large or progressive result sets - client streaming for uploads or batches - bidirectional streaming for coordinated two-way flows
- Wire server and client behavior together.
- register services with AddGrpc - use AddGrpcClient or long-lived GrpcChannel reuse - set deadlines and propagate cancellation - convert domain failures to appropriate RpcException status codes
- Add observability and resilience where the boundary justifies it.
- logging or exception interceptors - OpenTelemetry traces and status-code metrics - retry policy only for safe idempotent calls
- Validate with the repo's normal build and tests, plus a focused smoke call when runnable.
flowchart LR
A["RPC requirement"] --> B["proto contract"]
B --> C["server implementation"]
B --> D["client factory or channel"]
C --> E["deadlines / cancellation / status codes"]
D --> E
E --> F["build, tests, smoke call"]Deliver
- stable protobuf contracts and generated-code ownership
- service and client code that match the RPC shape
- explicit deadline, cancellation, retry, and status-code behavior
- tests or smoke checks for serialization and call behavior
- documentation of browser, transport, or deployment constraints when relevant
Validate
dotnet buildsucceeds after contract or generated-code changes- tests or smoke checks exercise at least one server/client call
- streaming methods respect cancellation and bounded message sizes
- channels are reused through client factory or a long-lived channel
- status-code handling is intentional and observable
- browser constraints are documented if gRPC-Web is involved
Anti-Patterns
- creating a new
GrpcChannelper call - omitting deadlines and relying only on client-side cancellation
- ignoring
ServerCallContext.CancellationTokenin streaming handlers - sending large single messages instead of chunking or streaming
- using gRPC as the default public browser API
- swallowing exceptions inside interceptors
- retrying non-idempotent calls without explicit policy
Load References
- references/patterns.md for proto design, streaming implementations, interceptors, health checks, load balancing, and client factory setup.
- references/anti-patterns.md for common channel, deadline, streaming, message-size, and exception-handling mistakes.
Related skills
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices.
Design and implement Minimal APIs in ASP.NET Core using handler-first endpoints, route groups, filters, and lightweight composition suited to modern .NET services.