agentleFS
tadoEngtadoEng/web-starter/.claude/skills/api-endpoint/SKILL.md

api-endpoint

Skill2 starsChanged 3 months agoMITView on GitHub

Add or change a backend API endpoint on this product, keeping Pydantic as the single contract authority and regenerating the TypeScript client. Use when asked to add an endpoint, expose data to the frontend, change a request or response shape, or wire a new backend capability into a page.

We split this skill into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read AGENTS.md first. The contract flows one way: Pydantic → OpenAPI → generated TS.

    line 12
  2. Very specific:

    one per authorization case: no token → 401, wrong role → 403, wrong owner → 403/404 (per docs/SECURITY.md), correct → 2xx

    line 33
  3. Very specific:

    Commit the frontend/src/generated/ diff as part of this change.

    line 42
  4. Very specific:

    Never a hand-written interface, never a raw fetch().

    line 46
  5. Distinctive:

    Never an exception string or SQL fragment.

    line 59
  6. Distinctive:

    If the endpoint seems to need a queue, a cache, a second data store, or logic in the frontend — stop and propose it per the stop condition …

    line 63

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

Add an API endpoint

Read AGENTS.md first. The contract flows one way: Pydantic → OpenAPI → generated TS. Nothing downstream is written by hand.

Steps

  1. Schemas — request and response models in backend/app/schemas/. Declare types, ranges, lengths and enums here; validation is Pydantic's job, not the handler's.
  2. Route — backend/app/api/<resource>.py, registered on the router in main.py. Keep it thin: parse, authorize, delegate, return. Always set an explicit response_model so OpenAPI is accurate and internal fields can't leak.
  3. Logic — backend/app/services/<resource>.py. This is the testable seam. Business rules in a route handler are a defect.
  4. Authorization — on the route, stated explicitly. Firebase established who; you decide may they. Never trust a user ID from the request body.
  5. Tests — backend/tests/:
    • service behaviour (the happy path and the interesting edge)
    • the route
    • one per authorization case: no token → 401, wrong role → 403, wrong owner → 403/404 (per docs/SECURITY.md), correct → 2xx
  6. Regenerate

    ./scripts/generate-api-client

    Commit the frontend/src/generated/ diff as part of this change. A schema change without a regenerated client is incomplete, and verify.sh will fail on the drift check.

  7. Frontend — a TanStack Query hook in frontend/src/api/ using the generated types. Never a hand-written interface, never a raw fetch().
  8. ./scripts/verify.sh

Conventions

  • Plural noun resources: /api/projects, /api/projects/{project_id}.
  • Verbs live in HTTP methods. POST /api/projects/{id}/archive is fine for a real state transition; POST /api/doProjectStuff is not.
  • List endpoints paginate by default, with a hard maximum page size. An unbounded list is an outage with a delay fuse.
  • UTC ISO-8601 timestamps. IDs opaque to the frontend.
  • Errors follow the contract in docs/ARCHITECTURE.md: machine-readable code + safe message. Never an exception string or SQL fragment.

Stop

If the endpoint seems to need a queue, a cache, a second data store, or logic in the frontend — stop and propose it per the stop condition in AGENTS.md.

Download now (ZIP)

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. nrjdalal/zerostarter★ 64same name
    2. Univers42/claude-deal-with-the-devil★ 4same name
    3. Univers42/harness42★ 4same name
    4. nrjdalal/inscope★ 3same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository9 other files it gives its agents.

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.