Communitygithub.com

brainzcode/premium-landing

根據提供的參考(截圖、PDF 頁面、模型或線上網址)精準重建設計,採用數值測量而非肉眼比對。適用於需要「完全一致」、「1:1 複製」或「零錯誤」複製、克隆、匹配或重建設計的情況,或當建構結果偏離參考時。涵蓋從有邊框的截圖中提取真實內容框、將元素位置轉換為百分比、解決 object-fit 裁切問題,以及判斷何時無法匹配參考。

premium-landing 是什麼?

這項技能是為 AI 代理(如 Claude Code、Cursor 等)設計的,用於從任何參考(截圖、PDF、模型或 URL)進行高精度、像素級別的設計複製。它解決了肉眼測量的根本不可靠性:人類善於感知「有問題」,但無法準確判斷「偏差多少」。該技能提供了一種基於 Python(PIL/NumPy)的系統性方法,用於從可能包含邊框或瀏覽器 chrome 的截圖中提取真實的內容框,然後以該框的百分比計算所有元素位置,確保比率精確。它超越了簡單的「對齊」;它涵蓋了驗證設計特徵(例如區分 1px 分隔線與照片邊緣)、通過計算推導出影像裁切(object-fit cover 和 position)的求解,以及計算上判斷何時給定的資源無法滿足參考要求(例如,當所需的 object-position 超出有效範圍 0–1 時)。該技能還強調工作流程紀律:始終同時使用桌面和行動參考,比較數值表格而非視覺印象,並按區塊逐步迭代。其實現語言為 Python,依賴 PIL 和 numpy 進行影像處理。

相容平台~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 的新對話。

說明文件

參考複製

眼睛擅長察覺「有哪裡不對勁」,但無法可靠判斷「差了多少」。當需求是「完全複製,不許有錯誤」時,就必須進行測量。每小時花在微調數值上的時間,其實用一個提取腳本早就解決了。

絕不信任截圖的邊緣

截圖經常帶有信箱黑邊、裝置外框,或是圓角的瀏覽器 chrome。如果直接用檔案尺寸進行測量,每個百分比都會稍微偏差,而這種誤差幾乎看不見,因為一切都「差不多」正確。

請先找出真正的內容框:

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 元件的行
# 檢查 200 到 W-200 之間是否有低於 228 - 0.8 的峰值
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.

相關技能