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.

chore(skills): fire splitting-oversized-modules at its own gate (#90810)

Julian Bez1b2afc510177
diff --git a/.agents/skills/splitting-oversized-modules/SKILL.md b/.agents/skills/splitting-oversized-modules/SKILL.md
index 748239635fd7..47d82214dada 100644
--- a/.agents/skills/splitting-oversized-modules/SKILL.md
+++ b/.agents/skills/splitting-oversized-modules/SKILL.md
@@ -1,14 +1,17 @@
---
name: splitting-oversized-modules
description: >
- Split an oversized Python module (a 2000+ line logic.py, models.py, api.py, or its test
- file) into a package of one module per concern, mechanically and provably without changing
- behavior. Use on a request to split / break up / decompose a god module or move functions
- out of one, or once a human has agreed to split one before some other change. Covers the
- worth-it gate, assigning symbols to concerns with an acyclic dependency graph, the AST plus
- tokenize move script, and proving the result is a pure move. Python only — for frontend
- files use writing-ui-components. Not for extracting a shared helper into common/, and not
- for moving code between products, which is isolating-product-facade-contracts.
+ Split an oversized Python module (a thousand-plus-line logic.py, models.py, api.py, or its
+ test file) into a package of one module per concern, mechanically and provably without
+ changing behavior. Use on a request to split / break up / decompose a god module or move
+ functions out of one, once a human has agreed to split one before some other change, or
+ before restructuring code inside a module already over roughly a thousand lines — breaking
+ up a long function or extracting helpers in place leaves everything in the same file, so
+ check the worth-it gate and propose the split first. Covers that gate, assigning symbols to
+ concerns with an acyclic dependency graph, the AST plus tokenize move script, and proving
+ the result is a pure move. Python only — for frontend files use writing-ui-components. Not
+ for extracting a shared helper into common/, and not for moving code between products,
+ which is isolating-product-facade-contracts.
---
# Splitting oversized modules
@@ -28,6 +31,11 @@ independently, and something still actively changing in it. A big cohesive froze
nothing. Skip generated files, and skip a file several people are mid-change in
(`git log --oneline -20 -- <file>`).
+A complexity warning on one function is a symptom of this, not a separate job. Extracting
+that function into helpers leaves every helper in the same file, so the read-set is
+unchanged and the file gets longer. Measure the file first (`wc -l`), and when it clears the
+gate, propose the split instead of the in-place extraction.
+
Splitting is a separate PR from whatever you came to do. Land the move as its own base PR
and branch your work on top — see `/stacking-prs`. Never bundle it into a feature diff, and
say what you are doing in one line before you start: which file, and that the split lands
diff --git a/AGENTS.md b/AGENTS.md
index f8cbd429f945..e2850d6df939 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -284,7 +284,7 @@ ALWAYS invoke the matching skill **before** writing or reviewing code in these a
- `/authoring-ci-workflows` — adding or editing any `.github/workflows` workflow, composite action, or reusable workflow
- `/reviewing-personhog-protocol` — any personhog coordination-protocol change (leases, fencing, handoffs, supervisors, budgets, warming, changelog semantics), and any request for an exhaustive review of personhog code
- `/gating-production-deploys` — any workflow that builds and pushes a production image or dispatches a deploy
-- `/splitting-oversized-modules` — splitting a Python module into a package, or deciding whether to propose splitting one before you work in it; propose, and land the move as a stacked base PR rather than inside your feature diff
+- `/splitting-oversized-modules` — splitting a Python module into a package, or deciding whether to propose splitting one before you work in it, including before you restructure code inside a module over roughly a thousand lines; propose, and land the move as a stacked base PR rather than inside your feature diff
- `/auditing-llm-gateway-parity` — changing either gateway's auth, attribution, billing, endpoints, providers, models, routing, or metadata contract; reviewing a `services/llm-gateway` change; or refreshing `services/llm-gateway/PARITY.md`
- `/finding-llm-gateway-migration-candidates` — finding, auditing, or ranking callers that could move from `services/llm-gateway` to `PostHog/ai-gateway`, including requests for the next or lowest-risk migration candidate
- `/migrating-llm-gateway-callers` — adding an LLM gateway caller or migrating an existing caller from `services/llm-gateway` to `PostHog/ai-gateway`, including shared client and gateway setting changes made for that migration