AgentSkillsCN

context-api-contracts

涵盖前端与后端 API 合约、路由定义、客户端接口及类型定义。 负责 API 端点定义、请求/响应类型、路由配置,以及跨栈集成的管理工作。 适用于处理 API 端点、请求/响应类型、路由定义,或进行前后端集成;亦可在用户提及 API 设计、新增端点、类型不匹配、API 合约、REST 端点、客户端集成、“404 Not Found” 错误、API 调用中的“类型错误”,或路由配置问题时使用。

SKILL.md
--- frontmatter
name: context-api-contracts
description: |
  Frontend-backend API contracts, routes, clients, and type definitions.
  Handles API endpoint definitions, request/response types, route configuration, and cross-stack integration.
  Use when working with API endpoints, request/response types, route definitions, or frontend-backend integration,
  or when user mentions API design, adding endpoints, type mismatches, API contracts, REST endpoints,
  client integration, "404 Not Found" errors, "Type error" in API calls, or route configuration issues.
tags: [api, contracts, integration, cross-stack]

API Contracts

Navigate frontend-backend API integration, routes, clients, and data flow.

Overview

API contracts define frontend ↔ backend communication. Critical for cross-stack changes.

Backend API Routes

  • backend/api/*.py - API v1 endpoints
  • backend/api/v2/*.py - API v2 endpoints
  • backend/api/analytics_api.py
  • backend/api/brokerage_connections.py
  • backend/api/accounts.py
  • backend/api/securities.py

Frontend API Clients

  • frontend/src/services/analyticsApi.ts
  • frontend/src/services/researchApi.ts
  • frontend/src/lib/apiClient.ts - Base API client

TypeScript Contracts

  • supabase/types/database.types.ts - Database types
  • frontend/src/types/**/*.ts - Frontend types

Backend Middleware

  • backend/middleware/*.py - Auth, CORS, etc.

Tests

  • backend/tests/integration/ - API integration tests
  • frontend/e2e/ - E2E API tests

Documentation

  • Internal: docs/backend/API_CONTRACTS.md (create if needed)

Related Areas

  • See context-clerk-integration for auth middleware
  • See context-testing-infrastructure for API test patterns