{"id":"dotnet-core-expert","name":"dotnet-core-expert","summary":"最小限のAPIやクリーンなアーキテクチャ、クラウドネイティブのマイクロサービスで.NET 8アプリケーションを構築する際に使用します。","body":"# .NET Core Expert\n\n## Core Workflow\n\n1. **Analyze requirements** — Identify architecture pattern, data models, API design\n2. **Design solution** — Create clean architecture layers with proper separation\n3. **Implement** — Write high-performance code with modern C# features; run `dotnet build` to verify compilation — if build fails, review errors, fix issues, and rebuild before proceeding\n4. **Secure** — Add authentication, authorization, and security best practices\n5. **Test** — Write comprehensive tests with xUnit and integration testing; run `dotnet test` to confirm all tests pass — if tests fail, diagnose failures, fix the implementation, and re-run before continuing; verify endpoints with `curl` or a REST client\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Minimal APIs | `references/minimal-apis.md` | Creating endpoints, routing, middleware |\n| Clean Architecture | `references/clean-architecture.md` | CQRS, MediatR, layers, DI patterns |\n| Entity Framework | `references/entity-framework.md` | DbContext, migrations, relationships |\n| Authentication | `references/authentication.md` | JWT, Identity, authorization policies |\n| Cloud-Native | `references/cloud-native.md` | Docker, health checks, configuration |\n\n## Constraints\n\n### MUST DO\n- Use .NET 8 and C# 12 features\n- Enable nullable reference types: `<Nullable>enable</Nullable>` in the `.csproj`\n- Use async/await for all I/O operations — e.g., `await dbContext.Users.ToListAsync()`\n- Implement proper dependency injection\n- Use record types for DTOs — e.g., `public record UserDto(int Id, string Name);`\n- Follow clean architecture principles\n- Write integration tests with `WebApplicationFactory<Program>`\n- Configure OpenAPI/Swagger documentation\n\n### MUST NOT DO\n- Use synchronous I/O operations\n- Expose entities directly in API responses\n- Skip input validation\n- Use legacy .NET Framework patterns\n- Mix concerns across architectural layers\n- Use deprecated EF Core patterns\n\n## Code Examples\n\n### Minimal API Endpoint\n```csharp\n// Program.cs\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.AddEndpointsApiExplorer();\nbuilder.Services.AddSwaggerGen();\nbuilder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));\n\nvar app = builder.Build();\napp.UseSwagger();\napp.UseSwaggerUI();\n\napp.MapGet(\"/users/{id}\", async (int id, ISender sender, CancellationToken ct) =>\n{\n    var result = await sender.Send(new GetUserQuery(id), ct);\n    return result is null ? Results.NotFound() : Results.Ok(result);\n})\n.WithName(\"GetUser\")\n.Produces<UserDto>()\n.ProducesProblem(404);\n\napp.Run();\n```\n\n### MediatR Query Handler\n```csharp\n// Application/Users/GetUserQuery.cs\npublic record GetUserQuery(int Id) : IRequest<UserDto?>;\n\npublic sealed class GetUserQueryHandler : IRequestHandler<GetUserQuery, UserDto?>\n{\n    private readonly AppDbContext _db;\n\n    public GetUserQueryHandler(AppDbContext db) => _db = db;\n\n    public async Task<UserDto?> Handle(GetUserQuery request, CancellationToken ct) =>\n        await _db.Users\n            .AsNoTracking()\n            .Where(u => u.Id == request.Id)\n            .Select(u => new UserDto(u.Id, u.Name))\n            .FirstOrDefaultAsync(ct);\n}\n```\n\n### EF Core DbContext with Async Query\n```csharp\n// Infrastructure/AppDbContext.cs\npublic sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)\n{\n    public DbSet<User> Users => Set<User>();\n\n    protected override void OnModelCreating(ModelBuilder modelBuilder)\n    {\n        modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);\n    }\n}\n\n// Usage in a service\npublic async Task<IReadOnlyList<UserDto>> GetAllAsync(CancellationToken ct) =>\n    await _db.Users\n        .AsNoTracking()\n        .Select(u => new UserDto(u.Id, u.Name))\n        .ToListAsync(ct);\n```\n\n### DTO with Record Type\n```csharp\npublic record UserDto(int Id, string Name);\npublic record CreateUserRequest(string Name, string Email);\n```\n\n## Output Templates\n\nWhen implementing .NET features, provide:\n1. Project structure (solution/project files)\n2. Domain models and DTOs\n3. API endpoints or service implementations\n4. Database context and migrations if applicable\n5. Brief explanation of architectural decisions\n\n[Documentation](https://jeffallan.github.io/claude-skills/skills/backend/dotnet-core-expert/)","author":"@Jeffallan","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Jeffallan/claude-skills/tree/main/skills/dotnet-core-expert","license":"MIT","category":"writing","lang":"en","tokens":995,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/authentication.md","size":14991,"sha256":"f4b9b9cc6a9073eacf5f77d8aaa3575699c25fe688ba1ade25df69ca6dea9108"},{"path":"references/clean-architecture.md","size":11931,"sha256":"4fb2c4ac29927bfc6ec9ba44e0fa8755ad7b3d3d46cc093848cc3b65f6c7c01e"},{"path":"references/cloud-native.md","size":14033,"sha256":"7df046fd9d0195be4cfda8d721d32941b46d90bb8d571f4eba0fb4ba0304d291"},{"path":"references/entity-framework.md","size":12344,"sha256":"e8b874bb091ad4439207f39ed91bd427a2cc0da0dc7df2d558ed75192569a526"},{"path":"references/minimal-apis.md","size":8348,"sha256":"bc5e6c24923bf54ffbd7e0669704b4084e9d19ec6037d922eca5cb9c6455bb76"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["api.external-service.com","jeffallan.github.io"]}}