Skip to main content
ClaudeWave
Skill66 repo starsupdated 29d ago

dotnet-backend-patterns

Provides .NET and ASP.NET Core patterns for REST APIs, Entity Framework, dependency injection, and middleware. Use when working with C# files (*.cs, *.csproj) or when the user mentions .NET, ASP.NET Core, C#, or Entity Framework.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/tranhieutt/software_development_department /tmp/dotnet-backend-patterns && cp -r /tmp/dotnet-backend-patterns/.claude/skills/dotnet-backend-patterns ~/.claude/skills/dotnet-backend-patterns
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# .NET Backend Development Patterns

C#/.NET patterns for production-grade APIs, MCP servers, and enterprise backends.

## API Structure (Minimal API + Controllers)

\`\`\`csharp
// Program.cs - Minimal API
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(o => o.UseNpgsql(connStr));
builder.Services.AddScoped<IOrderService, OrderService>();

var app = builder.Build();
app.MapGet("/orders/{id}", async (int id, IOrderService svc) =>
    await svc.GetByIdAsync(id) is { } order ? Results.Ok(order) : Results.NotFound());
\`\`\`

## Dependency Injection Patterns

\`\`\`csharp
// Register services
builder.Services.AddScoped<IPaymentService, StripePaymentService>();
builder.Services.AddSingleton<ICacheService, RedisCacheService>();
builder.Services.AddHttpClient<IApiClient, ExternalApiClient>(client => {
    client.BaseAddress = new Uri("https://api.external.com");
});
\`\`\`

Lifetime guide: Singleton (stateless/cache), Scoped (per-request), Transient (stateless utility).

## Entity Framework Core

\`\`\`csharp
// DbContext with conventions
public class AppDbContext : DbContext {
    public DbSet<Order> Orders => Set<Order>();
    protected override void OnModelCreating(ModelBuilder builder) {
        builder.Entity<Order>().HasIndex(o => o.UserId);
        builder.Entity<Order>().Property(o => o.Total).HasPrecision(18, 2);
    }
}
\`\`\`

Performance tips:
- Use `.AsNoTracking()` for read-only queries
- Avoid N+1 with `.Include()` or projection
- Use compiled queries for hot paths

## Middleware Pipeline

\`\`\`csharp
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseAuthentication();
app.UseAuthorization();
app.UseRateLimiter();
app.MapControllers();
\`\`\`

## Error Handling

\`\`\`csharp
// Global exception handler
app.UseExceptionHandler(err => err.Run(async context => {
    var exception = context.Features.Get<IExceptionHandlerFeature>()?.Error;
    var (status, message) = exception switch {
        NotFoundException => (404, exception.Message),
        UnauthorizedAccessException => (403, "Forbidden"),
        _ => (500, "Internal server error")
    };
    context.Response.StatusCode = status;
    await context.Response.WriteAsJsonAsync(new { error = message });
}));
\`\`\`

## Configuration (IOptions pattern)

\`\`\`csharp
builder.Services.Configure<StripeSettings>(
    builder.Configuration.GetSection("Stripe"));

// Usage
public class PaymentService(IOptions<StripeSettings> opts) {
    private readonly string _key = opts.Value.SecretKey;
}
\`\`\`

## Testing

\`\`\`csharp
// Integration test with WebApplicationFactory
public class OrderApiTests : IClassFixture<WebApplicationFactory<Program>> {
    private readonly HttpClient _client;
    [Fact]
    public async Task GetOrder_ReturnsOk() {
        var response = await _client.GetAsync("/orders/1");
        response.StatusCode.Should().Be(HttpStatusCode.OK);
    }
}
\`\`\`

## Related Skills

- `backend-architect` — architecture decisions
- `database-architect` — schema design
- `drizzle-orm-expert` — Node.js ORM alternative
accessibility-specialistSubagent

The Accessibility Specialist ensures the software is accessible to the widest possible audience. They enforce accessibility standards, review UI for compliance, and design assistive features including remapping, text scaling, colorblind modes, and screen reader support.

ai-programmerSubagent

The AI Programmer implements intelligent system features: recommendation engines, classification pipelines, LLM integrations, decision logic, and autonomous agent behavior. Use this agent for AI/ML feature implementation, model integration, intelligent automation, or AI system debugging.

analytics-engineerSubagent

The Analytics Engineer designs telemetry systems, user behavior tracking, A/B test frameworks, and data analysis pipelines. Use this agent for event tracking design, dashboard specification, A/B test design, or user behavior analysis methodology.

backend-developerSubagent

The Backend Developer builds and maintains server-side logic, APIs, databases, authentication, and integrations. Use this agent for REST/GraphQL API implementation, database operations, authentication systems, background jobs, microservices, server performance, and backend testing. Works from API design contracts and PRDs.

community-managerSubagent

The Community Manager handles user-facing communications, feedback synthesis, support escalation, and community engagement. Use this agent for drafting release announcements, synthesizing user feedback into actionable insights, writing support documentation, or coordinating community-facing communication around releases and incidents.

ctoSubagent

The CTO (Chief Technical Officer) owns the high-level technical vision, architecture decisions, technology choices, and technical strategy. Use this agent for architecture-level decisions, technology evaluations, cross-system conflicts, and when a technical choice will constrain or enable product possibilities. This is the highest technical authority in the department.

data-engineerSubagent

The Data Engineer designs database schemas, builds data pipelines, manages migrations, and owns the data infrastructure. Use this agent for schema design, complex migrations, data modeling, ETL/ELT pipelines, database performance optimization, analytics infrastructure, and data integrity strategies.

devops-engineerSubagent

The DevOps Engineer maintains build pipelines, CI/CD configuration, version control workflow, and deployment infrastructure. Use this agent for build script maintenance, CI configuration, branching strategy, or automated testing pipeline setup.