koan-api-building
About
This skill provides automatic CRUD API generation through EntityController<T> while allowing custom routes for business logic. It includes payload transformers and auth policies for data customization and security. Use it to rapidly build REST APIs with minimal boilerplate code.
Quick Install
Claude Code
Recommended/plugin add https://github.com/sylin-org/koan-frameworkgit clone https://github.com/sylin-org/koan-framework.git ~/.claude/skills/koan-api-buildingCopy and paste this command in Claude Code to install this skill
Documentation
Koan API Building
Core Principle
EntityController<T> provides full CRUD APIs automatically. Extend with custom routes for business operations. No manual endpoint implementation needed.
Quick Reference
Basic CRUD API
[Route("api/[controller]")]
public class TodosController : EntityController<Todo>
{
// Full CRUD auto-generated:
// GET /api/todos
// GET /api/todos/{id}
// POST /api/todos
// PUT /api/todos/{id}
// DELETE /api/todos/{id}
// PATCH /api/todos/{id}
}
Custom Routes
[Route("api/[controller]")]
public class ProductsController : EntityController<Product>
{
[HttpPost("{id}/discount")]
public async Task<IActionResult> ApplyDiscount(
string id,
[FromBody] DiscountRequest request,
CancellationToken ct)
{
var product = await Product.Get(id, ct);
if (product is null) return NotFound();
await product.ApplyDiscount(request.Amount);
return Ok(product);
}
[HttpGet("overstock")]
public async Task<IActionResult> GetOverstock(CancellationToken ct)
{
var products = await Product.Query(p => p.Stock > 1000, ct);
return Ok(products);
}
}
Auth Policies
[Route("api/[controller]")]
[Authorize] // Require authentication for all endpoints
public class OrdersController : EntityController<Order>
{
[HttpGet]
public Task<List<Order>> GetMyOrders(CancellationToken ct)
{
var userEmail = User.FindFirst(ClaimTypes.Email)?.Value;
return Order.Query(o => o.CustomerEmail == userEmail, ct);
}
[HttpPost]
[Authorize(Policy = "CanCreateOrders")] // Require specific policy
public override async Task<IActionResult> Post([FromBody] Order entity)
{
entity.CustomerEmail = User.FindFirst(ClaimTypes.Email)?.Value ?? "";
return await base.Post(entity);
}
}
Payload Transformers
public class TodoTransformer : IPayloadTransformer<Todo>
{
public Task<object> TransformAsync(Todo entity)
{
return Task.FromResult<object>(new
{
entity.Id,
entity.Title,
entity.Completed,
_links = new
{
self = $"/api/todos/{entity.Id}",
user = $"/api/users/{entity.UserId}"
}
});
}
}
// Register in KoanAutoRegistrar
services.AddScoped<IPayloadTransformer<Todo>, TodoTransformer>();
When This Skill Applies
- ✅ Building REST APIs
- ✅ Custom endpoints
- ✅ Authentication/authorization
- ✅ Response formatting
- ✅ Error handling
- ✅ API versioning
Reference Documentation
- Full Guide:
docs/guides/building-apis.md - API Conventions:
docs/api/web-http-api.md - Sample:
samples/S1.Web/Controllers/
GitHub Repository
Related Skills
evaluating-llms-harness
TestingThis Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.
langchain
MetaLangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.
content-collections
MetaThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
Algorithmic Art Generation
MetaThis skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.
