agentleFS
LeanMeanCleanAppsLeanMeanCleanApps/CleanWebApi/.agents/skills/api-conventions/SKILL.md

api-conventions

Skill4 starsChanged 10 days agoMITView on GitHub

The REST conventions for this API - plural lowercase routes, status codes per operation, problem details for errors, JSON casing and paging parameters. Use when choosing a route, a status code or a response shape.

15 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If an update can't change some fields, leave them out of the request class and say so in the remarks.

    line 33
  2. Distinctive:

    Add an integration test for each status code the action documents.

    line 34
  3. Very specific:

    Use verbs or singular nouns in routes (/api/getMovie, /api/movie), or [controller] tokens, which give Movies instead of movies.

    line 38
  4. Very specific:

    Add a separate /search route.

    line 40

“Common” is measured: kept by at least 6 in 10 of the 11 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

API conventions

The rule

TopicConvention
Routes[Route("api/<plural-lowercase-resource>")] on the controller, and {id:guid} for one item: /api/movies, /api/reviews/{id}
ListsGET with offset and limit (and query to search) in the query string, returning Page<T> (paging)
Read oneGET {id} returns 200 with the entity, 404 when it doesn't exist
CreatePOST returns 201 with the entity and a Location header from CreatedAtAction
UpdatePUT {id} with only the fields that may change, returns 204
DeleteDELETE {id} returns 204
Invalid input400 with validation problem details (errors grouped by property, or by JSON path when the body can't be read)
Not found404 problem details with a readable detail
Unexpected500 problem details with no internals. ApplicationExceptionHandler logs the exception as Error (serilog)
JSONcamelCase names, enums as camelCase strings, nulls left out, numbers strict (no numbers as strings)
AuthIn a solution created with --include-auth, ApiControllerBase has [Authorize] and only health, the OpenAPI document and Scalar are anonymous (optional-token-auth). Without it, nothing asks for authorization
TagsOne OpenAPI tag per resource, taken from the controller name

Errors are RFC 9457 problem details. ApplicationExceptionHandler (src/Presentation/Errors/) writes them for exceptions from Application, [ApiController] writes them when a body or route value can't be bound, and AddProblemDetails() with UseStatusCodePages() covers the rest (an unknown route, an unsupported media type).

Steps

  1. Pick the route and verb from the table. A new resource gets a new controller, which gives it a new tag.
  2. Declare every status the action can return with [ProducesResponseType] (expose-a-use-case).
  3. If an update can't change some fields, leave them out of the request class and say so in the remarks.
  4. Add an integration test for each status code the action documents.

Don't

  • Use verbs or singular nouns in routes (/api/getMovie, /api/movie), or [controller] tokens, which give Movies instead of movies.
  • Return 200 with an error in the body, or 404 for an empty list.
  • Add a separate /search route. Search is the query parameter on the list.
  • Version the API until there's a second version to show.

Check

dotnet test tests/Presentation.Tests.Integration

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.