backend-developer
Covers domain-specific architecture and conventions for building .NET microservices, including messaging, data access, and GraphQL.
Install
mkdir -p .claude/skills/backend-developer && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16633" && unzip -o skill.zip -d .claude/skills/backend-developer && rm skill.zipInstalls to .claude/skills/backend-developer
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use this skill when working on backend microservices — implementing GraphQL APIs with HotChocolate, writing MassTransit consumers/publishers, building MongoDB data access layers, configuring service startup, integrating data pipelines, or adding observability with OpenTelemetry. Triggers on: GraphQL resolvers, ObjectType, TypeExtensions, QueryRewriter, field middleware, DataLoaders, MassTransit IConsumer, Azure Service Bus, MongoDB repositories, data pipeline sender/receiver, service startup configuration, or any backend domain service work.Key capabilities
- →Implement GraphQL APIs with HotChocolate
- →Write MassTransit consumers and publishers
- →Build MongoDB data access layers
- →Configure service startup
- →Integrate data pipelines
- →Add observability with OpenTelemetry
How it works
The skill provides guidance on developing backend microservices by detailing patterns for GraphQL, MassTransit, MongoDB, data pipelines, and observability.
Inputs & outputs
When to use backend-developer
- →Implement GraphQL query rewriter
- →Configure MassTransit consumers
- →Develop MongoDB data repository
- →Integrate OpenTelemetry tracing
About this skill
Backend Developer
Guide for developing backend microservices. Covers domain-specific patterns, conventions, and internal libraries that the AI agent does not inherently know.
Scope: This skill covers project-specific patterns and conventions only. For general C# best practices, refer to the CSharpExpert agent. For testing conventions, follow
tests.instructions.md.
Architecture Quick Reference
Architecture, layer definitions, dependency rules, and coding standards are defined in general.instructions.md (always loaded). The following covers domain-specific patterns only.
Known domains: <!-- TODO: List your domain services here, e.g., Contract, Consultation, Profile, Document, etc. -->
API Stitching Layer
src/Api/ is the HotChocolate Stitching gateway. It stitches domain GraphQL schemas together and uses QueryDelegationRewriterBase to transform queries between schemas.
// Example: src/Api/src/Host/Addresses/AddressQueryRewriter.cs
public class AddressQueryRewriter : QueryDelegationRewriterBase
{
// Rewrites delegated queries for the stitched schema
}
Never add business logic to the Api layer — it only delegates and rewrites.
HotChocolate GraphQL Patterns
ObjectType Definitions
Use class-based type definitions extending ObjectType<T>:
public class MyEntityType : ObjectType<MyEntity>
{
protected override void Configure(IObjectTypeDescriptor<MyEntity> descriptor)
{
descriptor.Field(x => x.Id).Type<NonNullType<IdType>>();
}
}
TypeExtensions
Extend existing types without modifying their original definition. Use [ExtendObjectType]:
[ExtendObjectType(typeof(ParentEntity))]
public class ChildTypeExtensions
{
public async Task<ChildResult> GetChildData(
[Parent] ParentEntity parent,
[Service] IChildService service,
CancellationToken cancellationToken)
{
return await service.GetByParentIdAsync(parent.Id, cancellationToken);
}
}
Field Middleware
Chain middleware on fields using FieldDelegate and IMiddlewareContext:
public static class ComputeMiddleware
{
public static FieldDelegate Create(FieldDelegate next)
{
return async context =>
{
await next(context);
object? result = context.Result;
// Transform result
context.Result = transformed;
};
}
}
Pass data between middleware/resolvers via ScopedContextData with IImmutableStack<object>.
DataLoaders
Use GreenDonut BatchDataLoader<TKey, TValue> for batching and caching. Naming convention: {Entity}By{Key}DataLoader. Inject IMyRepository + IBatchScheduler in the constructor, call base(batchScheduler, options), and override LoadBatchAsync.
Translation & Localization
Consultation domain uses HotChocolate.Extensions.Translation with HeaderLocalization:
services.AddTranslation()
.AddHeaderLocalization(options => { /* configure */ });
Mutation Conventions
Use HotChocolate's built-in mutation conventions. Prefer implementation-first over schema-first. Use dedicated Input/Output types rather than separate parameters.
MassTransit Consumer Patterns
Standard Consumer
Mark consumers sealed. Use primary constructors for DI. Every consumer must include OpenTelemetry tracing and source-generated logging:
public sealed class ContractDeletedConsumer(
IConsultationUpdater updater) : IConsumer<ContractDeleted>
{
public async Task Consume(ConsumeContext<ContractDeleted> context)
{
using Activity? activity = App.ActivitySource.StartActivity();
App.Log.ConsumingContractDeleted(context.Message.ContractId);
await updater.DeleteByContractIdAsync(
context.Message.ContractId,
context.CancellationToken);
}
}
Abstract Base Consumer
For shared consumer logic across message types, use a generic abstract base:
public abstract class CustomerUpdateMessageConsumerBase<TMessage>
: IConsumer<TMessage> where TMessage : class
{
public async Task Consume(ConsumeContext<TMessage> context)
{
using Activity? activity = App.ActivitySource.StartActivity();
// Shared processing logic
await ProcessAsync(context.Message, context.CancellationToken);
}
protected abstract Task ProcessAsync(TMessage message, CancellationToken cancellationToken);
}
Consumer Organization
Organize consumers in Core/Messaging/Consumers/ by category:
E2E/CustomerUpdates/— End-to-end customer update eventsFuse/— Fuse-specific events (invites, codes)FusionIdentity/— Identity eventsIntegration/— External integration events
Request-Response Pattern
For consumers that need to respond:
await context.RespondAsync(new AdminResponse { /* ... */ });
Consumer Anti-Patterns
- Never catch and swallow exceptions in consumers — let MassTransit handle retries
- Never use
ILoggerdirectly — use source-generatedApp.Logmethods - Never skip
App.ActivitySource.StartActivity()— it breaks distributed tracing - Never add business logic outside
Core/layer — consumers orchestrate, not implement
Publisher Testing
Test publishers with MassTransit InMemoryTestHarness + Snapshooter:
public class ProfilePublisherTests
{
private readonly InMemoryTestHarness _harness;
[Fact]
public async Task Publish_ShouldSendMessage()
{
// Arrange + Act
await _publisher.PublishAsync(data);
// Assert
IPublishedMessage<ProfileUpdated>? message =
_harness.Published.Select<ProfileUpdated>().FirstOrDefault();
message.Should().NotBeNull();
message!.Context.Message.MatchSnapshot();
}
}
Observability
OpenTelemetry Tracing
Use a centralized activity source for all tracing. Start activities in every consumer/service method:
using Activity? activity = App.ActivitySource.StartActivity();
Record exceptions on the activity:
catch (Exception ex)
{
activity?.RecordException(ex);
throw;
}
Source-Generated Logging
Use the [LoggerMessage] attribute with App.Log — never use ILogger directly for structured log messages:
internal static partial class Log
{
[LoggerMessage(Level = LogLevel.Information,
Message = "Consuming contract deleted for {ContractId}")]
public static partial void ConsumingContractDeleted(
this ILogger logger, string contractId);
}
// Usage:
App.Log.ConsumingContractDeleted(contractId);
Service Startup Configuration
Standard Host Setup
Domain services use a consistent startup pattern:
public class StartUp
{
public void ConfigureServices(IServiceCollection services)
{
// Authentication
services.AddJwtBearerAuthentication(Configuration);
// GraphQL
services.AddGraphQLServer()
.AddTypes()
.AddTranslation();
// MongoDB
services.AddMongoDataAccess(Configuration);
// Health checks
services.AddHealthChecks()
.AddMongoHealthCheck();
// MassTransit / Service Bus
services.AddMassTransitServiceBus(Configuration);
}
}
Internal Libraries
<!-- TODO: Replace with your organization's internal libraries -->| Library | Purpose |
|---|---|
YourOrg.Security.Authentication.JwtBearer | JWT Bearer auth setup |
YourOrg.Health.* | Health check extensions (Mongo, etc.) |
YourOrg.Observability.* | Activity sources and structured logging |
YourOrg.{ProjectName}.* | Domain-specific shared code |
Authentication & Authorization
- Use
AddJwtBearerAuthentication(Configuration)for auth setup - Define authorization policies for specific endpoints (e.g., Invites, NeoInvites, MyLifeInvites)
- Swagger UI configured with Bearer token support
REST + GraphQL Coexistence
Some services expose both REST (controllers + Swagger) and GraphQL. DocConnector and Onboarding use this pattern:
services.AddControllers()
.AddNewtonsoftJson(o => o.SerializerSettings.Converters.Add(new StringEnumConverter()));
services.AddSwaggerGen(c => { /* Bearer auth config */ });
services.AddGraphQLServer()
.AddTypes();
NSwag-Generated Clients
External API clients live in ServiceReferences/Generated/. Never edit generated files. Register via DI and consume through the generated client interfaces.
Data Pipeline Integration
API Host
DataPipelineApi.Create<Startup>(SetupConfiguration, args);
Worker Host
DataPipelineHost.Create<DomainsReference>(SetupConfiguration, configureServices, args);
Messaging
Register sender/receiver in DI:
services.AddDataPipelineReceiver<MyWorker>();
services.AddDataPipelineSender();
Use IMessageSender<T> and IMessageSenderFactory for sending messages.
Tenant Structure
The data pipeline uses tenant-based organization:
<!-- TODO: Replace with your actual tenant names -->src/Tenants/TenantA/— Primary tenant (Api + Host)src/Tenants/TenantB/— Secondary tenant
Partial Program Pattern
Environment-specific config via partial classes:
Program.cs— Shared entry pointProgram.Dev.cs— Development configurationProgram.Prod.cs— Production configuration
Shared Config
Shared appsettings live in _Links/ directories, e.g., _Links/{TenantName}.Domains/appsettings.shared.json.
MongoDB Data Access
Repository Pattern
Repositories implement interfaces from Abstractions and use IMongoCollection<T> directly. Follow existing patterns in the domain you are working in.
Health Checks
Always register MongoDB health checks:
services.AddHealthChecks()
.AddMongoHealthCheck();
Testing Domain-Specific Code
Follow tests.instructions.md
Content truncated.
When not to use it
- →When adding business logic to the API stitching layer
- →When catching and swallowing exceptions in MassTransit consumers
- →When using `ILogger` directly instead of source-generated `App.Log` methods
Limitations
- →The skill covers project-specific patterns and conventions for backend microservices
- →The skill focuses on GraphQL APIs with HotChocolate, MassTransit, MongoDB, data pipelines, and OpenTelemetry
- →The skill does not cover general C# best practices or testing conventions
How it compares
This skill enforces project-specific patterns and conventions for backend microservices, ensuring consistency in GraphQL API implementation, MassTransit consumer design, and data access layers, unlike general C# best practices.
Compared to similar skills
backend-developer side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| backend-developer (this skill) | 0 | 6mo | No flags | Advanced |
| dotnet-backend-patterns | 7 | 5mo | No flags | Advanced |
| azure-servicebus-dotnet | 3 | 3mo | Review | Intermediate |
| azure-resource-manager-postgresql-dotnet | 1 | 3mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
dotnet-backend-patterns
wshobson
Master C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.
azure-servicebus-dotnet
microsoft
Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions, and sessions. Use for reliable message delivery, pub/sub patterns, dead letter handling, and background processing. Triggers: "Service Bus", "ServiceBusClient", "ServiceBusSender", "ServiceBusReceiver", "ServiceBusProcessor", "message queue", "pub/sub .NET", "dead letter queue".
azure-resource-manager-postgresql-dotnet
microsoft
Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for PostgreSQL", "PostgreSQL database management", "PostgreSQL firewall", "PostgreSQL backup", "Postgres".
azure-resource-manager-sql-dotnet
microsoft
Azure Resource Manager SDK for Azure SQL in .NET. Use for MANAGEMENT PLANE operations: creating/managing SQL servers, databases, elastic pools, firewall rules, and failover groups via Azure Resource Manager. NOT for data plane operations (executing queries) - use Microsoft.Data.SqlClient for that. Triggers: "SQL server", "create SQL database", "manage SQL resources", "ARM SQL", "SqlServerResource", "provision Azure SQL", "elastic pool", "firewall rule".
azure-eventgrid-dotnet
microsoft
Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven", "pub/sub".
websocket-integration
sunyonghuan
通过 WebSocket 连接 Cortana AI 对话服务。编写 C# 客户端代码,实现发送消息、接收流式回复、附件传输、系统事件监听。触发关键词:WebSocket、WS 连接、远程对话、流式回复、AI 接入、实时通信。