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.
npx agentmods add rules/posthog/posthog-foss/react-typescriptgit clone --depth 1 https://github.com/PostHog/posthog-fossWrote 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.
[](https://agentmods.dev/rules/posthog/posthog-foss/react-typescript)<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>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.
| Model | Per session | Once 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 |
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.
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
useStateoruseEffectto store local state. It's false convenience. Take the extra 3 minutes and change it to alogicearly 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 complicatedlib/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
camelCasevariables in JS,snake_casein Python). - Use clear, yet functional names (
searchResultsvsdata). - 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
.tsfile according to its main export:DashboardMenu.tsorDashboardMenu.tsxordashboardLogic.tsorDashboard.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
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.
- yesterday First seen · 59 lines · 0 tokens per session scan A 2dddeac4c4b9
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.
Other cursor rules, from other repositories
ai-agent-specialist
Cursor rules for TypeScript, React, Node.js, clean architecture, testing, and WHY-oriented engineering guidance.
django-python
Rules for writing Python services at PostHog (Python servers powered by the Django framework).
react-typescript
Rules for writing frontend code at PostHog (mostly React + Typescript with Kea).
rust
Rules for writing Rust services at PostHog. Focuses on writing async Rust with Tokio and encoding general Rust best practices from the Rust book and docs.
05-web-development
Use the following format for code blocks.
react-chakra-ui---typescript-usage
在使用 Chakra UI 的 React 组件时利用 TypeScript 确保类型安全.