Communitygithub.com

style-first-web-builder

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Starts with a style consultation - detects an existing project in the working folder (or discusses a new one), suggests styles that fit the project type, and can build a live style-preview page with switchable themes before any code is written. Use for complex artifacts requiring state management, routing, or shadcn/ui components, or when the user wants to choose / compare a visual style for a web project - not for simple single-file HTML/JSX artifacts.

What is style-first-web-builder?

style-first-web-builder is a Claude Code agent skill that suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Starts with a style consultation - detects an existing project in the working folder (or discusses a new one), suggests styles that fit the project type, and can build a live style-preview page with switchable themes before any code is written. Use for complex artifacts requiring state management, routing, or shadcn/ui components, or when the user wants to choose / compare a visual style for a web project - not for simple single-file HTML/JSX artifacts.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/hoyoboy0726123/style-first-web-builder/tree/HEAD

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Style-First Web Builder

To build powerful frontend claude.ai artifacts, follow these steps: 0. 風格確認(每次載入都先做,見下方 Step 0)

  1. Initialize the frontend repo using scripts/init-artifact.sh
  2. Develop your artifact by editing the generated code
  3. Bundle all code into a single HTML file using scripts/bundle-artifact.sh
  4. Display artifact to user
  5. (Optional) Test the artifact

Stack: React 18 + TypeScript + Vite + Parcel (bundling) + Tailwind CSS + shadcn/ui

Design & Style Guidelines

VERY IMPORTANT: To avoid what is often referred to as "AI slop", avoid using excessive centered layouts, purple gradients, uniform rounded corners, and Inter font.

Step 0: 風格確認(在寫任何程式之前)

使用者在請求裡已經把風格講得很具體(配色、參考網站、明確的風格名稱)時,只用一句話複述確認,直接進 Step 1。其他情況一律先做這一步。

0-1. 判斷是哪一種狀況

快速掃描目前的工作資料夾(只讀、不改):package.json、index.html 或其他 *.html、src/、app/、pages/、README*、框架設定檔(vite / next / nuxt / astro / tailwind config)、主要的 CSS 檔。

  • 狀況 A:資料夾裡已經有專案 → 走 0-2A
  • 狀況 B:資料夾是空的或沒有前端專案 → 走 0-2B

0-2A. 已有專案

  1. 從專案內容找出:
    • 專案類型(例:活動/產品形象頁、電商、後台儀表板、教學課程、作品集、部落格、遊戲、內部工具…)
    • 首頁或主要頁面的關鍵元素:標題、導覽、主視覺、主要按鈕、卡片或表格等
    • 目前已有的品牌線索:logo、主色、字型、圖片
  2. 先告訴使用者偵測結果,一兩句就好,例如:「偵測到專案:XX(看起來是教學活動報名頁,首頁有主視覺、課程卡片、報名按鈕;目前主色是橘色)」。
  3. 用選項(有 AskUserQuestion 就用它)提出 2–3 個依專案類型量身挑的風格建議。每個選項寫清楚風格名稱、氣氛、適合的理由。如果專案已有品牌色,至少一個選項要沿用它。
  4. 最後一個選項固定是「直接做幾個樣板讓我看」(使用者另外可以自己打字描述)。
  5. 使用者選了某個風格 → 進 0-4;選「做樣板」→ 進 0-3。

0-2B. 沒有專案

  1. 跟使用者簡短討論要做什麼。一次最多問 2–3 個重點:用途或主題、給誰看、主要內容有哪些、手機為主還是電腦為主。使用者已經講過的就不要再問。
  2. 依討論結果,跟 0-2A 一樣提出 2–3 個風格建議,最後一個選項固定是「直接做幾個樣板讓我看」。
  3. 選了風格 → 0-4;選樣板 → 0-3。

0-3. 做風格樣板(視覺化比較)

