api-endpoint

api-endpoint is a skill for Claude Code 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 Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit 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.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/muhammadusmangm/claude-code-best-practices/api-endpoint
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.

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.

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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for api-endpoint

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00052 $0.00713
Opus 5.5 $0.00021 $0.00285
Sonnet 5.5 $0.00010 $0.00143
Haiku 4.5 $0.00005 $0.00071

Measured 1mo ago against content hash c5c0f5ac2cb8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 (97 stars, last pushed 1mo ago), licensed MIT. It adds 52 tokens to every session and 713 once invoked, about $0.0002 per session on Opus 5.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.

Related

Other skills, from other repositories

architecture-patterns

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or…

wshobson/agents · 65 tokens

saga-orchestration

Implement saga patterns for distributed transactions and cross-aggregate workflows. Use this skill when implementing distributed transactions across microservices where 2PC is unavailable, designing compensating actions for failed order workflows that span inventory, payment, and shipping services, building…

wshobson/agents · 91 tokens

fastapi-templates

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

wshobson/agents · 37 tokens

event-store-design

Design and implement event stores for event-sourced systems. Use when building event sourcing infrastructure, choosing event store technologies, or implementing event persistence patterns.

wshobson/agents · 33 tokens

error-handling-patterns

Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.

wshobson/agents · 43 tokens

api-design-principles

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

wshobson/agents · 44 tokens