Generate a screen from a description using the configured generator (Stitch or Claude Code).
-
Generator selection (MUST run before generating):
- Read
.guardrc.json and check the generator field.
- IF
generator is already set (value is "stitch" or "claude"):
- Use it. Tell the user: "Using [Stitch MCP / Claude Code] as your configured generator."
- Do NOT ask again.
- IF
generator is NOT set (field missing or .guardrc.json does not exist):
-
Present the options to the user:
"Which generator would you like to use for this project?
- Claude Code (recommended) -- Generates HTML locally. Anti-slop rules from
.claude/rules/ are enforced during generation. Best for design-system compliance.
- Google Stitch -- Generates via Stitch MCP. More creative/varied layouts, but anti-slop rules do NOT apply during generation (the critic catches issues after).
Which do you prefer? (Default: Claude Code)"
-
If the user picks Claude Code (or does not express a preference): set generator to "claude".
-
If the user picks Stitch: set generator to "stitch".
-
Save the choice to .guardrc.json by updating the generator field (create file with defaults if it does not exist).
-
Tell the user: "Saved generator preference to .guardrc.json. You can change it anytime by editing the file or telling me to switch."
-
Read DESIGN.md (REQUIRED):
- Read DESIGN.md from the project root.
- IF DESIGN.md does NOT exist: STOP. Do NOT create one inline. Do NOT proceed with generation.
- Tell the user: "No DESIGN.md found. A design system is required before generating screens. Run
/dg-design to create one (or /dg-discover first if this is for a real business)."
- Do NOT offer to create DESIGN.md within this skill. The user MUST use
/dg-design which has context isolation and discover checks.
- IF DESIGN.md exists: use it as context for visual consistency. Extract colors, fonts, spacing, and component patterns.
-
Guide the user through building a good prompt using the zoom-out-zoom-in framework:
Zoom out (context ~30%):
- Product name and what it does
- Target user/audience
- Overall aesthetic direction
Zoom in (specifics ~70%):
- Page type (landing page, dashboard, pricing, about, contact, etc.)
- Goal of this screen
- Each section with specific descriptions
- UI patterns: "bento grid", "sticky header", "card layout"
- Specific numbers: "3 pricing tiers", "4 testimonials"
-
Build the prompt following this structure:
A [adjective] [page type] for "[Product Name]," a [product description].
Designed for [target user]. [Visual tone].
Include these sections:
1. [Section with brief description]
2. [Section with brief description]
...
-
Generate the screen:
- IF generator is
stitch:
- Model selection: Before generating, read
packages/cli/src/research/known-state.json to check available models. Use ONLY non-deprecated models:
- GEMINI_3_FLASH (350/month quota) — default for fast iteration and standard screens
- GEMINI_3_1_PRO (200/month quota) — use for high-quality hero pages or when the user explicitly requests best quality
- Do NOT use GEMINI_3_PRO or GEMINI_2_5_FLASH — these are deprecated and may produce inferior results or fail
- Call
mcp__stitch__generate_screen_from_text with the prompt, the selected model, and the Stitch project ID from .guardrc.json.
- IF generator is
claude: Generate a complete, single-file HTML page directly. Follow these constraints:
- Apply ALL rules from
.claude/rules/anti-slop-design.md
- Apply ALL rules from
.claude/rules/design-system-adherence.md
- Apply ALL rules from
.claude/rules/content-authenticity.md
- Follow DESIGN.md for all color, typography, spacing, and component decisions
- Use the zoom-out-zoom-in prompt structure from step 3 as the page specification
- Output a complete HTML file with embedded CSS (no external dependencies except Google Fonts)
- Run the self-check from
.claude/rules/post-generation-evaluation.md before presenting
-
After generation, retrieve the screen code and save the HTML to screens/[screen-name].html.
-
Post-generation quality gate: After saving the HTML, run the dg-critic agent to check quality:
- The critic runs static lint + 5 quick pattern checks (identical cards, gradient text, button hierarchy, palette compliance, content truth).
- If the critic returns FAIL: show the issues, attempt one automatic fix pass using the critic's suggestions as a refinement prompt, then re-lint. If still failing, present both versions to the user with the issues noted.
- If the critic returns WARN: show the warnings but proceed to preview.
- If the critic returns PASS: proceed to preview.
- The anti-slop rules in
.claude/rules/ prevent issues in Claude-generated HTML, but Stitch output is NOT influenced by rules — the critic catches what rules cannot.
-
Preview the screen after saving:
- Call
mcp__stitch__get_screen_image with the project ID and screen ID to get a base64 PNG.
- Display the image inline so the user can see the result immediately.
-
For refinements, use this structure (one change at a time):
On the [specific section] of [screen name], [specific change]:
- [Detail 1]
- [Detail 2]
-
Multi-screen requests — SEQUENTIAL ONLY:
When the user asks to generate multiple screens (e.g., "create a landing page, about page, and pricing page"), generate them ONE AT A TIME. Follow this sequence for each screen:
- Build the prompt for screen N
- Generate screen N (Stitch or Claude)
- Save to
screens/
- Run the critic on screen N
- Fix any issues the critic flags
- Wait for the full cycle to complete before starting screen N+1
NEVER send multiple generation requests in parallel — this causes cascading timeouts on Stitch and wastes quota when screens fail. If Stitch is already timing out on one request, sending more will make it worse.
For subsequent screens, prefix prompts with:
"Following the same design language as the homepage..."
-
For variants, offer to call mcp__stitch__generate_variants to produce 2-3 alternative designs the user can compare before committing to one direction.
-
For inline edits to an existing screen, use mcp__stitch__edit_screens instead of regenerating from scratch.
-
Next step: Based on the critic verdict, provide context-aware guidance:
- If PASS: "Screen passes quality gate. Preview with
/dg-preview, deep-evaluate with /dg-evaluate, or generate another screen."
- If WARN: "Screen has minor issues. Run
/dg-evaluate for detailed analysis, or refine with /dg-generate targeting the flagged issues."
- If FAIL: "Screen needs work. Use the suggested refinement prompt above, or run
/dg-evaluate for a full breakdown."
- Always show quota status: "Quota: Flash {used}/{limit}, Pro {used}/{limit}"
IF generating locally with Claude Code and the output is incomplete or malformed: