.claude/skills/grpc-standards/SKILL.md
Use when working with gRPC services, protobuf definitions, Protocol Buffers, streaming RPCs, interceptors, or gRPC client configuration in .NET. Provides domain-specific rules layered on top of base architectural standards.
npx skillsauth add klod68/littlerae grpc-standardsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Field | Value |
|---|---|
| Name | gRPC Service Standards |
| Domain | API, Messaging, RPC |
| Level | Feature |
| Tags | grpc, protobuf, streaming, interceptors, rpc |
Activate this skill when the task involves:
.proto filesThese rules layer on top of base architectural standards. On conflict, these win.
<!-- SHARED:rules/grpc.md -->Apply these rules in addition to _base.md for projects using gRPC services.
.proto file per service — file name matches service name: order_service.proto.snake_case for field names, PascalCase for message and service names (protobuf convention).option csharp_namespace explicitly to control generated C# namespace.package myapp.orders.v1; — never reuse package names for breaking changes.Request and Response message — never reuse messages across RPCs.google.protobuf.Timestamp for dates, google.protobuf.Duration for time spans, google.protobuf.StringValue for nullable strings.Base class: public class OrderService : Orders.OrdersBase.ServerCallContext and propagate its CancellationToken to downstream calls.RpcException with appropriate StatusCode — never throw raw exceptions.async + yield return pattern or write to IServerStreamWriter<T> in a loop.IAsyncStreamReader<T> until MoveNext() returns false.Task.WhenAll to read and write concurrently, not sequentially.context.CancellationToken in streaming loops — abort cleanly on client disconnect.MaxReceiveMessageSize and MaxSendMessageSize (default 4MB is often too small for file transfers).client.GetOrderAsync(req, deadline: DateTime.UtcNow.AddSeconds(5)).context.Deadline for cascading timeouts.StatusCode.DeadlineExceeded explicitly in client error handling.GrpcChannelOptions.MaxReceiveMessageSize.| Domain Error | gRPC StatusCode | When |
|---|---|---|
| Not found | NotFound | Resource doesn't exist |
| Validation failure | InvalidArgument | Bad request data |
| Already exists | AlreadyExists | Duplicate create |
| Permission denied | PermissionDenied | Auth check failed |
| Unauthorized | Unauthenticated | No/invalid credentials |
| Business rule violation | FailedPrecondition | State doesn't allow operation |
| Timeout | DeadlineExceeded | Operation took too long |
| Internal error | Internal | Unexpected server error |
RpcException for debugging — never expose stack traces.try/catch in every RPC method.AddGrpc(options => options.Interceptors.Add<LoggingInterceptor>()).GrpcChannel.ForAddress with IHttpClientFactory for connection management.AddGrpcClient<OrderService.OrderServiceClient>() in DI.ServiceConfig — gRPC has built-in retry policy support.CallInvoker for testing — mock at the channel level, not the service level.| Anti-Pattern | Fix |
|---|---|
| No deadline on client calls | Always set deadline: parameter |
| Throwing Exception from service method | Return RpcException(new Status(StatusCode.X, "msg")) |
| Large messages without streaming | Use server streaming for collections > 100 items |
| Blocking in streaming loop | Use async/await with CancellationToken |
| Reusing request/response messages across RPCs | One dedicated message pair per RPC method |
| new GrpcChannel() per call | Use DI with AddGrpcClient<T>() |
| Missing option csharp_namespace in .proto | Generates messy namespace — always specify |
| Sequential read/write in bidirectional stream | Use Task.WhenAll for concurrent read and write |
api-design.md — RESTful conventions, HTTP methods, pagination, error responsesresilience.md — Polly v8 resilience pipelines, retry, circuit breaker, timeoutauth.md — Authentication, authorization, OAuth/OIDC, secrets managementresult-error-handling.md — Result object pattern, error constants, exception boundariestools
Use when cross-cutting concerns (logging, metrics, validation, authorization) are tangled into command handlers or service methods, when building database command pipelines with reorderable concerns, or when HTTP client pipelines or message handlers need composable, independently-replaceable processing stages. Covers ICommandInterceptor interface, InterceptorPipeline with reverse-chain construction, zero-cost Empty sentinel to skip overhead when no interceptors are registered, and ConfigureAwait(false) discipline for library code. Domain: Architecture, Cross-Cutting Concerns. Level: Intermediate. Tags: interceptor, pipeline, middleware, decorator, cross-cutting-concerns.
development
Use when writing integration tests for Razor Pages, MVC, or Minimal API applications to validate routing, middleware, page rendering, and HTTP behavior without a browser or live server, or when adding fast smoke tests to a CI pipeline. Covers WebApplicationFactory<Program> setup with public partial class Program, in-memory test server, AngleSharp HTML parsing, CSS selector assertions, redirect and status code testing, and a shared static fixture pattern for minimal per-test startup overhead. Domain: Testing, ASP.NET Core. Level: Intermediate. Tags: integration-testing, webapplicationfactory, razor-pages, anglesharp, http-testing.
development
Use when designing indexes for new tables, diagnosing slow queries that are not using indexes efficiently, reviewing index fragmentation and maintenance, or when the current indexing strategy results in key lookups, table scans, or missing index warnings. Covers clustered index key selection (narrow, unique, ever-increasing), non-clustered index design for query patterns, covering indexes with INCLUDE columns, filtered indexes for subset queries, composite index column ordering, DMV-based monitoring for missing and unused indexes, and rebuild vs reorganize maintenance thresholds. Domain: Database, Performance. Level: Intermediate. Tags: index, sql-server, covering-index, filtered-index, performance, dmv, maintenance.
development
Use when building a searchable in-memory catalog or registry for documentation sites, admin panels, or type/API browsers where you need keyword matching, fuzzy search, and ranked results without an external search engine or database. Covers RegistryService with weighted scoring across name, description, keywords, and method names; Levenshtein fuzzy matching; synonym expansion; category and subcategory filtering; and singleton DI registration for datasets of hundreds to low thousands of items. Domain: Search, Data Access Patterns. Level: Intermediate. Tags: search, registry, fuzzy-matching, in-memory, catalog, filtering.