What problem does it solve?
PostHog's frontend contains thousands of manual API calls (api.get, api.create, api.surveys.get, new ApiRequest()) and handwritten TypeScript interfaces that duplicate backend serializers, causing type drift and maintenance burden. This Skill guides the systematic replacement of these legacy patterns with type-safe functions generated from Django serializers via the OpenAPI pipeline.
Core Features & Use Cases
- Pattern Detection and Replacement: Identifies all three legacy patterns (high-level object API, raw HTTP methods with manual URLs, and the ApiRequest builder) and maps each to its generated equivalent like
surveysRetrieve or domainsCreate.
- Type Migration Guidance: Explains differences between handwritten types and generated
Api-suffixed types, covering readonly fields, Patched variants, pagination wrappers, nullable vs optional fields, and enum conventions.
- Decision Framework: Provides a decision table for scenarios where generated functions or types are missing, directing developers to fix backend
@extend_schema annotations first rather than force-migrating.
- Use Case: While editing a Kea logic file that calls
api.surveys.list(), replace it with surveysList(projectId, params), swap Survey for SurveyApi, remove the dead handwritten type, and verify with pnpm --filter=@posthog/frontend typescript:check.
Quick Start
Ask the AI to migrate the manual API calls in the current frontend file to generated API functions and types.