home / skills / 404kidwiz / claude-supercode-skills / csharp-developer-skill

csharp-developer-skill skill

/csharp-developer-skill

This skill provides expert guidance on modern C# 12 and .NET 8 development, ASP.NET Core APIs, and EF Core data access.

npx playbooks add skill 404kidwiz/claude-supercode-skills --skill csharp-developer-skill

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.3 KB
---
name: csharp-developer
description: .NET 8 and C# 12 specialist with expertise in ASP.NET Core, EF Core, and modern enterprise development. Use when building C# applications, working with .NET, implementing ASP.NET Core APIs, or using Entity Framework.
---

# C# Developer

## Purpose
Provides expertise in modern C# and .NET development, including ASP.NET Core web applications, Entity Framework Core data access, and enterprise application patterns. Covers C# 12 features and .NET 8 best practices.

## When to Use
- Building C# applications with .NET 8
- Developing ASP.NET Core web APIs
- Implementing Entity Framework Core data access
- Using modern C# features (records, patterns, etc.)
- Building enterprise .NET applications
- Writing unit tests with xUnit/NUnit
- Implementing dependency injection patterns

## Quick Start
**Invoke this skill when:**
- Building C# applications with .NET 8
- Developing ASP.NET Core web APIs
- Implementing Entity Framework Core data access
- Using modern C# features
- Building enterprise .NET applications

**Do NOT invoke when:**
- Building cross-platform .NET MAUI apps (use dotnet-core-expert)
- Working with .NET Framework 4.8 (use dotnet-framework-4.8-expert)
- Building Windows desktop apps (use windows-app-developer)
- Azure-specific infrastructure (use azure-infra-engineer)

## Decision Framework
```
Project Type:
├── Web API → ASP.NET Core Minimal API or Controllers
├── Web App → Blazor or Razor Pages
├── Background service → Worker Service
├── Desktop → WPF, WinUI, or MAUI
└── Library → .NET Standard or .NET 8

Data Access:
├── SQL with ORM → Entity Framework Core
├── SQL with control → Dapper
├── NoSQL → MongoDB driver or Cosmos SDK
└── Multiple DBs → Repository pattern
```

## Core Workflows

### 1. ASP.NET Core API Development
1. Create project with appropriate template
2. Configure dependency injection
3. Implement domain models
4. Set up EF Core with migrations
5. Create controllers or minimal API endpoints
6. Add validation and error handling
7. Implement authentication/authorization
8. Add OpenAPI documentation

### 2. Entity Framework Core Setup
1. Define entity models
2. Configure DbContext
3. Set up relationships and constraints
4. Create initial migration
5. Implement repository pattern if needed
6. Add query optimization
7. Configure connection resilience

### 3. Testing Strategy
1. Set up xUnit or NUnit project
2. Create unit tests with mocks
3. Implement integration tests
4. Use WebApplicationFactory for API tests
5. Add test database fixtures
6. Configure CI test pipeline

## Best Practices
- Use records for DTOs and immutable data
- Leverage pattern matching for cleaner code
- Use nullable reference types
- Implement IAsyncDisposable for async cleanup
- Use primary constructors in C# 12
- Configure EF Core query splitting for includes

## Anti-Patterns
| Anti-Pattern | Problem | Correct Approach |
|--------------|---------|------------------|
| Service locator | Hidden dependencies | Constructor injection |
| Async void | Unhandled exceptions | async Task everywhere |
| N+1 queries | Performance issues | Use Include() or projection |
| Throwing from constructors | Hard to handle | Use factory methods |
| String-based config | Runtime errors | Strongly-typed options |

Overview

This skill provides hands-on expertise for building modern C# and .NET 8 applications, focusing on ASP.NET Core, Entity Framework Core, and enterprise patterns. It guides implementation of C# 12 features, clean architecture, testing strategies, and production-ready API design. Use it to accelerate development, avoid common anti-patterns, and apply best practices for performance and maintainability.

How this skill works

The skill inspects project type, runtime target, and data access needs, then recommends templates, DI configuration, and appropriate API patterns (minimal APIs or controllers). It outlines EF Core setup including DbContext, migrations, and query optimization, and provides testing workflows with xUnit/NUnit and integration testing using WebApplicationFactory. It also highlights common pitfalls and corrective approaches.

When to use it

  • Starting a new .NET 8 web API or service using ASP.NET Core
  • Implementing data access with Entity Framework Core and migrations
  • Applying C# 12 language features like primary constructors and records
  • Designing enterprise application architecture and dependency injection
  • Writing unit and integration tests for ASP.NET Core APIs

Best practices

  • Prefer records for DTOs and immutable data to reduce accidental state changes
  • Enable nullable reference types and use pattern matching for clearer logic
  • Use constructor injection instead of a service locator to expose dependencies
  • Avoid async void; return Task/Task<T> and implement IAsyncDisposable for async cleanup
  • Optimize EF Core queries with projection, Includes, or query splitting to prevent N+1

Example use cases

  • Create a .NET 8 REST API with EF Core-backed persistence, migrations, and OpenAPI docs
  • Refactor a legacy data layer to EF Core repositories with connection resilience and query tuning
  • Implement integration tests for controllers using WebApplicationFactory and an in-memory or test database
  • Adopt C# 12 primary constructors and records across DTOs and domain models for concise code
  • Set up CI pipelines that run unit and integration tests and apply EF Core migrations

FAQ

When should I choose minimal APIs versus controllers?

Use minimal APIs for small, high-performance endpoints and microservices; prefer controllers for larger apps where organization, filters, and attribute routing give clearer structure.

How do I avoid N+1 queries in EF Core?

Use Include() for related data or project into DTOs with Select to load only required fields; consider query splitting for complex includes to reduce cartesian explosion.