Skip to content

: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.

feat(devex): add Claude rules and AGENTS.md references for code governance (#57478)

Julian Bez70c912d5b7b9
diff --git a/.claude/rules/clickhouse-migrations.md b/.claude/rules/clickhouse-migrations.md
new file mode 100644
index 000000000000..a5a687fabb68
--- /dev/null
+++ b/.claude/rules/clickhouse-migrations.md
@@ -0,0 +1,7 @@
+---
+paths:
+ - 'posthog/clickhouse/migrations/**'
+---
+
+Invoke the `/clickhouse-migrations` skill before writing or modifying any migration here.
+The AGENTS.md in this directory has cluster topology and `run_sql_with_exceptions` reference.
diff --git a/.claude/rules/django-migrations.md b/.claude/rules/django-migrations.md
new file mode 100644
index 000000000000..4213e54a76fe
--- /dev/null
+++ b/.claude/rules/django-migrations.md
@@ -0,0 +1,7 @@
+---
+paths:
+ - 'posthog/migrations/**'
+ - 'products/*/backend/migrations/**'
+---
+
+Invoke the `/django-migrations` skill before writing or modifying any migration here.
diff --git a/.claude/rules/drf-endpoints.md b/.claude/rules/drf-endpoints.md
new file mode 100644
index 000000000000..dfccfad9d18a
--- /dev/null
+++ b/.claude/rules/drf-endpoints.md
@@ -0,0 +1,10 @@
+---
+paths:
+ - 'posthog/api/**'
+ - 'products/*/backend/api/**'
+ - 'products/*/backend/presentation/**'
+---
+
+Invoke the `/improving-drf-endpoints` skill before editing any viewset or serializer here.
+Every viewset method must have schema annotations (`@validated_request` or `@extend_schema`).
+Every serializer field must have `help_text`.
diff --git a/.claude/rules/generated-api-types.md b/.claude/rules/generated-api-types.md
new file mode 100644
index 000000000000..03882db02af6
--- /dev/null
+++ b/.claude/rules/generated-api-types.md
@@ -0,0 +1,10 @@
+---
+paths:
+ - 'frontend/src/**'
+ - 'products/*/frontend/**'
+---
+
+If this file calls `api.get<`, `api.create<`, `new ApiRequest()`, or uses handwritten API types,
+invoke the `/adopting-generated-api-types` skill before making changes.
+Files under `frontend/src/generated/core/` and `products/*/frontend/generated/` are auto-generated —
+never edit them manually; change the serializer and run `hogli build:openapi`.
diff --git a/.claude/rules/product-isolation.md b/.claude/rules/product-isolation.md
new file mode 100644
index 000000000000..3a5fab4432e9
--- /dev/null
+++ b/.claude/rules/product-isolation.md
@@ -0,0 +1,18 @@
+---
+paths:
+ - 'products/*/backend/**'
+---
+
+**Check this product's isolation status before making changes.**
+Look at the product's `package.json`: if `backend:contract-check` is listed under `scripts`,
+this product is isolated.
+
+- **Isolated:** external code (core, other products) may only import from
+ `backend/facade/api.py`. Do not expose internal modules directly, and do not add
+ raw cross-product imports — go through the target product's facade instead.
+- **Not isolated:** boundaries are not yet enforced by CI, but prefer using existing
+ facades when they exist rather than importing internals.
+
+If you need to extend what's reachable across a boundary, add a method to the relevant
+`backend/facade/api.py` — not a `depends_on` entry in `tach.toml`.
+Run `tach check --dependencies --interfaces` to verify import boundaries are clean.
diff --git a/.claude/rules/proto-changes.md b/.claude/rules/proto-changes.md
new file mode 100644
index 000000000000..63e3efdec9e9
--- /dev/null
+++ b/.claude/rules/proto-changes.md
@@ -0,0 +1,8 @@
+---
+paths:
+ - 'proto/**'
+---
+
+When adding or modifying an RPC or message type, all downstream consumers must be updated
+in the same change. See `proto/AGENTS.md` for the full protocol: Python stubs, Node stubs,
+and Rust implementation steps.
diff --git a/.claude/rules/tach-boundaries.md b/.claude/rules/tach-boundaries.md
new file mode 100644
index 000000000000..c0d0bf7f44a3
--- /dev/null
+++ b/.claude/rules/tach-boundaries.md
@@ -0,0 +1,15 @@
+---
+paths:
+ - 'tach.toml'
+---
+
+This file enforces Python import boundaries. Editing it carelessly breaks product isolation
+and makes selective CI unreliable.
+
+**Before adding a `depends_on` entry:** check whether the target product already has a facade
+(`products/<name>/backend/facade/api.py`). If it does, adding `depends_on` bypasses isolation —
+the correct fix is to add the missing method to that facade instead.
+If no facade exists yet, invoke the `/isolating-product-facade-contracts` skill to create one
+rather than adding a raw `depends_on`.
+
+Run `tach check --dependencies --interfaces` to validate after any change here.
diff --git a/CLAUDE.md b/CLAUDE.md
deleted file mode 100644
index 552c6121ed40..000000000000
--- a/CLAUDE.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# PostHog Development Guide
-
-See consolidated agents instructions in @AGENTS.md
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/packages/quill/CLAUDE.md b/packages/quill/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/packages/quill/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/packages/quill/packages/blocks/CLAUDE.md b/packages/quill/packages/blocks/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/packages/quill/packages/blocks/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/packages/quill/packages/primitives/CLAUDE.md b/packages/quill/packages/primitives/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/packages/quill/packages/primitives/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/packages/quill/packages/tokens/CLAUDE.md b/packages/quill/packages/tokens/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/packages/quill/packages/tokens/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/posthog/clickhouse/migrations/CLAUDE.md b/posthog/clickhouse/migrations/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/posthog/clickhouse/migrations/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/posthog/temporal/data_imports/signals/CLAUDE.md b/posthog/temporal/data_imports/signals/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/posthog/temporal/data_imports/signals/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/products/llm_analytics/CLAUDE.md b/products/llm_analytics/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/products/llm_analytics/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/products/signals/backend/management/CLAUDE.md b/products/signals/backend/management/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/products/signals/backend/management/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/products/signals/backend/report_generation/CLAUDE.md b/products/signals/backend/report_generation/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/products/signals/backend/report_generation/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/products/signals/eval/CLAUDE.md b/products/signals/eval/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/products/signals/eval/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/proto/CLAUDE.md b/proto/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/proto/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/rust/personhog-replica/CLAUDE.md b/rust/personhog-replica/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/rust/personhog-replica/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file
diff --git a/rust/personhog-router/CLAUDE.md b/rust/personhog-router/CLAUDE.md
new file mode 120000
index 000000000000..47dc3e3d863c
--- /dev/null
+++ b/rust/personhog-router/CLAUDE.md
@@ -0,0 +1 @@
+AGENTS.md
\ No newline at end of file