$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
.NET / C#beginnerNew

Minimal API

Share

Build minimal APIs with endpoint mapping

Works with OpenClaude

You are a .NET developer building REST APIs. The user wants to create a minimal API with endpoint mapping using ASP.NET Core's Minimal APIs feature (no controllers needed).

What to check first

  • Run dotnet --version to confirm .NET 6.0 or later is installed
  • Verify your project file has <TargetFramework>net6.0</TargetFramework> or higher in the .csproj

Steps

  1. Create a new ASP.NET Core project: dotnet new web -n MyMinimalApi
  2. Navigate to Program.cs — this is where all endpoint mapping happens (no Startup.cs needed)
  3. Call var builder = WebApplication.CreateBuilder(args); to initialize the builder
  4. Call var app = builder.Build(); to create the WebApplication instance
  5. Map HTTP methods using app.MapGet(), app.MapPost(), app.MapPut(), app.MapDelete() with route and handler function
  6. Use inline lambda expressions or named methods as handlers; handlers receive injected dependencies and route parameters
  7. Call app.Run(); at the end to start the server
  8. Run dotnet run to test endpoints locally (default: http://localhost:5000)

Code

using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services
builder.Services.AddScoped<IProductService, ProductService>();
builder.Services.AddCors(options =>
{
    options.AddDefaultPolicy(b => b.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
});

var app = builder.Build();

app.UseCors();

// GET all products
app.MapGet("/api/products", GetAllProducts)
    .WithName("GetProducts")
    .WithOpenApi();

// GET single product by ID
app.MapGet("/api/products/{id}", GetProductById)
    .WithName("GetProductById")
    .WithOpenApi();

// POST new product
app.MapPost("/api/products", CreateProduct)
    .WithName("CreateProduct")
    .WithOpenApi();

// PUT update product
app.MapPut("/api/products/{id}", UpdateProduct)
    .WithName("UpdateProduct")
    .WithOpenApi();

// DELETE product
app.MapDelete("/api/products/{id}", DeleteProduct)
    .WithName("DeleteProduct")
    .WithOpenApi();

app.Run();

// Handler functions
async Task<IResult> GetAllProducts(IProductService service)
{
    var products = await service.GetAllAsync();
    return Results.Ok(products);
}

async Task<IResult> GetProductById(int id, IProductService service)
{
    var product = await service.GetByIdAsync(id);
    return product == null ? Results.NotFound() : Results.Ok(product);
}

async Task

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Category.NET / C#
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
dotnetminimal-apiendpoints

Install command:

curl -o ~/.claude/skills/dotnet-minimal-api.md https://clskills.in/skills/dotnet/dotnet-minimal-api.md

Related .NET / C# Skills

Other Claude Code skills in the same category — free to download.

Want a .NET / C# skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.