Logo Dg Generate

Dg Generate

Cộng đồng
FReptar0
dg-generate

Tạo màn hình bằng Google Stitch hoặc Claude Code từ mô tả bằng văn bản. Dùng khi người dùng muốn tạo trang web, trang đích, bảng điều khiển, trang giá, trang giới thiệu hoặc bất kỳ thiết kế giao diện nào. Cũng dùng khi người dùng nói “thiết kế một trang”, “tạo một màn hình” hoặc “xây dựng một trang web”. Cần có DESIGN.md để đảm bảo tính nhất quán về hình ảnh — nếu thiếu tệp này, sẽ không tạo giao diện.

Add to TypingMind

Tổng quan

Nhà phát hànhFReptar0
Kho mãdesign-guard
Tên kỹ năngdg-generate
Sao
12
Bản fork
4
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được FReptar0 công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Dg Generate trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/FReptar0/design-guard/tree/main/.claude/skills/dg-generate
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/FReptar0/design-guard.git /tmp/design-guard
mkdir -p .claude/skills
cp -r /tmp/design-guard/.claude/skills/dg-generate .claude/skills/dg-generate
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Dg Generate trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Dg Generate ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Dg Generate với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Generate a screen from a description using the configured generator (Stitch or Claude Code).

Guardrails (MUST follow)

Before sending any prompt to Stitch:

  1. Verify prompt is under 5000 characters
  2. Verify prompt targets ONE screen only (not multiple pages)
  3. For refinements: verify ONE change only (not compound changes)
  4. Reject vague requests ("make it better", "improve it") — ask for specifics
  5. Check quota before generating: read .guardrc.json to see current usage
  6. DESIGN.md is required — step 1 blocks generation if missing
  7. Flag generic terms ("modern", "clean", "professional") and suggest specific UI/UX vocabulary replacements (e.g., "asymmetric hero layout", "bento grid", "sticky nav with CTA")

Instructions

  1. 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?

        1. Claude Code (recommended) -- Generates HTML locally. Anti-slop rules from .claude/rules/ are enforced during generation. Best for design-system compliance.
        2. 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."

  2. 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.
  3. 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"
  4. 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]
    ...
  5. 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
  6. After generation, retrieve the screen code and save the HTML to screens/[screen-name].html.

  7. 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.
  8. 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.
  9. For refinements, use this structure (one change at a time):

    On the [specific section] of [screen name], [specific change]:
    - [Detail 1]
    - [Detail 2]
  10. 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:

    1. Build the prompt for screen N
    2. Generate screen N (Stitch or Claude)
    3. Save to screens/
    4. Run the critic on screen N
    5. Fix any issues the critic flags
    6. 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..."

  11. For variants, offer to call mcp__stitch__generate_variants to produce 2-3 alternative designs the user can compare before committing to one direction.

  12. For inline edits to an existing screen, use mcp__stitch__edit_screens instead of regenerating from scratch.

  13. 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}"

Error Handling

Stitch Timeout Recovery

IF a Stitch MCP call (mcp__stitch__generate_screen_from_text) times out, hangs, or returns an error:

  1. Do NOT silently switch to Claude Code generation. The user chose Stitch and must be informed.
  2. Auto-check if the screen completed server-side: Stitch often completes generation even when the MCP response times out. Immediately call mcp__stitch__list_screens to check if the screen was created despite the timeout.
    • IF the screen IS found: download it via mcp__stitch__get_screen and get_screen_code, save to screens/, and tell the user: "Stitch timed out but the screen completed server-side. Downloaded to screens/[name].html." Proceed to the critic step as normal.
    • IF the screen is NOT found: continue to step 3.
  3. Tell the user exactly what happened: "Stitch MCP timed out while generating [screen name] and the screen was not completed server-side."
  4. Offer options (do NOT pick one silently):
    • "Would you like me to generate this screen locally with Claude Code instead? (Anti-slop rules will be enforced during generation.)"
    • "Or run /dg-sync later to check again if it appears."
  5. Generate locally with Claude Code ONLY if the user explicitly agrees.
  6. NEVER:
    • Retry the Stitch call (the timeout suggests a server-side issue)
    • Send parallel requests to Stitch
    • Generate locally without asking
    • Pretend the timeout didn't happen

Claude Code Generation Errors

IF generating locally with Claude Code and the output is incomplete or malformed:

  1. Tell the user what went wrong.
  2. Offer to retry generation.
  3. Do NOT switch to Stitch as a fallback.

Reference: See docs/prompting-guide.md for examples and strategies.

Câu hỏi thường gặp

Kỹ năng AI Dg Generate làm được gì?

Tạo màn hình bằng Google Stitch hoặc Claude Code từ mô tả bằng văn bản. Dùng khi người dùng muốn tạo trang web, trang đích, bảng điều khiển, trang giá, trang giới thiệu hoặc bất kỳ thiết kế giao diện nào. Cũng dùng khi người dùng nói “thiết kế một trang”, “tạo một màn hình” hoặc “xây dựng một trang web”. Cần có DESIGN.md để đảm bảo tính nhất quán về hình ảnh — nếu thiếu tệp này, sẽ không tạo giao diện.

Vì sao nên dùng Dg Generate trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Dg Generate là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Dg Generate trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/FReptar0/design-guard/tree/main/.claude/skills/dg-generate. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Dg Generate?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Dg Generate với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Dg Generate với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Dg Generate có miễn phí không?

Có. Kỹ năng này được FReptar0 phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