react-typescript

react-typescript is a cursor rule for Cursor from PostHog/posthog-foss. It costs 0 tokens per session (791 once invoked), scanned A, original, MIT.

Coding rules for PostHog frontend work using React, TypeScript, Kea, Tailwind, and UX practices. React builds user interfaces, while TypeScript adds type checking to JavaScript.

In plain words
What is it for?
Use them when adding or changing React components, Kea logic, TypeScript code, styling, or frontend state.
Why use it?
They keep frontend code consistent and warn about project-specific issues such as generated Kea types and state-management conventions.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/posthog/posthog-foss/react-typescript
Clone the repo
git clone --depth 1 https://github.com/PostHog/posthog-foss

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for react-typescript

README.md
[![agentmods](https://agentmods.dev/badge/rules/posthog/posthog-foss/react-typescript.svg)](https://agentmods.dev/rules/posthog/posthog-foss/react-typescript)
Your own site
<a href="https://agentmods.dev/rules/posthog/posthog-foss/react-typescript"><img src="https://agentmods.dev/badge/rules/posthog/posthog-foss/react-typescript.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 791 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00791
Opus 5 $0.00000 $0.00396
Sonnet 5 $0.00000 $0.00158
Haiku 4.5 $0.00000 $0.00079

Measured yesterday against content hash 2dddeac4c4b9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

react-typescript scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/react-typescript.mdc · 59 lines

What it actually says

You are an expert in TypeScript, React, Kea, Tailwind, and UX design.

Since you are an expert, remember that when you add or remove anything in a kea *logic.ts file there will always be typescript errors.

You need to wait for the kea typegen to complete before those errors go away, please don't start editing files trying to fix the errors until kea typegen has run

Also, any file with a name ending logicType.ts is autogenerated and should never be edited

Architecture

  • Two-layer system: Kea (data/state) -> React (view/template)
  • Always implement data layer in Kea logic; avoid React state

Code Style and Structure

  • Write TypeScript with proper typing for all new code
  • Use functional programming patterns; avoid classes
  • Prefer iteration and modularization over code duplication.
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
  • Don't use useState or useEffect to store local state. It's false convenience. Take the extra 3 minutes and change it to a logic early on in the development.
  • Logics still have a tiny initialization cost. Hence this rule doesn't apply to library components in the lib/ folder, which might be rendered hundreds of times on a page with different sets of data. Still feel free to write a logic for a complicated lib/ component when needed.
  • Use named exports; avoid default exports
  • Structure files logically: logic, component, types, styles

Naming Conventions

  • Always look around the codebase for naming conventions, and follow the best practices of the environment (e.g. use camelCase variables in JS, snake_case in Python).
  • Use clear, yet functional names (searchResults vs data).
  • Logics are camelCase (dashboardLogic)
  • React components are PascalCase (DashboardMenu).
  • Props for both logics and components are PascalCase and end with Props (DashboardLogicProps & DashboardMenuProps)
  • Name the .ts file according to its main export: DashboardMenu.ts or DashboardMenu.tsx or dashboardLogic.ts or Dashboard.scss. Pay attention to the case.
  • Avoid index.ts, styles.css, and other generic names, even if this is the only file in a directory.

UI and Styling

  • Use Tailwind CSS as primary styling solution
  • For non-Tailwind cases:
    • Use SCSS with component-specific files
    • Namespace under component class (.DashboardMenu)
    • Follow BEM for modals (.DashboardMenu__modal)
    • Import styles directly (MyComponent.scss)
  • Replace custom SCSS with Tailwind when possible
  • When mentioning PostHog products, the product names should use Sentence casing, not Title Casing. For example, 'Product analytics', not 'Product Analytics'. Any other buttons, tab text, tooltips, etc should also all use Sentence casing. For example, 'Save as view' instead of 'Save As View'.

Testing Requirements

  • Logic tests for all Kea logic files
  • React Testing Library tests for interactive lib/ components
  • Add presentational elements to Storybook
  • Run storybook locally: pnpm storybook

Core Principles

  • Prioritize maintainability over development speed
  • Keep data layer separate from view hierarchy
  • Write clear, understandable code
  • Think data first, implement views second
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 59 lines · 0 tokens per session scan A 2dddeac4c4b9

Subscribe to this mod's changes

react-typescript is a cursor rule published in the GitHub repository PostHog/posthog-foss (712 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 791 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.