Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

screenshot-to-code

БесплатноБез исполняемых скриптовНе проверен

screenshot-to-code is a self-hosted web app that turns a screenshot, mockup or short screen recording into HTML, Tailwind, React, Vue, Bootstrap or Ionic code…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

screenshot-to-code — turn a UI image into working front-end code

Overview

The repository (MIT licensed, no tagged releases, so pin a commit) has two parts: a FastAPI backend in backend/ that calls the model providers, and a React + Vite frontend in frontend/ where you drop an image, pick a stack and watch the code stream in. Each request produces several variants (four for image input, two for video) so you can compare models.

Supported stacks, as the backend accepts them: html_tailwind, html_css, react_tailwind, vue_tailwind, bootstrap, ionic_tailwind. Input modes are image, video and text. Generation costs money on your provider account, and the backend enforces a per-generation spend ceiling of 3 USD (GENERATION_MAX_COST_USD in backend/config.py).

A hosted version exists at screenshottocode.com; this skill is only about running the open-source code yourself.

Instructions

1. Get the code at a pinned commit

git clone --depth 1 https://github.com/abi/screenshot-to-code.git
cd screenshot-to-code
git rev-parse HEAD

Record the printed commit hash in your project notes so the setup is reproducible.

2. Create the keys file

The backend reads backend/.env. Only one of the three model keys is required:

Variable Needed Effect
OPENAI_API_KEY one of three GPT code generation
ANTHROPIC_API_KEY one of three Claude code generation
GEMINI_API_KEY one of three, recommended Gemini generation, asset extraction from the screenshot, required for video input
REPLICATE_API_KEY recommended image generation, background removal, image editing
OPENAI_BASE_URL optional OpenAI-compatible proxy, must end in /v1

Write the file with your editor from keys you created in each provider's console. Never commit .env. You can also paste keys into the frontend settings dialog (gear icon) instead; REPLICATE_API_KEY is the exception and must be in backend/.env.

3. Run the backend

cd backend
poetry install
poetry run playwright install chromium
poetry run python start.py --host 127.0.0.1 --port 7001

start.py binds to 127.0.0.1 by default and picks the next free port if 7001 is taken (it prints the port it chose). The upstream README runs poetry run uvicorn main:app --reload --port 7001, which works the same (uvicorn also binds to 127.0.0.1 by default).

Chromium is optional: it enables a screenshot-preview tool that lets the model look at its own generated page. Without it the app still works.

Check that it is up:

curl -s http://127.0.0.1:7001/
curl -s http://127.0.0.1:7001/api/capabilities

The first returns an HTML line saying the backend is running; the second returns {"screenshot_preview":false} until Chromium is installed.

4. Run the frontend

cd ../frontend
pnpm install
pnpm dev --host 127.0.0.1

Open http://127.0.0.1:5173. The repository's vite.config.ts sets host: true, so a plain pnpm dev listens on all interfaces; the flag keeps it on loopback. By default the dev server proxies /generate-code and /api to http://127.0.0.1:7001. If the backend runs on another port, create frontend/.env.local with VITE_WS_BACKEND_URL=ws://127.0.0.1:7002 and VITE_HTTP_BACKEND_URL=http://127.0.0.1:7002, then restart the dev server.

5. Docker alternative

printf 'OPENAI_API_KEY=%s\n' "$OPENAI_API_KEY" > .env
docker compose up -d --build

The compose file builds both services, reads the root .env, publishes the backend on ${BACKEND_PORT:-7001} and the frontend on 5173. It publishes on all interfaces and rebuilds are manual, so it is for running, not developing. On a shared host change the ports entries to 127.0.0.1:7001:7001 and 127.0.0.1:5173:5173.

6. Script the backend

Generation runs over a WebSocket at /generate-code, not a REST call. The first message is a JSON object:

import asyncio, base64, json, pathlib, websockets

async def generate(png_path: str, stack: str = "html_tailwind") -> list[str]:
    data_url = "data:image/png;base64," + base64.b64encode(pathlib.Path(png_path).read_bytes()).decode()
    request = {
        "generatedCodeConfig": stack,
        "inputMode": "image",
        "generationType": "create",
        "prompt": {"text": "", "images": [data_url], "videos": []},
        "history": [],
    }
    variants: dict[int, str] = {}
    async with websockets.connect("ws://127.0.0.1:7001/generate-code", max_size=None) as ws:
        await ws.send(json.dumps(request))
        async for raw in ws:
            msg = json.loads(raw)
            if msg["type"] == "setCode":
                variants[msg["variantIndex"]] = msg["value"]
            elif msg["type"] in ("error", "variantError"):
                raise RuntimeError(msg["value"])
    return [variants[i] for i in sorted(variants)]

pages = asyncio.run(generate("pricing-page.png", "react_tailwind"))

Messages the server sen

Полный SKILL.md на GitHub

Установить screenshot-to-code в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл screenshot-to-code?

screenshot-to-code is a self-hosted web app that turns a screenshot, mockup or short screen recording into HTML, Tailwind, React, Vue, Bootstrap or Ionic code using a multimodal LLM. Use it when a user asks to "turn this screenshot into code", "clone this UI from an image", "run screenshot-to-code locally", "self-host a screenshot to HTML tool", or "generate a React component from a mockup". It needs an OpenAI, Anthropic or Gemini API key that the user supplies; the skill covers setup, configuration and scripting the backend.

Как установить скилл screenshot-to-code?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл screenshot-to-code запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить screenshot-to-code с