.agents/skills/isolating-product-facade-contracts/references/phased-migration-plan.md
This reference provides a practical execution sequence for converting an existing product into the facade+contracts pattern used by Visual review.
Prerequisite: the product must already live under products/<name>/. This workflow does not cover moving code out of posthog/, ee/, or other shared directories — that is a separate step. If the product still lives in legacy/common code, stop here and do the move first.
hogli product:lint <name> — the isolation progress section shows exactly which layers exist,
what's structurally wrong with each, and what to do next. Use this as the starting point before
reading code.products/<name>/backend/ and identify what's already there vs. what's still missing (models, logic, presentation, facade).backend/tests/.Suggested commands:
rg -n "from products\.<target>\.backend\.(models|logic|presentation|tasks|storage)" .
rg -n "products\.<target>\.backend\.facade" .
Start with read paths before write paths.
backend/facade/contracts.py with frozen dataclasses for existing read responses.backend/facade/__init__.py exports to make imports straightforward.contracts.py or facade/enums.py if they grow.Reference patterns:
backend/facade/api.py with thin methods wrapping logic._to_contract mapper functions close to facade methods.list_*, get_*, create_*, etc.).Reference patterns:
Start with call sites that are easiest to verify:
models or logic.For DRF endpoints:
@validated_request or @extend_schema).Docs:
Reference patterns:
tach.toml dependency/interface declarations to match desired import rules.Then verify:
Use this template to avoid long, risky PRs:
tach.toml, dead code removal).When possible, keep each PR deployable and backward compatible.
Team.Additional references: