api-design-and-implementation

api-design-and-implementation is a cursor rule for Cursor from mrharishkumar/fastapi-cursor-boilerplate. It costs 434 tokens per session, scanned A, original, MIT.

A set of coding rules for building FastAPI web API endpoints in Python. FastAPI is a Python framework for creating services that receive and return data over the web.

In plain words
What is it for?
Defining Pydantic data models, organizing endpoint routers, documenting APIs, choosing HTTP status codes, and managing database connections.
Why use it?
It keeps request and response data validated and API structure consistent, reducing unclear contracts and poorly organized endpoint code.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Defining Pydantic data models, organizing endpoint routers, documenting APIs, choosing HTTP status codes, and managing database connections.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation
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.

Clone the repo
git clone --depth 1 https://github.com/mrharishkumar/fastapi-cursor-boilerplate

Made for: Cursor.

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-design-and-implementation

README.md
[![agentmods](https://agentmods.dev/badge/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation/github.svg)](https://agentmods.dev/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation)
Your own site
<a href="https://agentmods.dev/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation"><img src="https://agentmods.dev/badge/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation/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-design-and-implementation

Your own site · 80×15
<a href="https://agentmods.dev/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation"><img src="https://agentmods.dev/badge/rules/mrharishkumar/fastapi-cursor-boilerplate/api-design-and-implementation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 434 This file is loaded in full into every session.
When invoked 434 The same file — it is already loaded in full.
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.00434 $0.00434
Opus 5.5 $0.00174 $0.00174
Sonnet 5.5 $0.00087 $0.00087
Haiku 4.5 $0.00043 $0.00043

Measured 1mo ago against content hash 7ef2c7ed94fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

api-design-and-implementation 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.

.cursor/rules/api-design-and-implementation.mdc · 39 lines

What it actually says

API Design and Implementation

1. Pydantic Validation

  • Use Pydantic models for all incoming request bodies and outgoing responses. This ensures automatic data validation and clear API contracts.
  • Use response_model to define the schema for successful responses.
  • Use separate Pydantic schemas for creating, updating, and reading resources (e.g., UserCreate, UserUpdate, UserRead).

2. Router Structure

  • Create a single APIRouter instance per endpoint file.
  • Use descriptive prefixes when including routers in the main API router.
  • Always include proper HTTP status codes, response models, and documentation.
  • Use tags to group related endpoints in the API documentation.
  • Include docstrings for all endpoint functions.
  • Follow RESTful conventions for endpoint paths and HTTP methods.

3. API Router Aggregation

  • Import all endpoint routers in app/api/v1/api.py.
  • Use meaningful prefixes that match the feature domain.
  • Keep the main API router clean and focused on aggregation only.
  • Ensure all routers are properly included with appropriate prefixes.

4. Database Configuration and Connection Management

  • Database configuration is stored in app/core/config.py using Pydantic Settings.
  • Use database connection and session management from app/db/__init__.py.
  • Use SQLAlchemy's create_engine() with connection pooling for production.
  • Implement proper session lifecycle management with dependency injection.
  • Use get_db() dependency function for database sessions in endpoints.
  • Use database migrations with Alembic for schema changes.
  • Implement proper error handling for database connection failures.

5. Logging Standards

  • Use module-based naming: get_logger(__name__) for general module logging.
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 · 39 lines · 434 tokens per session scan A 7ef2c7ed94fd

Subscribe to this mod's changes

api-design-and-implementation is a cursor rule published in the GitHub repository mrharishkumar/fastapi-cursor-boilerplate (3 stars, last pushed 1y ago), licensed MIT. It adds 434 tokens to every session, about $0.0017 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-31.