glm-design-to-code — vision to frontend code

vision opus

Caution

GLM-5V-Turbo is an external vision API — not Claude. The skill calls Z.ai or OpenRouter directly. You need a ZAI_API_KEY or OPENROUTER_API_KEY before the first run. On first use, the skill walks you through key validation and storage interactively.

Tip

GLM-5V-Turbo scores 94.8 on the Design2Code benchmark — outperforming general-purpose multimodal models for pixel-accurate frontend generation. Average cost per conversion: ~$0.03 with glm-5v-turbo, or free with glm-4.6v-flash for development iterations.

Quick reference

FieldValue
Command/brewui:glm-design-to-code
ModesCREATE (default), REVIEW, FIX
Input typesImage file, text description, HTML file, URL (auto-detected)
Frameworkshtml (default), react, flutter, custom
Quality profilesmax (32K tokens), optimal (16K), efficient (8K)
Providerszai (default, Z.ai direct), openrouter
Modelopus (Claude orchestrates) + GLM-5V-Turbo (vision API)

When to use

  • Screenshot to code — export a Figma frame or take a browser screenshot, get working HTML/CSS in seconds
  • Mockup to React — convert a design file to component-based JSX with CSS Modules
  • Flutter UI — generate Dart widget hierarchy from any visual reference
  • Clone a live page — pass a URL and Playwright auto-screenshots before conversion
  • Iterative improvement — REVIEW scores the generated result 1-10, FIX applies targeted edits

Examples

# Image → HTML/CSS (default)
/brewui:glm-design-to-code screenshot.png
# Image → React with optimal quality
/brewui:glm-design-to-code mockup.png --framework react --profile optimal

# Text description → Flutter
/brewui:glm-design-to-code "Dark dashboard with sidebar and data tables" --framework flutter
# URL → HTML (Playwright auto-screenshots)
/brewui:glm-design-to-code https://example.com/landing

# Review generated result against original design
/brewui:glm-design-to-code --review original.png result-screenshot.png

# Fix issues from a previous review
/brewui:glm-design-to-code --fix "sidebar too narrow, wrong green color #3a9"

Modes

ModeTriggerWhat it does
CREATEDefault (no flag)Converts input to multi-file frontend code, builds, verifies with Playwright screenshot
REVIEW--review original.png result.pngSends both images to GLM for visual diff, returns score 1-10 with actionable feedback
FIX--fix "feedback" or --fix --review-file review.jsonApplies targeted edits to existing generated code without regenerating

Flow

  1. Parse and classify

    Arguments are parsed for input type (image / text / HTML / URL), framework, profile, provider, and mode. Input type is auto-detected from file extension or URL pattern. For ambiguous HTML input, the skill asks one clarifying question.

  2. API key setup (first run only)

    Checks for ZAI_API_KEY or OPENROUTER_API_KEY. If missing, asks for a key, validates it against the real API using a cheap test call, then saves to .env (gitignored). Offers to persist to CLAUDE.local.md or ~/.zshrc.

  3. Prepare input

    Images are base64-encoded. URLs are screenshotted via Playwright (npx playwright screenshot). HTML files are optionally screenshotted for dual input (image + source). Text descriptions go directly into the request body.

  4. Send to GLM vision API

    Payload is built with the quality profile prompt, framework context, and user intent instruction. Sent to glm-5v-turbo via Z.ai or OpenRouter with a 10-minute timeout. Before every API call, the resolved configuration table is printed so you always see what was sent.

  5. Extract and build

    Response is parsed for ===FILE: path=== markers. Files are written to ./d2c-output/. Framework-appropriate build runs: npm run build for React, flutter build web for Flutter, no build for HTML. Auto-fix loop (max 3 attempts) corrects compilation errors — layout and colors are never touched.

  6. Verify with Playwright

    The output is served locally and screenshotted. Screenshot is read and checked for blank pages. Server is killed after capture. Final report lists all files, build status, and cost estimate.

Provider matrix, models, and API internals

Providers

ProviderEndpointAuth variableNotes
Z.ai (default)https://api.z.ai/api/paas/v4/chat/completionsZAI_API_KEYSystem message caching — 80% discount on repeated prompts
OpenRouterhttps://openrouter.ai/api/v1/chat/completionsOPENROUTER_API_KEYModel IDs prefixed with z-ai/ (e.g. z-ai/glm-5v-turbo)

GLM models

ModelVisionPrice (in/out per 1M)ContextBest for
glm-5v-turboImage + Video$1.20 / $4.00202KProduction quality
glm-4.6v-flashImageFree131KDevelopment iterations
glm-4.6vImage + Video$0.30 / $0.90131KBudget production

Quality profiles

ProfileMax tokensQuality requirementsTypical cost
max (default)32 76813 — pixel-perfect colors, spacing, typography~$0.05–0.08
optimal16 3848 — correct proportions, balanced detail~$0.03–0.05
efficient8 1924 — basic layout and colors~$0.01–0.03

API parameters

  • temperature: 0.2, top_p: 0.85 — low randomness for reproducible output
  • File markers: ===FILE: path======END_FILE===
  • Thinking mode is NOT supported on glm-5v-turbo — never send thinking parameters
  • System message: quality profile prompt; user message: context + image + intent instruction

Benchmark results (internal research)

FrameworkScoreFilesBuild timeCost
HTML/CSS9.5/103N/A~$0.032
React 188.0/1019Vite 218ms~$0.035
Flutter Web9.0/1010flutter build web~$0.032

Same mockup, frozen prompts, temperature 0.2, dual evaluation by Claude Opus + GLM-4.6v-flash.

🖼️

Image Gen

Generate images via 5 AI providers with anti-slop controls. Pairs well with design-to-code for full visual workflows.

📄

Brewui overview

All brewui skills — image generation and design-to-code in one plugin.

🔗

GitHub source

Source code, scripts, and quality profile prompt files.

Updating plugins

Use /brewtools:plugin-update to check and update the brewcode plugin suite in one command. See the FAQ for details.