# writing-streamlit-apps

The writing-streamlit-apps skill guides Python code for Streamlit apps that read PostHog data inside a sandbox. Use it when building or debugging dashboards with tables and charts.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 177 installs · ★ 101 repo stars
- Author: PostHog
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/PostHog/ai-plugin/tree/HEAD/skills/writing-streamlit-apps/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/writing-streamlit-apps

## What it does

This skill covers source code for Streamlit 1.31 in a PostHog sandbox. Apps read project data through `posthog_apps.query()`, which returns a `pandas.DataFrame` from HogQL. It also explains how to cache bridge calls, keep values in `st.session_state`, arrange screens with columns, tabs, and expanders, and render charts or data tables.

The entry file is `app.py`. Helper modules and bundled data can sit beside it, with file paths resolved from `Path(__file__).parent`. The image includes Python 3.11 and packages such as `pandas`, `plotly`, `duckdb`, and `scikit-learn`; the sandbox does not install extra packages with `pip`.

A free-form widget value must not be placed directly into HogQL, since viewers could submit queries using the app author’s access. Server-side time and memory caps also make bounded, aggregated queries necessary before data reaches `pandas`. Files written in the sandbox disappear after a restart.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill writing-streamlit-apps -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/writing-streamlit-apps/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/writing-streamlit-apps/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill writing-streamlit-apps -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/writing-streamlit-apps/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill writing-streamlit-apps -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/writing-streamlit-apps/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install PostHog/ai-plugin skills/writing-streamlit-apps
```

2. **Manually: put the files in place**
- File: `.github/skills/writing-streamlit-apps/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill writing-streamlit-apps -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/PostHog/ai-plugin --path skills/writing-streamlit-apps
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/writing-streamlit-apps/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add PostHog/ai-plugin --skill writing-streamlit-apps -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/PostHog/ai-plugin/tree/HEAD/skills/writing-streamlit-apps/SKILL.md

## When to use it
- write a Streamlit app backed by PostHog data
- build a screen with metrics, tables, and charts
- cache query results across Streamlit reruns
- preserve user choices in `st.session_state`
- handle a failed HogQL query without a stack trace

## Example prompts
- Write `app.py` for a Streamlit view that counts PostHog events by day through `posthog_apps.query()`.
- Add cached queries and a bounded period selector, keeping free-form text out of HogQL.
- Debug the failed query in this app and show the error with `st.error`.

## Similar
- [harvard-artifacts-etl-streamlit](https://affpapa.org/en/nevibecode/skills/harvard-artifacts-etl-streamlit.md) — skill · 1400 installs
- [streamlit-to-marimo](https://affpapa.org/en/nevibecode/skills/streamlit-to-marimo.md) — skill · 2400 installs
- [harvard-artifacts-etl-streamlit-analytics](https://affpapa.org/en/nevibecode/skills/harvard-artifacts-etl-streamlit-analytics.md) — skill · 1900 installs
- [debugging-streamlit](https://affpapa.org/en/nevibecode/skills/debugging-streamlit.md) — skill · 502 installs
- [understanding-streamlit-architecture](https://affpapa.org/en/nevibecode/skills/understanding-streamlit-architecture.md) — skill · 123 installs
- [streamlit](https://affpapa.org/en/nevibecode/rules/streamlit.md) — rule · ★ 3589 repo stars

From the same set: [posthog/ai-plugin](https://affpapa.org/en/nevibecode/by/posthog/ai-plugin.md) — 82 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
