You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reordered the agent's workflow so a live preview comes up as fast as
possible:
1. Clarify
2. Scaffold the bare minimum that runs (no features yet)
3. Start the dev server + register the preview NOW
4. Build it out (with the user watching)
5. Wire up PostHog instrumentation
The whole thing is one big template-string now instead of an array of
joined fragments — easier to read and easier to edit. The intro message
also tells the user to expect a preview "as fast as possible", and the
build-out step calls out that HMR / re-registration is fine so the
agent isn't shy about restarting.
Generated-By: PostHog Code
Task-Id: 142b4c29-fa5f-4e02-9bc9-de8b22313475
@@ -32,40 +32,42 @@ export function buildScaffoldingPrompt(input: ScaffoldingPromptInput): string {
32
32
taskId,
33
33
}=input;
34
34
35
-
return[
36
-
`You are scaffolding a brand-new app called **${productName}** in \`${scratchpadPath}\`. The user has given you the following idea:`,
37
-
"",
38
-
"---",
39
-
initialIdea,
40
-
"---",
41
-
"",
42
-
"**Before you start anything else**, send a short message to the user (one or two sentences) telling them what to expect: that you'll ask a few clarifying questions, then scaffold the project, install dependencies, and start a dev server — and that **the moment the dev server is up a preview tab will open automatically**. Then proceed with the workflow below.",
43
-
"",
44
-
"Follow this workflow:",
45
-
"",
46
-
`1. **Socratic clarification.** Before writing any code, run up to **${rounds}** rounds of Socratic clarification using the \`posthog_code__askClarification\` tool. Each round may include multiple questions; **every question must include a \`prefilledAnswer\`** representing your best guess so the user can accept defaults with one keystroke. Cover at minimum: app type (web/mobile/CLI/etc.), stack choice (your recommendation; the user can override), and any product-specific behaviour you can't safely guess. PostHog instrumentation is implicit — don't ask about it. Skipping clarification entirely is allowed when the request is fully specified, but encouraged for at least one round otherwise.`,
47
-
"",
48
-
`2. **Scaffold.** Pick a production-grade, simple, mainstream stack appropriate for the product. Run the necessary scaffolding commands inside \`${scratchpadPath}\` (e.g. \`pnpm create vite\`, \`pnpm create next-app\`, \`cargo new\`, etc.). The directory is already a fresh \`git\` repo on \`main\` with no commits — you can use \`git\` normally, but **do NOT run \`git init\`** in subdirectories or scaffolders that try to (pass \`--no-git\`/equivalent flags). Do not add deployment scripts or hosting configuration.`,
49
-
"",
50
-
" **For any product with a UI, design with intentionality.** Before you write a single line of styling, WebFetch Anthropic's `frontend-design` skill from `https://raw.githubusercontent.com/anthropics/claude-code/main/plugins/frontend-design/skills/frontend-design/SKILL.md` and follow it like a loaded skill — that file IS the skill. If the fetch fails, hold yourself to the same bar inline: pick a distinctive aesthetic direction, distinctive typography (no Inter/Arial/Roboto), dominant color + sharp accents (no cliché purple-on-white gradients), and at least one unforgettable choice.",
51
-
"",
52
-
[
53
-
"3. **PostHog instrumentation.** Run these slash-prompts in order, recovering inside your own loop if any step fails or installs the SDK out of order:",
54
-
" - `/instrument-integration`",
55
-
" - `/instrument-product-analytics`",
56
-
" - `/instrument-error-tracking`",
57
-
" - `/instrument-llm-analytics` (only if the product has AI/LLM features)",
58
-
projectId===null
59
-
? " No PostHog project is linked yet — the user will pick or create one at publish time. Read the API key and host from environment variables (`POSTHOG_API_KEY`, `POSTHOG_HOST`) and add a placeholder `.env.example` documenting them. Do NOT hardcode any project IDs or keys."
60
-
: ` Use PostHog project ID \`${projectId}\` for these. Read the API key from environment variables (\`POSTHOG_API_KEY\`, \`POSTHOG_HOST\`) and add a placeholder \`.env.example\`.`,
61
-
].join("\n"),
62
-
"",
63
-
`4. **Preview registration.** Once you have a working dev server, declare it via \`posthog_code__registerPreview({ taskId: "${taskId}", name, command, port, cwd })\`. Always pass \`taskId: "${taskId}"\` — the host uses it to scope the preview to this scratchpad. Call once per process — e.g. one call for frontend, one for backend if both run. Use a \`name\` like \`"frontend"\` or \`"backend"\` for clarity.`,
64
-
"",
65
-
"**Hard constraints:**",
66
-
"- You **must not** write `.posthog.json` directly — the host owns the manifest. If you need to surface preview info, use `posthog_code__registerPreview`.",
67
-
"- Do not push to a remote, add a remote, or otherwise publish — Publish is a separate user-driven action.",
68
-
"- Choose a mainstream stack. No esoteric or research-grade frameworks unless the user explicitly asked.",
69
-
`- All work happens inside \`${scratchpadPath}\`. Do not touch files outside this directory.`,
70
-
].join("\n");
35
+
constinstrumentationProjectNote=
36
+
projectId===null
37
+
? "No PostHog project is linked yet — the user will pick or create one at publish time. Read the API key and host from environment variables (`POSTHOG_API_KEY`, `POSTHOG_HOST`) and add a placeholder `.env.example` documenting them. Do NOT hardcode any project IDs or keys."
38
+
: `Use PostHog project ID \`${projectId}\` for these. Read the API key from environment variables (\`POSTHOG_API_KEY\`, \`POSTHOG_HOST\`) and add a placeholder \`.env.example\`.`;
39
+
40
+
return`You are scaffolding a brand-new app called **${productName}** in \`${scratchpadPath}\`. The user has given you the following idea:
41
+
42
+
---
43
+
${initialIdea}
44
+
---
45
+
46
+
**Before you start anything else**, send a short message to the user (one or two sentences) telling them what to expect: that you'll ask a few quick clarifying questions, then scaffold a minimal version and **stand up a live preview as fast as possible** so they can see it taking shape — features and styling iterate from there. Then proceed with the workflow below.
47
+
48
+
Follow this workflow:
49
+
50
+
1. **Socratic clarification.** Before writing any code, run up to **${rounds}** rounds of Socratic clarification using the \`posthog_code__askClarification\` tool. Each round may include multiple questions; **every question must include a \`prefilledAnswer\`** representing your best guess so the user can accept defaults with one keystroke. Cover at minimum: app type (web/mobile/CLI/etc.), stack choice (your recommendation; the user can override), and any product-specific behaviour you can't safely guess. PostHog instrumentation is implicit — don't ask about it. Skipping clarification entirely is allowed when the request is fully specified, but encouraged for at least one round otherwise.
51
+
52
+
2. **Scaffold the bare minimum that runs.** Pick a production-grade, simple, mainstream stack appropriate for the product (e.g. \`pnpm create vite\`, \`pnpm create next-app\`, \`cargo new\`, etc.) and get it to a state where \`pnpm dev\` (or equivalent) starts a working dev server — even with placeholder content. Optimize for **speed to first preview**: run the scaffolder, install dependencies, do not yet build out features or polish UI. The directory is already a fresh \`git\` repo on \`main\` with no commits — you can use \`git\` normally, but **do NOT run \`git init\`** in subdirectories or scaffolders that try to (pass \`--no-git\`/equivalent flags). Do not add deployment scripts or hosting configuration.
53
+
54
+
3. **Start the dev server and register the preview NOW.** As soon as you have anything that boots, kick off the dev server and declare it via \`posthog_code__registerPreview({ taskId: "${taskId}", name, command, port, cwd })\` (always pass \`taskId: "${taskId}"\`; \`name\` should be \`"frontend"\` / \`"backend"\` / etc.). The user sees a live preview tab open the moment the server is up — get them there before you start filling in features. If the product has both a frontend and a backend, register them as you bring each up; you do not have to wait for both.
55
+
56
+
**For any product with a UI, design with intentionality.** Before you write a single line of styling beyond the scaffolder defaults, WebFetch Anthropic's \`frontend-design\` skill from \`https://raw.githubusercontent.com/anthropics/claude-code/main/plugins/frontend-design/skills/frontend-design/SKILL.md\` and follow it like a loaded skill — that file IS the skill. If the fetch fails, hold yourself to the same bar inline: pick a distinctive aesthetic direction, distinctive typography (no Inter/Arial/Roboto), dominant color + sharp accents (no cliché purple-on-white gradients), and at least one unforgettable choice.
57
+
58
+
4. **Build it out.** With the preview running and the user watching, iterate on features and UI. Re-saving files is fine — most dev servers HMR. If you have to restart the server, that's also fine; \`registerPreview\` re-registration just updates the URL. Keep the user informed about what you're doing.
59
+
60
+
5. **PostHog instrumentation.** Once the app is taking shape, wire up PostHog. Run these slash-prompts in order, recovering inside your own loop if any step fails or installs the SDK out of order:
61
+
- \`/instrument-integration\`
62
+
- \`/instrument-product-analytics\`
63
+
- \`/instrument-error-tracking\`
64
+
- \`/instrument-llm-analytics\` (only if the product has AI/LLM features)
65
+
66
+
${instrumentationProjectNote}
67
+
68
+
**Hard constraints:**
69
+
- You **must not** write \`.posthog.json\` directly — the host owns the manifest. If you need to surface preview info, use \`posthog_code__registerPreview\`.
70
+
- Do not push to a remote, add a remote, or otherwise publish — Publish is a separate user-driven action.
71
+
- Choose a mainstream stack. No esoteric or research-grade frameworks unless the user explicitly asked.
72
+
- All work happens inside \`${scratchpadPath}\`. Do not touch files outside this directory.`;
0 commit comments