一键导入
clean-architecture
Use this skill when designing application structure or clarifying layer responsibilities in .NET applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use this skill when designing application structure or clarifying layer responsibilities in .NET applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | clean-architecture |
| description | Use this skill when designing application structure or clarifying layer responsibilities in .NET applications. |
When implementing Clean Architecture in .NET applications, follow these core principles:
Entity<T>, IAggregateRoot, domain eventsICommandHandler<T>, IQueryHandler<T, TResult>DbContext, IRepository<T>, IEmailService// Domain Entity
public abstract class Entity<T>
{
public T Id { get; protected set; }
public DateTime CreatedAt { get; protected set; }
// Domain logic methods
public void Validate() { /* business rules */ }
}
// Multi-tenant entity
public abstract class MultiTenantEntity : Entity<Guid>, ITenantEntity
{
public Guid TenantId { get; protected set; }
public bool BelongsToTenant(Guid tenantId) =>
TenantId == tenantId;
}
// Application layer interface
public interface IRepository<T> where T : Entity<Guid>
{
Task<T> GetByIdAsync(Guid id);
Task<IEnumerable<T>> GetAllAsync();
Task AddAsync(T entity);
Task UpdateAsync(T entity);
Task DeleteAsync(Guid id);
}
// Infrastructure implementation
public class Repository<T> : IRepository<T> where T : Entity<Guid>
{
private readonly GloboTicketDbContext _context;
// Implementation with EF Core
}
public class CreateVenueCommand : IRequest<VenueDto>
{
public string Name { get; set; }
public string Address { get; set; }
public Guid TenantId { get; set; }
}
public class CreateVenueCommandHandler :
IRequestHandler<CreateVenueCommand, VenueDto>
{
private readonly IVenueRepository _venueRepository;
private readonly IMapper _mapper;
public async Task<VenueDto> Handle(CreateVenueCommand request)
{
var venue = new Venue(request.Name, request.Address, request.TenantId);
await _venueRepository.AddAsync(venue);
return _mapper.Map<VenueDto>(venue);
}
}
GloboTicket.Domain/ - Domain entities and business logicGloboTicket.Application/ - Use cases, DTOs, interfacesGloboTicket.Infrastructure/ - EF Core, external servicesGloboTicket.API/ - Controllers, middleware, API endpointsThis architecture ensures maintainability, testability, and adherence to SOLID principles while providing clear separation of concerns.
Design system patterns for reusable UI via atomic design, Tailwind tokens/variants, and accessibility. Use when creating atoms/molecules, theming, or hardening a11y.
Entity Framework Core best practices for configuration, queries, concurrency, and multi-tenancy.
Frontend architecture patterns for React apps (React Router 7, TanStack Query). Use when planning features, defining routes, data strategies, and component gaps.
Infrastructure standards for Docker, scripts, middleware, and authentication in multi-tenant deployments.
Integration testing performance optimization, test parallelization, cleanup strategies, and CI/CD categorization patterns. Use when optimizing test execution speed, managing test data, or structuring tests for automated pipelines.
ASP.NET Core Minimal APIs patterns for endpoints, DTOs, validation, and service integration. Use when implementing API endpoints, defining request/response contracts, or structuring API projects with clean separation of concerns.