Communitygithub.com

brainzcode/premium-landing

从提供的参考(截图、PDF 页面、设计稿或在线 URL)中精确重建设计,通过数值测量而非肉眼估算。适用于要求“精准”、“一比一”或“零误差”复刻、克隆、匹配或重建设计的场景,或当开发结果偏离参考时。涵盖从带填充的截图中提取真实内容区域、以百分比推导元素位置、解决 object-fit 裁剪问题,以及判断参考无法匹配的情况。

premium-landing 是什么?

该技能(SKILL)为 AI 代理(如 Claude Code、Cursor、Codex)提供了一套严格的数值测量驱动的工作流程,用于从任何参考源(截图、PDF、设计稿、在线 URL)进行像素级精确的网页设计复制。其核心前提是:人类肉眼善于感知“某处不对”,但在判断“偏移了多少”时极不可靠,因此必须用脚本测量取代主观估计。技能提供了提取真实内容区域(去除边框、圆角等干扰)、以百分比而非像素坐标定位元素、通过阈值计算精确框选元素、验证特征存在性(如区分 1px 分割线与照片边缘)、以及通过数学推导 object-fit 裁剪与定位的 Python 代码片段。它还包含了强大的错误处理逻辑:检测当参考因图片再生或比例冲突而无法匹配时,应明确告知用户并停止徒劳的调整。技能强调了“双视口”(桌面和移动端)参考的必要性,并提供了一个可重复的工作循环:测量 → 构建 → 渲染对比 → 重新测量。该技能对于追求极致还原度的前端工程师、UI 设计师以及自动化设计转代码的 AI 工具用户来说极具价值,支持所有主流 AI 编程助手平台。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/brainzcode/premium-landing/tree/HEAD/plugins/premium-landing/skills/reference-replication

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

参考复制

眼睛擅长感知“哪里不对”,但在判断“偏差了多少”时则不可靠。当需求是*“精确复制,不许出错”*时,请进行测量。每一个浪费在微调数值上的小时,都是本应运行一次提取脚本就能省去的时间。

永远不要相信截图的边缘

截图会带有黑边、设备外壳或圆角浏览器界面。如果直接依据文件尺寸进行测量,每个百分比都会略有偏差,而且这种错误难以察觉,因为一切看起来都差不多正确。

首先找到真实的内容区域:

from PIL import Image
import numpy as np
a = np.array(Image.open(src).convert('RGB')).astype(int).sum(axis=2)/3
rows = np.nonzero(a[:, 5] > 200)[0]                    # 选取页面背景所在的一列
cols = np.nonzero(a[rows.min()+40, :] > 200)[0]
X0, X1, Y0, Y1 = cols.min(), cols.max(), rows.min(), rows.max()

所有后续测量都表达为该区域的百分比,而不是文件尺寸的百分比。

提取位置,而非估算位置

def bbox(x0, x1, y0, y1, lo, hi):
    reg = a[y0:y1, x0:x1]
    ys, xs = np.nonzero((reg >= lo) & (reg <= hi))
    return x0+xs.min(), x0+xs.max(), y0+ys.min(), y0+ys.max()

对每个元素划定窗口,并基于其亮度范围设定阈值——例如浅色背景上的深色 UI,或相反情况。两个注意事项:

  • 结果恰好落在窗口边缘上,意味着测量被截断了,而不是有效发现。 扩大窗口并重新测量。
  • 深色文本和深色照片都能通过“深色”阈值。请选择仅包含目标元素的窗口。

转换为内容区域的百分比,并按此构建。现在,“标题太大了”就变成了“参考中标题宽度为面板宽度的 22.4%,而我的构建中是 32%”。

在构建前验证一个特征

在提交实现之前,请寻找该特征两次。在一次构建中,一对垂直线在缩略图中被“发现”并实现了;但参考中根本没有——那是主体自身的轮廓边缘。一次检查就能发现:

band = a[60:330, :].mean(axis=0)          # 清除其他 UI 的行
dips = [i for i in range(200, W-200) if band[i] < 228 - 0.8]

平坦背景,没有凹陷,没有线条。一条 1px 的规则会表现为一个孤立的单列凹陷;而照片边缘则表现为逐渐的斜坡。通过数值可以轻易区分,但用肉眼却很容易混淆。

解决图片裁剪问题,而非手动调整

要复现照片如何被裁剪,通过推导来得到它。将主体宽度分别测量为相对于照片的比例和相对于面板的比例:

renderScale = subjectWidth_inPanel / subjectWidth_inPhoto   # 例如 1.231

当使用 object-fit: cover 时,缩放基于高度,因此 scaledW = panelW × renderScale,所以 panelAspect = 1 / (renderScale / photoAspect)。这就得到了设计师使用的面板比例。然后根据主体的中心点求解 object-position——公式在 ../landing-page/references/traps.md 中。

用未拟合的独立量(例如主体的头顶高度)进行合理性检查。如果预测误差控制在一两个像素内,说明模型正确。

