‹ 首页

dotnet-core-expert

@jeffallan · 收录于 1 周前 · 上游提交 1 个月前

Use when building .NET 8 applications with minimal APIs, clean architecture, or cloud-native microservices. Invoke for Entity Framework Core, CQRS with MediatR, JWT authentication, AOT compilation.

适合你,如果正在用 .NET 8 开发云原生应用或微服务

/ 下载安装
dotnet-core-expert.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add jeffallan/claude-skills/dotnet-core-expert
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- jeffallan/claude-skills/dotnet-core-expert
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify jeffallan/claude-skills/dotnet-core-expert
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
10501GitHub stars
~971最小装载
~10.1K含声明引用
~10.1K文本包总量
镜像托管

怎么用

商店整理自技能原文 · 版本 e8be415 · 表述以原文为准
它做什么

这个技能让Claude成为.NET 8后端专家,能帮你设计、编写和测试使用最小API、整洁架构或云原生微服务的C#代码。它会自动遵循最佳实践,如使用异步操作、记录类型和依赖注入。

什么时候触发

当你提到“.NET Core”、“.NET 8”、“ASP.NET Core”、“C# 12”、“最小API”、“Entity Framework Core”、“微服务 .NET”、“CQRS”或“MediatR”等关键词时触发。

装好后可以这样说
Claude会配置认证中间件和授权策略。
技能原文 SKILL.md作者撰写 · MIT · e8be415

.NET Core Expert

Core Workflow
  1. Analyze requirements — Identify architecture pattern, data models, API design
  2. Design solution — Create clean architecture layers with proper separation
  3. 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
  4. Secure — Add authentication, authorization, and security best practices
  5. 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
Reference Guide

Load detailed guidance based on context:

| Topic | Reference | Load When | |-------|-----------|-----------| | Minimal APIs | references/minimal-apis.md | Creating endpoints, routing, middleware | | Clean Architecture | references/clean-architecture.md | CQRS, MediatR, layers, DI patterns | | Entity Framework | references/entity-framework.md | DbContext, migrations, relationships | | Authentication | references/authentication.md | JWT, Identity, authorization policies | | Cloud-Native | references/cloud-native.md | Docker, health checks, configuration |

Constraints
MUST DO
  • Use .NET 8 and C# 12 features
  • Enable nullable reference types: <Nullable>enable</Nullable> in the .csproj
  • Use async/await for all I/O operations — e.g., await dbContext.Users.ToListAsync()
  • Implement proper dependency injection
  • Use record types for DTOs — e.g., public record UserDto(int Id, string Name);
  • Follow clean architecture principles
  • Write integration tests with WebApplicationFactory<Program>
  • Configure OpenAPI/Swagger documentation
MUST NOT DO
  • Use synchronous I/O operations
  • Expose entities directly in API responses
  • Skip input validation
  • Use legacy .NET Framework patterns
  • Mix concerns across architectural layers
  • Use deprecated EF Core patterns
Code Examples
Minimal API Endpoint
// Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();

app.MapGet("/users/{id}", async (int id, ISender sender, CancellationToken ct) =>
{
    var result = await sender.Send(new GetUserQuery(id), ct);
    return result is null ? Results.NotFound() : Results.Ok(result);
})
.WithName("GetUser")
.Produces<UserDto>()
.ProducesProblem(404);

app.Run();
MediatR Query Handler
// Application/Users/GetUserQuery.cs
public record GetUserQuery(int Id) : IRequest<UserDto?>;

public sealed class GetUserQueryHandler : IRequestHandler<GetUserQuery, UserDto?>
{
    private readonly AppDbContext _db;

    public GetUserQueryHandler(AppDbContext db) => _db = db;

    public async Task<UserDto?> Handle(GetUserQuery request, CancellationToken ct) =>
        await _db.Users
            .AsNoTracking()
            .Where(u => u.Id == request.Id)
            .Select(u => new UserDto(u.Id, u.Name))
            .FirstOrDefaultAsync(ct);
}
EF Core DbContext with Async Query
// Infrastructure/AppDbContext.cs
public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
    public DbSet<User> Users => Set<User>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
    }
}

// Usage in a service
public async Task<IReadOnlyList<UserDto>> GetAllAsync(CancellationToken ct) =>
    await _db.Users
        .AsNoTracking()
        .Select(u => new UserDto(u.Id, u.Name))
        .ToListAsync(ct);
DTO with Record Type
public record UserDto(int Id, string Name);
public record CreateUserRequest(string Name, string Email);
Output Templates

When implementing .NET features, provide:

  1. Project structure (solution/project files)
  2. Domain models and DTOs
  3. API endpoints or service implementations
  4. Database context and migrations if applicable
  5. Brief explanation of architectural decisions

Documentation

按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。