:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(devex): state the thin-entrypoint rule repo-wide (#86298)
Julian Bez5c7aca04c61a
diff --git a/AGENTS.md b/AGENTS.mdindex d14b1bb6bb77..130b98eb55ea 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -179,6 +179,7 @@ See [.agents/security.md](.agents/security.md) for security guidelines — least## Architecture guidelines+- **Keep entrypoints thin.** The runtime calls the entrypoint first. Examples: a DRF view, a management command `handle()`, a Celery task body, an HTTP handler, a Rust `main()`, and a React component. An entrypoint reads the input, connects the dependencies, and formats the output. Put all other logic in a function that the entrypoint calls. Call that function directly in a test. If you cannot do this, move the logic out of the entrypoint. If the area already has a place for that logic, use it. Do not make a new one.- API views should declare request/response schemas — prefer `@validated_request` from `posthog.api.mixins` or `@extend_schema` from drf-spectacular. Plain `ViewSet` methods that validate manually need `@extend_schema(request=YourSerializer)` — without it, drf-spectacular can't discover the request body and generated code gets empty schemas- Django serializers are the source of truth for frontend API types — `hogli build:openapi` generates TypeScript via drf-spectacular + Orval. Generated files (`api.schemas.ts`, `api.ts`, `api.zod.ts`) live in `frontend/src/generated/core/` and `products/{product}/frontend/generated/` — don't edit them manually, change serializers and rerun. See [type system guide](docs/published/handbook/engineering/type-system.md) for the full pipeline- MCP tools are generated from the same OpenAPI spec — see [implementing MCP tools](docs/published/handbook/engineering/ai/implementing-mcp-tools.md) for the YAML config and codegen workflowdiff --git a/products/architecture.md b/products/architecture.mdindex 8f28aee8c8d1..10928fc71102 100644--- a/products/architecture.md+++ b/products/architecture.md@@ -146,6 +146,10 @@ myproduct/tasks.py # Celery entrypoints (call facade)schedules.py # Celery beat / periodic config (optional)+ management/+ commands/+ <command>.py # CLI entrypoints (parse args, call facade)+facade/__init__.pyapi.py # Facade (the only thing other products may import)@@ -368,6 +372,14 @@ The facade owns **tenant scoping** (`team_id` enforced via `for_team(team_id)` /No. Views only call facades, and facades only return frozen dataclasses. The presentation layer remains decoupled from internal details — when the facade hasn't changed, nothing outside the product is affected.+### Management commands++`backend/management/commands/` is an entrypoint, the same as presentation and `tasks/`. A command reads its arguments, calls the facade, and writes its output through `self.stdout` and `self.stderr`. Do not put business logic in a command.++The import-linter contract applies only to `presentation/`. It does not include this directory. Reviewers must enforce this rule.++A command sometimes needs a capability that the facade does not have. Add the necessary facade function. Do not import `logic` or `models` in the command.+# 8. Isolation Rules### Forbidden