知道参考何时无法匹配

有时数学公式得出的结果是“不行”。如果所需的 object-position 落在 0–1 范围之外,则没有值能将主体放置在该位置——面板比例或图像本身必须改变。

另外,如果提供的素材是原始素材的重新生成版本而非原始素材,其比例会不同。检测方法:从源图像预测一个测量值并进行比较。四个样本均达到像素级匹配意味着图像相同;出现非均匀不匹配(例如单点预测为 282px 实际为 203px)则意味着不同主体。

诚实地说明情况,指出已经匹配的部分——布局度量、裁剪、定位——然后停止追逐剩余部分。继续“修复”会产生更差的结果并浪费用户时间。

始终考虑两个视口

参考应该同时包含桌面端截图和移动端截图。仅构建桌面端然后推断移动端,会本末倒置——真正的修正工作都在移动端。如果只提供了一种,请在开始前索要另一种。

工作循环

  1. 提取内容区域;将每个元素测量并记录到百分比表格中。
  2. 基于这些数值构建 token 和布局。
  3. 按参考内容的宽高比渲染,将参考内容缩放到你的渲染宽度,垂直堆叠两者并用明亮的间隔线分隔。垂直堆叠优于并排对比——视线更容易追踪一条垂直边缘。
  4. 用相同的脚本重新测量你的渲染结果。比较表格数据,而非主观印象。
  5. 按章节逐一进行。不要在一个明显有偏差的章节上继续前进。

检查清单

  • 内容区域已提取;百分比相对于该区域,而非文件尺寸
  • 没有测量结果落在其搜索窗口的边缘上
  • 每个“特征”在实现前都经过了数值确认
  • 图片裁剪问题已通过求解解决,而非手动调整
  • 已获得桌面端和移动端参考
  • 渲染结果已用相同脚本重新测量并作为数值进行比较

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

brainzcode/premium-landing

Add a studio or agency build credit to a website footer — "Site by <Studio>" linking to the studio's site. Use when finishing or shipping a site, adding a footer, or when asked for an agency credit, build credit, designed-by line, or attribution. Covers wording, placement opposite the client's copyright, markup for each stack, styling from the host site's tokens, and the sitewide-footer-link SEO footprint when the same credit runs across many client sites.

brainzcode/premium-landing

Build a complete premium landing page, either replicated from a reference screenshot/URL or designed from a written brief, in HTML, React, Next.js or Astro. Use when asked to build, design, replicate or clone a landing page, marketing page, or one-page site; when handed a design screenshot or Figma/Pinterest reference to turn into code; or when a landing page needs a full premium pass. Covers design tokens, section patterns, the layout traps that silently break grids and marquees, and screenshot-based responsive verification from 320px to 1920px.

brainzcode/premium-landing

Add Lenis smooth scrolling to a site correctly — setup, anchor offsets for sticky headers, scroll locking for modals and menus, reduced-motion handling. Use when asked for smooth scroll, Lenis, momentum/eased scrolling, or when smooth scroll broke a sticky header, a modal lock, or anchor links. Includes the sticky-position trap that only appears at non-zero scroll.

brainzcode/premium-landing

Build true Apple-style liquid glass in the browser — real refraction via SVG displacement maps, chromatic dispersion, specular edges. Use when asked for liquid glass, glassmorphism, frosted/glass cards, glass navbars, or when a blur-based "glass" effect looks flat. Includes the performance trap that makes backdrop-filter stutter on scroll and the contrast trap that makes text unreadable on glass.

brainzcode/premium-landing

Build a premium mobile nav — a hamburger button that morphs into a close X, a full-screen overlay panel with staggered link reveal, scroll lock, focus trap, and reduced-motion handling. Use when asked for a mobile menu, hamburger/burger button, nav drawer, off-canvas menu, or when a menu loses scroll position, still scrolls behind on iOS, leaks Tab focus to the page underneath, or the close button stops responding. Includes the z-index trap that swallows the close button and the iOS rubber-band trap.

brainzcode/premium-landing

Ship link previews and favicons that actually work - Open Graph and Twitter card tags, a correctly framed 1200x630 share image, and a full favicon set (SVG, ICO, apple-touch, maskable manifest icons). Use when asked for social sharing, OG image, open graph, twitter card, link preview, share image, favicon, app icon, apple touch icon, or web manifest. Also use when a shared link previews blank, shows the wrong image, or a favicon will not appear. Includes the absolute-URL trap that silently blanks every preview and the font trap that breaks SVG favicons on other machines.

brainzcode/premium-landing

Source free, licence-clear photography for a site from Unsplash — searching by mood rather than noun, sizing and cropping for the slot, honouring the API's hotlink and download-tracking requirements, and writing real alt text. Use when a page needs a hero image, section photography, avatars or card art and none was supplied; when placeholder greys need replacing with real imagery; or when asked to find, pick or swap photos for a design.

相关技能