← 返回 Skills 市场
wangjipeng977

Ai Image To Code

作者 王继鹏 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
53
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install skill-factory-image-to-code
功能描述
Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild t...
使用说明 (SKILL.md)

AI Image to Code

Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild this UI", "code this design", or "generate HTML from screenshot". (3) user pastes an image and says "write the React component for this".

Core Position

This skill solves the specific problem of: a visual UI mockup needs to become actual runnable frontend code — not just a description, but a working implementation.

This skill IS NOT:

  • An image generation tool — it converts existing images to code, not creates images
  • A design tool — it interprets and codes a design, not create the design
  • A backend integration tool — it outputs HTML/CSS/JS, not server code

This skill IS activated ONLY when: image (screenshot/mockup) + code generation intent are both present.

Modes

/ai-image-to-code

Default mode. Converts a UI image into a complete HTML/CSS implementation.

When to use: User provides a screenshot and wants a working HTML page that resembles it.

/ai-image-to-code/react

Outputs a React functional component using Tailwind CSS.

When to use: User explicitly asks for React or a component, not a plain HTML page.

/ai-image-to-code/describe

Provides a detailed text description of the layout without writing code.

When to use: User only wants to understand the layout before committing to code generation.

Execution Steps

Step 1 — Analyze the Image

  1. Receive image (pasted, file attachment, or URL)
  2. Use vision model to inspect the image and extract:
    • Layout structure (header, sidebar, main content, footer)
    • Color palette (primary, secondary, background, text, accent)
    • Typography (headings, body, labels — size and weight hierarchy)
    • Spacing system (padding, margins, gaps)
    • Component types (buttons, inputs, cards, lists, navigation)
    • Visual hierarchy (what stands out, what recedes)
  3. If the image is complex (>10 distinct UI sections), focus on the main content area

Step 2 — Plan the Code Structure

Image Content Recommended Output
Landing page Single HTML with embedded CSS
Dashboard HTML + CSS grid layout
Mobile app screen Mobile-first responsive HTML
Form / login page Semantic HTML form with proper inputs
Card / list UI Component-based HTML with classes
Chart / data visualization SVG or canvas-based rendering

Step 3 — Generate Code

HTML/CSS output (default):

\x3C!DOCTYPE html>
\x3Chtml lang="en">
\x3Chead>
  \x3Cmeta charset="UTF-8">
  \x3Cmeta name="viewport" content="width=device-width, initial-scale=1.0">
  \x3Ctitle>UI\x3C/title>
  \x3Cstyle>
    /* Extracted colors, typography, spacing from image */
  \x3C/style>
\x3C/head>
\x3Cbody>
  \x3C!-- Structure matching the image layout -->
\x3C/body>
\x3C/html>

React + Tailwind (react mode):

export function UICard() {
  return (
    \x3Cdiv className="p-6 bg-white rounded-xl shadow-sm">
      {/* Component matching image */}
    \x3C/div>
  );
}

Step 4 — Validate

  • Key layout sections (header, main, sidebar) are present
  • Colors are within ±10% of the original image (subjective match)
  • No invented content — placeholder text is generic ("Card title", not specific brand names)
  • HTML is valid (proper tag nesting, no unclosed tags)

Mandatory Rules

Do not

  • Do not invent brand names, specific product names, or proprietary text not visible in the image
  • Do not claim the output is pixel-perfect — it is an interpretation
  • Do not generate backend code, JavaScript logic, or API calls
  • Do not reproduce copyrighted UI elements (logos, icons) — use generic equivalents

Do

  • Use placeholder text that fits the context (e.g., "Search..." for a search bar)
  • Preserve the visual hierarchy (primary > secondary > tertiary)
  • Use realistic placeholder data for images (e.g., via placeholder.com or picsum)
  • State explicitly: "This is an approximation; fine-tune colors and spacing as needed"

Quality Bar

A good output:

  • All major layout regions are present and positioned correctly
  • Color palette is recognizably derived from the image
  • Typography hierarchy matches (heading size > body size)
  • Code is valid, runnable HTML/CSS without external dependencies beyond a CDN

A bad output:

  • Layout is scrambled or missing major sections
  • Output includes broken or unclosed HTML tags
  • Fabricated text content not appropriate to the UI context
  • Output requires non-free dependencies or local asset files

Good vs. Bad Examples

Scenario Bad Output Good Output
E-commerce product card Generic lorem ipsum text "Price: $49.99 — Add to Cart" contextually appropriate
Dark mode UI Ignores dark theme Uses dark background, light text, correct contrast
Mobile screenshot Desktop-only output max-width: 375px container, mobile-first
Complex dashboard One undifferentiated div Grid layout with sidebar, header, main panels

References

  • references/ — Color extraction heuristics, layout structure patterns, Tailwind class mapping guide
安全使用建议
Reasonable to install if you want an agent to turn UI screenshots into approximate frontend code. Review generated code before using it, and avoid feeding screenshots that contain private data, copyrighted branding, or non-UI images unless you intend the agent to analyze them.
能力评估
Purpose & Capability
The artifacts consistently describe converting user-provided UI screenshots or mockups into HTML/CSS, React/Tailwind components, or a layout description, and explicitly exclude backend code, API calls, image generation, and proprietary content invention.
Instruction Scope
The activation wording is somewhat broad around screenshots/images plus code-generation intent, but it remains tied to UI-to-code work and includes limits on output behavior.
Install Mechanism
Installation is a normal ClawHub install or manual copy into the OpenClaw skills directory; no automatic installer, package execution, privileged setup, or hidden install behavior is present.
Credentials
The skill only needs the image the user provides and normal code-generation context; it does not request credentials, local profile/session stores, broad filesystem access, or external service authority.
Persistence & Privilege
No background workers, startup hooks, durable state, privilege escalation, destructive commands, or mutation of user data are instructed by the skill.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install skill-factory-image-to-code
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /skill-factory-image-to-code 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug skill-factory-image-to-code
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Ai Image To Code 是什么?

Use when (1) user provides a UI screenshot or image and asks to convert it into HTML, CSS, or component code. (2) user says "turn this into code", "rebuild t... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 53 次。

如何安装 Ai Image To Code?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install skill-factory-image-to-code」即可一键安装,无需额外配置。

Ai Image To Code 是免费的吗?

是的,Ai Image To Code 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Ai Image To Code 支持哪些平台?

Ai Image To Code 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Ai Image To Code?

由 王继鹏(@wangjipeng977)开发并维护,当前版本 v1.0.0。

💬 留言讨论