api-endpoint

api-endpoint is a skill for Claude Code, Codex from MuhammadUsmanGM/claude-code-best-practices. It costs 52 tokens per session (713 once invoked), scanned A, original, MIT.

A recipe for adding one API endpoint—the URL and method through which software receives or returns data—using request and response schemas, a service function, a route handler, and tests. It follows the project's existing layered structure.

In plain words
What is it for?
Use it when adding an API route or method, such as POST /users, including its data shapes, business logic, error responses, router registration, and pytest tests.
Why use it?
It reduces the risk of an endpoint being added in only one place or without checks for valid and invalid requests. It also keeps the implementation consistent with nearby endpoints.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/muhammadusmangm/claude-code-best-practices/api-endpoint
Any agent
npx skills add MuhammadUsmanGM/claude-code-best-practices --skill api-endpoint
Clone the repo
git clone --depth 1 https://github.com/MuhammadUsmanGM/claude-code-best-practices

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-endpoint

README.md
[![agentmods](https://agentmods.dev/badge/skills/muhammadusmangm/claude-code-best-practices/api-endpoint.svg)](https://agentmods.dev/skills/muhammadusmangm/claude-code-best-practices/api-endpoint)
Your own site
<a href="https://agentmods.dev/skills/muhammadusmangm/claude-code-best-practices/api-endpoint"><img src="https://agentmods.dev/badge/skills/muhammadusmangm/claude-code-best-practices/api-endpoint.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 713 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00052 $0.00713
Opus 5 $0.00026 $0.00357
Sonnet 5 $0.00010 $0.00143
Haiku 4.5 $0.00005 $0.00071

Measured 5d ago against content hash c5c0f5ac2cb8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-endpoint scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

starters/python/.claude/skills/api-endpoint/SKILL.md · 79 lines

How it starts

The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Endpoint

Scaffold one new endpoint across the layers the project already uses. Don't invent a layer the codebase doesn't have.

Steps

  1. Ask once (if not already specified): method + path (e.g. POST /users), what it does, and the response shape. Do not guess.
  2. Read a sibling endpoint in app/api/ (or the project's equivalent) to match: router setup, dependency injection, error handling, test file layout. If no sibling exists, use the shape below.
  3. Create or edit these files, in order:
    • app/schemas/<resource>.py — request + response Pydantic models. If the file exists, add the new models; do not rewrite it.
    • app/services/<resource>.py — the pure-ish function that does the work. No request/response handling here.
    • app/api/<resource>.py — the route handler. Call the service, map domain exceptions to HTTP codes.
    • tests/api/test_<resource>.py — one happy-path test and one failure test (invalid input → 422, or domain error → mapped status).
  4. Register the router in app/api/__init__.py (or the project's equivalent) only if adding a new resource file.
  5. Run ruff format and ruff check on the files you touched. Report any remaining lint errors; do not auto-fix mypy errors without showing the user the diff.

Default shape (FastAPI)

# app/schemas/widget.py
from pydantic import BaseModel, Field

class WidgetCreate(BaseModel):
    name: str = Field(min_length=1, max_length=80)

class WidgetOut(BaseModel):
    id: int
    name: str
# app/services/widgets.py
from app.schemas.widget import WidgetCreate, WidgetOut

def create_widget(db, payload: WidgetCreate) -> WidgetOut:
    widget = Widget(name=payload.name)
    db.add(widget); db.flush()
    return WidgetOut(id=widget.id, name=widget.name)
# app/api/widgets.py
from fastapi import APIRouter, Depends
from app.schemas.widget import WidgetCreate, WidgetOut
from app.services import widgets as service

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

@router.post("", response_model=WidgetOut, status_code=201)
def create(payload: WidgetCreate, db = Depends(get_db)) -> WidgetOut:
    return service.create_widget(db, payload)

Read the full file on GitHub · 79 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 79 lines · 52 tokens per session scan A c5c0f5ac2cb8

Subscribe to this mod's changes

api-endpoint is a skill published in the GitHub repository MuhammadUsmanGM/claude-code-best-practices (76 stars, last pushed 2mo ago), licensed MIT. It adds 52 tokens to every session and 713 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.