reconstructing-ui-from-screenshots
Use when implementing or correcting an app or web UI from a design image, screenshot, mockup, or reference PNG where accurate size, spacing, color, typography, assets, and alignment matter.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- reconstructing-ui-from-screenshots
- description
- Use when implementing or correcting an app or web UI from a design image, screenshot, mockup, or reference PNG where accurate size, spacing, color, typography, assets, and alignment matter.
02 资源文件 2
- 参考文档requirements.txt36 B
- 脚本scripts/analyze_ui_image.py29.1 KB
03 SKILL.md 正文
Reconstructing UI from Screenshots
Overview
Choose the shortest evidence path that can produce a correct edit. Measure only values that affect the implementation.
Workflow
1. Define the Change
Inspect the reference, target view, and direct dependencies. Record the changed region, unchanged anchors, and material unknowns.
Use the fast path for one component or section in an existing screen. Use the mapping path for a new/full screen, coupled regions, unknown crop origin, or absolute screenshot coordinates.
2A. Fast Path — Local Change
Reuse existing constraints, tokens, components, fonts, and assets. Record three to five inputs: container bounds, inset or gap, alignment, text style, color, or asset behavior.
Global viewport and DPR are unnecessary when values come from existing anchors, tokens, or relative relationships. Once these inputs distinguish the implementation, edit immediately. Use the nearest project value for low-impact ambiguity.
Do not run the analyzer merely to satisfy the workflow.
2B. Mapping Path — Full Reconstruction
Resolve viewport from runtime/project configuration, design specifications, or capture metadata. Image dimensions alone never prove viewport or DPR.
Run at most one analyzer command before the first edit:
python3 <skill_path>/scripts/analyze_ui_image.py reference.png \
--viewport 375x812 \
--json reference-report.json --annotated reference-boxes.png
Run --help for crops and ROI. Install dependencies only after ModuleNotFoundError. Confirmed mapping leads directly to recording major geometry and editing; blocked mapping leads to one focused question. Never replace an inaccurate result with chained ad-hoc Python scans.
3. Implement the First Pass
Correct geometry and assets first, then text, spacing, colors, and effects. Preserve unaffected behavior. Reconsider a settled value only when new evidence contradicts it.
4. Precision Pass
For each visible, code-relevant mismatch, make one targeted measurement or focused --roi run, then edit. Do not rescan anti-aliasing noise or infer fonts from text pixels; use project definitions.
Stop when no high-impact visible mismatch remains. Do not complete unrelated checklist entries.
5. Verify
Check overflow, clipping, missing assets, and essential interactions. Run formatting, static analysis, and the smallest relevant build. Use image diff only when requested or already available.
Analysis Budget
| Situation | Evidence before first edit | Analyzer budget |
|---|---|---|
| Existing local component | 3–5 relevant inputs | None by default |
| New or full-screen layout | Mapping plus major regions | One run |
| Visible mismatch after implementation | One decision-specific measurement | One focused run |
Analyzer regions and shapes are candidates, not ground truth. Sample solid interiors, not anti-aliased edges. Device DPR remains unconfirmed unless independently sourced. Require confirmed mapping only before converting absolute image pixels to logical layout constants.
Common Mistakes
- Proving viewport, Safe Area, or system bars for a local component replacement.
- Writing temporary pixel-scanning scripts instead of making the edit.
- Measuring the same value repeatedly without contradictory evidence.
- Treating image scale as DPR or detector candidates as final semantics.
Output
Report implementation changes, material assumptions, and code-check results.
04 同仓库更多 Skills
question-answer
Use when the user wants a read-only explanation of existing code behavior, architecture, control flow, data flow, dependencies, or implementation decisions and has not requested project changes.
java-to-swift
Use when converting Java 1.8 classes to Swift 5.0+ Codable structs - handling type mapping, nullability, inheritance flattening, BaseReq exclusions, and property naming conventions.
java-to-nextjs
Use when converting Java 1.8 classes to Next.js TypeScript interface definitions - handling type mapping, nullability, inheritance, naming conventions, and BaseReq/BaseResponse exclusions.
ios-i18n-workflow
Use when iOS apps using SwiftGen L10n need localization work - adding keys, checking missing translations, or cleaning unused entries. Triggered by hardcoded strings, missing L10n references, incomplete translations across multiple languages, or unused localization cleanup requests.
improve-codebase-architecture
Use when the user wants architectural deepening opportunities for a codebase or named files, shown as a visual HTML report, and when they then pick candidates from that report to implement in the code already reviewed.
handoff
Use when the user asks to create a handoff, session summary, context compact, continuation note, 交接文档, 压缩上下文, or instructions for the next agent to resume work later.