目的是讓使用者「看到」而不是「想像」。要快,不要做成完整網站。

  • 內容用真的:狀況 A 用專案首頁或主要頁面的真實元素與文字(標題、導覽、主視覺區、2–3 張卡片、主要按鈕、頁尾);狀況 B 用剛才討論出的內容。不要用 Lorem ipsum。
  • 3–4 種風格:包含剛才建議的那幾種,可以再加一種對比明顯的。
  • 呈現方式(照優先順序):
    1. 同一個 HTML 檔,上方固定一排按鈕切換風格。同一份結構,每種風格是一組 CSS 變數或一個 theme class(<body data-theme="...">),按鈕即時切換,才是同一份內容的公平比較。
    2. 風格之間的版面差太多、共用結構做不出來時 → 同一個檔案用分頁(每個分頁一份獨立的版面,切換時顯示或隱藏)。
    3. 真的塞不進一個檔案(例如某個風格需要大量專屬素材或程式)時,才拆成多個 HTML,另外做一個 index.html 放連結和縮圖說明。
  • 技術:樣板只用純 HTML + CSS(必要時加少量原生 JS 做切換)。不跑 init 腳本、不裝任何套件、不連外部資源(字型用系統字型或 CSS font stack),開檔就能看。
  • 每種風格在切換列上標名稱,畫面角落用一行小字寫這個風格的重點(配色、字型、圓角或留白特色),方便使用者說「要 B 的配色加 C 的字」。
  • 遵守上面的 Design & Style Guidelines,樣板也不能有「AI 味」。
  • 存放位置:狀況 A 放在專案裡的 style-preview/index.html(不碰專案原有檔案);狀況 B 放在工作資料夾的 style-preview/index.html。
  • 給使用者看:能用 artifact 或檔案傳送工具就直接呈現;不行就用瀏覽器打開,並告訴使用者完整路徑。
  • 看完請使用者挑一個,或指定混搭(例:「B 的配色+C 的字型」)。可以再改一輪樣板,直到使用者滿意。

0-4. 定案

  1. 把定案的風格寫成一份簡短的設計規格,存在 style-preview/STYLE.md(沒有做樣板就直接建):主色、輔色、背景、文字色(hex)、字型、圓角、陰影、間距密度、按鈕與卡片的樣子、要避免的東西。
  2. 之後 Step 2 開發時,依這份規格設定 src/index.css 的 CSS 變數與 tailwind.config.js,不要退回 shadcn 預設的黑白灰。
  3. 狀況 A 時先確認做法:是在使用者原本的專案與框架裡套用新風格,還是另外用本 skill 的 React 架構做一個新的 artifact。不要擅自把使用者的專案換成另一套框架。

Quick Start

Step 1: Initialize Project

Run the initialization script to create a new React project:

bash scripts/init-artifact.sh <project-name>
cd <project-name>

注意:init-artifact.sh 與 bundle-artifact.sh 會用 pnpm 從網路安裝大量 npm 套件(沒有 pnpm 時還會 npm install -g pnpm)。執行前先告訴使用者會安裝哪些東西,並遵守使用者對安裝套件的規範。

This creates a fully configured project with:

  • ✅ React + TypeScript (via Vite)
  • ✅ Tailwind CSS 3.4.1 with shadcn/ui theming system
  • ✅ Path aliases (@/) configured
  • ✅ 40+ shadcn/ui components pre-installed
  • ✅ All Radix UI dependencies included
  • ✅ Parcel configured for bundling (via .parcelrc)
  • ✅ Node 18+ compatibility (auto-detects and pins Vite version)

Step 2: Develop Your Artifact

To build the artifact, edit the generated files. Apply the style spec from Step 0 (style-preview/STYLE.md) to the theme variables first.

Step 3: Bundle to Single HTML File

To bundle the React app into a single HTML artifact:

bash scripts/bundle-artifact.sh

This creates bundle.html - a self-contained artifact with all JavaScript, CSS, and dependencies inlined. This file can be directly shared in Claude conversations as an artifact.

Requirements: Your project must have an index.html in the root directory.

What the script does:

  • Installs bundling dependencies (parcel, @parcel/config-default, parcel-resolver-tspaths, html-inline)
  • Creates .parcelrc config with path alias support
  • Builds with Parcel (no source maps)
  • Inlines all assets into single HTML using html-inline

Step 4: Share Artifact with User

Finally, share the bundled HTML file in conversation with the user so they can view it as an artifact.

Step 5: Testing/Visualizing the Artifact (Optional)

Note: This is a completely optional step. Only perform if necessary or requested.

To test/visualize the artifact, use available tools (including other Skills or built-in tools like Playwright or Puppeteer). In general, avoid testing the artifact upfront as it adds latency between the request and when the finished artifact can be seen. Test later, after presenting the artifact, if requested or if issues arise.

Reference

Related Skills