Communitygithub.com

brainzcode/premium-landing

提供された参照画像(スクリーンショット、PDF、モックアップ、ライブURLなど)からデザインを数値的に測定し、正確に再構築します。「完全に」「1対1で」「ミスなく」再現する際に使用します。

premium-landing とは?

このスキルは、AIエージェント(Claude Code、Cursor、Codexなど)がUIデザインを参照画像から「目視」ではなく「数値計測」に基づいて正確に複製するための手法を提供します。人間の目は「何かがおかしい」と感じることは得意ですが、「どのくらいずれているか」を正確に判断するのは苦手です。このスキルは、この弱点を補うために、Pythonスクリプトを用いて画像から要素の位置、サイズ、フレーミングを割合で抽出し、その数値に基づいてコードを生成することを推奨します。スクリーンショットの余白(レターボックス、デバイスフレーム、ブラウザの角丸など)を自動的に除去する「コンテンツボックス抽出」、要素のバウンディングボックスを輝度閾値で検出する手法、`object-fit: cover` を使用した画像のフレーミングを数値的に解決する方法、そして参照画像が複製不可能な場合の判断基準を提供します。デスクトップとモバイルの両方のビューポートを常に扱い、構築後に同じスクリプトで再計測して数値比較を行う反復プロセスを重視します。

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

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

参照複製

人間の目は「何かがおかしい」と感じることは得意ですが、「どのくらいずれているか」を正確に判断するのは苦手です。要件が 「完全に複製すること、ミスは許されない」 という場合、数値で測りましょう。値を微調整して失った時間は、たった一つの抽出スクリプトがあれば終わっていた時間です。

スクリーンショットの端を決して信用しない

スクリーンショットは、レターボックス(黒帯)が付いていたり、デバイスフレームに入っていたり、ブラウザの角丸がついていたりして届きます。その状態でファイルの寸法に対してパーセンテージを測ると、すべてのパーセンテージがわずかにずれます。そして、その誤差は目に見えません。なぜなら、すべてが ほぼ 正しいからです。

まず、本当のコンテンツボックスを見つけます:

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、またはその逆です。2つの注意点:

  • 結果がちょうどウィンドウの端に来た場合、それは発見ではなく、クリップされた計測値です。 ウィンドウを広げて再計測してください。
  • 暗いテキストと暗い写真は、どちらも「暗い」閾値を通過します。要素のみを含むウィンドウを選択してください。

これらをコンテンツボックスのパーセンテージに変換し、その数値に基づいて構築します。すると、「見出しが大きすぎる」という曖昧な表現が、「参照では見出しの幅はパネル幅の22.4%だが、私の実装では32%である」という明確な数値に変わります。

実装する前に主張を検証する

実装に取り掛かる前に、ある特徴が存在するかどうかを2回確認してください。ある構築で、サムネイルに一対の垂直なヘアラインが見えたため実装しましたが、参照には存在しませんでした — それは被写体自身のシルエットのエッジだったのです。一度確認していれば防げたはずです:

band = a[60:330, :].mean(axis=0)          # 他のUIのない行
102行目: dips = [i for i in range(200, W-200) if band[i] < 228 - 0.8]

平坦な背景、ディップなし、線なし。1pxの罫線は、孤立した1列のディップとして現れます。写真のエッジは、緩やかなランプ(階段状の変化)として現れます。これらは数値的には簡単に見分けられますが、目では簡単に混同されます。

画像のフレーミングを解決し、微調整しない

写真がどのように切り抜かれているかを再現するには、それを導き出します。被写体の幅を、写真全体に対する割合、およびパネルに対する割合として測定します:

renderScale = subjectWidth_inPanel / subjectWidth_inPhoto   # 例: 1.231

object-fit: cover は高さでスケーリングするため、scaledW = panelW × renderScale となり、結果として panelAspect = 1 / (renderScale / photoAspect) となります。これにより、デザイナーが使用したパネルの縦横比が得られます。次に、被写体の中心から object-position を解きます — 計算式は ../landing-page/references/traps.md にあります。

適合させなかった独立した量(例:被写体の頭頂部の高さ)で検証します。予測が1〜2ピクセル以内に収まれば、モデルは正しいです。

参照が一致しない場合を知る

時には、数式が「ノー」と言うことがあります。必要な object-position が0〜1の範囲外になる場合、被写体をその位置に配置できる値は存在しません — パネルの縦横比または画像自体を変更する必要があります。

また、提供されたアセットがオリジナルではなく、その再生成である場合、その比率は異なります。それを検出します:ソースからある計測値を予測し、比較します。4つのサンプルでピクセル単位で一致すれば同じ画像です。不均一な不一致(ある1点で282pxと予測されるところが203pxであるなど)は、別の被写体を意味します。

そのことを明確に述べ、何が一致しているか(レイアウトメトリクス、フレーミング、配置)を説明し、残りの追跡をやめます。「修正」を続けると、出力が悪化し、ユーザーの時間を浪費します。

常に両方のビューポート

参照は、デスクトップのスクリーンショットとモバイルのスクリーンショットです。デスクトップのみを構築し、モバイルを推測するのは、最も難しい部分(モバイルでは修正が集中する)を後回しにすることになります。片方だけが提供された場合は、開始する前に他方を依頼してください。

作業ループ

  1. コンテンツボックスを抽出し、すべての要素をパーセンテージテーブルに計測します。
  2. それらの数値に基づいてトークンとレイアウトを構築します。
  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.

関連スキル