api-design-dotnet

api-design-dotnet is a cursor rule for coding agents from adonai-labs/agent-runway. It costs 0 tokens per session (1,441 once invoked), scanned A, original, MIT.

A set of .NET web API design rules for ASP.NET Core, Microsoft's framework for building web services. It covers endpoint structure, request validation, and MediatR, a library for sending commands and queries through separate handlers.

In plain words
What is it for?
Use it when designing ASP.NET Core endpoints, choosing between minimal APIs and controllers, defining typed responses, or organizing commands and queries.
Why use it?
It helps keep API responses, validation, and application actions consistent as a .NET service grows.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/adonai-labs/agent-runway/api-design-dotnet
Clone the repo
git clone --depth 1 https://github.com/adonai-labs/agent-runway

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-design-dotnet

README.md
[![agentmods](https://agentmods.dev/badge/rules/adonai-labs/agent-runway/api-design-dotnet.svg)](https://agentmods.dev/rules/adonai-labs/agent-runway/api-design-dotnet)
Your own site
<a href="https://agentmods.dev/rules/adonai-labs/agent-runway/api-design-dotnet"><img src="https://agentmods.dev/badge/rules/adonai-labs/agent-runway/api-design-dotnet.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,441 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01441
Opus 5 $0.00000 $0.00720
Sonnet 5 $0.00000 $0.00288
Haiku 4.5 $0.00000 $0.00144

Measured 4d ago against content hash 3d83da697cc4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-design-dotnet scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/stacks/dotnet/api-design-dotnet.mdc · 280 lines

How it starts

The opening of the file, as written. The whole thing — 280 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Design for .NET

Extends core/rules/api-design.mdc with .NET and ASP.NET Core specific patterns.


ASP.NET Core Controllers

Minimal APIs vs Controllers

// Minimal API (simple endpoints)
app.MapGet("/api/users/{id}", async (int id, IUserService service) =>
{
    var user = await service.GetUserAsync(id);
    return user is not null ? Results.Ok(user) : Results.NotFound();
});

// Controller (complex endpoints with multiple actions)
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
    private readonly IUserService _userService;

    [HttpGet("{id}")]
    [ProducesResponseType(typeof(UserDto), StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    public async Task<ActionResult<UserDto>> GetUser(int id) { }
}

Action Return Types

  • Use ActionResult<T> for typed responses
  • Use IActionResult when returning multiple types
  • Use Results helpers in Minimal APIs
  • Document with [ProducesResponseType] attributes

MediatR CQRS Pattern

Commands and Queries

// Command (write operation)
public record CreateUserCommand(string Email, string Name)
    : IRequest<Result<UserId>>;

// Query (read operation)
public record GetUserQuery(int Id)
    : IRequest<Result<UserDto>>;

// Handler
public class CreateUserHandler : IRequestHandler<CreateUserCommand, Result<UserId>>
{
    public async Task<Result<UserId>> Handle(
        CreateUserCommand request,
        CancellationToken cancellationToken)
    {
        // Validation, business logic, persistence
    }
}

Benefits

  • Clear separation of reads and writes
  • Single responsibility per handler
  • Easier to test in isolation
  • Supports pipeline behaviors (logging, validation, caching)

FluentValidation

public class CreateUserCommandValidator : AbstractValidator<CreateUserCommand>
{
    public CreateUserCommandValidator()
    {
        RuleFor(x => x.Email)
            .NotEmpty()
            .EmailAddress()
            .MaximumLength(255);

        RuleFor(x => x.Name)
            .NotEmpty()
            .MinimumLength(2)
            .MaximumLength(100);
    }
}

// Register in DI
services.AddValidatorsFromAssemblyContaining<CreateUserCommandValidator>();

// Use in MediatR pipeline
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));

Read the full file on GitHub · 280 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 280 lines · 0 tokens per session scan A 3d83da697cc4

Subscribe to this mod's changes

api-design-dotnet is a cursor rule published in the GitHub repository adonai-labs/agent-runway (2 stars, last pushed 14d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,441 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.