Skip to content

: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.

feat(wizard): update PR agent prompt to handle skills, CLI env var setup, and config file examples (#71300)

Rafael Audibert6cbad58dff4d
diff --git a/products/tasks/backend/prompts.py b/products/tasks/backend/prompts.py
index ab61236599cb..2e4d691eb2be 100644
--- a/products/tasks/backend/prompts.py
+++ b/products/tasks/backend/prompts.py
@@ -15,17 +15,19 @@ WIZARD_HEAD_BRANCH_PREFIX = "posthog/instrumentation-"
def generate_wizard_head_branch() -> str:
- """A unique PR head branch for a wizard run; the random suffix only prevents
+ """A unique PR head branch for a wizard run; the random suffix is here to prevent
collisions with existing branches in the user's repo."""
return f"{WIZARD_HEAD_BRANCH_PREFIX}{secrets.token_hex(3)}"
-WIZARD_PR_AGENT_PROMPT = f"""
+WIZARD_PR_AGENT_PROMPT = rf"""
# Context
PostHog's setup wizard has already run in this repository and integrated PostHog. The working tree
contains its uncommitted changes: modified source files, an updated package manifest, installed
-dependencies, a `posthog-setup-report.md` summary, and possibly a `.posthog-events.json` plan.
+dependencies, a `posthog-setup-report.md` summary. It'll also possibly contain a
+`.posthog-events.json` plan and some skills definitions under a harness skills folder such as
+`.claude/skills/*` or `.agents/skills/*`.
The wizard's full console output is saved to `/tmp/wizard-cloud-run/wizard-output.log` (outside the
repository, so it can never be committed). Read it whenever you need to understand what the wizard
@@ -86,15 +88,26 @@ are actually in the repository.
4. Do NOT commit `posthog-setup-report.md` or `.posthog-events.json` - they are local reference
only. Leave them untracked or exclude them from staging.
+5. Do NOT commit any of the skills included under a harness skills folder like `.claude/skills/*`
+ or `.agents/skills/*` (any `.<harness>/skills/` path). Leave them untracked or exclude them
+ from staging.
-**Checkpoint:** the commit exists on `{WIZARD_HEAD_BRANCH_PLACEHOLDER}` and
-contains neither reference file:
+**Checkpoint:** the commit exists on `{WIZARD_HEAD_BRANCH_PLACEHOLDER}` and contains none of the
+forbidden files. Run the two checks separately so you can see exactly which kind leaked if either
+fails:
```bash
git rev-parse --abbrev-ref HEAD # prints: {WIZARD_HEAD_BRANCH_PLACEHOLDER}
-git show --stat HEAD # lists the wizard's files
-git show --stat HEAD | grep -E 'posthog-setup-report|posthog-events|wizard-output' && echo "FAIL: forbidden files committed" || echo "OK: no forbidden files"
-# expected: OK: no forbidden files (the grep finding nothing is the pass case)
+git show --stat HEAD # lists the wizard's files
+
+# 1. Reference files (local-only summaries/plans/logs):
+git show --stat HEAD | grep -E 'posthog-setup-report|posthog-events|wizard-output' && echo "FAIL: reference files committed" || echo "OK: no reference files"
+
+# 2. Harness skills folders (.claude/skills/, .agents/skills/, any .<harness>/skills/):
+git show --stat HEAD | grep -E '\.[^/]+/skills/' && echo "FAIL: skills files committed" || echo "OK: no skills files"
+
+# expected: both print OK (the grep finding nothing is the pass case). If either FAILs, unstage
+# those paths, amend the commit, and re-run this checkpoint.
```
## Step 3 - Configure environment variables for production
@@ -102,7 +115,8 @@ git show --stat HEAD | grep -E 'posthog-setup-report|posthog-events|wizard-outpu
1. Identify how the codebase is deployed to production.
2. If you can automatically configure the required PostHog environment variables in a file that
will be read in production, do so, and commit that change to the same branch as a SEPARATE
- commit.
+ commit. This includes any changes to `.env`, `wrangler.jsonc`, `docker-compose.yml`,
+ or any other file that is used to configure the production environment.
3. If you can't configure them automatically, do not commit anything in this step - instead write
down in your notes which variables are needed and what values they must be set to,
for use in the PR description in Step 4.
@@ -183,10 +197,12 @@ nothing about environment variables, so the reader cannot tell whether anything
### Examples of the env-var section when you could NOT configure them automatically
-This happens when the deployment does not read a committed file like `.env.production` - e.g. the
-env vars live in a hosting dashboard (Vercel, Netlify, Heroku, Fly.io) or in infrastructure config
-you cannot see from the repo. Name the platform you detected, list every variable with its exact
-value, and tell the reader where to put them. Calibrate to the audience.
+This happens when the deployment does not read a committed file like `.env.production`,
+`wrangler.jsonc`, `docker-compose.yml`, or any other file that is used to configure the production
+environment - e.g. the env vars live in a hosting dashboard (Vercel, Netlify, Heroku, Fly.io)
+or in infrastructure config you cannot see from the repo. Name the platform you detected,
+list every variable with its exact value, and tell the reader where to put them. Calibrate to the
+audience.
For a Javascript project (assume a non-technical reader - explain what env vars are and walk
through the exact clicks):
@@ -216,6 +232,25 @@ To set them:
settings only take effect on the next deployment.
```
+If there's a way to set these environment variables via a local CLI - like it's common for Vercel,
+Netlify, Heroku, Fly.io, etc. - then suggest using that instead of the dashboard.
+
+The following example is for Vercel, but you should use the appropriate command for the hosting provider
+you've inferred from the codebase.
+
+Double-check the exact CLI syntax for the provider you detected - many commands (including
+`vercel env add`) take the target environment as a positional argument and read the value from
+stdin, so passing the value as a positional would silently set the wrong thing.
+
+Add a "Setting environment variables via a local CLI" subsection that tells the reader they can run
+commands locally instead of using the dashboard. For Vercel the commands look like this (the value
+is piped in; `production` is the target environment):
+
+```bash
+echo "phc_abc123def456" | npx vercel env add NEXT_PUBLIC_POSTHOG_TOKEN production
+echo "https://us.i.posthog.com" | npx vercel env add NEXT_PUBLIC_POSTHOG_HOST production
+```
+
For any other language (assume a technical reader - be direct, no env-var explainer):
```markdown