chore(skills): add writing-kea-logics skill#58707
Conversation
Foundational skill for new engineers writing or reviewing PostHog kea logics. Captures the PostHog-specific conventions on top of upstream keajs.org — block ordering, state-container decisions, builder patterns, typing/typegen, React integration, testing. Structure is a slim SKILL.md as a router into eleven JTBD-focused reference files (state-decision, loading-data, polling, forms, routing, persisting-state, reacting-to-changes, keyed-logics, connecting-logics, testing, anti-patterns). Each reference leads with the pattern and why it's the right shape, then code, then anti-patterns. Cross-references existing skills rather than duplicating: defers to using-kea-disposables for cleanup and making-scenes-tab-aware for scene root logics. File:line citations to in-repo examples were deliberately avoided in favour of teaching the pattern itself, since example files age quickly. Two small History sections at the bottom of reacting-to-changes.md and anti-patterns.md link to merged PRs and commits where each anti-pattern or convention has a documented origin story. Generated-By: PostHog Code Task-Id: 6a7ab05c-307f-437c-bb62-ce042b709734
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1b81c8268
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 3. **`path` includes the key.** Without this, every instance writes to the same | ||
| redux node and they collide. The function form `path((key) => [...])` is what | ||
| wires the key in. |
There was a problem hiding this comment.
Remove requirement to include
key in keyed logic path
This section states that keyed logics must include the key in path or instances “collide in redux”, but path in Kea is metadata for debugging/typegen rather than instance identity, which is handled by key(...). Encoding this as a hard rule will push contributors/agents to rewrite valid keyed logics and can cause unnecessary state-key churn (e.g., persisted localStorage keys) without fixing any real collision bug.
Useful? React with 👍 / 👎.

after yet again telling the robot not to use a selector
i thought maybe even more markdown files will help...
Problem
New engineers picking up the frontend hit kea conventions piecemeal —
which builder belongs where, when a reducer vs selector vs cache is
the right container, why we prefer listeners over
kea-subscriptions,when a logic should be keyed, and so on. Two narrow skills already
exist (
using-kea-disposables,making-scenes-tab-aware) but neithercovers the foundational shape of a
*Logic.tsfile.This adds
writing-kea-logicsas the foundational kea skill, withcompanion-skill cross-references so the three together form a coherent
set without duplication.
Changes
New skill under
.agents/skills/writing-kea-logics/:SKILL.md— slim entry point with core principles, a quick anatomyexample, and a JTBD pattern index linking to references.
state-decision,loading-data,polling,forms,routing,persisting-state,reacting-to-changes,keyed-logics,connecting-logics,testing,anti-patterns. Eachleads with the pattern, then why it's the right shape, then code,
then anti-patterns.
Design choices worth flagging for reviewers:
using-kea-disposablesand
making-scenes-tab-awareare linked from the relevant sections,not re-explained.
faster than the patterns themselves, so references describe the shape
with inline code and only point at canonical files at the level of
"for a real form, search
forms(...)in the repo".## Historysections at the bottom ofreacting-to-changes.mdandanti-patterns.mdlink to merged PRs(feat: kea disposables #38754, feat: kea disposables auto-tracks browser visibility and stops/starts disposables #40284, fix(data-warehouse): use disposables for polling in dataModelingLogic #48039–fix(managed-migrations): use disposables for polling in managedMigrationLogic #48042, fix(frontend): pause disposables added while page is hidden #58691) and commits where each
anti-pattern or convention has a documented origin — readers wanting
the why-it-changed context can follow back to the original change.
How did you test this code?
I'm an agent (PostHog Code). The only automated check I ran is
hogli lint:skills, which passes (39 skills lint-clean).I did not exercise the skill through an end-to-end agent session.
Manual review by a human kea-fluent engineer is the right next step
to confirm the patterns and "why" framings match team intent.
Publish to changelog?
no
🤖 Agent context
Authored end-to-end by PostHog Code (Claude Opus 4.7) in a single
working session.
(
frontend/src/initKea.ts), plugin usage, conventional blockordering, test patterns, and recent best-practice PRs/commits.
SKILL.mdwith citation tables. Userpushed back: example files age quickly. Refactored into a slim
router + per-JTBD references each carrying the why.
Added
## Historysections to two references (the ones where PRhistory adds real teaching context — patterns banned because real
code went wrong) rather than sprinkling PR links everywhere.
using-kea-disposables/making-scenes-tab-aware: skill lives in.agents/skills/, notproducts/*/skills/, since it's a repo-local convention skill nota customer-facing PostHog AI skill.
including them.
Created with PostHog Code