agentleFS
paulieb89paulieb89/property-shared/.claude/skills/add-endpoint/SKILL.md

add-endpoint

Skill16 starsChanged 7 months agoMITView on GitHub

Use when adding a new API endpoint to app/api/v1/. Covers router creation, registration, and response patterns.

11 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 0

    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. Very specific:

    Prefer returning property_core models directly (Pydantic → JSON automatic)

    line 55
  2. Very specific:

    If you need an envelope, add to app/schemas/new_endpoint.py

    line 56

“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

Add an API Endpoint

API routers are thin HTTP wrappers — all business logic lives in property_core.

Step 1: Create Router File

Create app/api/v1/new_endpoint.py:

from __future__ import annotations

from fastapi import APIRouter, HTTPException, Query

router = APIRouter(prefix="/new", tags=["new"])


@router.get("/action")
async def action_endpoint(
    required: str = Query(..., description="Required parameter"),
    optional: str | None = Query(None, description="Optional filter"),
    limit: int = Query(50, ge=1, le=200, description="Max results"),
):
    """Endpoint description."""
    import asyncio
    from property_core import SomeService

    try:
        result = await asyncio.to_thread(
            SomeService().method,
            param=required,
            limit=limit,
        )
    except ValueError as exc:
        raise HTTPException(status_code=422, detail=str(exc))

    return result.model_dump(mode="json")

Step 2: Register in routes.py

Open app/api/routes.py:

from .v1 import new_endpoint
api_router.include_router(new_endpoint.router)

Step 3: Response Model (optional)

  • Prefer returning property_core models directly (Pydantic → JSON automatic)
  • If you need an envelope, add to app/schemas/new_endpoint.py
  • Re-export from app/schemas/__init__.py if needed

Patterns

PatternExample
Sync service callapp/api/v1/ppd.py
Async service callapp/api/v1/analysis.py
Simple calculatorapp/api/v1/stamp_duty.py
Configuration checkapp/api/v1/epc.py

Checklist

  • Router file created in app/api/v1/
  • Router registered in app/api/routes.py
  • No business logic in the router (property_core handles that)
  • Query() annotations with descriptions on all parameters
  • Error handling: ValueError → 422, upstream failure → 502

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.