apps/cli: generate style.css and page content section-by-section#3199
apps/cli: generate style.css and page content section-by-section#3199youknowriad merged 2 commits intotrunkfrom
Conversation
…on-by-section Measured across several "build me a landing page" sessions, the biggest silent gaps in the agent's flow were two single-turn generations: the theme's style.css (60-90s producing 15-20KB in one Write) and the page's post_content (40-50s producing a full multi-section page markup in one wp_cli call). These blocks of silence are the dominant contributor to the user's sense that "the agent is stuck", even when it's working. Rather than add new tools, lean on the existing Write/Edit/wp_cli flow and two workflow rules in the system prompt: - Step 3a: write style.css as a small :root + anchor-comment skeleton, then fill one `/* === <concern> === */` anchor per Edit call. - Step 4a: create the page empty, build its block markup in `<theme>/page-content.html` via a `<!-- section:<concern> -->` anchor skeleton + one Edit per section, and apply once at the end with `wp_cli post update --post_content-file=<path>`. Both rules explicitly forbid wrapping sections in `core/html`, which a prior run regressed on when given a similar tool-based workflow. Also bump the default maxTurns from 50 to 75: the first measured session hit the 50 ceiling and was cut off mid-refinement; the section-by-section pattern adds more turns, so 75 gives headroom without being visibly different on runs that complete quickly.
📊 Performance Test ResultsComparing 7414966 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
…dence approach Combines the complementary halves of the two approaches to the "silent mega-turn" problem: - From #3198 (Derek): the broad "one Write/Edit per turn" rule and the small-turn rule for the turn immediately after site_create. Without these, the agent packs an entire theme scaffold into one turn. - From this branch (section-by-section anchors): the concrete skeleton patterns for style.css (`/* === <concern> === */`) and page content (`<!-- section:<concern> -->` + `--post_content-file=`). Without these, the "skeleton-first" guidance alone was ignored for style.css — session 8 still wrote 12KB in a single Write (46.6s gap). Replaces the earlier verbose step 3a/4a blocks with a single compact "Working cadence" section after step 6 (roughly half the line count) while retaining the concrete anchor patterns. Also adds a short post-site_create reminder to the site-spec skill at the point where the rule matters most. Session 9 with the combined rules is in progress: longest content-generation gap measured so far is 18.3s (a 3.5KB style.css section fill). The 30s perceptual threshold is no longer breached on the generation side.
There was a problem hiding this comment.
Thanks for improving this @youknowriad! I have tested the same prompt against this branch and against trunk, and I have found the following:
-
In this branch, the duration of the requests is lower, the maximum duration is 22 seconds vs durations of 97 in trunk
-
The quality seems to be slightly better in trunk, you can see the preview generated sites:
- This branch: https://rarandalopez-qnmid-studio.wp.build
- Trunk: https://rarandalopez-hielv-studio.wp.build/
The difference is mainly in animations, but you can see there is not a big difference
-
I have found that in this branch, I was asked by the page style even though I provided it in the prompt. That doesn't happen in trunk:

-
Both versions reached max turns and asked to Continue
-
Both versions took the same amount of time to complete (~ 15 mins for both)
-
This branch produces less HTML blocks, the result is better on this branch compared to trunk
All in all, I think this improves the issues with the long running queries in the backend so I'm approving this, we can continue iterating.
sejas
left a comment
There was a problem hiding this comment.
I tested trunk with these changes. I was not able to get the Timeout. I tried it with different prompts similarly to Create a new site about AI development. Create a new beautiful theme in one shot.. I finished building one website, the other times I stop testing after the first answer.
It looked like it was stuck for ~1 minute on the first call after creating a site and get site info when it was creating the styles.css file, but it continued without any issue being much more responsive with smaller edits for the same file.
It reached the turns limit much faster, in 7 minutes of work.
After accepting it once, I didn't hit the turns limit anymore during my work session.
Regarding the quality of the website, it’s hard to assess whether it was affected. The site looks nice and works properly. It stopped after building the home page and left the rest of the pages empty. It took another prompt for me to generate them.
https://antoniosejas-svhop-studio.wp.build/
| Home | About | Blog | Contact |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |




Related issues
How AI was used in this PR
The system-prompt changes in this PR were designed and written by Claude together with the PR author. Both the analysis that motivated the change (comparing several landing-page build sessions and profiling where the silent generation gaps lived) and the final prompt wording were produced through that pairing. The numbers cited below are real measurements from recorded session JSONL files, not estimates. Reviewers should focus on whether the prompt wording is clear, correct, and consistent with the rest of the system prompt — and whether the workflow described is actually the one we want the agent to follow.
Proposed Changes
Measured across five "build me a landing page" sessions, the dominant contributors to user-perceived latency in the AI agent's flow were two single-turn generations:
style.css: 60–90s producing 14–20KB of CSS in oneWritecall.post_content: 40–50s producing a full multi-section page in onewp_cli post create/update --post_content=<huge>call.In both cases the agent is working, but from the user's point of view it's a long stretch of dead air.
Rather than add new MCP tools, this PR leans on the existing
Write/Edit/wp_clitoolset and adds two workflow rules to the system prompt:style.csssection-by-section. The agent first writes a small skeleton (:root { ... }+ anchor comments like/* === hero === */), then fills one anchor perEditcall. Each edit is bounded to 300–2000 bytes.<theme>/page-content.htmlvia a<!-- section:<concern> -->skeleton plus oneEditper section, and applies it with a singlewp_cli post update --post_content-file=<path>at the end. Both rules explicitly forbid wrapping sections incore/html, which a prior experiment regressed on.Also bumps the default
maxTurnsfrom 50 → 75 instartAiAgent. Session A in the measurements hit the 50 ceiling and was cut off mid-refinement; the section-by-section pattern adds more turns by design, so 75 gives headroom without being visibly different on runs that complete quickly.Expected impact
Based on the measurements:
style.css) to ~10–15s (per section).style.css,page-content.html) remain on disk as durable records that can be re-edited or re-applied without regenerating.Not in this PR
append_page_sectiontool and found the prompt-only path is cleaner and has better failure semantics).Testing Instructions
There are no new code paths — the behavioral change is entirely in the AI agent's system prompt. To verify:
npm run cli:build.node apps/cli/dist/cli/main.mjs ai(or through the desktop app), and ask it to build a landing page for a product.Writea small (< 2KB) skeleton forstyle.cssfirst, then do 6–10Editcalls against/* === <concern> === */anchors to fill the stylesheet.--post_content="",Writea small skeleton for<theme>/page-content.htmlwith<!-- section:<concern> -->anchors, do 5–10Editcalls to fill it, then apply once withwp_cli post update <id> --post_content-file=<absolute path>.<!-- wp:html ... -->.~/Library/Application Support/Studio/sessions/(macOS) will show the per-sectionEditcalls with small individual durations instead of one long silent generation.If the agent ignores the new guidance and reverts to single-Write / single-post_content calls, the prompt may need to be tightened — note that behavior and let the PR author know.
Pre-merge Checklist
npm run typecheck— clean)npm test -- apps/cli/ai— 105 tests passing)🤖 Generated with Claude Code