The problem
A two-founder startup doesn't open dashboards. Questions arrived in Slack ("did the new episode move signups?") and I answered them by hand, query by query. Product data sat in PostHog, social data across six accounts, email in Klaviyo. The answer to most questions needed all three.
So I built something the founder and I could check every day, instead of another dashboard nobody opened.
What I built
A small set of saved HogQL queries
One per recurring question: signups by channel, activation by cohort, episode-level watch time, creation events. Versioned, so the briefing and a human always ran the same query.
A Python job that runs them every morning
Pulls PostHog results through the query API, merges social metrics, and computes deltas vs. the trailing 7 days.
Claude writes the briefing, with guardrails
The model receives only computed numbers and the query text. It must cite which query each claim came from and must flag anything it can't explain instead of guessing a cause.
# Representative excerpt def run_hogql(query: str) -> list[dict]: r = requests.post( f"{HOST}/api/projects/{PROJECT_ID}/query/", headers={"Authorization": f"Bearer {POSTHOG_KEY}"}, json={"query": {"kind": "HogQLQuery", "query": query}}, timeout=60, ) r.raise_for_status() res = r.json() return [dict(zip(res["columns"], row)) for row in res["results"]] BRIEF_RULES = """Use only the numbers provided. Cite the query id for every claim. If a change has no explanation in the data, say 'unexplained' and stop."""
Product decisions inside the tool
- Numbers come from SQL, never from the model. The LLM narrates; it never computes.
- "Unexplained" is a first-class output. The founders trusted the briefing more once it started admitting what it didn't know.
- Every claim links to its query. One click to rerun it, which turned the briefing into a starting point for digs instead of a final word.
Why it matters for PostHog
PostHog describes itself as the context layer for you and your agents. I built a homemade version of that before the MCP made it easy, and the lessons transfer directly: agents are only as good as the event model underneath, people need provenance to trust an AI summary, and the most valuable output is often "this changed and I don't know why".
What I learned
Code and queries on this page are representative excerpts, rewritten for the page. Client code and dashboards are private; I am happy to walk through the real ones on a call.