agentleFS
MindrallyMindrally/skills/dotnet/SKILL.md

dotnet

Skill266 starsChanged 10 months agoApache-2.0View on GitHub

Guidelines for .NET backend development with C#, ASP.NET Core, and Entity Framework Core

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

39 rules. 0 are common, 34 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 34

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write concise, idiomatic C# code with accurate examples

    line 12
  2. Distinctive:

    Follow .NET conventions and best practices

    line 13
  3. Distinctive:

    Use object-oriented programming with proper encapsulation

    line 14
  4. Distinctive:

    Prefer LINQ for collection operations

    line 15
  5. Distinctive:

    Use proper HTTP methods (GET, POST, PUT, PATCH, DELETE)

    line 33
  6. Distinctive:

    Use plural nouns for resource endpoints

    line 35
  7. Distinctive:

    Use query parameters for filtering and sorting

    line 37
  8. Very specific:

    Use async/await for all I/O-bound operations

    line 58
  9. Very specific:

    Don't block on async code (avoid .Result and .Wait())

    line 60
  10. Very specific:

    Use CancellationToken for cancellation support

    line 61
  11. Very specific:

    Prefer ValueTask for frequently-called methods

    line 62
  12. Distinctive:

    Use Fluent API for entity configuration

    line 67
  13. Distinctive:

    Use migrations for schema changes

    line 69
  14. Very specific:

    Use AsNoTracking() for read-only queries

    line 73
  15. Distinctive:

    Use Include/ThenInclude for eager loading

    line 75
  16. Distinctive:

    Avoid N+1 query problems

    line 76
  17. Distinctive:

    Use projections for optimized queries

    line 77
  18. Distinctive:

    Use appropriate lifetimes (Scoped, Transient, Singleton)

    line 97
  19. Distinctive:

    Create interfaces for service abstractions

    line 98
  20. Distinctive:

    Use Options pattern for configuration

    line 99
  21. Distinctive:

    Use IMemoryCache for in-memory caching

    line 108
  22. Distinctive:

    Use IDistributedCache for distributed scenarios

    line 109
  23. Distinctive:

    Use response caching for HTTP responses

    line 111
  24. Distinctive:

    Consider Redis for production caching

    line 112
  25. Distinctive:

    Use FluentValidation for complex validation

    line 116
  26. Distinctive:

    Use Data Annotations for simple validation

    line 117
  27. Distinctive:

    Use global exception handling middleware

    line 124
  28. Distinctive:

    Create custom exception types

    line 125
  29. Distinctive:

    Don't expose internal details

    line 128
  30. Distinctive:

    Use JWT tokens for API authentication

    line 133
  31. Distinctive:

    Use ASP.NET Core Identity when appropriate

    line 136
  32. Distinctive:

    Use claims for fine-grained permissions

    line 142
  33. Distinctive:

    Write unit tests with xUnit

    line 146
  34. Distinctive:

    Use Moq for mocking dependencies

    line 147
  35. Distinctive:

    Write integration tests with WebApplicationFactory

    line 148
  36. Distinctive:

    Test API endpoints end-to-end

    line 149
  37. Distinctive:

    Use in-memory database for testing

    line 150
  38. Distinctive:

    Use Swagger/OpenAPI for API documentation

    line 154
  39. Distinctive:

    Document all endpoints with XML comments

    line 155

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

.NET Development Guidelines

You are an expert in .NET backend development with deep knowledge of C#, ASP.NET Core, Entity Framework Core, and modern .NET practices.

Code Style and Structure

  • Write concise, idiomatic C# code with accurate examples
  • Follow .NET conventions and best practices
  • Use object-oriented programming with proper encapsulation
  • Prefer LINQ for collection operations
  • Structure code according to Clean Architecture principles

Project Structure

src/
  Domain/           # Entities, value objects, domain logic
  Application/      # Use cases, DTOs, interfaces
  Infrastructure/   # Data access, external services
  WebApi/          # Controllers, middleware, configuration
tests/
  UnitTests/
  IntegrationTests/

RESTful API Design

  • Use proper HTTP methods (GET, POST, PUT, PATCH, DELETE)
  • Return appropriate status codes
  • Use plural nouns for resource endpoints
  • Implement proper pagination for collections
  • Use query parameters for filtering and sorting
  • Version APIs (URL path or header)
[ApiController]
[Route("api/v1/[controller]")]
public class UsersController : ControllerBase
{
    [HttpGet]
    public async Task<ActionResult<IEnumerable<UserDto>>> GetUsers([FromQuery] PaginationParams pagination)

    [HttpGet("{id}")]
    public async Task<ActionResult<UserDto>> GetUser(int id)

    [HttpPost]
    public async Task<ActionResult<UserDto>> CreateUser(CreateUserDto dto)
}

Async/Await Patterns

  • Use async/await for all I/O-bound operations
  • Suffix async methods with Async
  • Don't block on async code (avoid .Result and .Wait())
  • Use CancellationToken for cancellation support
  • Prefer ValueTask for frequently-called methods

Entity Framework Core

Configuration

  • Use Fluent API for entity configuration
  • Configure relationships explicitly
  • Use migrations for schema changes
  • Enable nullable reference types

Best Practices

  • Use AsNoTracking() for read-only queries
  • Implement the Repository pattern for data access
  • Use Include/ThenInclude for eager loading
  • Avoid N+1 query problems
  • Use projections for optimized queries
public async Task<IEnumerable<UserDto>> GetUsersAsync()
{
    return await _context.Users
        .AsNoTracking()
        .Select(u => new UserDto
        {
            Id = u.Id,
            Name = u.Name
        })
        .ToListAsync();
}

Dependency Injection

  • Use constructor injection
  • Register services in Program.cs
  • Use appropriate lifetimes (Scoped, Transient, Singleton)
  • Create interfaces for service abstractions
  • Use Options pattern for configuration
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.Configure<JwtSettings>(builder.Configuration.GetSection("Jwt"));

Caching

  • Use IMemoryCache for in-memory caching
  • Use IDistributedCache for distributed scenarios
  • Implement cache invalidation strategies
  • Use response caching for HTTP responses
  • Consider Redis for production caching

Validation

  • Use FluentValidation for complex validation
  • Use Data Annotations for simple validation
  • Validate early in the request pipeline
  • Return detailed validation errors
  • Implement model state validation

Error Handling

  • Use global exception handling middleware
  • Create custom exception types
  • Return consistent error responses
  • Log exceptions with context
  • Don't expose internal details

Security

Authentication

  • Use JWT tokens for API authentication
  • Implement refresh token rotation
  • Store tokens securely
  • Use ASP.NET Core Identity when appropriate

Authorization

  • Use policy-based authorization
  • Implement resource-based authorization
  • Apply [Authorize] attributes appropriately
  • Use claims for fine-grained permissions

Testing

  • Write unit tests with xUnit
  • Use Moq for mocking dependencies
  • Write integration tests with WebApplicationFactory
  • Test API endpoints end-to-end
  • Use in-memory database for testing

Documentation

  • Use Swagger/OpenAPI for API documentation
  • Document all endpoints with XML comments
  • Include request/response examples
  • Generate client SDKs from OpenAPI spec

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.