Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

docs(previews): seed data into a preview via port-forward + seed CLI (#15547)

Max Deichmann90b98d009a6d
diff --git a/.agents/skills/langfuse-previews/SKILL.md b/.agents/skills/langfuse-previews/SKILL.md
index 24402994c4..6dfa15e4a4 100644
--- a/.agents/skills/langfuse-previews/SKILL.md
+++ b/.agents/skills/langfuse-previews/SKILL.md
@@ -6,8 +6,10 @@ description: >
Use when spinning up or using a PR preview, logging into one, working out why
a preview did not come up (built but the URL 404s, ImagePullBackOff, pods
stuck Pending), reading web / worker / ClickHouse logs or otherwise debugging
- a preview with kubectl, waking a preview that went to sleep off-hours, or
- getting preview deploy or cluster access. Synthetic data only.
+ a preview with kubectl, waking a preview that went to sleep off-hours,
+ seeding or adding more test data to a preview (deep traces, big sessions,
+ bulk traces, v4 events) with the seed CLI over a port-forward, or getting
+ preview deploy or cluster access. Synthetic data only.
---
# Langfuse PR Previews
@@ -63,6 +65,51 @@ Pushing updates it; closing the PR tears it down.
**fresh** environment, not the old one.
- **Forks can't preview.** External / fork PRs never build or deploy.
+## Add or improve data in a preview
+
+Previews start pre-seeded with the demo project and some synthetic traces. To
+add the specific shape you're testing — a very deep trace, a huge session, bulk
+traces for list performance, v4 events, malformed payloads — run the
+deterministic **seed CLI from your local checkout**, pointed at the preview's
+datastores over a `port-forward`. The CLI has no LLM/agent loop; you (or your
+coding agent) pick the scenario — the **`seed-test-data` skill** maps "what I
+need" → the exact command and flags.
+
+Needs cluster access (see [Getting access](#getting-access)) and a working
+local `.env` (your normal local-dev setup — it supplies everything except the
+DB connection, which the commands below override).
+
+```bash
+NS=langfuse-pr-<N> # e.g. langfuse-pr-42
+
+# 1. tunnel Postgres + ClickHouse to localhost (leave these running)
+kubectl -n $NS port-forward svc/$NS-postgresql 5432:5432 &
+CH=$(kubectl -n $NS get svc -o name | grep clickhouse | head -1)
+kubectl -n $NS port-forward "$CH" 8123:8123 &
+
+# 2. per-preview generated passwords (synthetic, disposable)
+PGPW=$(kubectl -n $NS get secret langfuse-secrets -o jsonpath='{.data.postgres-password}' | base64 -d)
+CHPW=$(kubectl -n $NS get secret langfuse-secrets -o jsonpath='{.data.clickhouse-password}' | base64 -d)
+
+# 3. seed — overrides only the DB connection (your .env supplies the rest);
+# NEXTAUTH_URL makes the CLI's printed deep links point at the preview UI
+cd packages/shared
+DATABASE_URL="postgresql://postgres:$PGPW@localhost:5432/postgres_langfuse" \
+CLICKHOUSE_URL="http://localhost:8123" CLICKHOUSE_PASSWORD="$CHPW" \
+NEXTAUTH_URL="https://pr-<N>.preview.langfuse.com" \
+pnpm run seed:scenario -- deep-chain --v4
+```
+
+- `pnpm run seed:scenario -- list` shows every scenario and flag; add
+ `--dry-run` to predict counts and write nothing. Full catalog: the
+ `seed-test-data` skill.
+- The last stdout line is a JSON summary with `verified` and clickable `links`
+ straight into the preview UI.
+- Run from a checkout whose **migrations match the PR** — scenario code and the
+ preview DB must agree, so seed from the PR's branch (usually already checked
+ out), not a stale `main`.
+- **Synthetic data only** — same rule as everywhere else in a preview.
+
## Debug a preview
Needs cluster access (see [Getting access](#getting-access)). Set your PR's