fastapi-endpoint
Fungsinya
Skill ini memandu agent AI dalam menambahkan endpoint API baru ke proyek FastAPI yang sudah ada. Skill ini ditujukan bagi pengembang backend Python yang menginginkan rute yang teruji dengan baik.
Kapan dipakai
- βSaat Anda perlu menambahkan rute create, read, update, dan delete ke proyek FastAPI yang sudah ada.
- βKetika sebuah endpoint harus dilindungi dengan autentikasi melalui injeksi dependensi.
- βKetika Anda ingin tes pytest ditulis untuk rute API baru.
Link skill
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/web-development/fastapi-endpoint/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda menambahkan endpoint terlindungi untuk mendaftar faktur di aplikasi FastAPI saya, lengkap dengan tesnya?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent pertama-tama menjelajahi struktur dan pola proyek, merencanakan model data dan metode login, lalu menulis endpoint dan tesnya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
FastAPI Endpoint Builder
When to use
Use this skill when you need to:
- Add new API endpoints to an existing FastAPI project
- Build CRUD operations with proper validation and error handling
- Set up authenticated endpoints with dependency injection
- Create async database queries with SQLAlchemy 2.0
- Generate complete test coverage for API routes
Phase 1: Explore (Plan Mode)
Enter plan mode. Before writing any code, explore the existing project to understand:
Project structure
- Find the FastAPI app entry point (
main.py,app.py, orapp/__init__.py) - Identify the router organization pattern (single file vs
routers/directory) - Check for existing
models/,schemas/,crud/, orservices/directories - Look at
pyproject.tomlorrequirements.txtfor installed dependencies
Existing patterns
- How are existing endpoints structured? (function-based vs class-based)
- What ORM is used? (SQLAlchemy 2.0 async, Tortoise, raw SQL, none)
- How is the database session managed? (
Depends(get_db), middleware, other) - What auth pattern exists? (OAuth2PasswordBearer, API key header, custom)
- Are there existing Pydantic base models or shared schemas?
- What response format is standard? (direct model, wrapped
{"data": ..., "meta": ...})
Test patterns
- Where do tests live? (
tests/,test_*.py,*_test.py) - What test client is used? (httpx AsyncClient, TestClient, pytest-asyncio)
- Are there test fixtures for database and auth?
Phase 2: Interview (AskUserQuestion)
Use AskUserQuestion to clarify requirements. Ask in rounds β do NOT dump all questions at once.
Round 1: Core endpoint
Question: "What resource does this endpoint manage?"
Header: "Resource"
Options:
- "New resource (I'll describe the fields)" β Creating a new data model from scratch
- "Existing model (extend it)" β Adding endpoints for a model that already exists in the codebase
- "Relationship endpoint (nested)" β e.g., /users/{id}/orders β endpoint on a related resource
Question: "Which HTTP methods do you need?"
Header: "Methods"
multiSelect: true
Options:
- "Full CRUD (GET list, GET detail, POST, PUT/PATCH, DELETE)" β All standard operations
- "Read-only (GET list + GET detail)" β No mutations
- "Custom action (POST /resource/{id}/action)" β Business logic endpoint, not standard CRUD
Round 2: Data model (if new resource)
Question: "What fields does the resource have? (describe briefly)"
Header: "Fields"
Options:
- "Simple (< 6 fields, basic types)" β Strings, ints, booleans, dates
- "Medium (6-15 fields, some relations)" β Includes foreign keys or enums
- "Complex (nested objects, polymorphic)" β JSON fields, discriminated unions, computed fields
Round 3: Auth and access control
Question: "How should this endpoint be authenticated?"
Header: "Auth"
Options:
- "JWT Bearer token (Recommended)" β OAuth2PasswordBearer with JWT decode
- "API Key header" β X-API-Key header validation
- "No auth (public)" β Open endpoint, no authentication required
- "Use existing auth" β Reuse the auth dependency already in the project
Question: "Do you need role-based access control?"
Header: "RBAC"
Options:
- "No β any authenticated user" β Single permission level
- "Yes β role check (admin, user, etc.)" β Require specific roles per endpoint
- "Yes β ownership check" β Users can only access their own resources
Round 4: Pagination, filtering, caching
Question: "What pagination style for list endpoints?"
Header: "Pagination"
Options:
- "Cursor-based (Recommended)" β Best for real-time data, no offset drift
- "Offset/limit" β Simple, good for admin panels with page numbers
- "No pagination" β Small datasets, return all results
Question: "Do you need response caching?"
Header: "Caching"
Options:
- "No caching" β Fresh data on every request
- "Cache-Control headers" β Client-side caching via HTTP headers
- "Redis/in-memory cache" β Server-side caching with TTL
Phase 3: Plan (ExitPlanMode)
Write a concrete implementation plan covering:
- Files to create/modify β exact paths based on project structure discovered in Phase 1
- Pydantic schemas β
Create,Update,Response, andListschemas with field types - SQLAlchemy model β table name, columns, relationships, indexes
- CRUD/service layer β async functions for each operation
- Router β endpoint signatures, status codes, response models
- **Dependencie
Pertanyaan umum
Apakah bertanya dulu sebelum menulis kode?
Ya. Skill ini memakai langkah perencanaan bergaya wawancara untuk memperjelas model data, metode login, dan paginasi.
Pustaka basis data apa yang dipakai?
Skill ini dibangun di sekitar async SQLAlchemy 2.0 dan model Pydantic v2.
Apakah juga menulis tes?
Ya. Skill ini membuat tes pytest untuk rute API.
Detail
Deskripsi asli dari pembuat
Plan and build production-ready FastAPI endpoints with async SQLAlchemy, Pydantic v2 models, dependency injection for auth, and pytest tests. Uses interview-driven planning to clarify data models, authentication method, pagination strategy, and caching before writing any code.
Popularitas
- Bintang GitHub
- 33k
- Peringkat
- #9105
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
owasp-security
33kMengajari agent Anda panduan keamanan OWASP untuk aplikasi web, API, mobile, kontainer, dan agent AI, sehingga bisa menemukan kelemahan umum dan menyarankan perbaikan.
agent-management
33kMembiarkan agent Anda membuat, mencantumkan, menidurkan, membangunkan, mengganti nama, dan menghapus agent AI menggunakan baris perintah AI Maestro, sambil mengelola siklus hidup setiap agent.
agent-messaging
33kMembiarkan agent Anda mengirim, menerima, dan membalas pesan bertanda tangan antaragent AI, menggunakan Agent Messaging Protocol, sebagian besar di mesin Anda sendiri.
docs-search
33kMembiarkan agent Anda mencari dokumentasi kode yang dibuat otomatis untuk tanda tangan fungsi, definisi kelas, dan komentar, sehingga agent memeriksa API yang sebenarnya sebelum mengubah kode.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.