/storybook-stories
Write Storybook stories for PostHog UI components. Covers the provider stack stories run inside, the key gotcha that tRPC/useHostTRPC queries never resolve in Storybook (so data-fetching components render empty), and the pure-presentational split that makes a component
$ npx -y skills add posthog/posthog --skill storybook-stories --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/storybook-stories
Context preview
The summary Claude sees to decide when to auto-load this skill.
Write Storybook stories for PostHog UI components. Covers the provider stack stories run inside, the key gotcha that tRPC/useHostTRPC queries never resolve in Storybook (so data-fetching components render empty), and the pure-presentational split that makes a component
SKILL.md
storybook-stories.SKILL.mdname: storybook-stories
description: Write Storybook stories for PostHog UI components. Covers the provider stack stories run inside, the key gotcha that tRPC/useHostTRPC queries never resolve in Storybook (so data-fetching components render empty), and the pure-presentational split that makes a component storyable. Use when adding or fixing a *.stories.tsx file under packages/ui.
Storybook stories in PostHog
Stories live next to components as `*.stories.tsx` and are collected by `apps/code/.storybook/main.ts` (its glob includes `packages/ui/src/**/*.stories.tsx`). Run/build:
pnpm --filter code storybook # dev server on :6006
pnpm --filter code build-storybook # static build (also a good CI/typecheck gate)
Every story is already wrapped (don't re-wrap)
`apps/code/.storybook/preview.tsx` applies two global decorators, so a story should **not** add its own providers or `<Theme>`:
- `withAppProviders` — a QueryClient, the host tRPC context, a DI
`ServiceProvider`, and a minimal TanStack Router. So `useHostTRPC()`, `useService()`, `useRouterState()`, etc. render instead of throwing "must be used within a Provider".
- A `<Theme>` (Radix) bound to the dark/light toolbar global. This root provider is
the one sanctioned Radix usage — it supplies the CSS tokens. Radix *components* are banned: build stories and components from `@posthog/quill` plus `div` + Tailwind (see [UI Components](../../../AGENTS.md#ui-components)).
Add a per-story decorator only to constrain layout (e.g. wrap in a `maxWidth` div so a full-width component sizes realistically).
The gotcha: data never arrives in Storybook
This is the thing that wastes time. In `withAppProviders` the tRPC `ipcLink` is a **no-op** (`apps/code/.storybook/mocks/electron-trpc.ts`), so:
- Any query issued through `useHostTRPC()` (and hooks built on it, like
`useClaudeCliSessions`) **stays pending forever** — `query.data` is `undefined`, permanently.
- `useService(TOKEN)` returns an **inert proxy stub** for anything not
explicitly bound (`service.foo().bar` never throws, but calls are no-ops). Only a few tokens resolve for real: `HOST_TRPC_CLIENT` (a no-op client with a handful of stubbed methods), `IMPERATIVE_QUERY_CLIENT`, `DIFF_WORKER_FACTORY`.
So a component that fetches its own data renders its **empty/loading** branch in Storybook — frequently `null`. Storying it directly shows nothing.
The fix: split a pure presentational component
Separate the data/wiring from the rendering, and story the pure part — which also satisfies the repo rule "components render; hooks wrap exactly one query" (`AGENTS.md`). Keep both in the same file:
// Pure — takes data + handlers as props. This is what the story targets.
export function WidgetList({ items, onPick }: WidgetListProps) { … }
// Container — does the tRPC/useService wiring, renders <WidgetList/>.
export function Widget({ repoPath }: WidgetProps) {
const { data } = useSomeQuery(repoPath);
return <WidgetList items={data?.items ?? []} onPick={…} />;
}Then each story is just `args` for `WidgetList` — one per visual state (empty, single, over-limit, in-flight/disabled, fallback text, …). Real example: `packages/ui/src/features/task-detail/components/ContinueCliSessions.tsx` + `.stories.tsx`.
Filtering/branching that lives in the container (not the pure view) isn't exercised by these visual stories — cover it with a small unit test if it's worth pinning.
Conventions
- `title` groups in the sidebar, e.g. `"Task Detail/ContinueCliSessions"`.
- Build fixtures with a small factory (`session(overrides)`) rather than
repeating object literals across stories.
- `Date.now()`/`new Date()` are fine in stories, but fixed ISO strings keep
relative-time output stable enough for visual review.
- Typecheck covers stories (they're `.tsx` under the package); a
`build-storybook` additionally catches Storybook-specific breakage.
Read more
name: storybook-stories description: Write Storybook stories for PostHog UI components. Covers the provider stack stories run inside, the key gotcha that tRPC/useHostTRPC queries never resolve in Storybook (so data-fetching components render empty), and the pure-presentational split that makes a component storyable. Use when adding or fixing a *.stories.tsx file under packages/ui.
Storybook stories in PostHog
Stories live next to components as `*.stories.tsx` and are collected by `apps/code/.storybook/main.ts` (its glob includes `packages/ui/src/**/*.stories.tsx`). Run/build:
pnpm --filter code storybook # dev server on :6006 pnpm --filter code build-storybook # static build (also a good CI/typecheck gate)
Every story is already wrapped (don't re-wrap)
`apps/code/.storybook/preview.tsx` applies two global decorators, so a story should **not** add its own providers or `<Theme>`:
- `withAppProviders` — a QueryClient, the host tRPC context, a DI
`ServiceProvider`, and a minimal TanStack Router. So `useHostTRPC()`, `useService()`, `useRouterState()`, etc. render instead of throwing "must be used within a Provider".
- A `<Theme>` (Radix) bound to the dark/light toolbar global. This root provider is
the one sanctioned Radix usage — it supplies the CSS tokens. Radix *components* are banned: build stories and components from `@posthog/quill` plus `div` + Tailwind (see [UI Components](../../../AGENTS.md#ui-components)).
Add a per-story decorator only to constrain layout (e.g. wrap in a `maxWidth` div so a full-width component sizes realistically).
The gotcha: data never arrives in Storybook
This is the thing that wastes time. In `withAppProviders` the tRPC `ipcLink` is a **no-op** (`apps/code/.storybook/mocks/electron-trpc.ts`), so:
- Any query issued through `useHostTRPC()` (and hooks built on it, like
`useClaudeCliSessions`) **stays pending forever** — `query.data` is `undefined`, permanently.
- `useService(TOKEN)` returns an **inert proxy stub** for anything not
explicitly bound (`service.foo().bar` never throws, but calls are no-ops). Only a few tokens resolve for real: `HOST_TRPC_CLIENT` (a no-op client with a handful of stubbed methods), `IMPERATIVE_QUERY_CLIENT`, `DIFF_WORKER_FACTORY`.
So a component that fetches its own data renders its **empty/loading** branch in Storybook — frequently `null`. Storying it directly shows nothing.
The fix: split a pure presentational component
Separate the data/wiring from the rendering, and story the pure part — which also satisfies the repo rule "components render; hooks wrap exactly one query" (`AGENTS.md`). Keep both in the same file:
// Pure — takes data + handlers as props. This is what the story targets.
export function WidgetList({ items, onPick }: WidgetListProps) { … }
// Container — does the tRPC/useService wiring, renders <WidgetList/>.
export function Widget({ repoPath }: WidgetProps) {
const { data } = useSomeQuery(repoPath);
return <WidgetList items={data?.items ?? []} onPick={…} />;
}Then each story is just `args` for `WidgetList` — one per visual state (empty, single, over-limit, in-flight/disabled, fallback text, …). Real example: `packages/ui/src/features/task-detail/components/ContinueCliSessions.tsx` + `.stories.tsx`.
Filtering/branching that lives in the container (not the pure view) isn't exercised by these visual stories — cover it with a small unit test if it's worth pinning.
Conventions
- `title` groups in the sidebar, e.g. `"Task Detail/ContinueCliSessions"`.
- Build fixtures with a small factory (`session(overrides)`) rather than
repeating object literals across stories.
- `Date.now()`/`new Date()` are fine in stories, but fixed ISO strings keep
relative-time output stable enough for visual review.
- Typecheck covers stories (they're `.tsx` under the package); a
`build-storybook` additionally catches Storybook-specific breakage.
: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.
Repo: posthog/posthog
Other skills on posthog.
- /analyzing-expensive-users
Analyze the most expensive users in AI observability and explain why they cost so much. Use when the user asks about top spenders, expensive users, per-user LLM cost, user-level cost drivers, or patterns behind high AI observability spend.
Open skill - /creating-online-evaluations
Author continuously-running online evaluations in PostHog AI observability, grounded in real failure modes you've identified. Use when the user wants evaluations that automatically score new generations or whole traces going forward — "create an eval to catch X", "continuously
Open skill - /exploring-ai-failures
Find where an AI/LLM application is failing in production and surface the failure patterns, working from real traces. Use when someone wants to understand what's going wrong with an AI feature, find and categorize failure modes, triage errors, or investigate quality issues
Open skill - /exploring-llm-clusters
Investigate AI observability clusters — understand usage patterns in AI/LLM traffic, compare cluster behavior, compute cost/latency metrics, and drill into individual traces within clusters.
Open skill - /exploring-llm-costs
Investigate LLM spend in PostHog — total cost over time, cost by model, provider, user, trace, or custom dimension, token and cache-hit economics, and cost regressions. Use when the user asks "how much are we spending on LLMs?", "which model / user / feature is most expensive?",
Open skill - /exploring-llm-evaluations
Investigate AI observability evaluations — `hog` (deterministic code-based), `llm_judge` (LLM-prompt-based), and `sentiment` (user-message sentiment). Find existing evaluations, inspect their configuration, run them against specific generations, query individual results, and
Open skill

