grpc
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.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 511
- Forks
- 41
01 前言 Front Matter
- name
- grpc
- description
- 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.
- compatibility
- Requires ASP.NET Core gRPC or gRPC client projects.
02 资源文件 27
- 资产文件assets/examples/cell_summary_example.md8.7 KB
- 资产文件assets/examples/medical_structured_abstract.md11.8 KB
- 资产文件assets/examples/nature_abstract_examples.md8.7 KB
- 资产文件assets/examples/neurips_introduction_example.md8.6 KB
- 资产文件assets/grants/nih_specific_aims.tex8.9 KB
- 资产文件assets/grants/nsf_proposal_template.tex12.8 KB
- 资产文件assets/journals/nature_article.tex6.1 KB
- 资产文件assets/journals/neurips_article.tex8.7 KB
- 资产文件assets/journals/plos_one.tex11.4 KB
- 资产文件assets/posters/beamerposter_academic.tex8.3 KB
- 参考文档manifest.json74 B
- 参考文档references/anti-patterns.md24.6 KB
- 参考文档references/cell_press_style.md14.0 KB
- 参考文档references/conferences_formatting.md16.8 KB
- 参考文档references/cs_conference_style.md15.3 KB
- 参考文档references/grants_requirements.md22.3 KB
- 参考文档references/journals_formatting.md17.2 KB
- 参考文档references/medical_journal_styles.md15.6 KB
- 参考文档references/ml_conference_style.md17.4 KB
- 参考文档references/nature_science_style.md13.3 KB
- 参考文档references/patterns.md22.2 KB
- 参考文档references/posters_guidelines.md16.7 KB
- 参考文档references/reviewer_expectations.md15.5 KB
- 参考文档references/venue_writing_styles.md12.4 KB
- 脚本scripts/customize_template.py6.7 KB
- 脚本scripts/query_template.py8.7 KB
- 脚本scripts/validate_format.py8.6 KB
03 SKILL.md 正文
gRPC for .NET
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
Do Not Use For
- public browser-first APIs unless gRPC-Web limitations are explicitly acceptable
- SignalR hub design, realtime UI fan-out, or websocket-style client collaboration
- generic ASP.NET Core minimal APIs or REST controllers with no protobuf/RPC requirement
- non-.NET gRPC work unless the user asks for cross-stack contract guidance
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.
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
- keep package names,
- 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
AddGrpcClientor long-livedGrpcChannelreuse - set deadlines and propagate cancellation
- convert domain failures to appropriate
RpcExceptionstatus codes
- register services with
- 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.
Current Upstream Notes
dotnet/aspnetcorev10.0.11is servicing and does not change the gRPC programming model. Keep guidance focused on proto compatibility, streaming shape, deadlines, cancellation, channel reuse, and smoke calls.- The August 2026 ASP.NET Core overview still treats gRPC as a contract-first RPC option. After package servicing updates, regenerate protobuf outputs only when inputs or generator packages actually changed; do not churn generated files as a proxy for validation.
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"]
Examples
Use client factory for normal app integration:
builder.Services.AddGrpcClient<Greeter.GreeterClient>(options =>
{
options.Address = new Uri("https://localhost:5001");
});
Always set a deadline and pass cancellation:
var response = await client.SayHelloAsync(
new HelloRequest { Name = name },
deadline: DateTime.UtcNow.AddSeconds(5),
cancellationToken: cancellationToken);
For streaming, check cancellation inside the read/write loop and keep message sizes bounded. Load references/patterns.md before writing detailed streaming code.
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
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
04 同仓库更多 Skills
xtwitter-scraper
Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook/event flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
sep
Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser/writer options, and low-allocation row/column workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
webgpu-threejs-tsl
Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.
roslynk
Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.
system-text-json-net11
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.
process-api-net11
Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.