Plan and execute incremental product isolation migrations to a facade plus contract layer in PostHog, following the Visual review architecture. Use when a product still exposes internals (models/logic/views) across boundaries and needs a safe, multi-PR migration toward contracts.py + facade/api.py + presentation separation.
Use this skill to migrate an existing product to the isolated architecture used by Visual review. Keep migrations incremental, with narrow PRs that avoid broad breakage.
Prerequisite: the product must already live under products/<name>/. This skill does not cover moving code out of posthog/, ee/, or other shared directories — do that first.
Read these before changing code:
Use Visual review as the concrete reference implementation:
For detailed sequencing, load references/phased-migration-plan.md.
logic.py.team_id in querysets.Team; use a Team Extension model.@validated_request or @extend_schema).hogli build:openapi) when serializer/view changes affect API schema.models, logic, presentation, non-facade modules).backend/facade/contracts.py.backend/facade/api.py.
[[interfaces]] block in tach.toml with expose patterns for the facade and presentation views.backend:contract-check to package.json so turbo-discover treats the product as isolated.tach check --interfaces to verify no external imports bypass the facade.hogli product:lint <name> to verify the product passes all checks.Default to several PRs instead of one big migration:
If a product has many endpoints, migrate in this order:
Treat migration as complete only when:
backend/facade only.[[interfaces]] block in tach.toml restricts imports to facade + presentation views.tach check --interfaces passes with no violations for this product.lint-imports passes (import-linter verifies presentation doesn't bypass the facade internally).hogli product:lint <name> shows no legacy leak warning.backend:contract-check is present in package.json (enables isolated testing in CI).